@bigbinary/neetoui 6.7.4 → 6.8.0

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.
Files changed (296) hide show
  1. package/dist/Accordion.js +5 -6
  2. package/dist/Accordion.js.map +1 -1
  3. package/dist/ActionDropdown.js +16 -11
  4. package/dist/ActionDropdown.js.map +1 -1
  5. package/dist/Alert.js +23 -13
  6. package/dist/Alert.js.map +1 -1
  7. package/dist/Avatar.js +6 -6
  8. package/dist/Button.js +7 -8
  9. package/dist/Button.js.map +1 -1
  10. package/dist/Callout.js +4 -5
  11. package/dist/Callout.js.map +1 -1
  12. package/dist/Checkbox.js +22 -13
  13. package/dist/Checkbox.js.map +1 -1
  14. package/dist/ColorPicker.js +20 -14
  15. package/dist/ColorPicker.js.map +1 -1
  16. package/dist/DatePicker.js +21 -12
  17. package/dist/DatePicker.js.map +1 -1
  18. package/dist/DateTimePicker.js +27 -17
  19. package/dist/DateTimePicker.js.map +1 -1
  20. package/dist/Dropdown.js +18 -13
  21. package/dist/Dropdown.js.map +1 -1
  22. package/dist/Input.js +21 -12
  23. package/dist/Input.js.map +1 -1
  24. package/dist/Kbd.js +6 -6
  25. package/dist/Label.js +54 -18
  26. package/dist/Label.js.map +1 -1
  27. package/dist/Modal.js +23 -13
  28. package/dist/Modal.js.map +1 -1
  29. package/dist/MultiEmailInput.js +41 -16
  30. package/dist/MultiEmailInput.js.map +1 -1
  31. package/dist/NoData.js +7 -8
  32. package/dist/NoData.js.map +1 -1
  33. package/dist/Pagination.js +15 -10
  34. package/dist/Pagination.js.map +1 -1
  35. package/dist/Pane.js +23 -13
  36. package/dist/Pane.js.map +1 -1
  37. package/dist/Popover.js +7 -8
  38. package/dist/Popover.js.map +1 -1
  39. package/dist/ProgressBar.js +1 -1
  40. package/dist/Radio.js +22 -13
  41. package/dist/Radio.js.map +1 -1
  42. package/dist/Select.js +42 -14
  43. package/dist/Select.js.map +1 -1
  44. package/dist/Sidebar.js +16 -11
  45. package/dist/Sidebar.js.map +1 -1
  46. package/dist/Slider.js +22 -13
  47. package/dist/Slider.js.map +1 -1
  48. package/dist/Spinner.js +1 -1
  49. package/dist/Stepper.js +1 -1
  50. package/dist/Switch.js +22 -13
  51. package/dist/Switch.js.map +1 -1
  52. package/dist/Tab.js +4 -5
  53. package/dist/Tab.js.map +1 -1
  54. package/dist/Table.js +19 -14
  55. package/dist/Table.js.map +1 -1
  56. package/dist/Tag.js +3 -3
  57. package/dist/Textarea.js +22 -13
  58. package/dist/Textarea.js.map +1 -1
  59. package/dist/TimePicker.js +22 -13
  60. package/dist/TimePicker.js.map +1 -1
  61. package/dist/TimePickerInput.js +258 -21
  62. package/dist/TimePickerInput.js.map +1 -1
  63. package/dist/Toastr.js +15 -126
  64. package/dist/Toastr.js.map +1 -1
  65. package/dist/Tooltip.js +73 -7
  66. package/dist/Tooltip.js.map +1 -1
  67. package/dist/Tree.js +13 -8
  68. package/dist/Tree.js.map +1 -1
  69. package/dist/TreeSelect.js +21 -11
  70. package/dist/TreeSelect.js.map +1 -1
  71. package/dist/Typography.js +4 -5
  72. package/dist/Typography.js.map +1 -1
  73. package/dist/cjs/Accordion.js +25 -21
  74. package/dist/cjs/Accordion.js.map +1 -1
  75. package/dist/cjs/ActionDropdown.js +24 -16
  76. package/dist/cjs/ActionDropdown.js.map +1 -1
  77. package/dist/cjs/Alert.js +25 -14
  78. package/dist/cjs/Alert.js.map +1 -1
  79. package/dist/cjs/Avatar.js +17 -13
  80. package/dist/cjs/Avatar.js.map +1 -1
  81. package/dist/cjs/Button.js +17 -14
  82. package/dist/cjs/Button.js.map +1 -1
  83. package/dist/cjs/Callout.js +11 -8
  84. package/dist/cjs/Callout.js.map +1 -1
  85. package/dist/cjs/Checkbox.js +32 -20
  86. package/dist/cjs/Checkbox.js.map +1 -1
  87. package/dist/cjs/ColorPicker.js +33 -22
  88. package/dist/cjs/ColorPicker.js.map +1 -1
  89. package/dist/cjs/DatePicker.js +35 -21
  90. package/dist/cjs/DatePicker.js.map +1 -1
  91. package/dist/cjs/DateTimePicker.js +45 -29
  92. package/dist/cjs/DateTimePicker.js.map +1 -1
  93. package/dist/cjs/Dropdown.js +50 -39
  94. package/dist/cjs/Dropdown.js.map +1 -1
  95. package/dist/cjs/Input.js +39 -25
  96. package/dist/cjs/Input.js.map +1 -1
  97. package/dist/cjs/Kbd.js +13 -10
  98. package/dist/cjs/Kbd.js.map +1 -1
  99. package/dist/cjs/Label.js +61 -21
  100. package/dist/cjs/Label.js.map +1 -1
  101. package/dist/cjs/Modal.js +36 -21
  102. package/dist/cjs/Modal.js.map +1 -1
  103. package/dist/cjs/MultiEmailInput.js +71 -39
  104. package/dist/cjs/MultiEmailInput.js.map +1 -1
  105. package/dist/cjs/NoData.js +15 -13
  106. package/dist/cjs/NoData.js.map +1 -1
  107. package/dist/cjs/Pagination.js +24 -17
  108. package/dist/cjs/Pagination.js.map +1 -1
  109. package/dist/cjs/Pane.js +36 -21
  110. package/dist/cjs/Pane.js.map +1 -1
  111. package/dist/cjs/Popover.js +14 -12
  112. package/dist/cjs/Popover.js.map +1 -1
  113. package/dist/cjs/ProgressBar.js +3 -2
  114. package/dist/cjs/ProgressBar.js.map +1 -1
  115. package/dist/cjs/Radio.js +39 -25
  116. package/dist/cjs/Radio.js.map +1 -1
  117. package/dist/cjs/Select.js +91 -54
  118. package/dist/cjs/Select.js.map +1 -1
  119. package/dist/cjs/Sidebar.js +38 -28
  120. package/dist/cjs/Sidebar.js.map +1 -1
  121. package/dist/cjs/Slider.js +29 -17
  122. package/dist/cjs/Slider.js.map +1 -1
  123. package/dist/cjs/Spinner.js +3 -2
  124. package/dist/cjs/Spinner.js.map +1 -1
  125. package/dist/cjs/Stepper.js +7 -6
  126. package/dist/cjs/Stepper.js.map +1 -1
  127. package/dist/cjs/Switch.js +35 -23
  128. package/dist/cjs/Switch.js.map +1 -1
  129. package/dist/cjs/Tab.js +15 -12
  130. package/dist/cjs/Tab.js.map +1 -1
  131. package/dist/cjs/Table.js +55 -44
  132. package/dist/cjs/Table.js.map +1 -1
  133. package/dist/cjs/Tag.js +10 -7
  134. package/dist/cjs/Tag.js.map +1 -1
  135. package/dist/cjs/Textarea.js +38 -24
  136. package/dist/cjs/Textarea.js.map +1 -1
  137. package/dist/cjs/TimePicker.js +31 -18
  138. package/dist/cjs/TimePicker.js.map +1 -1
  139. package/dist/cjs/TimePickerInput.js +268 -22
  140. package/dist/cjs/TimePickerInput.js.map +1 -1
  141. package/dist/cjs/Toastr.js +32 -155
  142. package/dist/cjs/Toastr.js.map +1 -1
  143. package/dist/cjs/Tooltip.js +78 -8
  144. package/dist/cjs/Tooltip.js.map +1 -1
  145. package/dist/cjs/Tree.js +20 -12
  146. package/dist/cjs/Tree.js.map +1 -1
  147. package/dist/cjs/TreeSelect.js +30 -16
  148. package/dist/cjs/TreeSelect.js.map +1 -1
  149. package/dist/cjs/Typography.js +11 -8
  150. package/dist/cjs/Typography.js.map +1 -1
  151. package/dist/cjs/formik/ActionBlock.js +12 -11
  152. package/dist/cjs/formik/ActionBlock.js.map +1 -1
  153. package/dist/cjs/formik/BlockNavigation.js +29 -16
  154. package/dist/cjs/formik/BlockNavigation.js.map +1 -1
  155. package/dist/cjs/formik/Button.js +11 -10
  156. package/dist/cjs/formik/Button.js.map +1 -1
  157. package/dist/cjs/formik/Checkbox.js +28 -16
  158. package/dist/cjs/formik/Checkbox.js.map +1 -1
  159. package/dist/cjs/formik/Form.js +29 -24
  160. package/dist/cjs/formik/Form.js.map +1 -1
  161. package/dist/cjs/formik/Input.js +27 -15
  162. package/dist/cjs/formik/Input.js.map +1 -1
  163. package/dist/cjs/formik/MultiEmailInput.js +47 -15
  164. package/dist/cjs/formik/MultiEmailInput.js.map +1 -1
  165. package/dist/cjs/formik/Radio.js +31 -18
  166. package/dist/cjs/formik/Radio.js.map +1 -1
  167. package/dist/cjs/formik/Select.js +48 -16
  168. package/dist/cjs/formik/Select.js.map +1 -1
  169. package/dist/cjs/formik/Slider.js +31 -18
  170. package/dist/cjs/formik/Slider.js.map +1 -1
  171. package/dist/cjs/formik/Switch.js +28 -16
  172. package/dist/cjs/formik/Switch.js.map +1 -1
  173. package/dist/cjs/formik/Textarea.js +28 -16
  174. package/dist/cjs/formik/Textarea.js.map +1 -1
  175. package/dist/cjs/formik/TreeSelect.js +27 -14
  176. package/dist/cjs/formik/TreeSelect.js.map +1 -1
  177. package/dist/cjs/formik/index.js +45 -16
  178. package/dist/cjs/formik/index.js.map +1 -1
  179. package/dist/cjs/index-f2e36d91.js +167 -0
  180. package/dist/cjs/index-f2e36d91.js.map +1 -0
  181. package/dist/cjs/index.css +1 -1
  182. package/dist/cjs/index.js +49 -20
  183. package/dist/cjs/index.js.map +1 -1
  184. package/dist/cjs/layouts.js +16 -11
  185. package/dist/cjs/layouts.js.map +1 -1
  186. package/dist/cjs/managers.js +2 -2
  187. package/dist/cjs/overlayManager.js +9 -4
  188. package/dist/cjs/overlayManager.js.map +1 -1
  189. package/dist/cjs/{react-select-creatable.esm-b39742a3.js → react-select-creatable.esm-23eddf9f.js} +130 -367
  190. package/dist/cjs/react-select-creatable.esm-23eddf9f.js.map +1 -0
  191. package/dist/cjs/{useOverlayManager-359ed795.js → useOverlayManager-1de0435e.js} +37 -75
  192. package/dist/cjs/useOverlayManager-1de0435e.js.map +1 -0
  193. package/dist/cjs/{useQueryParams-14f054b3.js → useQueryParams-a8ee2f76.js} +9 -5
  194. package/dist/cjs/useQueryParams-a8ee2f76.js.map +1 -0
  195. package/dist/formik/ActionBlock.js +7 -8
  196. package/dist/formik/ActionBlock.js.map +1 -1
  197. package/dist/formik/BlockNavigation.js +23 -13
  198. package/dist/formik/BlockNavigation.js.map +1 -1
  199. package/dist/formik/Button.js +7 -8
  200. package/dist/formik/Button.js.map +1 -1
  201. package/dist/formik/Checkbox.js +22 -13
  202. package/dist/formik/Checkbox.js.map +1 -1
  203. package/dist/formik/Form.js +13 -14
  204. package/dist/formik/Form.js.map +1 -1
  205. package/dist/formik/Input.js +21 -12
  206. package/dist/formik/Input.js.map +1 -1
  207. package/dist/formik/MultiEmailInput.js +41 -12
  208. package/dist/formik/MultiEmailInput.js.map +1 -1
  209. package/dist/formik/Radio.js +23 -14
  210. package/dist/formik/Radio.js.map +1 -1
  211. package/dist/formik/Select.js +40 -12
  212. package/dist/formik/Select.js.map +1 -1
  213. package/dist/formik/Slider.js +23 -14
  214. package/dist/formik/Slider.js.map +1 -1
  215. package/dist/formik/Switch.js +22 -13
  216. package/dist/formik/Switch.js.map +1 -1
  217. package/dist/formik/Textarea.js +22 -13
  218. package/dist/formik/Textarea.js.map +1 -1
  219. package/dist/formik/TreeSelect.js +21 -11
  220. package/dist/formik/TreeSelect.js.map +1 -1
  221. package/dist/formik/index.js +45 -16
  222. package/dist/formik/index.js.map +1 -1
  223. package/dist/index-9d5142b4.js +145 -0
  224. package/dist/index-9d5142b4.js.map +1 -0
  225. package/dist/index.css +1 -1
  226. package/dist/index.js +47 -18
  227. package/dist/index.js.map +1 -1
  228. package/dist/layouts.js +16 -11
  229. package/dist/layouts.js.map +1 -1
  230. package/dist/managers.js +2 -2
  231. package/dist/overlayManager.js +2 -2
  232. package/dist/{react-select-creatable.esm-93affeca.js → react-select-creatable.esm-ad71b0c0.js} +43 -289
  233. package/dist/react-select-creatable.esm-ad71b0c0.js.map +1 -0
  234. package/dist/{useOverlayManager-95a474d5.js → useOverlayManager-9d385819.js} +9 -54
  235. package/dist/useOverlayManager-9d385819.js.map +1 -0
  236. package/dist/{useQueryParams-4e7ddcf8.js → useQueryParams-dcb34865.js} +4 -4
  237. package/dist/{useQueryParams-4e7ddcf8.js.map → useQueryParams-dcb34865.js.map} +1 -1
  238. package/package.json +13 -6
  239. package/types/Label.d.ts +7 -0
  240. package/dist/cjs/createClass-80e17c6a.js +0 -31
  241. package/dist/cjs/createClass-80e17c6a.js.map +0 -1
  242. package/dist/cjs/defineProperty-ee86604b.js +0 -21
  243. package/dist/cjs/defineProperty-ee86604b.js.map +0 -1
  244. package/dist/cjs/extends-1b35a664.js +0 -19
  245. package/dist/cjs/extends-1b35a664.js.map +0 -1
  246. package/dist/cjs/index-302c3d37.js +0 -58
  247. package/dist/cjs/index-302c3d37.js.map +0 -1
  248. package/dist/cjs/index-5d74cfeb.js +0 -375
  249. package/dist/cjs/index-5d74cfeb.js.map +0 -1
  250. package/dist/cjs/index-6e09c7bc.js +0 -2211
  251. package/dist/cjs/index-6e09c7bc.js.map +0 -1
  252. package/dist/cjs/index-773961dd.js +0 -453
  253. package/dist/cjs/index-773961dd.js.map +0 -1
  254. package/dist/cjs/index-a8cc581e.js +0 -2383
  255. package/dist/cjs/index-a8cc581e.js.map +0 -1
  256. package/dist/cjs/index-becc6543.js +0 -262
  257. package/dist/cjs/index-becc6543.js.map +0 -1
  258. package/dist/cjs/objectWithoutProperties-2fed2d7d.js +0 -33
  259. package/dist/cjs/objectWithoutProperties-2fed2d7d.js.map +0 -1
  260. package/dist/cjs/react-select-creatable.esm-b39742a3.js.map +0 -1
  261. package/dist/cjs/slicedToArray-732a2048.js +0 -63
  262. package/dist/cjs/slicedToArray-732a2048.js.map +0 -1
  263. package/dist/cjs/toConsumableArray-418424fc.js +0 -23
  264. package/dist/cjs/toConsumableArray-418424fc.js.map +0 -1
  265. package/dist/cjs/toPropertyKey-bfa2e465.js +0 -31
  266. package/dist/cjs/toPropertyKey-bfa2e465.js.map +0 -1
  267. package/dist/cjs/useOverlayManager-359ed795.js.map +0 -1
  268. package/dist/cjs/useQueryParams-14f054b3.js.map +0 -1
  269. package/dist/createClass-601a36b2.js +0 -28
  270. package/dist/createClass-601a36b2.js.map +0 -1
  271. package/dist/defineProperty-e5245270.js +0 -19
  272. package/dist/defineProperty-e5245270.js.map +0 -1
  273. package/dist/extends-093996c9.js +0 -17
  274. package/dist/extends-093996c9.js.map +0 -1
  275. package/dist/index-34956d66.js +0 -372
  276. package/dist/index-34956d66.js.map +0 -1
  277. package/dist/index-3659771d.js +0 -56
  278. package/dist/index-3659771d.js.map +0 -1
  279. package/dist/index-661b9fd6.js +0 -253
  280. package/dist/index-661b9fd6.js.map +0 -1
  281. package/dist/index-7fae3611.js +0 -2381
  282. package/dist/index-7fae3611.js.map +0 -1
  283. package/dist/index-c442518b.js +0 -445
  284. package/dist/index-c442518b.js.map +0 -1
  285. package/dist/index-c8d9113c.js +0 -2193
  286. package/dist/index-c8d9113c.js.map +0 -1
  287. package/dist/objectWithoutProperties-a0edb288.js +0 -31
  288. package/dist/objectWithoutProperties-a0edb288.js.map +0 -1
  289. package/dist/react-select-creatable.esm-93affeca.js.map +0 -1
  290. package/dist/slicedToArray-45fa766e.js +0 -57
  291. package/dist/slicedToArray-45fa766e.js.map +0 -1
  292. package/dist/toConsumableArray-1186e144.js +0 -20
  293. package/dist/toConsumableArray-1186e144.js.map +0 -1
  294. package/dist/toPropertyKey-bdc24cb9.js +0 -28
  295. package/dist/toPropertyKey-bdc24cb9.js.map +0 -1
  296. package/dist/useOverlayManager-95a474d5.js.map +0 -1
@@ -1,2383 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var ramda = require('ramda');
5
-
6
- var MODES = {
7
- "default": "default",
8
- global: "global",
9
- scoped: "scoped"
10
- };
11
- var DEFAULT_CONFIG = {
12
- mode: MODES["default"],
13
- unbindOnUnmount: true,
14
- enabled: true
15
- };
16
- var MAC_TO_WINDOWS_KEYS_MAP = {
17
- option: "alt",
18
- command: "ctrl",
19
- "return": "enter",
20
- "delete": "backspace"
21
- };
22
- var OS = {
23
- mac: "OS X",
24
- windows: "Windows"
25
- };
26
- var KEY_NAMES = {
27
- "delete": "delete",
28
- backspace: "backspace"
29
- };
30
-
31
- function _arrayWithHoles(arr) {
32
- if (Array.isArray(arr)) return arr;
33
- }
34
-
35
- function _iterableToArrayLimit(r, l) {
36
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
37
- if (null != t) {
38
- var e,
39
- n,
40
- i,
41
- u,
42
- a = [],
43
- f = !0,
44
- o = !1;
45
- try {
46
- if (i = (t = t.call(r)).next, 0 === l) {
47
- if (Object(t) !== t) return;
48
- f = !1;
49
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
50
- } catch (r) {
51
- o = !0, n = r;
52
- } finally {
53
- try {
54
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
55
- } finally {
56
- if (o) throw n;
57
- }
58
- }
59
- return a;
60
- }
61
- }
62
-
63
- function _arrayLikeToArray(arr, len) {
64
- if (len == null || len > arr.length) len = arr.length;
65
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
66
- return arr2;
67
- }
68
-
69
- function _unsupportedIterableToArray(o, minLen) {
70
- if (!o) return;
71
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
72
- var n = Object.prototype.toString.call(o).slice(8, -1);
73
- if (n === "Object" && o.constructor) n = o.constructor.name;
74
- if (n === "Map" || n === "Set") return Array.from(o);
75
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
76
- }
77
-
78
- function _nonIterableRest() {
79
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
80
- }
81
-
82
- function _slicedToArray(arr, i) {
83
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
84
- }
85
-
86
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
87
-
88
- function getDefaultExportFromCjs (x) {
89
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
90
- }
91
-
92
- var mousetrap = {exports: {}};
93
-
94
- /*global define:false */
95
- mousetrap.exports;
96
- (function (module) {
97
- /**
98
- * Copyright 2012-2017 Craig Campbell
99
- *
100
- * Licensed under the Apache License, Version 2.0 (the "License");
101
- * you may not use this file except in compliance with the License.
102
- * You may obtain a copy of the License at
103
- *
104
- * http://www.apache.org/licenses/LICENSE-2.0
105
- *
106
- * Unless required by applicable law or agreed to in writing, software
107
- * distributed under the License is distributed on an "AS IS" BASIS,
108
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
109
- * See the License for the specific language governing permissions and
110
- * limitations under the License.
111
- *
112
- * Mousetrap is a simple keyboard shortcut library for Javascript with
113
- * no external dependencies
114
- *
115
- * @version 1.6.5
116
- * @url craig.is/killing/mice
117
- */
118
- (function (window, document, undefined$1) {
119
- // Check if mousetrap is used inside browser, if not, return
120
- if (!window) {
121
- return;
122
- }
123
-
124
- /**
125
- * mapping of special keycodes to their corresponding keys
126
- *
127
- * everything in this dictionary cannot use keypress events
128
- * so it has to be here to map to the correct keycodes for
129
- * keyup/keydown events
130
- *
131
- * @type {Object}
132
- */
133
- var _MAP = {
134
- 8: 'backspace',
135
- 9: 'tab',
136
- 13: 'enter',
137
- 16: 'shift',
138
- 17: 'ctrl',
139
- 18: 'alt',
140
- 20: 'capslock',
141
- 27: 'esc',
142
- 32: 'space',
143
- 33: 'pageup',
144
- 34: 'pagedown',
145
- 35: 'end',
146
- 36: 'home',
147
- 37: 'left',
148
- 38: 'up',
149
- 39: 'right',
150
- 40: 'down',
151
- 45: 'ins',
152
- 46: 'del',
153
- 91: 'meta',
154
- 93: 'meta',
155
- 224: 'meta'
156
- };
157
-
158
- /**
159
- * mapping for special characters so they can support
160
- *
161
- * this dictionary is only used incase you want to bind a
162
- * keyup or keydown event to one of these keys
163
- *
164
- * @type {Object}
165
- */
166
- var _KEYCODE_MAP = {
167
- 106: '*',
168
- 107: '+',
169
- 109: '-',
170
- 110: '.',
171
- 111: '/',
172
- 186: ';',
173
- 187: '=',
174
- 188: ',',
175
- 189: '-',
176
- 190: '.',
177
- 191: '/',
178
- 192: '`',
179
- 219: '[',
180
- 220: '\\',
181
- 221: ']',
182
- 222: '\''
183
- };
184
-
185
- /**
186
- * this is a mapping of keys that require shift on a US keypad
187
- * back to the non shift equivelents
188
- *
189
- * this is so you can use keyup events with these keys
190
- *
191
- * note that this will only work reliably on US keyboards
192
- *
193
- * @type {Object}
194
- */
195
- var _SHIFT_MAP = {
196
- '~': '`',
197
- '!': '1',
198
- '@': '2',
199
- '#': '3',
200
- '$': '4',
201
- '%': '5',
202
- '^': '6',
203
- '&': '7',
204
- '*': '8',
205
- '(': '9',
206
- ')': '0',
207
- '_': '-',
208
- '+': '=',
209
- ':': ';',
210
- '\"': '\'',
211
- '<': ',',
212
- '>': '.',
213
- '?': '/',
214
- '|': '\\'
215
- };
216
-
217
- /**
218
- * this is a list of special strings you can use to map
219
- * to modifier keys when you specify your keyboard shortcuts
220
- *
221
- * @type {Object}
222
- */
223
- var _SPECIAL_ALIASES = {
224
- 'option': 'alt',
225
- 'command': 'meta',
226
- 'return': 'enter',
227
- 'escape': 'esc',
228
- 'plus': '+',
229
- 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
230
- };
231
-
232
- /**
233
- * variable to store the flipped version of _MAP from above
234
- * needed to check if we should use keypress or not when no action
235
- * is specified
236
- *
237
- * @type {Object|undefined}
238
- */
239
- var _REVERSE_MAP;
240
-
241
- /**
242
- * loop through the f keys, f1 to f19 and add them to the map
243
- * programatically
244
- */
245
- for (var i = 1; i < 20; ++i) {
246
- _MAP[111 + i] = 'f' + i;
247
- }
248
-
249
- /**
250
- * loop through to map numbers on the numeric keypad
251
- */
252
- for (i = 0; i <= 9; ++i) {
253
- // This needs to use a string cause otherwise since 0 is falsey
254
- // mousetrap will never fire for numpad 0 pressed as part of a keydown
255
- // event.
256
- //
257
- // @see https://github.com/ccampbell/mousetrap/pull/258
258
- _MAP[i + 96] = i.toString();
259
- }
260
-
261
- /**
262
- * cross browser add event method
263
- *
264
- * @param {Element|HTMLDocument} object
265
- * @param {string} type
266
- * @param {Function} callback
267
- * @returns void
268
- */
269
- function _addEvent(object, type, callback) {
270
- if (object.addEventListener) {
271
- object.addEventListener(type, callback, false);
272
- return;
273
- }
274
- object.attachEvent('on' + type, callback);
275
- }
276
-
277
- /**
278
- * takes the event and returns the key character
279
- *
280
- * @param {Event} e
281
- * @return {string}
282
- */
283
- function _characterFromEvent(e) {
284
- // for keypress events we should return the character as is
285
- if (e.type == 'keypress') {
286
- var character = String.fromCharCode(e.which);
287
-
288
- // if the shift key is not pressed then it is safe to assume
289
- // that we want the character to be lowercase. this means if
290
- // you accidentally have caps lock on then your key bindings
291
- // will continue to work
292
- //
293
- // the only side effect that might not be desired is if you
294
- // bind something like 'A' cause you want to trigger an
295
- // event when capital A is pressed caps lock will no longer
296
- // trigger the event. shift+a will though.
297
- if (!e.shiftKey) {
298
- character = character.toLowerCase();
299
- }
300
- return character;
301
- }
302
-
303
- // for non keypress events the special maps are needed
304
- if (_MAP[e.which]) {
305
- return _MAP[e.which];
306
- }
307
- if (_KEYCODE_MAP[e.which]) {
308
- return _KEYCODE_MAP[e.which];
309
- }
310
-
311
- // if it is not in the special map
312
-
313
- // with keydown and keyup events the character seems to always
314
- // come in as an uppercase character whether you are pressing shift
315
- // or not. we should make sure it is always lowercase for comparisons
316
- return String.fromCharCode(e.which).toLowerCase();
317
- }
318
-
319
- /**
320
- * checks if two arrays are equal
321
- *
322
- * @param {Array} modifiers1
323
- * @param {Array} modifiers2
324
- * @returns {boolean}
325
- */
326
- function _modifiersMatch(modifiers1, modifiers2) {
327
- return modifiers1.sort().join(',') === modifiers2.sort().join(',');
328
- }
329
-
330
- /**
331
- * takes a key event and figures out what the modifiers are
332
- *
333
- * @param {Event} e
334
- * @returns {Array}
335
- */
336
- function _eventModifiers(e) {
337
- var modifiers = [];
338
- if (e.shiftKey) {
339
- modifiers.push('shift');
340
- }
341
- if (e.altKey) {
342
- modifiers.push('alt');
343
- }
344
- if (e.ctrlKey) {
345
- modifiers.push('ctrl');
346
- }
347
- if (e.metaKey) {
348
- modifiers.push('meta');
349
- }
350
- return modifiers;
351
- }
352
-
353
- /**
354
- * prevents default for this event
355
- *
356
- * @param {Event} e
357
- * @returns void
358
- */
359
- function _preventDefault(e) {
360
- if (e.preventDefault) {
361
- e.preventDefault();
362
- return;
363
- }
364
- e.returnValue = false;
365
- }
366
-
367
- /**
368
- * stops propogation for this event
369
- *
370
- * @param {Event} e
371
- * @returns void
372
- */
373
- function _stopPropagation(e) {
374
- if (e.stopPropagation) {
375
- e.stopPropagation();
376
- return;
377
- }
378
- e.cancelBubble = true;
379
- }
380
-
381
- /**
382
- * determines if the keycode specified is a modifier key or not
383
- *
384
- * @param {string} key
385
- * @returns {boolean}
386
- */
387
- function _isModifier(key) {
388
- return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
389
- }
390
-
391
- /**
392
- * reverses the map lookup so that we can look for specific keys
393
- * to see what can and can't use keypress
394
- *
395
- * @return {Object}
396
- */
397
- function _getReverseMap() {
398
- if (!_REVERSE_MAP) {
399
- _REVERSE_MAP = {};
400
- for (var key in _MAP) {
401
- // pull out the numeric keypad from here cause keypress should
402
- // be able to detect the keys from the character
403
- if (key > 95 && key < 112) {
404
- continue;
405
- }
406
- if (_MAP.hasOwnProperty(key)) {
407
- _REVERSE_MAP[_MAP[key]] = key;
408
- }
409
- }
410
- }
411
- return _REVERSE_MAP;
412
- }
413
-
414
- /**
415
- * picks the best action based on the key combination
416
- *
417
- * @param {string} key - character for key
418
- * @param {Array} modifiers
419
- * @param {string=} action passed in
420
- */
421
- function _pickBestAction(key, modifiers, action) {
422
- // if no action was picked in we should try to pick the one
423
- // that we think would work best for this key
424
- if (!action) {
425
- action = _getReverseMap()[key] ? 'keydown' : 'keypress';
426
- }
427
-
428
- // modifier keys don't work as expected with keypress,
429
- // switch to keydown
430
- if (action == 'keypress' && modifiers.length) {
431
- action = 'keydown';
432
- }
433
- return action;
434
- }
435
-
436
- /**
437
- * Converts from a string key combination to an array
438
- *
439
- * @param {string} combination like "command+shift+l"
440
- * @return {Array}
441
- */
442
- function _keysFromString(combination) {
443
- if (combination === '+') {
444
- return ['+'];
445
- }
446
- combination = combination.replace(/\+{2}/g, '+plus');
447
- return combination.split('+');
448
- }
449
-
450
- /**
451
- * Gets info for a specific key combination
452
- *
453
- * @param {string} combination key combination ("command+s" or "a" or "*")
454
- * @param {string=} action
455
- * @returns {Object}
456
- */
457
- function _getKeyInfo(combination, action) {
458
- var keys;
459
- var key;
460
- var i;
461
- var modifiers = [];
462
-
463
- // take the keys from this pattern and figure out what the actual
464
- // pattern is all about
465
- keys = _keysFromString(combination);
466
- for (i = 0; i < keys.length; ++i) {
467
- key = keys[i];
468
-
469
- // normalize key names
470
- if (_SPECIAL_ALIASES[key]) {
471
- key = _SPECIAL_ALIASES[key];
472
- }
473
-
474
- // if this is not a keypress event then we should
475
- // be smart about using shift keys
476
- // this will only work for US keyboards however
477
- if (action && action != 'keypress' && _SHIFT_MAP[key]) {
478
- key = _SHIFT_MAP[key];
479
- modifiers.push('shift');
480
- }
481
-
482
- // if this key is a modifier then add it to the list of modifiers
483
- if (_isModifier(key)) {
484
- modifiers.push(key);
485
- }
486
- }
487
-
488
- // depending on what the key combination is
489
- // we will try to pick the best event for it
490
- action = _pickBestAction(key, modifiers, action);
491
- return {
492
- key: key,
493
- modifiers: modifiers,
494
- action: action
495
- };
496
- }
497
- function _belongsTo(element, ancestor) {
498
- if (element === null || element === document) {
499
- return false;
500
- }
501
- if (element === ancestor) {
502
- return true;
503
- }
504
- return _belongsTo(element.parentNode, ancestor);
505
- }
506
- function Mousetrap(targetElement) {
507
- var self = this;
508
- targetElement = targetElement || document;
509
- if (!(self instanceof Mousetrap)) {
510
- return new Mousetrap(targetElement);
511
- }
512
-
513
- /**
514
- * element to attach key events to
515
- *
516
- * @type {Element}
517
- */
518
- self.target = targetElement;
519
-
520
- /**
521
- * a list of all the callbacks setup via Mousetrap.bind()
522
- *
523
- * @type {Object}
524
- */
525
- self._callbacks = {};
526
-
527
- /**
528
- * direct map of string combinations to callbacks used for trigger()
529
- *
530
- * @type {Object}
531
- */
532
- self._directMap = {};
533
-
534
- /**
535
- * keeps track of what level each sequence is at since multiple
536
- * sequences can start out with the same sequence
537
- *
538
- * @type {Object}
539
- */
540
- var _sequenceLevels = {};
541
-
542
- /**
543
- * variable to store the setTimeout call
544
- *
545
- * @type {null|number}
546
- */
547
- var _resetTimer;
548
-
549
- /**
550
- * temporary state where we will ignore the next keyup
551
- *
552
- * @type {boolean|string}
553
- */
554
- var _ignoreNextKeyup = false;
555
-
556
- /**
557
- * temporary state where we will ignore the next keypress
558
- *
559
- * @type {boolean}
560
- */
561
- var _ignoreNextKeypress = false;
562
-
563
- /**
564
- * are we currently inside of a sequence?
565
- * type of action ("keyup" or "keydown" or "keypress") or false
566
- *
567
- * @type {boolean|string}
568
- */
569
- var _nextExpectedAction = false;
570
-
571
- /**
572
- * resets all sequence counters except for the ones passed in
573
- *
574
- * @param {Object} doNotReset
575
- * @returns void
576
- */
577
- function _resetSequences(doNotReset) {
578
- doNotReset = doNotReset || {};
579
- var activeSequences = false,
580
- key;
581
- for (key in _sequenceLevels) {
582
- if (doNotReset[key]) {
583
- activeSequences = true;
584
- continue;
585
- }
586
- _sequenceLevels[key] = 0;
587
- }
588
- if (!activeSequences) {
589
- _nextExpectedAction = false;
590
- }
591
- }
592
-
593
- /**
594
- * finds all callbacks that match based on the keycode, modifiers,
595
- * and action
596
- *
597
- * @param {string} character
598
- * @param {Array} modifiers
599
- * @param {Event|Object} e
600
- * @param {string=} sequenceName - name of the sequence we are looking for
601
- * @param {string=} combination
602
- * @param {number=} level
603
- * @returns {Array}
604
- */
605
- function _getMatches(character, modifiers, e, sequenceName, combination, level) {
606
- var i;
607
- var callback;
608
- var matches = [];
609
- var action = e.type;
610
-
611
- // if there are no events related to this keycode
612
- if (!self._callbacks[character]) {
613
- return [];
614
- }
615
-
616
- // if a modifier key is coming up on its own we should allow it
617
- if (action == 'keyup' && _isModifier(character)) {
618
- modifiers = [character];
619
- }
620
-
621
- // loop through all callbacks for the key that was pressed
622
- // and see if any of them match
623
- for (i = 0; i < self._callbacks[character].length; ++i) {
624
- callback = self._callbacks[character][i];
625
-
626
- // if a sequence name is not specified, but this is a sequence at
627
- // the wrong level then move onto the next match
628
- if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
629
- continue;
630
- }
631
-
632
- // if the action we are looking for doesn't match the action we got
633
- // then we should keep going
634
- if (action != callback.action) {
635
- continue;
636
- }
637
-
638
- // if this is a keypress event and the meta key and control key
639
- // are not pressed that means that we need to only look at the
640
- // character, otherwise check the modifiers as well
641
- //
642
- // chrome will not fire a keypress if meta or control is down
643
- // safari will fire a keypress if meta or meta+shift is down
644
- // firefox will fire a keypress if meta or control is down
645
- if (action == 'keypress' && !e.metaKey && !e.ctrlKey || _modifiersMatch(modifiers, callback.modifiers)) {
646
- // when you bind a combination or sequence a second time it
647
- // should overwrite the first one. if a sequenceName or
648
- // combination is specified in this call it does just that
649
- //
650
- // @todo make deleting its own method?
651
- var deleteCombo = !sequenceName && callback.combo == combination;
652
- var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
653
- if (deleteCombo || deleteSequence) {
654
- self._callbacks[character].splice(i, 1);
655
- }
656
- matches.push(callback);
657
- }
658
- }
659
- return matches;
660
- }
661
-
662
- /**
663
- * actually calls the callback function
664
- *
665
- * if your callback function returns false this will use the jquery
666
- * convention - prevent default and stop propogation on the event
667
- *
668
- * @param {Function} callback
669
- * @param {Event} e
670
- * @returns void
671
- */
672
- function _fireCallback(callback, e, combo, sequence) {
673
- // if this event should not happen stop here
674
- if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
675
- return;
676
- }
677
- if (callback(e, combo) === false) {
678
- _preventDefault(e);
679
- _stopPropagation(e);
680
- }
681
- }
682
-
683
- /**
684
- * handles a character key event
685
- *
686
- * @param {string} character
687
- * @param {Array} modifiers
688
- * @param {Event} e
689
- * @returns void
690
- */
691
- self._handleKey = function (character, modifiers, e) {
692
- var callbacks = _getMatches(character, modifiers, e);
693
- var i;
694
- var doNotReset = {};
695
- var maxLevel = 0;
696
- var processedSequenceCallback = false;
697
-
698
- // Calculate the maxLevel for sequences so we can only execute the longest callback sequence
699
- for (i = 0; i < callbacks.length; ++i) {
700
- if (callbacks[i].seq) {
701
- maxLevel = Math.max(maxLevel, callbacks[i].level);
702
- }
703
- }
704
-
705
- // loop through matching callbacks for this key event
706
- for (i = 0; i < callbacks.length; ++i) {
707
- // fire for all sequence callbacks
708
- // this is because if for example you have multiple sequences
709
- // bound such as "g i" and "g t" they both need to fire the
710
- // callback for matching g cause otherwise you can only ever
711
- // match the first one
712
- if (callbacks[i].seq) {
713
- // only fire callbacks for the maxLevel to prevent
714
- // subsequences from also firing
715
- //
716
- // for example 'a option b' should not cause 'option b' to fire
717
- // even though 'option b' is part of the other sequence
718
- //
719
- // any sequences that do not match here will be discarded
720
- // below by the _resetSequences call
721
- if (callbacks[i].level != maxLevel) {
722
- continue;
723
- }
724
- processedSequenceCallback = true;
725
-
726
- // keep a list of which sequences were matches for later
727
- doNotReset[callbacks[i].seq] = 1;
728
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
729
- continue;
730
- }
731
-
732
- // if there were no sequence matches but we are still here
733
- // that means this is a regular match so we should fire that
734
- if (!processedSequenceCallback) {
735
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
736
- }
737
- }
738
-
739
- // if the key you pressed matches the type of sequence without
740
- // being a modifier (ie "keyup" or "keypress") then we should
741
- // reset all sequences that were not matched by this event
742
- //
743
- // this is so, for example, if you have the sequence "h a t" and you
744
- // type "h e a r t" it does not match. in this case the "e" will
745
- // cause the sequence to reset
746
- //
747
- // modifier keys are ignored because you can have a sequence
748
- // that contains modifiers such as "enter ctrl+space" and in most
749
- // cases the modifier key will be pressed before the next key
750
- //
751
- // also if you have a sequence such as "ctrl+b a" then pressing the
752
- // "b" key will trigger a "keypress" and a "keydown"
753
- //
754
- // the "keydown" is expected when there is a modifier, but the
755
- // "keypress" ends up matching the _nextExpectedAction since it occurs
756
- // after and that causes the sequence to reset
757
- //
758
- // we ignore keypresses in a sequence that directly follow a keydown
759
- // for the same character
760
- var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
761
- if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
762
- _resetSequences(doNotReset);
763
- }
764
- _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
765
- };
766
-
767
- /**
768
- * handles a keydown event
769
- *
770
- * @param {Event} e
771
- * @returns void
772
- */
773
- function _handleKeyEvent(e) {
774
- // normalize e.which for key events
775
- // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
776
- if (typeof e.which !== 'number') {
777
- e.which = e.keyCode;
778
- }
779
- var character = _characterFromEvent(e);
780
-
781
- // no character found then stop
782
- if (!character) {
783
- return;
784
- }
785
-
786
- // need to use === for the character check because the character can be 0
787
- if (e.type == 'keyup' && _ignoreNextKeyup === character) {
788
- _ignoreNextKeyup = false;
789
- return;
790
- }
791
- self.handleKey(character, _eventModifiers(e), e);
792
- }
793
-
794
- /**
795
- * called to set a 1 second timeout on the specified sequence
796
- *
797
- * this is so after each key press in the sequence you have 1 second
798
- * to press the next key before you have to start over
799
- *
800
- * @returns void
801
- */
802
- function _resetSequenceTimer() {
803
- clearTimeout(_resetTimer);
804
- _resetTimer = setTimeout(_resetSequences, 1000);
805
- }
806
-
807
- /**
808
- * binds a key sequence to an event
809
- *
810
- * @param {string} combo - combo specified in bind call
811
- * @param {Array} keys
812
- * @param {Function} callback
813
- * @param {string=} action
814
- * @returns void
815
- */
816
- function _bindSequence(combo, keys, callback, action) {
817
- // start off by adding a sequence level record for this combination
818
- // and setting the level to 0
819
- _sequenceLevels[combo] = 0;
820
-
821
- /**
822
- * callback to increase the sequence level for this sequence and reset
823
- * all other sequences that were active
824
- *
825
- * @param {string} nextAction
826
- * @returns {Function}
827
- */
828
- function _increaseSequence(nextAction) {
829
- return function () {
830
- _nextExpectedAction = nextAction;
831
- ++_sequenceLevels[combo];
832
- _resetSequenceTimer();
833
- };
834
- }
835
-
836
- /**
837
- * wraps the specified callback inside of another function in order
838
- * to reset all sequence counters as soon as this sequence is done
839
- *
840
- * @param {Event} e
841
- * @returns void
842
- */
843
- function _callbackAndReset(e) {
844
- _fireCallback(callback, e, combo);
845
-
846
- // we should ignore the next key up if the action is key down
847
- // or keypress. this is so if you finish a sequence and
848
- // release the key the final key will not trigger a keyup
849
- if (action !== 'keyup') {
850
- _ignoreNextKeyup = _characterFromEvent(e);
851
- }
852
-
853
- // weird race condition if a sequence ends with the key
854
- // another sequence begins with
855
- setTimeout(_resetSequences, 10);
856
- }
857
-
858
- // loop through keys one at a time and bind the appropriate callback
859
- // function. for any key leading up to the final one it should
860
- // increase the sequence. after the final, it should reset all sequences
861
- //
862
- // if an action is specified in the original bind call then that will
863
- // be used throughout. otherwise we will pass the action that the
864
- // next key in the sequence should match. this allows a sequence
865
- // to mix and match keypress and keydown events depending on which
866
- // ones are better suited to the key provided
867
- for (var i = 0; i < keys.length; ++i) {
868
- var isFinal = i + 1 === keys.length;
869
- var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
870
- _bindSingle(keys[i], wrappedCallback, action, combo, i);
871
- }
872
- }
873
-
874
- /**
875
- * binds a single keyboard combination
876
- *
877
- * @param {string} combination
878
- * @param {Function} callback
879
- * @param {string=} action
880
- * @param {string=} sequenceName - name of sequence if part of sequence
881
- * @param {number=} level - what part of the sequence the command is
882
- * @returns void
883
- */
884
- function _bindSingle(combination, callback, action, sequenceName, level) {
885
- // store a direct mapped reference for use with Mousetrap.trigger
886
- self._directMap[combination + ':' + action] = callback;
887
-
888
- // make sure multiple spaces in a row become a single space
889
- combination = combination.replace(/\s+/g, ' ');
890
- var sequence = combination.split(' ');
891
- var info;
892
-
893
- // if this pattern is a sequence of keys then run through this method
894
- // to reprocess each pattern one key at a time
895
- if (sequence.length > 1) {
896
- _bindSequence(combination, sequence, callback, action);
897
- return;
898
- }
899
- info = _getKeyInfo(combination, action);
900
-
901
- // make sure to initialize array if this is the first time
902
- // a callback is added for this key
903
- self._callbacks[info.key] = self._callbacks[info.key] || [];
904
-
905
- // remove an existing match if there is one
906
- _getMatches(info.key, info.modifiers, {
907
- type: info.action
908
- }, sequenceName, combination, level);
909
-
910
- // add this call back to the array
911
- // if it is a sequence put it at the beginning
912
- // if not put it at the end
913
- //
914
- // this is important because the way these are processed expects
915
- // the sequence ones to come first
916
- self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
917
- callback: callback,
918
- modifiers: info.modifiers,
919
- action: info.action,
920
- seq: sequenceName,
921
- level: level,
922
- combo: combination
923
- });
924
- }
925
-
926
- /**
927
- * binds multiple combinations to the same callback
928
- *
929
- * @param {Array} combinations
930
- * @param {Function} callback
931
- * @param {string|undefined} action
932
- * @returns void
933
- */
934
- self._bindMultiple = function (combinations, callback, action) {
935
- for (var i = 0; i < combinations.length; ++i) {
936
- _bindSingle(combinations[i], callback, action);
937
- }
938
- };
939
-
940
- // start!
941
- _addEvent(targetElement, 'keypress', _handleKeyEvent);
942
- _addEvent(targetElement, 'keydown', _handleKeyEvent);
943
- _addEvent(targetElement, 'keyup', _handleKeyEvent);
944
- }
945
-
946
- /**
947
- * binds an event to mousetrap
948
- *
949
- * can be a single key, a combination of keys separated with +,
950
- * an array of keys, or a sequence of keys separated by spaces
951
- *
952
- * be sure to list the modifier keys first to make sure that the
953
- * correct key ends up getting bound (the last key in the pattern)
954
- *
955
- * @param {string|Array} keys
956
- * @param {Function} callback
957
- * @param {string=} action - 'keypress', 'keydown', or 'keyup'
958
- * @returns void
959
- */
960
- Mousetrap.prototype.bind = function (keys, callback, action) {
961
- var self = this;
962
- keys = keys instanceof Array ? keys : [keys];
963
- self._bindMultiple.call(self, keys, callback, action);
964
- return self;
965
- };
966
-
967
- /**
968
- * unbinds an event to mousetrap
969
- *
970
- * the unbinding sets the callback function of the specified key combo
971
- * to an empty function and deletes the corresponding key in the
972
- * _directMap dict.
973
- *
974
- * TODO: actually remove this from the _callbacks dictionary instead
975
- * of binding an empty function
976
- *
977
- * the keycombo+action has to be exactly the same as
978
- * it was defined in the bind method
979
- *
980
- * @param {string|Array} keys
981
- * @param {string} action
982
- * @returns void
983
- */
984
- Mousetrap.prototype.unbind = function (keys, action) {
985
- var self = this;
986
- return self.bind.call(self, keys, function () {}, action);
987
- };
988
-
989
- /**
990
- * triggers an event that has already been bound
991
- *
992
- * @param {string} keys
993
- * @param {string=} action
994
- * @returns void
995
- */
996
- Mousetrap.prototype.trigger = function (keys, action) {
997
- var self = this;
998
- if (self._directMap[keys + ':' + action]) {
999
- self._directMap[keys + ':' + action]({}, keys);
1000
- }
1001
- return self;
1002
- };
1003
-
1004
- /**
1005
- * resets the library back to its initial state. this is useful
1006
- * if you want to clear out the current keyboard shortcuts and bind
1007
- * new ones - for example if you switch to another page
1008
- *
1009
- * @returns void
1010
- */
1011
- Mousetrap.prototype.reset = function () {
1012
- var self = this;
1013
- self._callbacks = {};
1014
- self._directMap = {};
1015
- return self;
1016
- };
1017
-
1018
- /**
1019
- * should we stop this event before firing off callbacks
1020
- *
1021
- * @param {Event} e
1022
- * @param {Element} element
1023
- * @return {boolean}
1024
- */
1025
- Mousetrap.prototype.stopCallback = function (e, element) {
1026
- var self = this;
1027
-
1028
- // if the element has the class "mousetrap" then no need to stop
1029
- if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
1030
- return false;
1031
- }
1032
- if (_belongsTo(element, self.target)) {
1033
- return false;
1034
- }
1035
-
1036
- // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
1037
- // not the initial event target in the shadow tree. Note that not all events cross the
1038
- // shadow boundary.
1039
- // For shadow trees with `mode: 'open'`, the initial event target is the first element in
1040
- // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event
1041
- // target cannot be obtained.
1042
- if ('composedPath' in e && typeof e.composedPath === 'function') {
1043
- // For open shadow trees, update `element` so that the following check works.
1044
- var initialEventTarget = e.composedPath()[0];
1045
- if (initialEventTarget !== e.target) {
1046
- element = initialEventTarget;
1047
- }
1048
- }
1049
-
1050
- // stop for input, select, and textarea
1051
- return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
1052
- };
1053
-
1054
- /**
1055
- * exposes _handleKey publicly so it can be overwritten by extensions
1056
- */
1057
- Mousetrap.prototype.handleKey = function () {
1058
- var self = this;
1059
- return self._handleKey.apply(self, arguments);
1060
- };
1061
-
1062
- /**
1063
- * allow custom key mappings
1064
- */
1065
- Mousetrap.addKeycodes = function (object) {
1066
- for (var key in object) {
1067
- if (object.hasOwnProperty(key)) {
1068
- _MAP[key] = object[key];
1069
- }
1070
- }
1071
- _REVERSE_MAP = null;
1072
- };
1073
-
1074
- /**
1075
- * Init the global mousetrap functions
1076
- *
1077
- * This method is needed to allow the global mousetrap functions to work
1078
- * now that mousetrap is a constructor function.
1079
- */
1080
- Mousetrap.init = function () {
1081
- var documentMousetrap = Mousetrap(document);
1082
- for (var method in documentMousetrap) {
1083
- if (method.charAt(0) !== '_') {
1084
- Mousetrap[method] = function (method) {
1085
- return function () {
1086
- return documentMousetrap[method].apply(documentMousetrap, arguments);
1087
- };
1088
- }(method);
1089
- }
1090
- }
1091
- };
1092
- Mousetrap.init();
1093
-
1094
- // expose mousetrap to the global object
1095
- window.Mousetrap = Mousetrap;
1096
-
1097
- // expose as a common js module
1098
- if (module.exports) {
1099
- module.exports = Mousetrap;
1100
- }
1101
-
1102
- // expose mousetrap as an AMD module
1103
- if (typeof undefined$1 === 'function' && undefined$1.amd) {
1104
- undefined$1(function () {
1105
- return Mousetrap;
1106
- });
1107
- }
1108
- })(typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);
1109
- })(mousetrap);
1110
- var mousetrapExports = mousetrap.exports;
1111
- var Mousetrap$1 = /*@__PURE__*/getDefaultExportFromCjs(mousetrapExports);
1112
-
1113
- /**
1114
- * adds a bindGlobal method to Mousetrap that allows you to
1115
- * bind specific keyboard shortcuts that will still work
1116
- * inside a text input field
1117
- *
1118
- * usage:
1119
- * Mousetrap.bindGlobal('ctrl+s', _saveChanges);
1120
- */
1121
- /* global Mousetrap:true */
1122
- (function (Mousetrap) {
1123
- var _globalCallbacks = {};
1124
- var _originalStopCallback = Mousetrap.prototype.stopCallback;
1125
- Mousetrap.prototype.stopCallback = function (e, element, combo, sequence) {
1126
- var self = this;
1127
- if (self.paused) {
1128
- return true;
1129
- }
1130
- if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
1131
- return false;
1132
- }
1133
- return _originalStopCallback.call(self, e, element, combo);
1134
- };
1135
- Mousetrap.prototype.bindGlobal = function (keys, callback, action) {
1136
- var self = this;
1137
- self.bind(keys, callback, action);
1138
- if (keys instanceof Array) {
1139
- for (var i = 0; i < keys.length; i++) {
1140
- _globalCallbacks[keys[i]] = true;
1141
- }
1142
- return;
1143
- }
1144
- _globalCallbacks[keys] = true;
1145
- };
1146
- Mousetrap.prototype.unbindGlobal = function (keys, action) {
1147
- var self = this;
1148
- self.unbind(keys, action);
1149
- if (keys instanceof Array) {
1150
- for (var i = 0; i < keys.length; i++) {
1151
- _globalCallbacks[keys[i]] = false;
1152
- }
1153
- return;
1154
- }
1155
- _globalCallbacks[keys] = false;
1156
- };
1157
- Mousetrap.init();
1158
- })(Mousetrap);
1159
-
1160
- function _typeof(o) {
1161
- "@babel/helpers - typeof";
1162
-
1163
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
1164
- return typeof o;
1165
- } : function (o) {
1166
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1167
- }, _typeof(o);
1168
- }
1169
-
1170
- var platform$1 = {exports: {}};
1171
-
1172
- platform$1.exports;
1173
- (function (module, exports) {
1174
- (function () {
1175
-
1176
- /** Used to determine if values are of the language type `Object`. */
1177
- var objectTypes = {
1178
- 'function': true,
1179
- 'object': true
1180
- };
1181
-
1182
- /** Used as a reference to the global object. */
1183
- var root = objectTypes[typeof window === "undefined" ? "undefined" : _typeof(window)] && window || this;
1184
-
1185
- /** Detect free variable `exports`. */
1186
- var freeExports = exports;
1187
-
1188
- /** Detect free variable `module`. */
1189
- var freeModule = module && !module.nodeType && module;
1190
-
1191
- /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
1192
- var freeGlobal = freeExports && freeModule && _typeof(commonjsGlobal) == 'object' && commonjsGlobal;
1193
- if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
1194
- root = freeGlobal;
1195
- }
1196
-
1197
- /**
1198
- * Used as the maximum length of an array-like object.
1199
- * See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
1200
- * for more details.
1201
- */
1202
- var maxSafeInteger = Math.pow(2, 53) - 1;
1203
-
1204
- /** Regular expression to detect Opera. */
1205
- var reOpera = /\bOpera/;
1206
-
1207
- /** Used for native method references. */
1208
- var objectProto = Object.prototype;
1209
-
1210
- /** Used to check for own properties of an object. */
1211
- var hasOwnProperty = objectProto.hasOwnProperty;
1212
-
1213
- /** Used to resolve the internal `[[Class]]` of values. */
1214
- var toString = objectProto.toString;
1215
-
1216
- /*--------------------------------------------------------------------------*/
1217
-
1218
- /**
1219
- * Capitalizes a string value.
1220
- *
1221
- * @private
1222
- * @param {string} string The string to capitalize.
1223
- * @returns {string} The capitalized string.
1224
- */
1225
- function capitalize(string) {
1226
- string = String(string);
1227
- return string.charAt(0).toUpperCase() + string.slice(1);
1228
- }
1229
-
1230
- /**
1231
- * A utility function to clean up the OS name.
1232
- *
1233
- * @private
1234
- * @param {string} os The OS name to clean up.
1235
- * @param {string} [pattern] A `RegExp` pattern matching the OS name.
1236
- * @param {string} [label] A label for the OS.
1237
- */
1238
- function cleanupOS(os, pattern, label) {
1239
- // Platform tokens are defined at:
1240
- // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
1241
- // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
1242
- var data = {
1243
- '10.0': '10',
1244
- '6.4': '10 Technical Preview',
1245
- '6.3': '8.1',
1246
- '6.2': '8',
1247
- '6.1': 'Server 2008 R2 / 7',
1248
- '6.0': 'Server 2008 / Vista',
1249
- '5.2': 'Server 2003 / XP 64-bit',
1250
- '5.1': 'XP',
1251
- '5.01': '2000 SP1',
1252
- '5.0': '2000',
1253
- '4.0': 'NT',
1254
- '4.90': 'ME'
1255
- };
1256
- // Detect Windows version from platform tokens.
1257
- if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) && (data = data[/[\d.]+$/.exec(os)])) {
1258
- os = 'Windows ' + data;
1259
- }
1260
- // Correct character case and cleanup string.
1261
- os = String(os);
1262
- if (pattern && label) {
1263
- os = os.replace(RegExp(pattern, 'i'), label);
1264
- }
1265
- os = format(os.replace(/ ce$/i, ' CE').replace(/\bhpw/i, 'web').replace(/\bMacintosh\b/, 'Mac OS').replace(/_PowerPC\b/i, ' OS').replace(/\b(OS X) [^ \d]+/i, '$1').replace(/\bMac (OS X)\b/, '$1').replace(/\/(\d)/, ' $1').replace(/_/g, '.').replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '').replace(/\bx86\.64\b/gi, 'x86_64').replace(/\b(Windows Phone) OS\b/, '$1').replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1').split(' on ')[0]);
1266
- return os;
1267
- }
1268
-
1269
- /**
1270
- * An iteration utility for arrays and objects.
1271
- *
1272
- * @private
1273
- * @param {Array|Object} object The object to iterate over.
1274
- * @param {Function} callback The function called per iteration.
1275
- */
1276
- function each(object, callback) {
1277
- var index = -1,
1278
- length = object ? object.length : 0;
1279
- if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
1280
- while (++index < length) {
1281
- callback(object[index], index, object);
1282
- }
1283
- } else {
1284
- forOwn(object, callback);
1285
- }
1286
- }
1287
-
1288
- /**
1289
- * Trim and conditionally capitalize string values.
1290
- *
1291
- * @private
1292
- * @param {string} string The string to format.
1293
- * @returns {string} The formatted string.
1294
- */
1295
- function format(string) {
1296
- string = trim(string);
1297
- return /^(?:webOS|i(?:OS|P))/.test(string) ? string : capitalize(string);
1298
- }
1299
-
1300
- /**
1301
- * Iterates over an object's own properties, executing the `callback` for each.
1302
- *
1303
- * @private
1304
- * @param {Object} object The object to iterate over.
1305
- * @param {Function} callback The function executed per own property.
1306
- */
1307
- function forOwn(object, callback) {
1308
- for (var key in object) {
1309
- if (hasOwnProperty.call(object, key)) {
1310
- callback(object[key], key, object);
1311
- }
1312
- }
1313
- }
1314
-
1315
- /**
1316
- * Gets the internal `[[Class]]` of a value.
1317
- *
1318
- * @private
1319
- * @param {*} value The value.
1320
- * @returns {string} The `[[Class]]`.
1321
- */
1322
- function getClassOf(value) {
1323
- return value == null ? capitalize(value) : toString.call(value).slice(8, -1);
1324
- }
1325
-
1326
- /**
1327
- * Host objects can return type values that are different from their actual
1328
- * data type. The objects we are concerned with usually return non-primitive
1329
- * types of "object", "function", or "unknown".
1330
- *
1331
- * @private
1332
- * @param {*} object The owner of the property.
1333
- * @param {string} property The property to check.
1334
- * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
1335
- */
1336
- function isHostType(object, property) {
1337
- var type = object != null ? _typeof(object[property]) : 'number';
1338
- return !/^(?:boolean|number|string|undefined)$/.test(type) && (type == 'object' ? !!object[property] : true);
1339
- }
1340
-
1341
- /**
1342
- * Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
1343
- *
1344
- * @private
1345
- * @param {string} string The string to qualify.
1346
- * @returns {string} The qualified string.
1347
- */
1348
- function qualify(string) {
1349
- return String(string).replace(/([ -])(?!$)/g, '$1?');
1350
- }
1351
-
1352
- /**
1353
- * A bare-bones `Array#reduce` like utility function.
1354
- *
1355
- * @private
1356
- * @param {Array} array The array to iterate over.
1357
- * @param {Function} callback The function called per iteration.
1358
- * @returns {*} The accumulated result.
1359
- */
1360
- function reduce(array, callback) {
1361
- var accumulator = null;
1362
- each(array, function (value, index) {
1363
- accumulator = callback(accumulator, value, index, array);
1364
- });
1365
- return accumulator;
1366
- }
1367
-
1368
- /**
1369
- * Removes leading and trailing whitespace from a string.
1370
- *
1371
- * @private
1372
- * @param {string} string The string to trim.
1373
- * @returns {string} The trimmed string.
1374
- */
1375
- function trim(string) {
1376
- return String(string).replace(/^ +| +$/g, '');
1377
- }
1378
-
1379
- /*--------------------------------------------------------------------------*/
1380
-
1381
- /**
1382
- * Creates a new platform object.
1383
- *
1384
- * @memberOf platform
1385
- * @param {Object|string} [ua=navigator.userAgent] The user agent string or
1386
- * context object.
1387
- * @returns {Object} A platform object.
1388
- */
1389
- function parse(ua) {
1390
- /** The environment context object. */
1391
- var context = root;
1392
-
1393
- /** Used to flag when a custom context is provided. */
1394
- var isCustomContext = ua && _typeof(ua) == 'object' && getClassOf(ua) != 'String';
1395
-
1396
- // Juggle arguments.
1397
- if (isCustomContext) {
1398
- context = ua;
1399
- ua = null;
1400
- }
1401
-
1402
- /** Browser navigator object. */
1403
- var nav = context.navigator || {};
1404
-
1405
- /** Browser user agent string. */
1406
- var userAgent = nav.userAgent || '';
1407
- ua || (ua = userAgent);
1408
-
1409
- /** Used to detect if browser is like Chrome. */
1410
- var likeChrome = isCustomContext ? !!nav.likeChrome : /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
1411
-
1412
- /** Internal `[[Class]]` value shortcuts. */
1413
- var objectClass = 'Object',
1414
- airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
1415
- enviroClass = isCustomContext ? objectClass : 'Environment',
1416
- javaClass = isCustomContext && context.java ? 'JavaPackage' : getClassOf(context.java),
1417
- phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
1418
-
1419
- /** Detect Java environments. */
1420
- var java = /\bJava/.test(javaClass) && context.java;
1421
-
1422
- /** Detect Rhino. */
1423
- var rhino = java && getClassOf(context.environment) == enviroClass;
1424
-
1425
- /** A character to represent alpha. */
1426
- var alpha = java ? 'a' : "\u03B1";
1427
-
1428
- /** A character to represent beta. */
1429
- var beta = java ? 'b' : "\u03B2";
1430
-
1431
- /** Browser document object. */
1432
- var doc = context.document || {};
1433
-
1434
- /**
1435
- * Detect Opera browser (Presto-based).
1436
- * http://www.howtocreate.co.uk/operaStuff/operaObject.html
1437
- * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
1438
- */
1439
- var opera = context.operamini || context.opera;
1440
-
1441
- /** Opera `[[Class]]`. */
1442
- var operaClass = reOpera.test(operaClass = isCustomContext && opera ? opera['[[Class]]'] : getClassOf(opera)) ? operaClass : opera = null;
1443
-
1444
- /*------------------------------------------------------------------------*/
1445
-
1446
- /** Temporary variable used over the script's lifetime. */
1447
- var data;
1448
-
1449
- /** The CPU architecture. */
1450
- var arch = ua;
1451
-
1452
- /** Platform description array. */
1453
- var description = [];
1454
-
1455
- /** Platform alpha/beta indicator. */
1456
- var prerelease = null;
1457
-
1458
- /** A flag to indicate that environment features should be used to resolve the platform. */
1459
- var useFeatures = ua == userAgent;
1460
-
1461
- /** The browser/environment version. */
1462
- var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
1463
-
1464
- /** A flag to indicate if the OS ends with "/ Version" */
1465
- var isSpecialCasedOS;
1466
-
1467
- /* Detectable layout engines (order is important). */
1468
- var layout = getLayout([{
1469
- 'label': 'EdgeHTML',
1470
- 'pattern': 'Edge'
1471
- }, 'Trident', {
1472
- 'label': 'WebKit',
1473
- 'pattern': 'AppleWebKit'
1474
- }, 'iCab', 'Presto', 'NetFront', 'Tasman', 'KHTML', 'Gecko']);
1475
-
1476
- /* Detectable browser names (order is important). */
1477
- var name = getName(['Adobe AIR', 'Arora', 'Avant Browser', 'Breach', 'Camino', 'Electron', 'Epiphany', 'Fennec', 'Flock', 'Galeon', 'GreenBrowser', 'iCab', 'Iceweasel', 'K-Meleon', 'Konqueror', 'Lunascape', 'Maxthon', {
1478
- 'label': 'Microsoft Edge',
1479
- 'pattern': '(?:Edge|Edg|EdgA|EdgiOS)'
1480
- }, 'Midori', 'Nook Browser', 'PaleMoon', 'PhantomJS', 'Raven', 'Rekonq', 'RockMelt', {
1481
- 'label': 'Samsung Internet',
1482
- 'pattern': 'SamsungBrowser'
1483
- }, 'SeaMonkey', {
1484
- 'label': 'Silk',
1485
- 'pattern': '(?:Cloud9|Silk-Accelerated)'
1486
- }, 'Sleipnir', 'SlimBrowser', {
1487
- 'label': 'SRWare Iron',
1488
- 'pattern': 'Iron'
1489
- }, 'Sunrise', 'Swiftfox', 'Vivaldi', 'Waterfox', 'WebPositive', {
1490
- 'label': 'Yandex Browser',
1491
- 'pattern': 'YaBrowser'
1492
- }, {
1493
- 'label': 'UC Browser',
1494
- 'pattern': 'UCBrowser'
1495
- }, 'Opera Mini', {
1496
- 'label': 'Opera Mini',
1497
- 'pattern': 'OPiOS'
1498
- }, 'Opera', {
1499
- 'label': 'Opera',
1500
- 'pattern': 'OPR'
1501
- }, 'Chromium', 'Chrome', {
1502
- 'label': 'Chrome',
1503
- 'pattern': '(?:HeadlessChrome)'
1504
- }, {
1505
- 'label': 'Chrome Mobile',
1506
- 'pattern': '(?:CriOS|CrMo)'
1507
- }, {
1508
- 'label': 'Firefox',
1509
- 'pattern': '(?:Firefox|Minefield)'
1510
- }, {
1511
- 'label': 'Firefox for iOS',
1512
- 'pattern': 'FxiOS'
1513
- }, {
1514
- 'label': 'IE',
1515
- 'pattern': 'IEMobile'
1516
- }, {
1517
- 'label': 'IE',
1518
- 'pattern': 'MSIE'
1519
- }, 'Safari']);
1520
-
1521
- /* Detectable products (order is important). */
1522
- var product = getProduct([{
1523
- 'label': 'BlackBerry',
1524
- 'pattern': 'BB10'
1525
- }, 'BlackBerry', {
1526
- 'label': 'Galaxy S',
1527
- 'pattern': 'GT-I9000'
1528
- }, {
1529
- 'label': 'Galaxy S2',
1530
- 'pattern': 'GT-I9100'
1531
- }, {
1532
- 'label': 'Galaxy S3',
1533
- 'pattern': 'GT-I9300'
1534
- }, {
1535
- 'label': 'Galaxy S4',
1536
- 'pattern': 'GT-I9500'
1537
- }, {
1538
- 'label': 'Galaxy S5',
1539
- 'pattern': 'SM-G900'
1540
- }, {
1541
- 'label': 'Galaxy S6',
1542
- 'pattern': 'SM-G920'
1543
- }, {
1544
- 'label': 'Galaxy S6 Edge',
1545
- 'pattern': 'SM-G925'
1546
- }, {
1547
- 'label': 'Galaxy S7',
1548
- 'pattern': 'SM-G930'
1549
- }, {
1550
- 'label': 'Galaxy S7 Edge',
1551
- 'pattern': 'SM-G935'
1552
- }, 'Google TV', 'Lumia', 'iPad', 'iPod', 'iPhone', 'Kindle', {
1553
- 'label': 'Kindle Fire',
1554
- 'pattern': '(?:Cloud9|Silk-Accelerated)'
1555
- }, 'Nexus', 'Nook', 'PlayBook', 'PlayStation Vita', 'PlayStation', 'TouchPad', 'Transformer', {
1556
- 'label': 'Wii U',
1557
- 'pattern': 'WiiU'
1558
- }, 'Wii', 'Xbox One', {
1559
- 'label': 'Xbox 360',
1560
- 'pattern': 'Xbox'
1561
- }, 'Xoom']);
1562
-
1563
- /* Detectable manufacturers. */
1564
- var manufacturer = getManufacturer({
1565
- 'Apple': {
1566
- 'iPad': 1,
1567
- 'iPhone': 1,
1568
- 'iPod': 1
1569
- },
1570
- 'Alcatel': {},
1571
- 'Archos': {},
1572
- 'Amazon': {
1573
- 'Kindle': 1,
1574
- 'Kindle Fire': 1
1575
- },
1576
- 'Asus': {
1577
- 'Transformer': 1
1578
- },
1579
- 'Barnes & Noble': {
1580
- 'Nook': 1
1581
- },
1582
- 'BlackBerry': {
1583
- 'PlayBook': 1
1584
- },
1585
- 'Google': {
1586
- 'Google TV': 1,
1587
- 'Nexus': 1
1588
- },
1589
- 'HP': {
1590
- 'TouchPad': 1
1591
- },
1592
- 'HTC': {},
1593
- 'Huawei': {},
1594
- 'Lenovo': {},
1595
- 'LG': {},
1596
- 'Microsoft': {
1597
- 'Xbox': 1,
1598
- 'Xbox One': 1
1599
- },
1600
- 'Motorola': {
1601
- 'Xoom': 1
1602
- },
1603
- 'Nintendo': {
1604
- 'Wii U': 1,
1605
- 'Wii': 1
1606
- },
1607
- 'Nokia': {
1608
- 'Lumia': 1
1609
- },
1610
- 'Oppo': {},
1611
- 'Samsung': {
1612
- 'Galaxy S': 1,
1613
- 'Galaxy S2': 1,
1614
- 'Galaxy S3': 1,
1615
- 'Galaxy S4': 1
1616
- },
1617
- 'Sony': {
1618
- 'PlayStation': 1,
1619
- 'PlayStation Vita': 1
1620
- },
1621
- 'Xiaomi': {
1622
- 'Mi': 1,
1623
- 'Redmi': 1
1624
- }
1625
- });
1626
-
1627
- /* Detectable operating systems (order is important). */
1628
- var os = getOS(['Windows Phone', 'KaiOS', 'Android', 'CentOS', {
1629
- 'label': 'Chrome OS',
1630
- 'pattern': 'CrOS'
1631
- }, 'Debian', {
1632
- 'label': 'DragonFly BSD',
1633
- 'pattern': 'DragonFly'
1634
- }, 'Fedora', 'FreeBSD', 'Gentoo', 'Haiku', 'Kubuntu', 'Linux Mint', 'OpenBSD', 'Red Hat', 'SuSE', 'Ubuntu', 'Xubuntu', 'Cygwin', 'Symbian OS', 'hpwOS', 'webOS ', 'webOS', 'Tablet OS', 'Tizen', 'Linux', 'Mac OS X', 'Macintosh', 'Mac', 'Windows 98;', 'Windows ']);
1635
-
1636
- /*------------------------------------------------------------------------*/
1637
-
1638
- /**
1639
- * Picks the layout engine from an array of guesses.
1640
- *
1641
- * @private
1642
- * @param {Array} guesses An array of guesses.
1643
- * @returns {null|string} The detected layout engine.
1644
- */
1645
- function getLayout(guesses) {
1646
- return reduce(guesses, function (result, guess) {
1647
- return result || RegExp('\\b' + (guess.pattern || qualify(guess)) + '\\b', 'i').exec(ua) && (guess.label || guess);
1648
- });
1649
- }
1650
-
1651
- /**
1652
- * Picks the manufacturer from an array of guesses.
1653
- *
1654
- * @private
1655
- * @param {Array} guesses An object of guesses.
1656
- * @returns {null|string} The detected manufacturer.
1657
- */
1658
- function getManufacturer(guesses) {
1659
- return reduce(guesses, function (result, value, key) {
1660
- // Lookup the manufacturer by product or scan the UA for the manufacturer.
1661
- return result || (value[product] || value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] || RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)) && key;
1662
- });
1663
- }
1664
-
1665
- /**
1666
- * Picks the browser name from an array of guesses.
1667
- *
1668
- * @private
1669
- * @param {Array} guesses An array of guesses.
1670
- * @returns {null|string} The detected browser name.
1671
- */
1672
- function getName(guesses) {
1673
- return reduce(guesses, function (result, guess) {
1674
- return result || RegExp('\\b' + (guess.pattern || qualify(guess)) + '\\b', 'i').exec(ua) && (guess.label || guess);
1675
- });
1676
- }
1677
-
1678
- /**
1679
- * Picks the OS name from an array of guesses.
1680
- *
1681
- * @private
1682
- * @param {Array} guesses An array of guesses.
1683
- * @returns {null|string} The detected OS name.
1684
- */
1685
- function getOS(guesses) {
1686
- return reduce(guesses, function (result, guess) {
1687
- var pattern = guess.pattern || qualify(guess);
1688
- if (!result && (result = RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua))) {
1689
- result = cleanupOS(result, pattern, guess.label || guess);
1690
- }
1691
- return result;
1692
- });
1693
- }
1694
-
1695
- /**
1696
- * Picks the product name from an array of guesses.
1697
- *
1698
- * @private
1699
- * @param {Array} guesses An array of guesses.
1700
- * @returns {null|string} The detected product name.
1701
- */
1702
- function getProduct(guesses) {
1703
- return reduce(guesses, function (result, guess) {
1704
- var pattern = guess.pattern || qualify(guess);
1705
- if (!result && (result = RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) || RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) || RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua))) {
1706
- // Split by forward slash and append product version if needed.
1707
- if ((result = String(guess.label && !RegExp(pattern, 'i').test(guess.label) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
1708
- result[0] += ' ' + result[1];
1709
- }
1710
- // Correct character case and cleanup string.
1711
- guess = guess.label || guess;
1712
- result = format(result[0].replace(RegExp(pattern, 'i'), guess).replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ').replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
1713
- }
1714
- return result;
1715
- });
1716
- }
1717
-
1718
- /**
1719
- * Resolves the version using an array of UA patterns.
1720
- *
1721
- * @private
1722
- * @param {Array} patterns An array of UA patterns.
1723
- * @returns {null|string} The detected version.
1724
- */
1725
- function getVersion(patterns) {
1726
- return reduce(patterns, function (result, pattern) {
1727
- return result || (RegExp(pattern + '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
1728
- });
1729
- }
1730
-
1731
- /**
1732
- * Returns `platform.description` when the platform object is coerced to a string.
1733
- *
1734
- * @name toString
1735
- * @memberOf platform
1736
- * @returns {string} Returns `platform.description` if available, else an empty string.
1737
- */
1738
- function toStringPlatform() {
1739
- return this.description || '';
1740
- }
1741
-
1742
- /*------------------------------------------------------------------------*/
1743
-
1744
- // Convert layout to an array so we can add extra details.
1745
- layout && (layout = [layout]);
1746
-
1747
- // Detect Android products.
1748
- // Browsers on Android devices typically provide their product IDS after "Android;"
1749
- // up to "Build" or ") AppleWebKit".
1750
- // Example:
1751
- // "Mozilla/5.0 (Linux; Android 8.1.0; Moto G (5) Plus) AppleWebKit/537.36
1752
- // (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36"
1753
- if (/\bAndroid\b/.test(os) && !product && (data = /\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(ua))) {
1754
- product = trim(data[1])
1755
- // Replace any language codes (eg. "en-US").
1756
- .replace(/^[a-z]{2}-[a-z]{2};\s*/i, '') || null;
1757
- }
1758
- // Detect product names that contain their manufacturer's name.
1759
- if (manufacturer && !product) {
1760
- product = getProduct([manufacturer]);
1761
- } else if (manufacturer && product) {
1762
- product = product.replace(RegExp('^(' + qualify(manufacturer) + ')[-_.\\s]', 'i'), manufacturer + ' ').replace(RegExp('^(' + qualify(manufacturer) + ')[-_.]?(\\w)', 'i'), manufacturer + ' $2');
1763
- }
1764
- // Clean up Google TV.
1765
- if (data = /\bGoogle TV\b/.exec(product)) {
1766
- product = data[0];
1767
- }
1768
- // Detect simulators.
1769
- if (/\bSimulator\b/i.test(ua)) {
1770
- product = (product ? product + ' ' : '') + 'Simulator';
1771
- }
1772
- // Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
1773
- if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
1774
- description.push('running in Turbo/Uncompressed mode');
1775
- }
1776
- // Detect IE Mobile 11.
1777
- if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
1778
- data = parse(ua.replace(/like iPhone OS/, ''));
1779
- manufacturer = data.manufacturer;
1780
- product = data.product;
1781
- }
1782
- // Detect iOS.
1783
- else if (/^iP/.test(product)) {
1784
- name || (name = 'Safari');
1785
- os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua)) ? ' ' + data[1].replace(/_/g, '.') : '');
1786
- }
1787
- // Detect Kubuntu.
1788
- else if (name == 'Konqueror' && /^Linux\b/i.test(os)) {
1789
- os = 'Kubuntu';
1790
- }
1791
- // Detect Android browsers.
1792
- else if (manufacturer && manufacturer != 'Google' && (/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua) || /\bVita\b/.test(product)) || /\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua)) {
1793
- name = 'Android Browser';
1794
- os = /\bAndroid\b/.test(os) ? os : 'Android';
1795
- }
1796
- // Detect Silk desktop/accelerated modes.
1797
- else if (name == 'Silk') {
1798
- if (!/\bMobi/i.test(ua)) {
1799
- os = 'Android';
1800
- description.unshift('desktop mode');
1801
- }
1802
- if (/Accelerated *= *true/i.test(ua)) {
1803
- description.unshift('accelerated');
1804
- }
1805
- }
1806
- // Detect UC Browser speed mode.
1807
- else if (name == 'UC Browser' && /\bUCWEB\b/.test(ua)) {
1808
- description.push('speed mode');
1809
- }
1810
- // Detect PaleMoon identifying as Firefox.
1811
- else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
1812
- description.push('identifying as Firefox ' + data[1]);
1813
- }
1814
- // Detect Firefox OS and products running Firefox.
1815
- else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
1816
- os || (os = 'Firefox OS');
1817
- product || (product = data[1]);
1818
- }
1819
- // Detect false positives for Firefox/Safari.
1820
- else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
1821
- // Escape the `/` for Firefox 1.
1822
- if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
1823
- // Clear name of false positives.
1824
- name = null;
1825
- }
1826
- // Reassign a generic name.
1827
- if ((data = product || manufacturer || os) && (product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
1828
- name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
1829
- }
1830
- }
1831
- // Add Chrome version to description for Electron.
1832
- else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
1833
- description.push('Chromium ' + data);
1834
- }
1835
- // Detect non-Opera (Presto-based) versions (order is important).
1836
- if (!version) {
1837
- version = getVersion(['(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)', 'Version', qualify(name), '(?:Firefox|Minefield|NetFront)']);
1838
- }
1839
- // Detect stubborn layout engines.
1840
- if (data = layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' || /\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') || /\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' || !layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') || layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront') {
1841
- layout = [data];
1842
- }
1843
- // Detect Windows Phone 7 desktop mode.
1844
- if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
1845
- name += ' Mobile';
1846
- os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
1847
- description.unshift('desktop mode');
1848
- }
1849
- // Detect Windows Phone 8.x desktop mode.
1850
- else if (/\bWPDesktop\b/i.test(ua)) {
1851
- name = 'IE Mobile';
1852
- os = 'Windows Phone 8.x';
1853
- description.unshift('desktop mode');
1854
- version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
1855
- }
1856
- // Detect IE 11 identifying as other browsers.
1857
- else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
1858
- if (name) {
1859
- description.push('identifying as ' + name + (version ? ' ' + version : ''));
1860
- }
1861
- name = 'IE';
1862
- version = data[1];
1863
- }
1864
- // Leverage environment features.
1865
- if (useFeatures) {
1866
- // Detect server-side environments.
1867
- // Rhino has a global function while others have a global object.
1868
- if (isHostType(context, 'global')) {
1869
- if (java) {
1870
- data = java.lang.System;
1871
- arch = data.getProperty('os.arch');
1872
- os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
1873
- }
1874
- if (rhino) {
1875
- try {
1876
- version = context.require('ringo/engine').version.join('.');
1877
- name = 'RingoJS';
1878
- } catch (e) {
1879
- if ((data = context.system) && data.global.system == context.system) {
1880
- name = 'Narwhal';
1881
- os || (os = data[0].os || null);
1882
- }
1883
- }
1884
- if (!name) {
1885
- name = 'Rhino';
1886
- }
1887
- } else if (_typeof(context.process) == 'object' && !context.process.browser && (data = context.process)) {
1888
- if (_typeof(data.versions) == 'object') {
1889
- if (typeof data.versions.electron == 'string') {
1890
- description.push('Node ' + data.versions.node);
1891
- name = 'Electron';
1892
- version = data.versions.electron;
1893
- } else if (typeof data.versions.nw == 'string') {
1894
- description.push('Chromium ' + version, 'Node ' + data.versions.node);
1895
- name = 'NW.js';
1896
- version = data.versions.nw;
1897
- }
1898
- }
1899
- if (!name) {
1900
- name = 'Node.js';
1901
- arch = data.arch;
1902
- os = data.platform;
1903
- version = /[\d.]+/.exec(data.version);
1904
- version = version ? version[0] : null;
1905
- }
1906
- }
1907
- }
1908
- // Detect Adobe AIR.
1909
- else if (getClassOf(data = context.runtime) == airRuntimeClass) {
1910
- name = 'Adobe AIR';
1911
- os = data.flash.system.Capabilities.os;
1912
- }
1913
- // Detect PhantomJS.
1914
- else if (getClassOf(data = context.phantom) == phantomClass) {
1915
- name = 'PhantomJS';
1916
- version = (data = data.version || null) && data.major + '.' + data.minor + '.' + data.patch;
1917
- }
1918
- // Detect IE compatibility modes.
1919
- else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
1920
- // We're in compatibility mode when the Trident version + 4 doesn't
1921
- // equal the document mode.
1922
- version = [version, doc.documentMode];
1923
- if ((data = +data[1] + 4) != version[1]) {
1924
- description.push('IE ' + version[1] + ' mode');
1925
- layout && (layout[1] = '');
1926
- version[1] = data;
1927
- }
1928
- version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
1929
- }
1930
- // Detect IE 11 masking as other browsers.
1931
- else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
1932
- description.push('masking as ' + name + ' ' + version);
1933
- name = 'IE';
1934
- version = '11.0';
1935
- layout = ['Trident'];
1936
- os = 'Windows';
1937
- }
1938
- os = os && format(os);
1939
- }
1940
- // Detect prerelease phases.
1941
- if (version && (data = /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) || /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) || /\bMinefield\b/i.test(ua) && 'a')) {
1942
- prerelease = /b/i.test(data) ? 'beta' : 'alpha';
1943
- version = version.replace(RegExp(data + '\\+?$'), '') + (prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
1944
- }
1945
- // Detect Firefox Mobile.
1946
- if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS|KaiOS)\b/.test(os)) {
1947
- name = 'Firefox Mobile';
1948
- }
1949
- // Obscure Maxthon's unreliable version.
1950
- else if (name == 'Maxthon' && version) {
1951
- version = version.replace(/\.[\d.]+/, '.x');
1952
- }
1953
- // Detect Xbox 360 and Xbox One.
1954
- else if (/\bXbox\b/i.test(product)) {
1955
- if (product == 'Xbox 360') {
1956
- os = null;
1957
- }
1958
- if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
1959
- description.unshift('mobile mode');
1960
- }
1961
- }
1962
- // Add mobile postfix.
1963
- else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) && (os == 'Windows CE' || /Mobi/i.test(ua))) {
1964
- name += ' Mobile';
1965
- }
1966
- // Detect IE platform preview.
1967
- else if (name == 'IE' && useFeatures) {
1968
- try {
1969
- if (context.external === null) {
1970
- description.unshift('platform preview');
1971
- }
1972
- } catch (e) {
1973
- description.unshift('embedded');
1974
- }
1975
- }
1976
- // Detect BlackBerry OS version.
1977
- // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
1978
- else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data = (RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] || version)) {
1979
- data = [data, /BB10/.test(ua)];
1980
- os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
1981
- version = null;
1982
- }
1983
- // Detect Opera identifying/masking itself as another browser.
1984
- // http://www.opera.com/support/kb/view/843/
1985
- else if (this != forOwn && product != 'Wii' && (useFeatures && opera || /Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua) || name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os) || name == 'IE' && (os && !/^Win/.test(os) && version > 5.5 || /\bWindows XP\b/.test(os) && version > 8 || version == 8 && !/\bTrident\b/.test(ua))) && !reOpera.test(data = parse.call(forOwn, ua.replace(reOpera, '') + ';')) && data.name) {
1986
- // When "identifying", the UA contains both Opera and the other browser's name.
1987
- data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
1988
- if (reOpera.test(name)) {
1989
- if (/\bIE\b/.test(data) && os == 'Mac OS') {
1990
- os = null;
1991
- }
1992
- data = 'identify' + data;
1993
- }
1994
- // When "masking", the UA contains only the other browser's name.
1995
- else {
1996
- data = 'mask' + data;
1997
- if (operaClass) {
1998
- name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
1999
- } else {
2000
- name = 'Opera';
2001
- }
2002
- if (/\bIE\b/.test(data)) {
2003
- os = null;
2004
- }
2005
- if (!useFeatures) {
2006
- version = null;
2007
- }
2008
- }
2009
- layout = ['Presto'];
2010
- description.push(data);
2011
- }
2012
- // Detect WebKit Nightly and approximate Chrome/Safari versions.
2013
- if (data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1]) {
2014
- // Correct build number for numeric comparison.
2015
- // (e.g. "532.5" becomes "532.05")
2016
- data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
2017
- // Nightly builds are postfixed with a "+".
2018
- if (name == 'Safari' && data[1].slice(-1) == '+') {
2019
- name = 'WebKit Nightly';
2020
- prerelease = 'alpha';
2021
- version = data[1].slice(0, -1);
2022
- }
2023
- // Clear incorrect browser versions.
2024
- else if (version == data[1] || version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
2025
- version = null;
2026
- }
2027
- // Use the full Chrome version when available.
2028
- data[1] = (/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(ua) || 0)[1];
2029
- // Detect Blink layout engine.
2030
- if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
2031
- layout = ['Blink'];
2032
- }
2033
- // Detect JavaScriptCore.
2034
- // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
2035
- if (!useFeatures || !likeChrome && !data[1]) {
2036
- layout && (layout[1] = 'like Safari');
2037
- data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : data < 602 ? 9 : data < 604 ? 10 : data < 606 ? 11 : data < 608 ? 12 : '12');
2038
- } else {
2039
- layout && (layout[1] = 'like Chrome');
2040
- data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
2041
- }
2042
- // Add the postfix of ".x" or "+" for approximate versions.
2043
- layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
2044
- // Obscure version for some Safari 1-2 releases.
2045
- if (name == 'Safari' && (!version || parseInt(version) > 45)) {
2046
- version = data;
2047
- } else if (name == 'Chrome' && /\bHeadlessChrome/i.test(ua)) {
2048
- description.unshift('headless');
2049
- }
2050
- }
2051
- // Detect Opera desktop modes.
2052
- if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
2053
- name += ' ';
2054
- description.unshift('desktop mode');
2055
- if (data == 'zvav') {
2056
- name += 'Mini';
2057
- version = null;
2058
- } else {
2059
- name += 'Mobile';
2060
- }
2061
- os = os.replace(RegExp(' *' + data + '$'), '');
2062
- }
2063
- // Detect Chrome desktop mode.
2064
- else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
2065
- description.unshift('desktop mode');
2066
- name = 'Chrome Mobile';
2067
- version = null;
2068
- if (/\bOS X\b/.test(os)) {
2069
- manufacturer = 'Apple';
2070
- os = 'iOS 4.3+';
2071
- } else {
2072
- os = null;
2073
- }
2074
- }
2075
- // Newer versions of SRWare Iron uses the Chrome tag to indicate its version number.
2076
- else if (/\bSRWare Iron\b/.test(name) && !version) {
2077
- version = getVersion('Chrome');
2078
- }
2079
- // Strip incorrect OS versions.
2080
- if (version && version.indexOf(data = /[\d.]+$/.exec(os)) == 0 && ua.indexOf('/' + data + '-') > -1) {
2081
- os = trim(os.replace(data, ''));
2082
- }
2083
- // Ensure OS does not include the browser name.
2084
- if (os && os.indexOf(name) != -1 && !RegExp(name + ' OS').test(os)) {
2085
- os = os.replace(RegExp(' *' + qualify(name) + ' *'), '');
2086
- }
2087
- // Add layout engine.
2088
- if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (/Browser|Lunascape|Maxthon/.test(name) || name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) || /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(name) && layout[1])) {
2089
- // Don't add layout details to description if they are falsey.
2090
- (data = layout[layout.length - 1]) && description.push(data);
2091
- }
2092
- // Combine contextual information.
2093
- if (description.length) {
2094
- description = ['(' + description.join('; ') + ')'];
2095
- }
2096
- // Append manufacturer to description.
2097
- if (manufacturer && product && product.indexOf(manufacturer) < 0) {
2098
- description.push('on ' + manufacturer);
2099
- }
2100
- // Append product to description.
2101
- if (product) {
2102
- description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
2103
- }
2104
- // Parse the OS into an object.
2105
- if (os) {
2106
- data = / ([\d.+]+)$/.exec(os);
2107
- isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
2108
- os = {
2109
- 'architecture': 32,
2110
- 'family': data && !isSpecialCasedOS ? os.replace(data[0], '') : os,
2111
- 'version': data ? data[1] : null,
2112
- 'toString': function toString() {
2113
- var version = this.version;
2114
- return this.family + (version && !isSpecialCasedOS ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
2115
- }
2116
- };
2117
- }
2118
- // Add browser/OS architecture.
2119
- if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
2120
- if (os) {
2121
- os.architecture = 64;
2122
- os.family = os.family.replace(RegExp(' *' + data), '');
2123
- }
2124
- if (name && (/\bWOW64\b/i.test(ua) || useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua))) {
2125
- description.unshift('32-bit');
2126
- }
2127
- }
2128
- // Chrome 39 and above on OS X is always 64-bit.
2129
- else if (os && /^OS X/.test(os.family) && name == 'Chrome' && parseFloat(version) >= 39) {
2130
- os.architecture = 64;
2131
- }
2132
- ua || (ua = null);
2133
-
2134
- /*------------------------------------------------------------------------*/
2135
-
2136
- /**
2137
- * The platform object.
2138
- *
2139
- * @name platform
2140
- * @type Object
2141
- */
2142
- var platform = {};
2143
-
2144
- /**
2145
- * The platform description.
2146
- *
2147
- * @memberOf platform
2148
- * @type string|null
2149
- */
2150
- platform.description = ua;
2151
-
2152
- /**
2153
- * The name of the browser's layout engine.
2154
- *
2155
- * The list of common layout engines include:
2156
- * "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
2157
- *
2158
- * @memberOf platform
2159
- * @type string|null
2160
- */
2161
- platform.layout = layout && layout[0];
2162
-
2163
- /**
2164
- * The name of the product's manufacturer.
2165
- *
2166
- * The list of manufacturers include:
2167
- * "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
2168
- * "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
2169
- * "Nokia", "Samsung" and "Sony"
2170
- *
2171
- * @memberOf platform
2172
- * @type string|null
2173
- */
2174
- platform.manufacturer = manufacturer;
2175
-
2176
- /**
2177
- * The name of the browser/environment.
2178
- *
2179
- * The list of common browser names include:
2180
- * "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
2181
- * "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
2182
- * "Opera Mini" and "Opera"
2183
- *
2184
- * Mobile versions of some browsers have "Mobile" appended to their name:
2185
- * eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
2186
- *
2187
- * @memberOf platform
2188
- * @type string|null
2189
- */
2190
- platform.name = name;
2191
-
2192
- /**
2193
- * The alpha/beta release indicator.
2194
- *
2195
- * @memberOf platform
2196
- * @type string|null
2197
- */
2198
- platform.prerelease = prerelease;
2199
-
2200
- /**
2201
- * The name of the product hosting the browser.
2202
- *
2203
- * The list of common products include:
2204
- *
2205
- * "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
2206
- * "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
2207
- *
2208
- * @memberOf platform
2209
- * @type string|null
2210
- */
2211
- platform.product = product;
2212
-
2213
- /**
2214
- * The browser's user agent string.
2215
- *
2216
- * @memberOf platform
2217
- * @type string|null
2218
- */
2219
- platform.ua = ua;
2220
-
2221
- /**
2222
- * The browser/environment version.
2223
- *
2224
- * @memberOf platform
2225
- * @type string|null
2226
- */
2227
- platform.version = name && version;
2228
-
2229
- /**
2230
- * The name of the operating system.
2231
- *
2232
- * @memberOf platform
2233
- * @type Object
2234
- */
2235
- platform.os = os || {
2236
- /**
2237
- * The CPU architecture the OS is built for.
2238
- *
2239
- * @memberOf platform.os
2240
- * @type number|null
2241
- */
2242
- 'architecture': null,
2243
- /**
2244
- * The family of the OS.
2245
- *
2246
- * Common values include:
2247
- * "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
2248
- * "Windows XP", "OS X", "Linux", "Ubuntu", "Debian", "Fedora", "Red Hat",
2249
- * "SuSE", "Android", "iOS" and "Windows Phone"
2250
- *
2251
- * @memberOf platform.os
2252
- * @type string|null
2253
- */
2254
- 'family': null,
2255
- /**
2256
- * The version of the OS.
2257
- *
2258
- * @memberOf platform.os
2259
- * @type string|null
2260
- */
2261
- 'version': null,
2262
- /**
2263
- * Returns the OS string.
2264
- *
2265
- * @memberOf platform.os
2266
- * @returns {string} The OS string.
2267
- */
2268
- 'toString': function toString() {
2269
- return 'null';
2270
- }
2271
- };
2272
- platform.parse = parse;
2273
- platform.toString = toStringPlatform;
2274
- if (platform.version) {
2275
- description.unshift(version);
2276
- }
2277
- if (platform.name) {
2278
- description.unshift(name);
2279
- }
2280
- if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
2281
- description.push(product ? '(' + os + ')' : 'on ' + os);
2282
- }
2283
- if (description.length) {
2284
- platform.description = description.join(' ');
2285
- }
2286
- return platform;
2287
- }
2288
-
2289
- /*--------------------------------------------------------------------------*/
2290
-
2291
- // Export platform.
2292
- var platform = parse();
2293
-
2294
- // Some AMD build optimizers, like r.js, check for condition patterns like the following:
2295
- if (freeExports && freeModule) {
2296
- // Export for CommonJS support.
2297
- forOwn(platform, function (value, key) {
2298
- freeExports[key] = value;
2299
- });
2300
- } else {
2301
- // Export to the global object.
2302
- root.platform = platform;
2303
- }
2304
- }).call(commonjsGlobal);
2305
- })(platform$1, platform$1.exports);
2306
- var platformExports = platform$1.exports;
2307
- var platform = /*@__PURE__*/getDefaultExportFromCjs(platformExports);
2308
-
2309
- var isMultipleHotkey = Array.isArray;
2310
- var replaceKeys = function replaceKeys(hotkey, keyName, replaceWith) {
2311
- return isMultipleHotkey(hotkey) ? hotkey.map(function (item) {
2312
- return item.replaceAll(keyName, replaceWith);
2313
- }) : hotkey.replaceAll(keyName, replaceWith);
2314
- };
2315
- var convertHotKeyToWindows = function convertHotKeyToWindows(hotkey) {
2316
- ramda.toPairs(MAC_TO_WINDOWS_KEYS_MAP).forEach(function (_ref) {
2317
- var _ref2 = _slicedToArray(_ref, 2),
2318
- macKey = _ref2[0],
2319
- windowsKey = _ref2[1];
2320
- hotkey = replaceKeys(hotkey, macKey, windowsKey);
2321
- });
2322
- return hotkey;
2323
- };
2324
- var convertHotkeyToUsersPlatform = function convertHotkeyToUsersPlatform(hotkey) {
2325
- var _platformInfo$os;
2326
- var platformInfo = platform.parse(navigator.userAgent);
2327
- var isOSX = (_platformInfo$os = platformInfo.os) === null || _platformInfo$os === void 0 || (_platformInfo$os = _platformInfo$os.family) === null || _platformInfo$os === void 0 ? void 0 : _platformInfo$os.includes(OS.mac);
2328
- if (isOSX) return replaceKeys(hotkey, KEY_NAMES["delete"], KEY_NAMES.backspace);
2329
- return convertHotKeyToWindows(hotkey);
2330
- };
2331
- var bindHotKey = function bindHotKey(_ref3) {
2332
- var mode = _ref3.mode,
2333
- hotkey = _ref3.hotkey,
2334
- handler = _ref3.handler,
2335
- ref = _ref3.ref;
2336
- var mousetrapInstance;
2337
- switch (mode) {
2338
- case MODES.global:
2339
- Mousetrap$1.bindGlobal(hotkey, handler);
2340
- break;
2341
- case MODES.scoped:
2342
- mousetrapInstance = Mousetrap$1(ref.current).bind(hotkey, handler);
2343
- break;
2344
- default:
2345
- mousetrapInstance = Mousetrap$1.bind(hotkey, handler);
2346
- }
2347
- return mousetrapInstance;
2348
- };
2349
- var unBindHotKey = function unBindHotKey(_ref4) {
2350
- var mousetrapInstance = _ref4.mousetrapInstance,
2351
- mode = _ref4.mode,
2352
- hotkey = _ref4.hotkey;
2353
- return mode === MODES.global ? Mousetrap$1.unbindGlobal(hotkey) : mousetrapInstance === null || mousetrapInstance === void 0 ? void 0 : mousetrapInstance.unbind(hotkey);
2354
- };
2355
-
2356
- var useHotKeys = function useHotKeys(hotkey, handler, userConfig) {
2357
- var ref = React.useRef(null);
2358
- var convertedHotkey = convertHotkeyToUsersPlatform(hotkey);
2359
- var config = ramda.mergeLeft(userConfig, DEFAULT_CONFIG);
2360
- if (!handler) {
2361
- throw new Error("You must provide a handler function to useHotKeys");
2362
- }
2363
- React.useEffect(function () {
2364
- if (!config.enabled) return undefined;
2365
- var mousetrapInstance = bindHotKey({
2366
- mode: config.mode,
2367
- hotkey: convertedHotkey,
2368
- handler: handler,
2369
- ref: ref
2370
- });
2371
- return function () {
2372
- unBindHotKey({
2373
- mousetrapInstance: mousetrapInstance,
2374
- mode: config.mode,
2375
- hotkey: convertedHotkey
2376
- });
2377
- };
2378
- }, [handler, config.mode, convertedHotkey, config]);
2379
- return config.mode === MODES.scoped ? ref : null;
2380
- };
2381
-
2382
- exports.useHotKeys = useHotKeys;
2383
- //# sourceMappingURL=index-a8cc581e.js.map