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