@peter.naydenov/shortcuts 1.0.0 → 1.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/Changelog.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Release History
2
2
 
3
+ ### 1.0.1 (2023-09-23)
4
+ - [x] Mouse click: preventDefault();
5
+ - [x] Dependencies update: @peter.naydenov/notice - v.2.2.1
3
6
 
4
7
 
5
8
  ### 1.0.0 (2023-08-14)
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ![version](https://img.shields.io/github/package-json/v/peterNaydenov/shortcuts)
4
4
  ![license](https://img.shields.io/github/license/peterNaydenov/shortcuts)
5
5
 
6
- Build a keyboard shortcuts maps and describe a mouse clicks. Control them on context.
6
+ Define a context based keyboard-shortcuts and describe a mouse clicks. Switch among contexts.
7
7
 
8
8
 
9
9
 
@@ -11,6 +11,10 @@ Build a keyboard shortcuts maps and describe a mouse clicks. Control them on con
11
11
  The shortcuts definition includes a context name and a set of rules(object). The rules are a set of key-value pairs. The key is a shortcut name and the value is a function or array of functions, to be executed when the shortcut is triggered (action function).
12
12
 
13
13
  ```js
14
+ // { context: { shortcutName: actionFunction } }
15
+ // or
16
+ // { context: { shortcutName: [ actionFunction1, actionFunction2 ] }}
17
+ ```
14
18
  // Shortcut definition object:
15
19
  {
16
20
  contextName : {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peter.naydenov/shortcuts",
3
- "version": "1.0.0",
4
- "description": "Create shortcuts for your web application based on keyboard and mouse events",
3
+ "version": "1.0.1",
4
+ "description": "Context control of shortcuts based on keyboard and mouse events",
5
5
  "keywords": [
6
6
  "shortcut",
7
7
  "key",
@@ -16,13 +16,17 @@
16
16
  "build": "vite build",
17
17
  "test": "cypress open --component --browser chrome test"
18
18
  },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/PeterNaydenov/shortcuts"
22
+ },
19
23
  "dependencies": {
20
- "@peter.naydenov/notice": "^2.1.0"
24
+ "@peter.naydenov/notice": "^2.2.1"
21
25
  },
22
26
  "devDependencies": {
23
27
  "@vitejs/plugin-react": "^4.0.4",
24
- "chai": "^4.3.7",
25
- "cypress": "^12.17.3",
28
+ "chai": "^4.3.8",
29
+ "cypress": "^13.2.0",
26
30
  "mocha": "^10.2.0",
27
31
  "react": "^18.2.0",
28
32
  "react-dom": "^18.2.0",
package/src/listen.js CHANGED
@@ -93,6 +93,7 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
93
93
 
94
94
  function listenMouse () {
95
95
  window.addEventListener ( 'contextmenu', event => { // Listen for right mouse clicks
96
+ event.preventDefault ()
96
97
  clearTimeout ( mouseTimer )
97
98
  if ( mouseIgnore ) {
98
99
  clearTimeout ( mouseIgnore )
@@ -104,7 +105,6 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
104
105
  mouseIgnore = setTimeout ( () => mouseIgnore=null, mouseWait )
105
106
  return
106
107
  }
107
- event.preventDefault ()
108
108
  mouseTarget = findTarget (event.target, clickTarget )
109
109
  mouseDomEvent = event
110
110
  count++
@@ -112,6 +112,7 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
112
112
  })
113
113
 
114
114
  document.addEventListener ( 'click', event => { // Listen for left and middle mouse clicks
115
+ event.preventDefault ()
115
116
  clearTimeout ( mouseTimer )
116
117
  if ( mouseIgnore ) {
117
118
  clearTimeout ( mouseIgnore )