@rescui/focus-manager 0.1.0 → 0.1.2
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 +1 -1
- package/lib/autorun.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/runner.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
package/lib/autorun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"autorun.js","names":["run"],"sources":["../src/autorun.js"],"sourcesContent":["import run from './runner';\n\nrun();\n"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,UAAhB;AAEAA,GAAG"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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","_unbindEvents","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":";;;IAAqBA,Y;EACnB,sBAAYC,MAAZ,EAAoBC,IAApB,EAA0B;IAAA;;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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F;;;WAED,sBAAa;MACX,KAAKR,YAAL,GAAoB,KAApB;IACD;;;WAED,wBAAe;MACb,IAAI,KAAKA,YAAL,KAAsB,OAA1B,EAAmC;QACjC,KAAKA,YAAL,GAAoB,OAApB;MACD;IACF;;;WAED,yBAAgB;MACd,KAAKA,YAAL,GAAoB,OAApB;IACD;;;WAED,kBAASa,KAAT,EAAgB;MACd,IAAI,CAAC,KAAKb,YAAV,EAAwB;QACtB,KAAKA,YAAL,GAAoB,KAAKC,gBAAzB;MACD;;MAEDY,KAAK,CAACnB,MAAN,CAAaoB,YAAb,CAA0B,KAAKf,KAA/B,EAAsC,KAAKC,YAA3C;MACA,KAAKC,gBAAL,GAAwB,KAAKD,YAA7B;MACA,KAAKA,YAAL,GAAoB,IAApB;IACD;;;WAED,iBAAQa,KAAR,EAAe;MACbA,KAAK,CAACnB,MAAN,CAAaqB,eAAb,CAA6B,KAAKhB,KAAlC;IACD;;;WAED,yBAAgB;MACd,KAAKC,YAAL,GAAoB,IAApB;IACD;;;WAED,mBAAU;MACR,KAAKgB,aAAL;IACD;;;;;;SAvEkBvB,Y;AA0ErB,SAASwB,OAAO,IAAIC,eAApB,QAA2C,UAA3C"}
|
package/lib/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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;MAAA,OAAM,IAAID,YAAJ,EAAN;IAAA,CAAD,CAAV;EACD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/focus-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"core-js": "^3.9.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@rescui/scripts": "^0.1.
|
|
23
|
+
"@rescui/scripts": "^0.1.6"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rescui-scripts babel"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "c5b48e321608ae1755e691238aa5db5977318c75"
|
|
29
29
|
}
|