@shortfuse/materialdesignweb 0.0.9 → 0.4.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 (392) hide show
  1. package/.browserslistrc +3 -0
  2. package/.eslintrc.json +146 -27
  3. package/.stylelintrc.json +598 -2
  4. package/.vscode/launch.json +20 -5
  5. package/.vscode/settings.json +3 -0
  6. package/.vscode/tasks.json +19 -10
  7. package/CHANGELOG.md +24 -0
  8. package/README.md +84 -2
  9. package/adapters/datatable/column.js +203 -0
  10. package/adapters/datatable/index.js +972 -0
  11. package/adapters/dom/index.js +601 -0
  12. package/adapters/list/index.js +69 -0
  13. package/adapters/search/index.js +521 -0
  14. package/components/appbar/_spec.scss +225 -0
  15. package/components/appbar/_theme.scss +0 -0
  16. package/components/appbar/index.scss +2 -0
  17. package/components/banner/_spec.scss +118 -0
  18. package/components/banner/_theme.scss +0 -0
  19. package/components/banner/index.scss +2 -0
  20. package/components/bottomnav/README.md +85 -0
  21. package/components/bottomnav/_spec.scss +157 -0
  22. package/components/bottomnav/_theme.scss +0 -0
  23. package/components/bottomnav/index.js +122 -0
  24. package/components/bottomnav/index.scss +2 -0
  25. package/components/bottomnav/item.js +89 -0
  26. package/components/{core/button → button}/README.md +16 -22
  27. package/components/button/_spec.scss +161 -0
  28. package/components/button/_theme.scss +65 -0
  29. package/components/button/index.eta +32 -0
  30. package/components/button/index.js +43 -0
  31. package/components/button/index.pug +18 -0
  32. package/components/button/index.scss +2 -0
  33. package/components/card/_spec.scss +249 -0
  34. package/components/card/_theme.scss +0 -0
  35. package/components/card/index.scss +2 -0
  36. package/components/chip/_spec.scss +134 -0
  37. package/components/chip/_theme.scss +177 -0
  38. package/components/chip/index.js +21 -0
  39. package/components/chip/index.scss +2 -0
  40. package/components/chip/item.js +20 -0
  41. package/components/datatable/_spec.scss +288 -0
  42. package/components/datatable/_theme.scss +154 -0
  43. package/components/datatable/cell.js +45 -0
  44. package/components/datatable/columnheader.js +47 -0
  45. package/components/datatable/index.js +388 -0
  46. package/components/datatable/index.scss +2 -0
  47. package/components/datatable/row.js +49 -0
  48. package/components/datatable/rowheader.js +18 -0
  49. package/components/dialog/_spec.scss +213 -0
  50. package/components/dialog/_theme.scss +0 -0
  51. package/components/dialog/index.js +627 -0
  52. package/components/dialog/index.scss +2 -0
  53. package/components/divider/_spec.scss +13 -0
  54. package/components/divider/_theme.scss +0 -0
  55. package/components/divider/index.scss +2 -0
  56. package/components/elevation/_spec.scss +9 -0
  57. package/components/elevation/_theme.scss +0 -0
  58. package/components/elevation/index.scss +2 -0
  59. package/components/fab/_spec.scss +222 -0
  60. package/components/fab/_theme.scss +0 -0
  61. package/components/fab/index.js +103 -0
  62. package/components/fab/index.scss +2 -0
  63. package/components/grid/_spec.scss +312 -0
  64. package/components/grid/_theme.scss +0 -0
  65. package/components/grid/index.scss +2 -0
  66. package/components/layout/_mixins.scss +33 -0
  67. package/components/layout/_spec.scss +1012 -0
  68. package/components/layout/_theme.scss +44 -0
  69. package/components/layout/index.js +464 -0
  70. package/components/layout/index.scss +2 -0
  71. package/components/list/_spec.scss +397 -0
  72. package/components/list/_theme.scss +111 -0
  73. package/components/list/content.js +110 -0
  74. package/components/list/index.js +260 -0
  75. package/components/list/index.scss +2 -0
  76. package/components/list/item.js +170 -0
  77. package/components/list/secondary.js +46 -0
  78. package/components/menu/_spec.scss +362 -0
  79. package/components/menu/_theme.scss +0 -0
  80. package/components/menu/index.js +721 -0
  81. package/components/menu/index.scss +2 -0
  82. package/components/menu/item.js +239 -0
  83. package/components/{core/progress/style.scss → progress/_spec.scss} +36 -25
  84. package/components/progress/_theme.scss +0 -0
  85. package/components/progress/index.js +36 -0
  86. package/components/progress/index.scss +2 -0
  87. package/components/selection/_spec.scss +386 -0
  88. package/components/selection/_theme.scss +166 -0
  89. package/components/selection/index.eta +60 -0
  90. package/components/selection/index.js +76 -0
  91. package/components/selection/index.pug +30 -0
  92. package/components/selection/index.scss +2 -0
  93. package/components/selection/input.js +56 -0
  94. package/components/selection/radiogroup.js +47 -0
  95. package/components/slider/_spec.scss +64 -0
  96. package/components/slider/_theme.scss +0 -0
  97. package/components/slider/index.scss +2 -0
  98. package/components/snackbar/_spec.scss +195 -0
  99. package/components/snackbar/_theme.scss +0 -0
  100. package/components/snackbar/index.js +344 -0
  101. package/components/snackbar/index.scss +2 -0
  102. package/components/tab/_spec.scss +235 -0
  103. package/components/tab/_theme.scss +0 -0
  104. package/components/tab/content.js +205 -0
  105. package/components/tab/index.js +260 -0
  106. package/components/tab/index.scss +2 -0
  107. package/components/tab/item.js +89 -0
  108. package/components/tab/list.js +210 -0
  109. package/components/tab/panel.js +54 -0
  110. package/components/template/_theme.scss +27 -0
  111. package/components/{core/textfield → textfield}/README.md +70 -50
  112. package/components/textfield/_mixins.scss +52 -0
  113. package/components/textfield/_spec.scss +809 -0
  114. package/components/textfield/_theme.scss +299 -0
  115. package/components/textfield/index.eta +74 -0
  116. package/components/textfield/index.js +168 -0
  117. package/components/textfield/index.pug +30 -0
  118. package/components/textfield/index.scss +2 -0
  119. package/components/tooltip/_spec.scss +188 -0
  120. package/components/tooltip/_theme.scss +0 -0
  121. package/components/tooltip/index.scss +2 -0
  122. package/components/type/_spec.scss +224 -0
  123. package/components/type/_theme.scss +0 -0
  124. package/components/type/index.scss +2 -0
  125. package/core/_breakpoint.scss +189 -0
  126. package/core/_elevation.scss +38 -0
  127. package/core/_length.scss +9 -0
  128. package/core/_motion.scss +31 -0
  129. package/core/_platform.scss +34 -0
  130. package/core/_type.scss +127 -0
  131. package/core/aria/attributes.js +141 -0
  132. package/core/aria/button.js +50 -0
  133. package/core/aria/keyboard.js +93 -0
  134. package/core/aria/rovingtabindex.js +178 -0
  135. package/core/aria/tab.js +60 -0
  136. package/core/color/_spec.scss +0 -0
  137. package/core/color/_theme.scss +390 -0
  138. package/core/color/index.scss +2 -0
  139. package/core/document/index.js +39 -0
  140. package/core/dom.js +271 -0
  141. package/core/overlay/_spec.scss +31 -0
  142. package/core/overlay/_theme.scss +171 -0
  143. package/core/overlay/index.js +108 -0
  144. package/core/overlay/index.scss +2 -0
  145. package/core/ripple/_spec.scss +197 -0
  146. package/core/ripple/_theme.scss +40 -0
  147. package/core/ripple/index.js +294 -0
  148. package/core/ripple/index.scss +2 -0
  149. package/core/theme/_config.scss +2 -0
  150. package/core/theme/_mixins.scss +172 -0
  151. package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -150
  152. package/core/theme/_variables.scss +24 -0
  153. package/core/theme/index.js +50 -0
  154. package/core/throttler.js +42 -0
  155. package/core/transition/index.js +468 -0
  156. package/docs/_flex.scss +22 -0
  157. package/docs/_menuoptions.js +183 -0
  158. package/docs/_mixins.pug +155 -0
  159. package/docs/_partials/_androidnavbar.eta +5 -0
  160. package/docs/_partials/_androidstatusbar.eta +13 -0
  161. package/docs/_partials/_appbar.eta +29 -0
  162. package/docs/_partials/_buttontest.eta +31 -0
  163. package/docs/_partials/_header.eta +149 -0
  164. package/docs/_partials/_navlistitem.eta +16 -0
  165. package/docs/_partials/_target.eta +1 -0
  166. package/docs/_sample-utils.js +93 -0
  167. package/docs/_storage.js +33 -0
  168. package/docs/docs.scss +295 -0
  169. package/docs/index.eta +16 -0
  170. package/docs/index.js +0 -0
  171. package/docs/pages/appbar.eta +114 -0
  172. package/docs/pages/appbar.js +0 -0
  173. package/docs/pages/appbar.pug +78 -0
  174. package/docs/pages/bottomnav.eta +188 -0
  175. package/docs/pages/bottomnav.js +115 -0
  176. package/docs/pages/bottomnav.pug +137 -0
  177. package/docs/pages/button.eta +124 -0
  178. package/docs/pages/button.js +224 -0
  179. package/docs/pages/button.pug +121 -0
  180. package/docs/pages/card.eta +90 -0
  181. package/docs/pages/card.js +177 -0
  182. package/docs/pages/card.pug +74 -0
  183. package/docs/pages/chip.eta +122 -0
  184. package/docs/pages/chip.js +82 -0
  185. package/docs/pages/chip.pug +91 -0
  186. package/docs/pages/color.eta +143 -0
  187. package/docs/pages/color.js +262 -0
  188. package/docs/pages/color.pug +121 -0
  189. package/docs/pages/datatable.eta +323 -0
  190. package/docs/pages/datatable.js +164 -0
  191. package/docs/pages/datatable.pug +283 -0
  192. package/docs/pages/dialog.eta +186 -0
  193. package/docs/pages/dialog.js +177 -0
  194. package/docs/pages/dialog.pug +132 -0
  195. package/docs/pages/dom.eta +26 -0
  196. package/docs/pages/dom.js +143 -0
  197. package/docs/pages/dom.pug +22 -0
  198. package/docs/pages/elevation.eta +35 -0
  199. package/docs/pages/elevation.js +0 -0
  200. package/docs/pages/elevation.pug +25 -0
  201. package/docs/pages/fab.eta +99 -0
  202. package/docs/pages/fab.js +44 -0
  203. package/docs/pages/fab.pug +66 -0
  204. package/docs/pages/grid.eta +135 -0
  205. package/docs/pages/grid.js +128 -0
  206. package/docs/pages/grid.pug +95 -0
  207. package/docs/pages/layout.eta +8 -0
  208. package/docs/pages/layout.js +0 -0
  209. package/docs/pages/layout.pug +7 -0
  210. package/docs/pages/list.eta +465 -0
  211. package/docs/pages/list.js +9 -0
  212. package/docs/pages/list.pug +326 -0
  213. package/docs/pages/menu.eta +276 -0
  214. package/docs/pages/menu.js +217 -0
  215. package/docs/pages/menu.pug +205 -0
  216. package/docs/pages/overlay.eta +69 -0
  217. package/docs/pages/overlay.js +4 -0
  218. package/docs/pages/overlay.pug +55 -0
  219. package/docs/pages/progress.eta +23 -0
  220. package/docs/pages/progress.js +12 -0
  221. package/docs/pages/progress.pug +16 -0
  222. package/docs/pages/ripple.eta +27 -0
  223. package/docs/pages/ripple.js +4 -0
  224. package/docs/pages/ripple.pug +21 -0
  225. package/docs/pages/search.eta +246 -0
  226. package/docs/pages/search.js +243 -0
  227. package/docs/pages/search.pug +165 -0
  228. package/docs/pages/selection.eta +111 -0
  229. package/docs/pages/selection.js +13 -0
  230. package/docs/pages/selection.pug +74 -0
  231. package/docs/pages/slider.eta +23 -0
  232. package/docs/pages/slider.js +0 -0
  233. package/docs/pages/slider.pug +17 -0
  234. package/docs/pages/snackbar.eta +83 -0
  235. package/docs/pages/snackbar.js +158 -0
  236. package/docs/pages/snackbar.pug +60 -0
  237. package/docs/pages/tab.eta +421 -0
  238. package/docs/pages/tab.js +151 -0
  239. package/docs/pages/tab.pug +304 -0
  240. package/docs/pages/textfield.eta +486 -0
  241. package/docs/pages/textfield.js +254 -0
  242. package/docs/pages/textfield.pug +360 -0
  243. package/docs/pages/tooltip.eta +94 -0
  244. package/docs/pages/tooltip.js +0 -0
  245. package/docs/pages/tooltip.pug +78 -0
  246. package/docs/pages/transition.eta +117 -0
  247. package/docs/pages/transition.js +54 -0
  248. package/docs/pages/transition.pug +76 -0
  249. package/docs/pages/type.eta +31 -0
  250. package/docs/pages/type.js +0 -0
  251. package/docs/pages/type.pug +29 -0
  252. package/docs/postrender.js +39 -0
  253. package/docs/prerender.js +16 -0
  254. package/docs/pwa/_dialogs.eta +143 -0
  255. package/docs/pwa/_dialogs.pug +96 -0
  256. package/docs/pwa/_menus.eta +16 -0
  257. package/docs/pwa/_menus.pug +11 -0
  258. package/docs/pwa/pwa-prerender.js +3 -0
  259. package/docs/pwa/pwa.eta +480 -0
  260. package/docs/pwa/pwa.js +306 -0
  261. package/docs/pwa/pwa.pug +325 -0
  262. package/docs/pwa/pwa.scss +26 -0
  263. package/docs/spec.scss +26 -0
  264. package/docs/themes/_component-themes.scss +26 -0
  265. package/docs/themes/theme-colored-fallbacks.scss +17 -0
  266. package/docs/themes/theme-colored.scss +17 -0
  267. package/docs/themes/theme-default-fallbacks.scss +17 -0
  268. package/docs/themes/theme-default.scss +17 -0
  269. package/jsconfig.json +4 -2
  270. package/package.json +43 -28
  271. package/scripts/deploy-docs.sh +9 -0
  272. package/templates/index.eta +2 -0
  273. package/templates/index.pug +3 -0
  274. package/utils/function.js +3 -0
  275. package/webpack.config.cjs +257 -0
  276. package/components/_index.scss +0 -4
  277. package/components/all-components.scss +0 -14
  278. package/components/common/functions.scss +0 -173
  279. package/components/common/mixins.scss +0 -107
  280. package/components/common/motion.scss +0 -36
  281. package/components/common/ripple.scss +0 -92
  282. package/components/common/variables.scss +0 -48
  283. package/components/complex/dialog/style.scss +0 -159
  284. package/components/complex/dialog/theming.scss +0 -29
  285. package/components/complex/navdrawer/style.scss +0 -477
  286. package/components/complex/navdrawer/theming.scss +0 -58
  287. package/components/complex/search/index.js +0 -492
  288. package/components/core/bottomnav/README.md +0 -85
  289. package/components/core/bottomnav/index.js +0 -140
  290. package/components/core/bottomnav/style.scss +0 -173
  291. package/components/core/bottomnav/theming.scss +0 -42
  292. package/components/core/button/index.js +0 -52
  293. package/components/core/button/style.scss +0 -283
  294. package/components/core/button/theming.scss +0 -131
  295. package/components/core/list/index.js +0 -94
  296. package/components/core/list/style.scss +0 -269
  297. package/components/core/list/theming.scss +0 -74
  298. package/components/core/menu/index.js +0 -127
  299. package/components/core/menu/style.scss +0 -239
  300. package/components/core/menu/theming.scss +0 -55
  301. package/components/core/progress/index.js +0 -33
  302. package/components/core/selection/style.scss +0 -249
  303. package/components/core/selection/theming.scss +0 -49
  304. package/components/core/switch/style.scss +0 -3
  305. package/components/core/tab/index.js +0 -174
  306. package/components/core/tab/style.scss +0 -202
  307. package/components/core/tab/theming.scss +0 -43
  308. package/components/core/textfield/index.js +0 -169
  309. package/components/core/textfield/style.scss +0 -672
  310. package/components/core/textfield/theming.scss +0 -262
  311. package/components/core/toolbar/style.scss +0 -109
  312. package/components/core/toolbar/theming.scss +0 -28
  313. package/components/core/tooltip/style.scss +0 -127
  314. package/components/core/type/style.scss +0 -133
  315. package/components/core/type/theming.scss +0 -25
  316. package/components/index.js +0 -24
  317. package/components/template/theming.scss +0 -31
  318. package/components/theming/theming.scss +0 -504
  319. package/docs/bottomnav.html +0 -171
  320. package/docs/bottomnav.min.js +0 -383
  321. package/docs/button.html +0 -322
  322. package/docs/button.min.js +0 -251
  323. package/docs/components.min.css +0 -1
  324. package/docs/components.min.js +0 -83
  325. package/docs/dialog.html +0 -103
  326. package/docs/dialog.min.js +0 -160
  327. package/docs/docs.min.css +0 -1
  328. package/docs/docs.min.js +0 -83
  329. package/docs/index.html +0 -55
  330. package/docs/index.min.js +0 -83
  331. package/docs/list.html +0 -442
  332. package/docs/list.min.js +0 -312
  333. package/docs/menu.html +0 -185
  334. package/docs/menu.min.js +0 -370
  335. package/docs/navdrawer.html +0 -199
  336. package/docs/navdrawer.min.js +0 -244
  337. package/docs/progress.html +0 -75
  338. package/docs/progress.min.js +0 -162
  339. package/docs/search.html +0 -230
  340. package/docs/search.min.js +0 -1202
  341. package/docs/selection.html +0 -188
  342. package/docs/selection.min.js +0 -160
  343. package/docs/src/complex/dialog.js +0 -3
  344. package/docs/src/complex/dialog.pug +0 -44
  345. package/docs/src/complex/navdrawer.js +0 -82
  346. package/docs/src/complex/navdrawer.pug +0 -109
  347. package/docs/src/complex/search.js +0 -207
  348. package/docs/src/complex/search.pug +0 -143
  349. package/docs/src/components.scss +0 -1
  350. package/docs/src/core/bottomnav.js +0 -22
  351. package/docs/src/core/bottomnav.pug +0 -93
  352. package/docs/src/core/button.js +0 -16
  353. package/docs/src/core/button.pug +0 -73
  354. package/docs/src/core/list.js +0 -21
  355. package/docs/src/core/list.pug +0 -246
  356. package/docs/src/core/menu.js +0 -33
  357. package/docs/src/core/menu.pug +0 -108
  358. package/docs/src/core/progress.js +0 -11
  359. package/docs/src/core/progress.pug +0 -17
  360. package/docs/src/core/selection.js +0 -4
  361. package/docs/src/core/selection.pug +0 -92
  362. package/docs/src/core/tab.js +0 -21
  363. package/docs/src/core/tab.pug +0 -180
  364. package/docs/src/core/textfield.js +0 -15
  365. package/docs/src/core/textfield.pug +0 -274
  366. package/docs/src/core/toolbar.js +0 -4
  367. package/docs/src/core/toolbar.pug +0 -79
  368. package/docs/src/core/tooltip.js +0 -4
  369. package/docs/src/core/tooltip.pug +0 -76
  370. package/docs/src/core/type.js +0 -4
  371. package/docs/src/core/type.pug +0 -36
  372. package/docs/src/docs.scss +0 -200
  373. package/docs/src/index.pug +0 -5
  374. package/docs/src/mixins.pug +0 -72
  375. package/docs/src/targetHandler.js +0 -50
  376. package/docs/src/theming.ie11.scss +0 -35
  377. package/docs/src/theming.scss +0 -36
  378. package/docs/tab.html +0 -301
  379. package/docs/tab.min.js +0 -397
  380. package/docs/textfield.html +0 -476
  381. package/docs/textfield.min.js +0 -381
  382. package/docs/theming.ie11.min.css +0 -1
  383. package/docs/theming.ie11.min.js +0 -83
  384. package/docs/theming.min.css +0 -1
  385. package/docs/theming.min.js +0 -83
  386. package/docs/toolbar.html +0 -213
  387. package/docs/toolbar.min.js +0 -160
  388. package/docs/tooltip.html +0 -138
  389. package/docs/tooltip.min.js +0 -160
  390. package/docs/type.html +0 -94
  391. package/docs/type.min.js +0 -160
  392. package/webpack.config.js +0 -176
@@ -1,1202 +0,0 @@
1
- /******/ (function(modules) { // webpackBootstrap
2
- /******/ // The module cache
3
- /******/ var installedModules = {};
4
- /******/
5
- /******/ // The require function
6
- /******/ function __webpack_require__(moduleId) {
7
- /******/
8
- /******/ // Check if module is in cache
9
- /******/ if(installedModules[moduleId]) {
10
- /******/ return installedModules[moduleId].exports;
11
- /******/ }
12
- /******/ // Create a new module (and put it into the cache)
13
- /******/ var module = installedModules[moduleId] = {
14
- /******/ i: moduleId,
15
- /******/ l: false,
16
- /******/ exports: {}
17
- /******/ };
18
- /******/
19
- /******/ // Execute the module function
20
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
- /******/
22
- /******/ // Flag the module as loaded
23
- /******/ module.l = true;
24
- /******/
25
- /******/ // Return the exports of the module
26
- /******/ return module.exports;
27
- /******/ }
28
- /******/
29
- /******/
30
- /******/ // expose the modules object (__webpack_modules__)
31
- /******/ __webpack_require__.m = modules;
32
- /******/
33
- /******/ // expose the module cache
34
- /******/ __webpack_require__.c = installedModules;
35
- /******/
36
- /******/ // define getter function for harmony exports
37
- /******/ __webpack_require__.d = function(exports, name, getter) {
38
- /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, {
40
- /******/ configurable: false,
41
- /******/ enumerable: true,
42
- /******/ get: getter
43
- /******/ });
44
- /******/ }
45
- /******/ };
46
- /******/
47
- /******/ // getDefaultExport function for compatibility with non-harmony modules
48
- /******/ __webpack_require__.n = function(module) {
49
- /******/ var getter = module && module.__esModule ?
50
- /******/ function getDefault() { return module['default']; } :
51
- /******/ function getModuleExports() { return module; };
52
- /******/ __webpack_require__.d(getter, 'a', getter);
53
- /******/ return getter;
54
- /******/ };
55
- /******/
56
- /******/ // Object.prototype.hasOwnProperty.call
57
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58
- /******/
59
- /******/ // __webpack_public_path__
60
- /******/ __webpack_require__.p = "";
61
- /******/
62
- /******/ // Load entry module and return exports
63
- /******/ return __webpack_require__(__webpack_require__.s = 57);
64
- /******/ })
65
- /************************************************************************/
66
- /******/ ({
67
-
68
- /***/ 1:
69
- /***/ (function(module, exports, __webpack_require__) {
70
-
71
- "use strict";
72
-
73
-
74
- Object.defineProperty(exports, "__esModule", {
75
- value: true
76
- });
77
-
78
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
79
-
80
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
81
-
82
- var List = function () {
83
- /**
84
- * @param {Element} element
85
- */
86
- function List(element) {
87
- _classCallCheck(this, List);
88
-
89
- this.element = element;
90
- }
91
-
92
- _createClass(List, [{
93
- key: 'detach',
94
- value: function detach() {
95
- this.element = null;
96
- }
97
-
98
- /**
99
- * Clear and detach all children
100
- * @param {WeakMap=} elementMap
101
- * @return {void}
102
- */
103
-
104
- }, {
105
- key: 'clear',
106
- value: function clear(elementMap) {
107
- var el = this.element;
108
- if (!el) {
109
- return;
110
- }
111
- while (el.firstChild) {
112
- if (elementMap && elementMap.has(el.firstChild)) {
113
- elementMap.get(el.firstChild).detach();
114
- elementMap.delete(el.firstChild);
115
- }
116
- el.removeChild(el.firstChild);
117
- }
118
- }
119
- }]);
120
-
121
- return List;
122
- }();
123
-
124
- var ListItem = function () {
125
- /**
126
- * @param {Element} element
127
- */
128
- function ListItem(element) {
129
- var _this = this;
130
-
131
- _classCallCheck(this, ListItem);
132
-
133
- this.element = element;
134
- var rippleElements = element.getElementsByClassName('mdw-ripple');
135
- this.ripple = rippleElements && rippleElements[0];
136
- if (!this.ripple) {
137
- var ripple = document.createElement('div');
138
- ripple.classList.add('mdw-ripple');
139
- this.element.insertBefore(ripple, this.element.firstChild);
140
- this.ripple = ripple;
141
- }
142
- var innerRippleElements = this.ripple.getElementsByClassName('mdw-ripple__inner');
143
- this.rippleInner = innerRippleElements && innerRippleElements[0];
144
- if (!this.rippleInner) {
145
- var rippleInner = document.createElement('div');
146
- rippleInner.classList.add('mdw-ripple__inner');
147
- this.ripple.appendChild(rippleInner);
148
- this.rippleInner = rippleInner;
149
- }
150
- this.element.setAttribute('mdw-ripple', '');
151
- this.element.addEventListener('click', function (event) {
152
- _this.updateRipplePosition(event);
153
- });
154
- }
155
-
156
- /**
157
- * @param {MouseEvent|PointerEvent} event
158
- * @return {void}
159
- */
160
-
161
-
162
- _createClass(ListItem, [{
163
- key: 'updateRipplePosition',
164
- value: function updateRipplePosition(event) {
165
- if (event.target !== this.element && event.target !== this.ripple) {
166
- return;
167
- }
168
- if (!event.pointerType && !event.detail) {
169
- // Ripple from center
170
- this.rippleInner.style.removeProperty('left');
171
- this.rippleInner.style.removeProperty('top');
172
- return;
173
- }
174
- var x = event.offsetX;
175
- var y = event.offsetY;
176
- this.rippleInner.style.setProperty('left', x + 'px');
177
- this.rippleInner.style.setProperty('top', y + 'px');
178
- }
179
-
180
- /**
181
- * Destroys all HTML Element references for garbage collection
182
- * @return {void}
183
- */
184
-
185
- }, {
186
- key: 'detach',
187
- value: function detach() {
188
- this.ripple = null;
189
- this.element = null;
190
- }
191
- }]);
192
-
193
- return ListItem;
194
- }();
195
-
196
- exports.List = List;
197
- exports.ListItem = ListItem;
198
-
199
- /***/ }),
200
-
201
- /***/ 2:
202
- /***/ (function(module, exports, __webpack_require__) {
203
-
204
- "use strict";
205
-
206
-
207
- Object.defineProperty(exports, "__esModule", {
208
- value: true
209
- });
210
-
211
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
212
-
213
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
214
-
215
- var TextField = function () {
216
- /**
217
- * @param {HTMLElement} element
218
- */
219
- function TextField(element) {
220
- var _this = this;
221
-
222
- _classCallCheck(this, TextField);
223
-
224
- this.element = element;
225
- /** @type {HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement} */
226
- this.input = element.querySelector('.mdw-textfield__input');
227
- if (this.input) {
228
- if (this.input instanceof HTMLTextAreaElement && this.element.hasAttribute('mdw-multiline')) {
229
- this.input.addEventListener('input', function () {
230
- _this.updateTextAreaSize();
231
- });
232
- this.updateTextAreaSize();
233
- }
234
- this.input.addEventListener('input', function () {
235
- _this.updateInputEmptyState();
236
- });
237
- this.updateInputEmptyState();
238
- }
239
- this.border = element.querySelector('.mdw-textfield__border-line');
240
- if (!this.border) {
241
- var border = document.createElement('div');
242
- border.classList.add('.mdw-textfield__border-line');
243
- element.appendChild(border);
244
- this.border = border;
245
- }
246
- var rippleElements = this.border.getElementsByClassName('mdw-ripple');
247
- this.ripple = rippleElements && rippleElements[0];
248
- if (!this.ripple) {
249
- var ripple = document.createElement('div');
250
- ripple.classList.add('mdw-ripple');
251
- this.border.appendChild(ripple);
252
- this.ripple = ripple;
253
- }
254
- var innerRippleElements = this.ripple.getElementsByClassName('mdw-ripple__inner');
255
- this.rippleInner = innerRippleElements && innerRippleElements[0];
256
- if (!this.rippleInner) {
257
- var rippleInner = document.createElement('div');
258
- rippleInner.classList.add('mdw-ripple__inner');
259
- this.ripple.appendChild(rippleInner);
260
- this.rippleInner = rippleInner;
261
- }
262
- this.element.setAttribute('mdw-ripple', '');
263
- this.border.addEventListener('click', function (event) {
264
- _this.updateRipplePosition(event);
265
- });
266
- }
267
-
268
- /** @return {void} */
269
-
270
-
271
- _createClass(TextField, [{
272
- key: 'updateInputEmptyState',
273
- value: function updateInputEmptyState() {
274
- var attributeName = 'mdw-value-empty';
275
- if (this.input.value) {
276
- if (this.element.hasAttribute(attributeName)) {
277
- this.element.removeAttribute(attributeName);
278
- }
279
- } else if (!this.element.hasAttribute(attributeName)) {
280
- this.element.setAttribute('mdw-value-empty', '');
281
- }
282
- }
283
-
284
- /** @return {number} Single row height */
285
-
286
- }, {
287
- key: 'updateTextAreaSize',
288
- value: function updateTextAreaSize() {
289
- var previousRowsValue = this.input.getAttribute('rows');
290
- this.input.setAttribute('rows', '1');
291
-
292
- var _window$getComputedSt = window.getComputedStyle(this.input),
293
- height = _window$getComputedSt.height,
294
- paddingTop = _window$getComputedSt.paddingTop;
295
-
296
- if (height === 'auto') {
297
- this.input.setAttribute('rows', previousRowsValue);
298
- return -1;
299
- }
300
- var heightPx = parseInt(height.replace('px', ''), 10);
301
- var paddingTopPx = parseInt(paddingTop.replace('px', ''), 10);
302
- this.input.setAttribute('rows', Math.floor((this.input.scrollHeight - paddingTopPx) / heightPx).toString());
303
- return heightPx;
304
- }
305
-
306
- /**
307
- * @param {MouseEvent|PointerEvent} event
308
- * @return {void}
309
- */
310
-
311
- }, {
312
- key: 'updateRipplePosition',
313
- value: function updateRipplePosition(event) {
314
- if (event.target !== this.border && event.target !== this.ripple) {
315
- return;
316
- }
317
- if (!event.pointerType && !event.detail) {
318
- // Ripple from center
319
- this.rippleInner.style.removeProperty('left');
320
- this.rippleInner.style.removeProperty('top');
321
- return;
322
- }
323
- var x = event.offsetX;
324
- var y = event.offsetY;
325
- this.rippleInner.style.setProperty('left', x + 'px');
326
- this.rippleInner.style.setProperty('top', y + 'px');
327
- }
328
-
329
- /**
330
- * @return {string|Date|number}
331
- */
332
-
333
- }, {
334
- key: 'value',
335
- get: function get() {
336
- if (this.input instanceof HTMLTextAreaElement || this.input instanceof HTMLSelectElement) {
337
- return this.value;
338
- }
339
- var type = this.input.hasAttribute('type') && this.input.getAttribute('type').toLowerCase();
340
- switch (type) {
341
- case 'date':
342
- case 'time':
343
- return this.input.valueAsDate;
344
- case 'datetime-local':
345
- case 'number':
346
- case 'range':
347
- return this.input.valueAsNumber;
348
- default:
349
- return this.input.value;
350
- }
351
- }
352
-
353
- /** @param {(string|Date|number)=} value */
354
- ,
355
- set: function set(value) {
356
- if (value == null) {
357
- this.input.value = null;
358
- } else if (this.input instanceof HTMLTextAreaElement || this.input instanceof HTMLSelectElement) {
359
- if (value instanceof Date) {
360
- this.input.value = value.toString();
361
- } else if (typeof value === 'string') {
362
- this.input.value = value;
363
- } else {
364
- this.input.value = value.toString(10);
365
- }
366
- } else if (value instanceof Date) {
367
- var type = this.input.hasAttribute('type') && this.input.getAttribute('type').toLowerCase();
368
- switch (type) {
369
- case 'date':
370
- case 'time':
371
- case 'datetime-local':
372
- this.input.valueAsDate = value;
373
- break;
374
- case 'number':
375
- case 'range':
376
- this.input.valueAsNumber = value.getTime();
377
- break;
378
- default:
379
- this.input.value = value.toString();
380
- }
381
- } else if (typeof value === 'string') {
382
- this.input.value = value;
383
- } else {
384
- var _type = this.input.hasAttribute('type') && this.input.getAttribute('type').toLowerCase();
385
- switch (_type) {
386
- case 'date':
387
- case 'time':
388
- case 'datetime-local':
389
- case 'number':
390
- case 'range':
391
- this.input.valueAsNumber = value;
392
- break;
393
- default:
394
- this.input.value = value.toString();
395
- }
396
- }
397
- this.updateInputEmptyState();
398
- this.updateTextAreaSize();
399
- }
400
- }]);
401
-
402
- return TextField;
403
- }();
404
-
405
- exports.TextField = TextField;
406
-
407
- /***/ }),
408
-
409
- /***/ 57:
410
- /***/ (function(module, exports, __webpack_require__) {
411
-
412
- __webpack_require__(58);
413
- module.exports = __webpack_require__(60);
414
-
415
-
416
- /***/ }),
417
-
418
- /***/ 58:
419
- /***/ (function(module, exports, __webpack_require__) {
420
-
421
- "use strict";
422
-
423
-
424
- var _index = __webpack_require__(1);
425
-
426
- var _index2 = __webpack_require__(2);
427
-
428
- var _index3 = __webpack_require__(59);
429
-
430
- var componentMap = new WeakMap();
431
- /** @return {void} */
432
- function buildCustomSearch1() {
433
- var textfield = componentMap.get(document.getElementById('search-textfield-custom1'));
434
- var list = componentMap.get(document.getElementById('search-list-custom1'));
435
- var busyIndicator = textfield.element.querySelector('.custom-busy-indicator');
436
- var resultsCache = void 0;
437
- var listUpdated = false;
438
- var customPerformSearch = function customPerformSearch() {
439
- if (listUpdated) {
440
- return Promise.resolve();
441
- }
442
- if (resultsCache != null) {
443
- return Promise.resolve(resultsCache);
444
- }
445
- return new Promise(function (resolve) {
446
- busyIndicator.style.setProperty('display', '');
447
- var myData = [];
448
- for (var key in window.navigator) {
449
- myData.push({ line1: key, line2: navigator[key] });
450
- }
451
- setTimeout(function () {
452
- resultsCache = myData;
453
- resolve(myData);
454
- }, 2000);
455
- });
456
- };
457
- var customUpdateList = function customUpdateList(items) {
458
- if (listUpdated) {
459
- return Promise.resolve();
460
- }
461
- return new Promise(function (resolve) {
462
- list.clear(componentMap);
463
- busyIndicator.style.setProperty('display', 'none');
464
- var markup = '\n <div class="mdw-list__text">\n <div class="mdw-list__text-line"></div>\n <div class="mdw-list__text-line"></div>\n </div>\n '.trim();
465
- items.forEach(function (item) {
466
- var listItem = document.createElement('li');
467
- listItem.classList.add('mdw-list__item');
468
- listItem.innerHTML = markup;
469
- var lines = listItem.querySelectorAll('.mdw-list__text-line');
470
- lines[0].textContent = item.line1;
471
- lines[1].textContent = item.line2;
472
- componentMap.set(listItem, new _index.ListItem(listItem));
473
- list.element.appendChild(listItem);
474
- });
475
- listUpdated = true;
476
- resolve();
477
- });
478
- };
479
-
480
- var searchDocsCustom = new _index3.Search({
481
- textfield: textfield,
482
- list: list,
483
- searchOnFocus: false,
484
- dropdown: true,
485
- textFilter: 'startsWith',
486
- suggestionMethod: 'append',
487
- performSearch: customPerformSearch,
488
- updateList: customUpdateList
489
- });
490
- }
491
-
492
- /** @return {void} */
493
- function buildCustomSearch2() {
494
- /**
495
- * @param {HTMLElement} element
496
- * @return {Promise}
497
- */
498
- function hideElement(element) {
499
- return new Promise(function (resolve) {
500
- element.style.setProperty('display', 'none');
501
- resolve();
502
- });
503
- }
504
- /**
505
- * @param {HTMLElement} element
506
- * @return {Promise}
507
- */
508
- function showElement(element) {
509
- return new Promise(function (resolve) {
510
- element.style.setProperty('display', '');
511
- resolve();
512
- });
513
- }
514
- var textfield = componentMap.get(document.getElementById('search-textfield-custom2'));
515
- var list = componentMap.get(document.getElementById('search-list-custom2'));
516
- var busyIndicator = textfield.element.querySelector('.custom-busy-indicator');
517
- var noResultsIndicator = textfield.element.querySelector('.custom-no-results-indicator');
518
- var customPerformSearch = function customPerformSearch(searchTerm) {
519
- /**
520
- * @return {Promise}
521
- */
522
- function clearList() {
523
- return new Promise(function (resolve) {
524
- list.clear(componentMap);
525
- resolve();
526
- });
527
- }
528
- /**
529
- * @param {string} searchTerm
530
- * @return {Promise}
531
- */
532
- function performSearch(searchTerm) {
533
- return new Promise(function (resolve) {
534
- var myData = [];
535
- for (var key in window.navigator) {
536
- var value = navigator[key] && navigator[key].toString();
537
- if (key.indexOf(searchTerm) !== -1 || value && value.indexOf(searchTerm) !== -1) {
538
- myData.push({ line1: key, line2: navigator[key] });
539
- }
540
- }
541
- setTimeout(function () {
542
- resolve(myData);
543
- }, 1000);
544
- });
545
- }
546
- return clearList().then(function () {
547
- return showElement(busyIndicator);
548
- }).then(function () {
549
- return hideElement(noResultsIndicator);
550
- }).then(function () {
551
- return performSearch(searchTerm);
552
- }).catch(function (error) {
553
- console.error(error);
554
- });
555
- };
556
- var customUpdateList = function customUpdateList(items) {
557
- return hideElement(busyIndicator).then(function () {
558
- if (!items.length) {
559
- return showElement(noResultsIndicator);
560
- }
561
- var markup = '\n <div class="mdw-list__text">\n <div class="mdw-list__text-line"></div>\n <div class="mdw-list__text-line"></div>\n </div>\n '.trim();
562
- items.forEach(function (item) {
563
- var listItem = document.createElement('li');
564
- listItem.classList.add('mdw-list__item');
565
- listItem.innerHTML = markup;
566
- var lines = listItem.querySelectorAll('.mdw-list__text-line');
567
- lines[0].textContent = item.line1;
568
- lines[1].textContent = item.line2;
569
- componentMap.set(listItem, new _index.ListItem(listItem));
570
- list.element.appendChild(listItem);
571
- });
572
- return Promise.resolve();
573
- });
574
- };
575
- var searchDocsCustom = new _index3.Search({
576
- textfield: textfield,
577
- list: list,
578
- debounce: 300,
579
- dropdown: true,
580
- filterItems: false,
581
- performSearch: customPerformSearch,
582
- updateList: customUpdateList
583
- });
584
- }
585
-
586
- /** @return {void} */
587
- function setupSearches() {
588
- var searchDocsSimple = new _index3.Search({
589
- textfield: componentMap.get(document.getElementById('search-textfield-simple')),
590
- list: componentMap.get(document.getElementById('search-list-simple'))
591
- });
592
- var searchDocsMultiline = new _index3.Search({
593
- textfield: componentMap.get(document.getElementById('search-textfield-multiline')),
594
- list: componentMap.get(document.getElementById('search-list-multiline')),
595
- suggestionMethod: 'none'
596
- });
597
-
598
- buildCustomSearch1();
599
- buildCustomSearch2();
600
- }
601
-
602
- /** @return {void} */
603
- function initializeMdwComponents() {
604
- var components = void 0;
605
-
606
- components = document.querySelectorAll('.js .mdw-textfield');
607
- for (var i = 0; i < components.length; i += 1) {
608
- componentMap.set(components[i], new _index2.TextField(components[i]));
609
- }
610
-
611
- components = document.querySelectorAll('.js .mdw-list');
612
- for (var _i = 0; _i < components.length; _i += 1) {
613
- componentMap.set(components[_i], new _index.List(components[_i]));
614
- }
615
-
616
- components = document.querySelectorAll('.js .mdw-list__item');
617
- for (var _i2 = 0; _i2 < components.length; _i2 += 1) {
618
- componentMap.set(components[_i2], new _index.ListItem(components[_i2]));
619
- }
620
- }
621
-
622
- initializeMdwComponents();
623
- setupSearches();
624
-
625
- /***/ }),
626
-
627
- /***/ 59:
628
- /***/ (function(module, exports, __webpack_require__) {
629
-
630
- "use strict";
631
-
632
-
633
- Object.defineProperty(exports, "__esModule", {
634
- value: true
635
- });
636
- exports.Search = undefined;
637
-
638
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
639
-
640
- var _index = __webpack_require__(2);
641
-
642
- var _index2 = __webpack_require__(1);
643
-
644
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
645
-
646
- /**
647
- * @param {Object} options
648
- * @param {string} options.input
649
- * @param {string} options.content
650
- * @return {boolean}
651
- */
652
- function containsTextFilter(options) {
653
- return options.content.trim().toLocaleLowerCase().indexOf(options.input.trim().toLocaleLowerCase()) !== -1;
654
- }
655
-
656
- /**
657
- * @param {Object} options
658
- * @param {string} options.input
659
- * @param {string} options.content
660
- * @return {boolean}
661
- */
662
- function startsWithTextFilter(options) {
663
- return options.content.trim().toLocaleLowerCase().indexOf(options.input.trim().toLocaleLowerCase()) === 0;
664
- }
665
-
666
- /**
667
- * @param {HTMLElement} item
668
- * @return {string}
669
- */
670
- function defaultItemTextParser(item) {
671
- /**
672
- * @param {Node} node
673
- * @return {string}
674
- */
675
- function getTextNodeOnly(node) {
676
- var text = '';
677
- for (var i = 0; i < node.childNodes.length; i += 1) {
678
- var childNode = node.childNodes[i];
679
- if (childNode.nodeType === Node.TEXT_NODE) {
680
- text += childNode.textContent;
681
- }
682
- }
683
- return text;
684
- }
685
- if (item.hasAttribute('data-mdw-search-text')) {
686
- return item.getAttribute('data-mdw-search-text');
687
- }
688
- var textElement = item.querySelector('.mdw-list__text .mdw-list__text-line');
689
- if (!textElement) {
690
- textElement = item.querySelector('.mdw-list__text');
691
- }
692
- if (!textElement) {
693
- textElement = item.querySelector('.mdw-list__text');
694
- }
695
- if (textElement) {
696
- return getTextNodeOnly(textElement);
697
- }
698
- return getTextNodeOnly(item);
699
- }
700
-
701
- /**
702
- * @param {Element} list
703
- * @param {boolean=} backwards
704
- * @return {Element} sibling
705
- */
706
- function selectSibling(list, backwards) {
707
- var current = list.querySelector('.mdw-list__item[selected]');
708
- var items = list.querySelectorAll('.mdw-list__item:not([hidden]):not([disabled])');
709
- var sibling = void 0;
710
- if (current && !current.hasAttribute('hidden')) {
711
- for (var i = 0; i < items.length; i += 1) {
712
- var item = items[i];
713
- if (item === current) {
714
- if (backwards) {
715
- sibling = items[i - 1];
716
- } else {
717
- sibling = items[i + 1];
718
- }
719
- break;
720
- }
721
- }
722
- } else if (backwards) {
723
- sibling = items[items.length - 1];
724
- } else {
725
- sibling = items[0];
726
- }
727
- if (sibling && sibling !== current) {
728
- if (current) {
729
- current.removeAttribute('selected');
730
- }
731
- sibling.setAttribute('selected', '');
732
- return sibling;
733
- }
734
- return null;
735
- }
736
-
737
- /**
738
- * @param {HTMLElement} listItem
739
- * @return {void}
740
- */
741
- function scrollItemIntoView(listItem) {
742
- /**
743
- * @param {HTMLElement} el
744
- * @return {number}
745
- */
746
- function getElementVisibility(el) {
747
- var rect = el.getBoundingClientRect();
748
- var _rect = rect,
749
- top = _rect.top,
750
- height = _rect.height;
751
-
752
- var next = el.parentElement;
753
- do {
754
- rect = next.getBoundingClientRect();
755
- if (top + height > rect.bottom) {
756
- // bottom clipped
757
- return 1;
758
- }
759
- if (top < rect.top) {
760
- // top clipped
761
- return -1;
762
- }
763
- next = next.parentElement;
764
- } while (next !== document.body);
765
- if (top < 0) {
766
- return -1;
767
- } else if (top + height > document.documentElement.clientHeight) {
768
- return 1;
769
- }
770
- return 0;
771
- }
772
- var visibility = getElementVisibility(listItem);
773
- if (visibility < 0) {
774
- listItem.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });
775
- } else if (visibility > 0) {
776
- listItem.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });
777
- }
778
- }
779
-
780
- var Search = function () {
781
- /**
782
- * @param {Object} options
783
- * @param {TextField} options.textfield
784
- * @param {List} options.list
785
- * @param {('contains'|'startsWith'|function({input:string, content:string}):boolean)=} [options.textFilter='contains']
786
- * @param {(function(HTMLElement):string)=} options.itemTextParser
787
- * @param {boolean=} [options.dropdown=false]
788
- * @param {boolean=} [options.filterItems=true]
789
- * @param {('replace'|'append'|'none')} [options.suggestionMethod='replace']
790
- * @param {(function(HTMLElement))=} options.onItemActivated
791
- * @param {(function(string):Promise)=} options.performSearch
792
- * @param {(function(any):Promise)=} options.updateList
793
- * @param {boolean=} [options.searchOnFocus=true]
794
- * @param {number=} options.debounce Debounce time in milliseconds
795
- */
796
- function Search(options) {
797
- var _this = this;
798
-
799
- _classCallCheck(this, Search);
800
-
801
- this.textfield = options.textfield;
802
- this.list = options.list;
803
- if (typeof options.textFilter === 'function') {
804
- this.filter = options.textFilter;
805
- } else if (options.textFilter === 'startsWith') {
806
- this.filter = startsWithTextFilter;
807
- } else {
808
- this.filter = containsTextFilter;
809
- }
810
- this.itemTextParser = defaultItemTextParser || options.itemTextParser;
811
-
812
- this.list.element.addEventListener('click', function (event) {
813
- _this.handleClickEvent(event);
814
- });
815
- this.textfield.input.addEventListener('keydown', function (event) {
816
- _this.onTextFieldKeydownEvent(event);
817
- });
818
- this.textfield.input.addEventListener('input', function (event) {
819
- if (_this.handleInputEvent) {
820
- _this.handleInputEvent(event);
821
- }
822
- });
823
- this.textfield.input.addEventListener('blur', function (event) {
824
- if (_this.handleBlurEvent) {
825
- _this.handleBlurEvent(event);
826
- }
827
- });
828
- this.textfield.input.addEventListener('focus', function (event) {
829
- if (_this.searchOnFocus) {
830
- _this.handleInputEvent(event);
831
- }
832
- });
833
-
834
- this.dropdown = options.dropdown;
835
- if (options.filterItems !== false) {
836
- this.filterItems = true;
837
- }
838
- if (options.searchOnFocus !== false) {
839
- this.searchOnFocus = true;
840
- }
841
- this.debounce = options.debounce;
842
- this.suggestionMethod = options.suggestionMethod || 'replace';
843
- this.currentSearchTerm = this.textfield.input.value || '';
844
- /** @type {string} */
845
- this.suggestedInput = null;
846
- /** @type {string} */
847
- this.previousValue = null;
848
- if (options.onItemActivated) {
849
- this.onItemActivated = options.onItemActivated;
850
- }
851
- this.performSearch = options.performSearch || function () {
852
- return Promise.resolve();
853
- };
854
- this.updateList = options.updateList || function () {
855
- return Promise.resolve();
856
- };
857
- }
858
-
859
- /**
860
- * @param {MouseEvent} event
861
- * @return {void}
862
- */
863
-
864
-
865
- _createClass(Search, [{
866
- key: 'handleClickEvent',
867
- value: function handleClickEvent(event) {
868
- if (!event.target) {
869
- return;
870
- }
871
- if (!event.target.classList) {
872
- return;
873
- }
874
- if (!event.target.classList.contains('mdw-list__item')) {
875
- return;
876
- }
877
- this.onItemActivated(event.target);
878
- }
879
-
880
- /**
881
- * Default input handler
882
- * @param {Event|InputEvent} event
883
- * @return {void}
884
- */
885
-
886
- }, {
887
- key: 'handleInputEvent',
888
- value: function handleInputEvent(event) {
889
- var _this2 = this;
890
-
891
- if (document.activeElement !== this.textfield.input) {
892
- return;
893
- }
894
- this.showDropDown();
895
- var inputValue = this.textfield.input.value || '';
896
- if (inputValue === this.suggestedInput) {
897
- return;
898
- }
899
- if (inputValue === this.previousValue) {
900
- return;
901
- }
902
- this.previousValue = inputValue;
903
- this.currentSearchTerm = inputValue;
904
- var results = null;
905
- Promise.resolve().then(function () {
906
- return _this2.performDebounce(inputValue);
907
- }).then(function () {
908
- return _this2.checkExpired(inputValue);
909
- }).then(function () {
910
- return _this2.performSearch(inputValue);
911
- }).then(function (searchResults) {
912
- results = searchResults;
913
- }).then(function () {
914
- return _this2.checkExpired(inputValue);
915
- }).then(function () {
916
- return _this2.updateList(results);
917
- }).then(function () {
918
- return _this2.filterListItems();
919
- }).catch(function (error) {
920
- if (error.message === 'debounced') {
921
- return;
922
- }
923
- if (error.message === 'expired') {
924
- return;
925
- }
926
- throw error;
927
- });
928
- }
929
- }, {
930
- key: 'checkExpired',
931
- value: function checkExpired(inputValue) {
932
- var _this3 = this;
933
-
934
- return new Promise(function (resolve, reject) {
935
- if (inputValue === _this3.currentSearchTerm) {
936
- resolve();
937
- } else {
938
- reject(new Error('expired'));
939
- }
940
- });
941
- }
942
-
943
- /**
944
- * @param {string} searchTerm
945
- * @return {Promise}
946
- */
947
-
948
- }, {
949
- key: 'performDebounce',
950
- value: function performDebounce(searchTerm) {
951
- var _this4 = this;
952
-
953
- if (!this.debounce) {
954
- return Promise.resolve();
955
- }
956
- return new Promise(function (resolve, reject) {
957
- setTimeout(function () {
958
- if (searchTerm !== _this4.currentSearchTerm) {
959
- reject(new Error('debounced'));
960
- return;
961
- }
962
- resolve();
963
- }, _this4.debounce);
964
- });
965
- }
966
-
967
- /** @return {boolean} handled */
968
-
969
- }, {
970
- key: 'showDropDown',
971
- value: function showDropDown() {
972
- if (!this.dropdown) {
973
- return false;
974
- }
975
- var dropDownElement = this.textfield.element.querySelector('.mdw-textfield__dropdown');
976
- var changed = false;
977
- if (dropDownElement.hasAttribute('mdw-hide')) {
978
- dropDownElement.removeAttribute('mdw-hide');
979
- changed = true;
980
- }
981
- if (!dropDownElement.hasAttribute('mdw-show')) {
982
- dropDownElement.setAttribute('mdw-show', '');
983
- changed = true;
984
- }
985
- return changed;
986
- }
987
-
988
- /** @return {boolean} handled */
989
-
990
- }, {
991
- key: 'isDropDownShown',
992
- value: function isDropDownShown() {
993
- if (!this.dropdown) {
994
- return true;
995
- }
996
- var dropDownElement = this.textfield.element.querySelector('.mdw-textfield__dropdown');
997
- if (dropDownElement.hasAttribute('mdw-hide')) {
998
- return false;
999
- }
1000
- if (this.textfield.input === document.activeElement) {
1001
- return true;
1002
- }
1003
- if (dropDownElement.hasAttribute('mdw-show')) {
1004
- return true;
1005
- }
1006
- return false;
1007
- }
1008
-
1009
- /** @return {boolean} handled */
1010
-
1011
- }, {
1012
- key: 'hideDropDown',
1013
- value: function hideDropDown() {
1014
- if (!this.dropdown) {
1015
- return true;
1016
- }
1017
- var dropDownElement = this.textfield.element.querySelector('.mdw-textfield__dropdown');
1018
- if (!dropDownElement.hasAttribute('mdw-hide')) {
1019
- dropDownElement.setAttribute('mdw-hide', '');
1020
- return true;
1021
- }
1022
- return false;
1023
- }
1024
-
1025
- /**
1026
- * @param {Event|FocusEvent} event
1027
- * @return {void}
1028
- */
1029
-
1030
- }, {
1031
- key: 'handleBlurEvent',
1032
- value: function handleBlurEvent(event) {
1033
- if (this.dropdown) {
1034
- var dropDownElement = this.textfield.element.querySelector('.mdw-textfield__dropdown');
1035
- if (dropDownElement.hasAttribute('mdw-show')) {
1036
- dropDownElement.removeAttribute('mdw-show');
1037
- }
1038
- }
1039
- }
1040
-
1041
- /**
1042
- * @param {HTMLElement} item
1043
- * @return {void}
1044
- */
1045
-
1046
- }, {
1047
- key: 'onItemSelected',
1048
- value: function onItemSelected(item) {
1049
- if (this.suggestionMethod === 'none') {
1050
- return;
1051
- }
1052
- var suggestion = this.itemTextParser(item);
1053
- if (suggestion) {
1054
- suggestion = suggestion.trim();
1055
- }
1056
- if (!suggestion) {
1057
- return;
1058
- }
1059
- this.suggestedInput = suggestion;
1060
- if (this.suggestionMethod === 'replace') {
1061
- this.textfield.input.value = suggestion;
1062
- } else if (this.suggestionMethod === 'append') {
1063
- var selectionStart = (this.previousValue || '').length;
1064
- var selectionEnd = suggestion.length;
1065
- this.textfield.input.value = suggestion;
1066
- this.textfield.input.setSelectionRange(selectionStart, selectionEnd);
1067
- }
1068
- }
1069
-
1070
- /**
1071
- * @param {HTMLElement} item
1072
- * @return {void}
1073
- */
1074
-
1075
- }, {
1076
- key: 'onItemActivated',
1077
- value: function onItemActivated(item) {}
1078
- // Override me
1079
-
1080
-
1081
- /**
1082
- * @param {(function({input:string, content:string}):boolean)=} fnFilter
1083
- * @return {void}
1084
- */
1085
-
1086
- }, {
1087
- key: 'filterListItems',
1088
- value: function filterListItems(fnFilter) {
1089
- if (!this.filterItems) {
1090
- return;
1091
- }
1092
- var input = this.textfield.input.value;
1093
- var current = this.list.element.querySelector('.mdw-list__item[selected]');
1094
- var items = this.list.element.querySelectorAll('.mdw-list__item');
1095
- var hasItem = false;
1096
- for (var i = 0; i < items.length; i += 1) {
1097
- var item = items[i];
1098
- var content = this.itemTextParser(item);
1099
- var fn = fnFilter || this.filter;
1100
- if (fn({ input: input, content: content })) {
1101
- hasItem = true;
1102
- item.removeAttribute('hidden');
1103
- } else {
1104
- item.setAttribute('hidden', '');
1105
- }
1106
- }
1107
- if (current && current.hasAttribute('hidden')) {
1108
- var newSelection = selectSibling(this.list.element);
1109
- if (newSelection) {
1110
- this.onItemSelected(newSelection);
1111
- }
1112
- }
1113
- if (!hasItem) {
1114
- this.hideDropDown();
1115
- }
1116
- }
1117
-
1118
- /**
1119
- * @param {KeyboardEvent} event
1120
- * @return {void}
1121
- */
1122
-
1123
- }, {
1124
- key: 'onTextFieldKeydownEvent',
1125
- value: function onTextFieldKeydownEvent(event) {
1126
- if (event.defaultPrevented) {
1127
- return;
1128
- }
1129
- if (event.ctrlKey || event.altKey || event.shiftKey) {
1130
- return;
1131
- }
1132
- switch (event.key) {
1133
- case 'ArrowUp':
1134
- {
1135
- if (this.isDropDownShown()) {
1136
- var sibling = selectSibling(this.list.element, true);
1137
- if (sibling) {
1138
- scrollItemIntoView(sibling);
1139
- this.onItemSelected(sibling);
1140
- }
1141
- }
1142
- event.stopPropagation();
1143
- event.preventDefault();
1144
- break;
1145
- }
1146
- case 'ArrowDown':
1147
- {
1148
- if (this.isDropDownShown()) {
1149
- var _sibling = selectSibling(this.list.element, false);
1150
- if (_sibling) {
1151
- scrollItemIntoView(_sibling);
1152
- this.onItemSelected(_sibling);
1153
- }
1154
- }
1155
- event.stopPropagation();
1156
- event.preventDefault();
1157
- break;
1158
- }
1159
- case 'Escape':
1160
- {
1161
- if (this.hideDropDown()) {
1162
- this.suggestedInput = this.previousValue;
1163
- this.textfield.input.value = this.previousValue;
1164
- event.stopPropagation();
1165
- event.preventDefault();
1166
- }
1167
- break;
1168
- }
1169
- case 'Enter':
1170
- {
1171
- var current = this.list.element.querySelector('.mdw-list__item[selected]');
1172
- if (current) {
1173
- if (this.hideDropDown()) {
1174
- var inputValue = this.textfield.input.value || '';
1175
- this.textfield.input.setSelectionRange(inputValue.length, inputValue.length);
1176
- this.onItemActivated(current);
1177
- event.stopPropagation();
1178
- event.preventDefault();
1179
- }
1180
- }
1181
- break;
1182
- }
1183
- default:
1184
- }
1185
- }
1186
- }]);
1187
-
1188
- return Search;
1189
- }();
1190
-
1191
- exports.Search = Search;
1192
-
1193
- /***/ }),
1194
-
1195
- /***/ 60:
1196
- /***/ (function(module, exports) {
1197
-
1198
- // removed by extract-text-webpack-plugin
1199
-
1200
- /***/ })
1201
-
1202
- /******/ });