@rnacanvas/draw.interact 1.1.0 → 1.2.1

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.
@@ -0,0 +1,48 @@
1
+ interface Nucleobase {
2
+ /**
3
+ * The actual DOM node corresponding to the nucleobase.
4
+ */
5
+ domNode: SVGGraphicsElement;
6
+ }
7
+ /**
8
+ * An RNAcanvas structure drawing.
9
+ */
10
+ interface Drawing<B extends Nucleobase> {
11
+ /**
12
+ * The bases in the drawing.
13
+ */
14
+ bases: Iterable<B>;
15
+ }
16
+ /**
17
+ * A live set of items that may also be referenced and modified by outside code.
18
+ */
19
+ interface LiveSet<T> {
20
+ /**
21
+ * Returns true if the set includes the specified item and returns false otherwise.
22
+ */
23
+ include(item: T): boolean;
24
+ /**
25
+ * Adds all of the specified items to the set.
26
+ */
27
+ addAll(items: T[]): void;
28
+ }
29
+ /**
30
+ * Represents the set of currently selected bases in a target drawing
31
+ * given the set of currently selected SVG elements.
32
+ */
33
+ export declare class SelectedBases<B extends Nucleobase> {
34
+ private targetDrawing;
35
+ private selectedSVGElements;
36
+ constructor(targetDrawing: Drawing<B>, selectedSVGElements: LiveSet<SVGGraphicsElement>);
37
+ [Symbol.iterator](): IterableIterator<B>;
38
+ /**
39
+ * Returns true if the specified base is currently selected and returns false otherwise.
40
+ */
41
+ include(b: B): boolean;
42
+ /**
43
+ * Adds all of the specified bases to the set of currently selected bases.
44
+ */
45
+ addAll(bs: Iterable<B>): void;
46
+ }
47
+ export {};
48
+ //# sourceMappingURL=SelectedBases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectedBases.d.ts","sourceRoot":"","sources":["../src/SelectedBases.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;GAEG;AACH,UAAU,OAAO,CAAC,CAAC,SAAS,UAAU;IACpC;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,OAAO,CAAC,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,UAAU;IACjC,OAAO,CAAC,aAAa;IAAc,OAAO,CAAC,mBAAmB;gBAAtD,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,EAAU,mBAAmB,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAEvG,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB;;OAEG;IACH,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO;IAItB;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;CAG9B"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { ConsecutiveBasesSelectingTool } from './ConsecutiveBasesSelectingTool';
2
2
  export { ConsecutiveBasesSelectingTool };
3
+ import { SelectedBases } from './SelectedBases';
4
+ export { SelectedBases };
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["draw.interact"]=t():e["draw.interact"]=t()}(this,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var s in o)e.o(o,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:o[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ConsecutiveBasesSelectingTool:()=>o});class o{constructor(e,t){this.targetDrawing=e,this.selectedBases=t,this.mouseIsDown=!1,window.addEventListener("mousedown",(e=>this.handleMouseDown(e))),window.addEventListener("mouseup",(e=>this.handleMouseUp(e))),window.addEventListener("mouseover",(e=>this.handleMouseOver(e)))}handleMouseDown(e){this.lastMouseDown=e,this.mouseIsDown=!0}handleMouseUp(e){this.mouseIsDown=!1}handleMouseOver(e){if(!this.mouseIsDown)return;let t=this.lastMouseDown;if(!t)return;if(!t.shiftKey)return;if(!(e.target instanceof Node))return;if(!this.targetDrawing.domNode.contains(e.target))return;let o=[...this.targetDrawing.bases],s=o.findIndex((t=>t.domNode===e.target));if(s<0)return;let n=o.findIndex((e=>e.domNode===t.target));if(n<0)return;try{let e=o[n];if(!this.selectedBases.include(e))return}catch(e){console.error(e)}let r=Math.min(n,s),i=Math.max(n,s);this.selectedBases.addAll(o.slice(r,i+1))}}return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["draw.interact"]=t():e["draw.interact"]=t()}(this,(()=>(()=>{"use strict";var e={d:(t,s)=>{for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ConsecutiveBasesSelectingTool:()=>s,SelectedBases:()=>o});class s{constructor(e,t){this.targetDrawing=e,this.selectedBases=t,this.mouseIsDown=!1,window.addEventListener("mousedown",(e=>this.handleMouseDown(e))),window.addEventListener("mouseup",(e=>this.handleMouseUp(e))),window.addEventListener("mouseover",(e=>this.handleMouseOver(e)))}handleMouseDown(e){this.lastMouseDown=e,this.mouseIsDown=!0}handleMouseUp(e){this.mouseIsDown=!1}handleMouseOver(e){if(!this.mouseIsDown)return;let t=this.lastMouseDown;if(!t)return;if(!t.shiftKey)return;if(!(e.target instanceof Node))return;if(!this.targetDrawing.domNode.contains(e.target))return;let s=[...this.targetDrawing.bases],o=s.findIndex((t=>t.domNode===e.target));if(o<0)return;let n=s.findIndex((e=>e.domNode===t.target));if(n<0)return;try{let e=s[n];if(!this.selectedBases.include(e))return}catch(e){console.error(e)}let r=Math.min(n,o),i=Math.max(n,o);this.selectedBases.addAll(s.slice(r,i+1))}}class o{constructor(e,t){this.targetDrawing=e,this.selectedSVGElements=t}[Symbol.iterator](){return[...this.targetDrawing.bases].filter((e=>this.selectedSVGElements.include(e.domNode))).values()}include(e){return this.selectedSVGElements.include(e.domNode)}addAll(e){this.selectedSVGElements.addAll([...e].map((e=>e.domNode)))}}return t})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/draw.interact",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Interact with RNAcanvas structure drawings",
5
5
  "repository": {
6
6
  "type": "git",