@rescui/focus-manager 0.1.12 → 0.1.14-RUI-229-Mark-packages-as-ES-modules-62bc27a1.26
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/lib/index.js +55 -74
- package/lib/index.js.map +1 -1
- package/lib/runner.js +2 -4
- package/lib/runner.js.map +1 -1
- package/package.json +10 -5
package/lib/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var FocusManager = /*#__PURE__*/function () {
|
|
5
|
-
function FocusManager(target, attr) {
|
|
6
|
-
_classCallCheck(this, FocusManager);
|
|
7
|
-
|
|
1
|
+
export default class FocusManager {
|
|
2
|
+
constructor(target, attr) {
|
|
8
3
|
this._target = target || document.body;
|
|
9
4
|
this._attr = attr || 'data-focus-method';
|
|
10
5
|
this._focusMethod = null;
|
|
@@ -19,88 +14,74 @@ var FocusManager = /*#__PURE__*/function () {
|
|
|
19
14
|
this._bindEvents();
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (this._target.addEventListener) {
|
|
26
|
-
this._target.addEventListener('keydown', this._onKeyDown, true);
|
|
17
|
+
_bindEvents() {
|
|
18
|
+
if (this._target.addEventListener) {
|
|
19
|
+
this._target.addEventListener('keydown', this._onKeyDown, true);
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
this._target.addEventListener('mousedown', this._onMouseDown, true);
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
this._target.addEventListener('touchstart', this._onTouchStart, true);
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
this._target.addEventListener('focus', this._onFocus, true);
|
|
33
26
|
|
|
34
|
-
|
|
27
|
+
this._target.addEventListener('blur', this._onBlur, true);
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
}
|
|
29
|
+
window.addEventListener('blur', this._onWindowBlur);
|
|
38
30
|
}
|
|
39
|
-
}
|
|
40
|
-
key: "_unbindEvents",
|
|
41
|
-
value: function _unbindEvents() {
|
|
42
|
-
if (this._target.removeEventListener) {
|
|
43
|
-
this._target.removeEventListener('keydown', this._onKeyDown, true);
|
|
31
|
+
}
|
|
44
32
|
|
|
45
|
-
|
|
33
|
+
_unbindEvents() {
|
|
34
|
+
if (this._target.removeEventListener) {
|
|
35
|
+
this._target.removeEventListener('keydown', this._onKeyDown, true);
|
|
46
36
|
|
|
47
|
-
|
|
37
|
+
this._target.removeEventListener('mousedown', this._onMouseDown, true);
|
|
48
38
|
|
|
49
|
-
|
|
39
|
+
this._target.removeEventListener('touchstart', this._onTouchStart, true);
|
|
50
40
|
|
|
51
|
-
|
|
41
|
+
this._target.removeEventListener('focus', this._onFocus, true);
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, {
|
|
57
|
-
key: "_onKeyDown",
|
|
58
|
-
value: function _onKeyDown() {
|
|
59
|
-
this._focusMethod = 'key';
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "_onMouseDown",
|
|
63
|
-
value: function _onMouseDown() {
|
|
64
|
-
if (this._focusMethod !== 'touch') {
|
|
65
|
-
this._focusMethod = 'mouse';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "_onTouchStart",
|
|
70
|
-
value: function _onTouchStart() {
|
|
71
|
-
this._focusMethod = 'touch';
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "_onFocus",
|
|
75
|
-
value: function _onFocus(event) {
|
|
76
|
-
if (!this._focusMethod) {
|
|
77
|
-
this._focusMethod = this._lastFocusMethod;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
event.target.setAttribute(this._attr, this._focusMethod);
|
|
81
|
-
this._lastFocusMethod = this._focusMethod;
|
|
82
|
-
this._focusMethod = null;
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "_onBlur",
|
|
86
|
-
value: function _onBlur(event) {
|
|
87
|
-
event.target.removeAttribute(this._attr);
|
|
43
|
+
this._target.removeEventListener('blur', this._onBlur, true);
|
|
44
|
+
|
|
45
|
+
window.removeEventListener('blur', this._onWindowBlur);
|
|
88
46
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_onKeyDown() {
|
|
50
|
+
this._focusMethod = 'key';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_onMouseDown() {
|
|
54
|
+
if (this._focusMethod !== 'touch') {
|
|
55
|
+
this._focusMethod = 'mouse';
|
|
93
56
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_onTouchStart() {
|
|
60
|
+
this._focusMethod = 'touch';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_onFocus(event) {
|
|
64
|
+
if (!this._focusMethod) {
|
|
65
|
+
this._focusMethod = this._lastFocusMethod;
|
|
98
66
|
}
|
|
99
|
-
}]);
|
|
100
67
|
|
|
101
|
-
|
|
102
|
-
|
|
68
|
+
event.target.setAttribute(this._attr, this._focusMethod);
|
|
69
|
+
this._lastFocusMethod = this._focusMethod;
|
|
70
|
+
this._focusMethod = null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_onBlur(event) {
|
|
74
|
+
event.target.removeAttribute(this._attr);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_onWindowBlur() {
|
|
78
|
+
this._focusMethod = null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
destroy() {
|
|
82
|
+
this._unbindEvents();
|
|
83
|
+
}
|
|
103
84
|
|
|
104
|
-
|
|
85
|
+
}
|
|
105
86
|
export { default as runFocusManager } from './runner';
|
|
106
87
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["FocusManager","target","attr","_target","document","body","_attr","_focusMethod","_lastFocusMethod","_onKeyDown","bind","_onMouseDown","_onTouchStart","_onFocus","_onBlur","_onWindowBlur","_bindEvents","addEventListener","window","removeEventListener","event","setAttribute","removeAttribute","
|
|
1
|
+
{"version":3,"file":"index.js","names":["FocusManager","constructor","target","attr","_target","document","body","_attr","_focusMethod","_lastFocusMethod","_onKeyDown","bind","_onMouseDown","_onTouchStart","_onFocus","_onBlur","_onWindowBlur","_bindEvents","addEventListener","window","_unbindEvents","removeEventListener","event","setAttribute","removeAttribute","destroy","default","runFocusManager"],"sources":["../src/index.js"],"sourcesContent":["export default class FocusManager {\n constructor(target, attr) {\n this._target = target || document.body;\n this._attr = attr || 'data-focus-method';\n this._focusMethod = null;\n this._lastFocusMethod = null;\n this._onKeyDown = this._onKeyDown.bind(this);\n this._onMouseDown = this._onMouseDown.bind(this);\n this._onTouchStart = this._onTouchStart.bind(this);\n this._onFocus = this._onFocus.bind(this);\n this._onBlur = this._onBlur.bind(this);\n this._onWindowBlur = this._onWindowBlur.bind(this);\n this._bindEvents();\n }\n\n _bindEvents() {\n if (this._target.addEventListener) {\n this._target.addEventListener('keydown', this._onKeyDown, true);\n this._target.addEventListener('mousedown', this._onMouseDown, true);\n this._target.addEventListener('touchstart', this._onTouchStart, true);\n this._target.addEventListener('focus', this._onFocus, true);\n this._target.addEventListener('blur', this._onBlur, true);\n window.addEventListener('blur', this._onWindowBlur);\n }\n }\n\n _unbindEvents() {\n if (this._target.removeEventListener) {\n this._target.removeEventListener('keydown', this._onKeyDown, true);\n this._target.removeEventListener('mousedown', this._onMouseDown, true);\n this._target.removeEventListener('touchstart', this._onTouchStart, true);\n this._target.removeEventListener('focus', this._onFocus, true);\n this._target.removeEventListener('blur', this._onBlur, true);\n window.removeEventListener('blur', this._onWindowBlur);\n }\n }\n\n _onKeyDown() {\n this._focusMethod = 'key';\n }\n\n _onMouseDown() {\n if (this._focusMethod !== 'touch') {\n this._focusMethod = 'mouse';\n }\n }\n\n _onTouchStart() {\n this._focusMethod = 'touch';\n }\n\n _onFocus(event) {\n if (!this._focusMethod) {\n this._focusMethod = this._lastFocusMethod;\n }\n\n event.target.setAttribute(this._attr, this._focusMethod);\n this._lastFocusMethod = this._focusMethod;\n this._focusMethod = null;\n }\n\n _onBlur(event) {\n event.target.removeAttribute(this._attr);\n }\n\n _onWindowBlur() {\n this._focusMethod = null;\n }\n\n destroy() {\n this._unbindEvents();\n }\n}\n\nexport { default as runFocusManager } from './runner';\n"],"mappings":"AAAA,eAAe,MAAMA,YAAN,CAAmB;EAChCC,WAAW,CAACC,MAAD,EAASC,IAAT,EAAe;IACxB,KAAKC,OAAL,GAAeF,MAAM,IAAIG,QAAQ,CAACC,IAAlC;IACA,KAAKC,KAAL,GAAaJ,IAAI,IAAI,mBAArB;IACA,KAAKK,YAAL,GAAoB,IAApB;IACA,KAAKC,gBAAL,GAAwB,IAAxB;IACA,KAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAAlB;IACA,KAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAuB,IAAvB,CAApB;IACA,KAAKE,aAAL,GAAqB,KAAKA,aAAL,CAAmBF,IAAnB,CAAwB,IAAxB,CAArB;IACA,KAAKG,QAAL,GAAgB,KAAKA,QAAL,CAAcH,IAAd,CAAmB,IAAnB,CAAhB;IACA,KAAKI,OAAL,GAAe,KAAKA,OAAL,CAAaJ,IAAb,CAAkB,IAAlB,CAAf;IACA,KAAKK,aAAL,GAAqB,KAAKA,aAAL,CAAmBL,IAAnB,CAAwB,IAAxB,CAArB;;IACA,KAAKM,WAAL;EACD;;EAEDA,WAAW,GAAG;IACZ,IAAI,KAAKb,OAAL,CAAac,gBAAjB,EAAmC;MACjC,KAAKd,OAAL,CAAac,gBAAb,CAA8B,SAA9B,EAAyC,KAAKR,UAA9C,EAA0D,IAA1D;;MACA,KAAKN,O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,KAAKd,YAAV,EAAwB;MACtB,KAAKA,YAAL,GAAoB,KAAKC,gBAAzB;IACD;;IAEDa,KAAK,CAACpB,MAAN,CAAaqB,YAAb,CAA0B,KAAKhB,KAA/B,EAAsC,KAAKC,YAA3C;IACA,KAAKC,gBAAL,GAAwB,KAAKD,YAA7B;IACA,KAAKA,YAAL,GAAoB,IAApB;EACD;;EAEDO,OAAO,CAACO,KAAD,EAAQ;IACbA,KAAK,CAACpB,MAAN,CAAasB,eAAb,CAA6B,KAAKjB,KAAlC;EACD;;EAEDS,aAAa,GAAG;IACd,KAAKR,YAAL,GAAoB,IAApB;EACD;;EAEDiB,OAAO,GAAG;IACR,KAAKL,aAAL;EACD;;AAvE+B;AA0ElC,SAASM,OAAO,IAAIC,eAApB,QAA2C,UAA3C"}
|
package/lib/runner.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import FocusManager from './index';
|
|
3
3
|
|
|
4
4
|
function onDOMReady(callback) {
|
|
5
|
-
|
|
5
|
+
let loaded;
|
|
6
6
|
|
|
7
7
|
function load() {
|
|
8
8
|
if (!loaded) {
|
|
@@ -22,9 +22,7 @@ function onDOMReady(callback) {
|
|
|
22
22
|
|
|
23
23
|
export default function run() {
|
|
24
24
|
if (typeof document !== 'undefined') {
|
|
25
|
-
onDOMReady(
|
|
26
|
-
return new FocusManager();
|
|
27
|
-
});
|
|
25
|
+
onDOMReady(() => new FocusManager());
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
//# sourceMappingURL=runner.js.map
|
package/lib/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","names":["FocusManager","onDOMReady","callback","loaded","load","indexOf","document","readyState","addEventListener","window","run"],"sources":["../src/runner.js"],"sourcesContent":["// eslint-disable-next-line import/no-useless-path-segments\nimport FocusManager from './index';\n\nfunction onDOMReady(callback) {\n let loaded;\n\n function load() {\n if (!loaded) {\n loaded = true;\n\n callback();\n }\n }\n\n if (['interactive', 'complete'].indexOf(document.readyState) >= 0) {\n callback();\n } else {\n loaded = false;\n document.addEventListener('DOMContentLoaded', load, false);\n window.addEventListener('load', load, false);\n }\n}\n\nexport default function run() {\n if (typeof document !== 'undefined') {\n onDOMReady(() => new FocusManager());\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,YAAP,MAAyB,SAAzB;;AAEA,SAASC,UAAT,CAAoBC,QAApB,EAA8B;EAC5B,IAAIC,MAAJ;;EAEA,SAASC,IAAT,GAAgB;IACd,IAAI,CAACD,MAAL,EAAa;MACXA,MAAM,GAAG,IAAT;MAEAD,QAAQ;IACT;EACF;;EAED,IAAI,CAAC,aAAD,EAAgB,UAAhB,EAA4BG,OAA5B,CAAoCC,QAAQ,CAACC,UAA7C,KAA4D,CAAhE,EAAmE;IACjEL,QAAQ;EACT,CAFD,MAEO;IACLC,MAAM,GAAG,KAAT;IACAG,QAAQ,CAACE,gBAAT,CAA0B,kBAA1B,EAA8CJ,IAA9C,EAAoD,KAApD;IACAK,MAAM,CAACD,gBAAP,CAAwB,MAAxB,EAAgCJ,IAAhC,EAAsC,KAAtC;EACD;AACF;;AAED,eAAe,SAASM,GAAT,GAAe;EAC5B,IAAI,OAAOJ,QAAP,KAAoB,WAAxB,EAAqC;IACnCL,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"runner.js","names":["FocusManager","onDOMReady","callback","loaded","load","indexOf","document","readyState","addEventListener","window","run"],"sources":["../src/runner.js"],"sourcesContent":["// eslint-disable-next-line import/no-useless-path-segments\nimport FocusManager from './index';\n\nfunction onDOMReady(callback) {\n let loaded;\n\n function load() {\n if (!loaded) {\n loaded = true;\n\n callback();\n }\n }\n\n if (['interactive', 'complete'].indexOf(document.readyState) >= 0) {\n callback();\n } else {\n loaded = false;\n document.addEventListener('DOMContentLoaded', load, false);\n window.addEventListener('load', load, false);\n }\n}\n\nexport default function run() {\n if (typeof document !== 'undefined') {\n onDOMReady(() => new FocusManager());\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,YAAP,MAAyB,SAAzB;;AAEA,SAASC,UAAT,CAAoBC,QAApB,EAA8B;EAC5B,IAAIC,MAAJ;;EAEA,SAASC,IAAT,GAAgB;IACd,IAAI,CAACD,MAAL,EAAa;MACXA,MAAM,GAAG,IAAT;MAEAD,QAAQ;IACT;EACF;;EAED,IAAI,CAAC,aAAD,EAAgB,UAAhB,EAA4BG,OAA5B,CAAoCC,QAAQ,CAACC,UAA7C,KAA4D,CAAhE,EAAmE;IACjEL,QAAQ;EACT,CAFD,MAEO;IACLC,MAAM,GAAG,KAAT;IACAG,QAAQ,CAACE,gBAAT,CAA0B,kBAA1B,EAA8CJ,IAA9C,EAAoD,KAApD;IACAK,MAAM,CAACD,gBAAP,CAAwB,MAAxB,EAAgCJ,IAAhC,EAAsC,KAAtC;EACD;AACF;;AAED,eAAe,SAASM,GAAT,GAAe;EAC5B,IAAI,OAAOJ,QAAP,KAAoB,WAAxB,EAAqC;IACnCL,UAAU,CAAC,MAAM,IAAID,YAAJ,EAAP,CAAV;EACD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/focus-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14-RUI-229-Mark-packages-as-ES-modules-62bc27a1.26+62bc27a1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./lib/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./*": "./*"
|
|
13
|
+
},
|
|
8
14
|
"src:main": "src/index.js",
|
|
9
15
|
"typings": "typings/index.d.ts",
|
|
10
16
|
"files": [
|
|
@@ -16,15 +22,14 @@
|
|
|
16
22
|
"access": "public"
|
|
17
23
|
},
|
|
18
24
|
"dependencies": {
|
|
19
|
-
"@babel/runtime-corejs3": "^7.
|
|
20
|
-
"core-js": "^3.9.1"
|
|
25
|
+
"@babel/runtime-corejs3": "^7.26.0"
|
|
21
26
|
},
|
|
22
27
|
"devDependencies": {
|
|
23
|
-
"@rescui/scripts": "
|
|
28
|
+
"@rescui/scripts": "0.3.5"
|
|
24
29
|
},
|
|
25
30
|
"scripts": {
|
|
26
31
|
"build": "rescui-scripts babel"
|
|
27
32
|
},
|
|
28
33
|
"nx": {},
|
|
29
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "62bc27a12c78adf2a930b830aeaec251ecfe93fa"
|
|
30
35
|
}
|