@rnacanvas/utilities 4.3.1 → 5.0.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.
- package/README.md +8 -2
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -1
- package/dist/KeyBinding.d.ts +0 -21
- package/dist/KeyBinding.d.ts.map +0 -1
- package/dist/isBeingInteractedWith.d.ts +0 -9
- package/dist/isBeingInteractedWith.d.ts.map +0 -1
- package/dist/userIsTyping.d.ts +0 -8
- package/dist/userIsTyping.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -42,8 +42,8 @@ var ele2 = document.createElement('div');
|
|
|
42
42
|
ele1.append(ele2);
|
|
43
43
|
|
|
44
44
|
// make elements focusable
|
|
45
|
-
ele1.tabIndex =
|
|
46
|
-
ele2.tabIndex =
|
|
45
|
+
ele1.tabIndex = 0;
|
|
46
|
+
ele2.tabIndex = 0;
|
|
47
47
|
|
|
48
48
|
ele1.focus();
|
|
49
49
|
containsFocus(ele1); // true
|
|
@@ -53,3 +53,9 @@ ele2.focus();
|
|
|
53
53
|
containsFocus(ele1); // true
|
|
54
54
|
containsFocus(ele2); // true
|
|
55
55
|
```
|
|
56
|
+
|
|
57
|
+
## `class KeyBinding`
|
|
58
|
+
|
|
59
|
+
The `KeyBinding` class represents a key binding.
|
|
60
|
+
|
|
61
|
+
See the [@rnacanvas/key-bindings](https://pzhaojohnson.github.io/rnacanvas.key-bindings/) package for documentation.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { shuffled } from './shuffled';
|
|
2
2
|
export { shuffled };
|
|
3
|
-
import { userIsTyping } from './userIsTyping';
|
|
4
|
-
export { userIsTyping };
|
|
5
|
-
import { isBeingInteractedWith } from './isBeingInteractedWith';
|
|
6
|
-
export { isBeingInteractedWith };
|
|
7
3
|
import { hasFocus } from './hasFocus';
|
|
8
4
|
export { hasFocus };
|
|
9
5
|
import { containsFocus } from './containsFocus';
|
|
10
6
|
export { containsFocus };
|
|
11
|
-
import { KeyBinding } from '
|
|
7
|
+
import { KeyBinding } from '@rnacanvas/key-bindings';
|
|
12
8
|
export { KeyBinding };
|
|
13
9
|
import { detectMacOS } from './detectMacOS';
|
|
14
10
|
export { detectMacOS };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,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.utilities=t():e.utilities=t()}(this,(()=>(()=>{"use strict";var e={d:(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.utilities=t():e.utilities=t()}(this,(()=>(()=>{var e={992:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},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,{KeyBinding:()=>v});var r,i,n,o,s,a,l,h,c,u,d=function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};class v{constructor(e,t,a){r.add(this),this.key=e,i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),s.set(this,void 0),d(this,i,t,"f"),d(this,n,(e=>f(this,r,"m",u).call(this,e)),"f"),d(this,o,a,"f")}get owner(){return f(this,s,"f")}set owner(e){var t;null===(t=f(this,s,"f"))||void 0===t||t.removeEventListener("keydown",f(this,n,"f")),null==e||e.addEventListener("keydown",f(this,n,"f"),{passive:!1}),d(this,s,e,"f")}}return i=new WeakMap,n=new WeakMap,o=new WeakMap,s=new WeakMap,r=new WeakSet,a=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.altKey)&&void 0!==t&&t},l=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.ctrlKey)&&void 0!==t&&t},h=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.metaKey)&&void 0!==t&&t},c=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.shiftKey)&&void 0!==t&&t},u=function(e){this.owner&&this.owner===document.activeElement&&e.key.toUpperCase()===this.key.toUpperCase()&&e.altKey===f(this,r,"a",a)&&e.ctrlKey===f(this,r,"a",l)&&e.metaKey===f(this,r,"a",h)&&e.shiftKey===f(this,r,"a",c)&&(e.preventDefault(),f(this,i,"f").call(this))},t})(),e.exports=t()}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";function e(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function t(e){return e===document.activeElement}function n(e){return!!document.activeElement&&e.contains(document.activeElement)}r.r(i),r.d(i,{DownloadableFile:()=>a,EventfulSet:()=>l,FiniteStack:()=>v,KeyBinding:()=>o.KeyBinding,containsFocus:()=>n,detectMacOS:()=>s,hasFocus:()=>t,isURL:()=>p,shuffled:()=>e});var o=r(992);function s(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}class a{constructor(e){this.textContent=e}downloadAs(e,t){let r=new File([this.textContent],e,{type:t.type}),i=URL.createObjectURL(r),n=document.createElement("a");n.href=i,n.download=r.name,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(i)}}class l{constructor(){this.eventListeners={change:[]},this.underlyingSet=new Set}[Symbol.iterator](){return this.underlyingSet.values()}includes(e){return this.underlyingSet.has(e)}include(e){return this.includes(e)}addAll(e){let t=[...e];0!=t.length&&(t.every((e=>this.includes(e)))||(t.forEach((e=>this.underlyingSet.add(e))),this.callEventListeners("change")))}removeAll(e){let t=[...e];0!=t.length&&(t.every((e=>!this.includes(e)))||(t.forEach((e=>this.underlyingSet.delete(e))),this.callEventListeners("change")))}clear(){0!=this.underlyingSet.size&&(this.underlyingSet.clear(),this.callEventListeners("change"))}addEventListener(e,t){this.eventListeners[e].push(t)}callEventListeners(e){this.eventListeners[e].forEach((e=>e()))}removeEventListener(e,t){this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))}}var h,c,u,d,f=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};class v{constructor(e){h.add(this),this.maxSize=e,c.set(this,[]),u.set(this,{change:[]})}get size(){return f(this,c,"f").length}isEmpty(){return 0==this.size}empty(){0!=this.size&&(function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?n.call(e,r):n?n.value=r:t.set(e,r)}(this,c,[],"f"),f(this,h,"m",d).call(this,"change"))}peek(){if(0==this.size)throw new Error("The stack is empty.");return f(this,c,"f")[f(this,c,"f").length-1]}push(e){f(this,c,"f").push(e),this.size>this.maxSize&&f(this,c,"f").shift(),f(this,h,"m",d).call(this,"change")}pop(){if(0==this.size)throw new Error("The stack is empty.");let e=f(this,c,"f").pop();return f(this,h,"m",d).call(this,"change"),e}addEventListener(e,t){f(this,u,"f")[e].push(t)}removeEventListener(e,t){f(this,u,"f")[e]=f(this,u,"f")[e].filter((e=>e!==t))}}function p(e){try{return new URL(e),!0}catch(e){return!1}}c=new WeakMap,u=new WeakMap,h=new WeakSet,d=function(e){f(this,u,"f")[e].forEach((e=>e()))}})(),i})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnacanvas/utilities",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "General utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,5 +20,8 @@
|
|
|
20
20
|
"typescript": "^5.3.3",
|
|
21
21
|
"webpack": "^5.89.0",
|
|
22
22
|
"webpack-cli": "^6.0.1"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@rnacanvas/key-bindings": "^1.1.0"
|
|
23
26
|
}
|
|
24
27
|
}
|
package/dist/KeyBinding.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare class KeyBinding {
|
|
2
|
-
#private;
|
|
3
|
-
readonly key: string;
|
|
4
|
-
/**
|
|
5
|
-
* Must be currently being interacted with by the user
|
|
6
|
-
* for the key binding to be triggered
|
|
7
|
-
* (and must be set to an element for the key binding to become active).
|
|
8
|
-
*
|
|
9
|
-
* Set to the document body for the key binding to apply to the whole webpage.
|
|
10
|
-
*/
|
|
11
|
-
scope: Element | undefined;
|
|
12
|
-
constructor(key: string, callbackFn: () => void, options?: Options);
|
|
13
|
-
}
|
|
14
|
-
type Options = {
|
|
15
|
-
altKey?: boolean;
|
|
16
|
-
shiftKey?: boolean;
|
|
17
|
-
ctrlKey?: boolean;
|
|
18
|
-
metaKey?: boolean;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=KeyBinding.d.ts.map
|
package/dist/KeyBinding.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KeyBinding.d.ts","sourceRoot":"","sources":["../src/KeyBinding.ts"],"names":[],"mappings":"AAIA,qBAAa,UAAU;;IAYT,QAAQ,CAAC,GAAG,EAAE,MAAM;IAXhC;;;;;;OAMG;IACI,KAAK,EAAE,OAAO,GAAG,SAAS,CAAa;gBAIzB,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO;CAqB5E;AAED,KAAK,OAAO,GAAG;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns true if and only if the provided element (or any of its child elements)
|
|
3
|
-
* are currently being interacted with by the user.
|
|
4
|
-
*
|
|
5
|
-
* Note that this function may not work properly with lazy loading or dynamic imports
|
|
6
|
-
* (since it only begins tracking which elements are being interacted with after being imported).
|
|
7
|
-
*/
|
|
8
|
-
export declare function isBeingInteractedWith(ele: Element): boolean;
|
|
9
|
-
//# sourceMappingURL=isBeingInteractedWith.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isBeingInteractedWith.d.ts","sourceRoot":"","sources":["../src/isBeingInteractedWith.ts"],"names":[],"mappings":"AAsBA;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAK3D"}
|
package/dist/userIsTyping.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userIsTyping.d.ts","sourceRoot":"","sources":["../src/userIsTyping.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAOtC"}
|