@nanoporetech-digital/components 2.6.0 → 2.9.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 (249) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/cjs/form-control-d54a847f.js +85 -0
  3. package/dist/cjs/form-control-d54a847f.js.map +1 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/nano-checkbox-group.cjs.entry.js +1 -1
  6. package/dist/cjs/nano-checkbox-group.cjs.entry.js.map +1 -1
  7. package/dist/cjs/nano-checkbox.cjs.entry.js +1 -1
  8. package/dist/cjs/nano-components.cjs.js +1 -1
  9. package/dist/cjs/nano-datalist_3.cjs.entry.js +4 -3
  10. package/dist/cjs/nano-datalist_3.cjs.entry.js.map +1 -1
  11. package/dist/cjs/nano-date-input.cjs.entry.js +1 -1
  12. package/dist/cjs/nano-date-input.cjs.entry.js.map +1 -1
  13. package/dist/cjs/nano-dropdown.cjs.entry.js +1 -1
  14. package/dist/cjs/nano-file-upload.cjs.entry.js +1 -1
  15. package/dist/cjs/nano-file-upload.cjs.entry.js.map +1 -1
  16. package/dist/cjs/nano-global-nav.cjs.entry.js +50 -47
  17. package/dist/cjs/nano-global-nav.cjs.entry.js.map +1 -1
  18. package/dist/cjs/nano-input.cjs.entry.js +14 -10
  19. package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
  20. package/dist/cjs/nano-nav-item_2.cjs.entry.js +16 -14
  21. package/dist/cjs/nano-nav-item_2.cjs.entry.js.map +1 -1
  22. package/dist/cjs/nano-resize-observe_2.cjs.entry.js +6 -4
  23. package/dist/cjs/nano-resize-observe_2.cjs.entry.js.map +1 -1
  24. package/dist/cjs/nano-tooltip.cjs.entry.js +1 -1
  25. package/dist/cjs/{popover-8c86d338.js → popover-5f152a19.js} +3 -8
  26. package/dist/cjs/{popover-8c86d338.js.map → popover-5f152a19.js.map} +1 -1
  27. package/dist/collection/components/accordion/accordion.js +1 -1
  28. package/dist/collection/components/alert/alert.js +1 -1
  29. package/dist/collection/components/algolia/algolia-filter.js +2 -2
  30. package/dist/collection/components/algolia/algolia-input.js +5 -5
  31. package/dist/collection/components/algolia/algolia-results.js +1 -1
  32. package/dist/collection/components/algolia/algolia.js +6 -6
  33. package/dist/collection/components/checkbox/checkbox-group.css +4 -1
  34. package/dist/collection/components/checkbox/checkbox-group.js +2 -2
  35. package/dist/collection/components/checkbox/checkbox.css +2 -2
  36. package/dist/collection/components/checkbox/checkbox.js +3 -3
  37. package/dist/collection/components/datalist/datalist.js +4 -2
  38. package/dist/collection/components/datalist/datalist.js.map +1 -1
  39. package/dist/collection/components/date-input/date-input.css +1 -0
  40. package/dist/collection/components/date-input/date-input.js +7 -7
  41. package/dist/collection/components/date-picker/date-picker.js +5 -5
  42. package/dist/collection/components/details/details.js +1 -1
  43. package/dist/collection/components/dialog/dialog.js +1 -1
  44. package/dist/collection/components/dropdown/dropdown.js +1 -1
  45. package/dist/collection/components/file-upload/file-upload.css +2 -2
  46. package/dist/collection/components/file-upload/file-upload.js +4 -4
  47. package/dist/collection/components/form-control/form-control.js +37 -32
  48. package/dist/collection/components/form-control/form-control.js.map +1 -1
  49. package/dist/collection/components/global-nav/global-nav.js +78 -50
  50. package/dist/collection/components/global-nav/global-nav.js.map +1 -1
  51. package/dist/collection/components/grid/grid-item.js +1 -1
  52. package/dist/collection/components/icon/icon.js +1 -1
  53. package/dist/collection/components/input/input.css +251 -258
  54. package/dist/collection/components/input/input.js +21 -14
  55. package/dist/collection/components/input/input.js.map +1 -1
  56. package/dist/collection/components/menu/menu.js +1 -2
  57. package/dist/collection/components/menu/menu.js.map +1 -1
  58. package/dist/collection/components/nav-item/nav-item.js +4 -4
  59. package/dist/collection/components/range/range.js +4 -4
  60. package/dist/collection/components/resize-observe/resize-observe.js +7 -6
  61. package/dist/collection/components/resize-observe/resize-observe.js.map +1 -1
  62. package/dist/collection/components/select/select.css +277 -274
  63. package/dist/collection/components/select/select.js +25 -21
  64. package/dist/collection/components/select/select.js.map +1 -1
  65. package/dist/collection/components/slides/slides.js +7 -7
  66. package/dist/collection/components/tabs/tab-group.js +2 -2
  67. package/dist/collection/utils/popover.js +2 -7
  68. package/dist/collection/utils/popover.js.map +1 -1
  69. package/dist/components/datalist.js +3 -1
  70. package/dist/components/datalist.js.map +1 -1
  71. package/dist/components/form-control.js +37 -32
  72. package/dist/components/form-control.js.map +1 -1
  73. package/dist/components/input.js +15 -10
  74. package/dist/components/input.js.map +1 -1
  75. package/dist/components/menu.js +1 -2
  76. package/dist/components/menu.js.map +1 -1
  77. package/dist/components/nano-checkbox-group.js +1 -1
  78. package/dist/components/nano-checkbox-group.js.map +1 -1
  79. package/dist/components/nano-checkbox.js +1 -1
  80. package/dist/components/nano-date-input.js +1 -1
  81. package/dist/components/nano-date-input.js.map +1 -1
  82. package/dist/components/nano-file-upload.js +1 -1
  83. package/dist/components/nano-file-upload.js.map +1 -1
  84. package/dist/components/nano-global-nav.js +51 -47
  85. package/dist/components/nano-global-nav.js.map +1 -1
  86. package/dist/components/popover.js +2 -7
  87. package/dist/components/popover.js.map +1 -1
  88. package/dist/components/resize-observe.js +6 -4
  89. package/dist/components/resize-observe.js.map +1 -1
  90. package/dist/components/select.js +16 -13
  91. package/dist/components/select.js.map +1 -1
  92. package/dist/custom-elements/index.js +134 -122
  93. package/dist/custom-elements/index.js.map +1 -1
  94. package/dist/esm/form-control-cf23c6a2.js +82 -0
  95. package/dist/esm/form-control-cf23c6a2.js.map +1 -0
  96. package/dist/esm/loader.js +1 -1
  97. package/dist/esm/nano-checkbox-group.entry.js +1 -1
  98. package/dist/esm/nano-checkbox-group.entry.js.map +1 -1
  99. package/dist/esm/nano-checkbox.entry.js +1 -1
  100. package/dist/esm/nano-components.js +1 -1
  101. package/dist/esm/nano-datalist_3.entry.js +4 -3
  102. package/dist/esm/nano-datalist_3.entry.js.map +1 -1
  103. package/dist/esm/nano-date-input.entry.js +1 -1
  104. package/dist/esm/nano-date-input.entry.js.map +1 -1
  105. package/dist/esm/nano-dropdown.entry.js +1 -1
  106. package/dist/esm/nano-file-upload.entry.js +1 -1
  107. package/dist/esm/nano-file-upload.entry.js.map +1 -1
  108. package/dist/esm/nano-global-nav.entry.js +50 -47
  109. package/dist/esm/nano-global-nav.entry.js.map +1 -1
  110. package/dist/esm/nano-input.entry.js +14 -10
  111. package/dist/esm/nano-input.entry.js.map +1 -1
  112. package/dist/esm/nano-nav-item_2.entry.js +16 -14
  113. package/dist/esm/nano-nav-item_2.entry.js.map +1 -1
  114. package/dist/esm/nano-resize-observe_2.entry.js +6 -4
  115. package/dist/esm/nano-resize-observe_2.entry.js.map +1 -1
  116. package/dist/esm/nano-tooltip.entry.js +1 -1
  117. package/dist/esm/{popover-7639005b.js → popover-a03563f3.js} +3 -8
  118. package/dist/esm/{popover-7639005b.js.map → popover-a03563f3.js.map} +1 -1
  119. package/dist/esm-es5/form-control-cf23c6a2.js +5 -0
  120. package/dist/esm-es5/form-control-cf23c6a2.js.map +1 -0
  121. package/dist/esm-es5/loader.js +1 -1
  122. package/dist/esm-es5/loader.js.map +1 -1
  123. package/dist/esm-es5/nano-checkbox-group.entry.js +1 -1
  124. package/dist/esm-es5/nano-checkbox-group.entry.js.map +1 -1
  125. package/dist/esm-es5/nano-checkbox.entry.js +1 -1
  126. package/dist/esm-es5/nano-components.js +1 -1
  127. package/dist/esm-es5/nano-components.js.map +1 -1
  128. package/dist/esm-es5/nano-datalist_3.entry.js +1 -1
  129. package/dist/esm-es5/nano-datalist_3.entry.js.map +1 -1
  130. package/dist/esm-es5/nano-date-input.entry.js +1 -1
  131. package/dist/esm-es5/nano-date-input.entry.js.map +1 -1
  132. package/dist/esm-es5/nano-dropdown.entry.js +1 -1
  133. package/dist/esm-es5/nano-file-upload.entry.js +1 -1
  134. package/dist/esm-es5/nano-file-upload.entry.js.map +1 -1
  135. package/dist/esm-es5/nano-global-nav.entry.js +1 -1
  136. package/dist/esm-es5/nano-global-nav.entry.js.map +1 -1
  137. package/dist/esm-es5/nano-input.entry.js +2 -2
  138. package/dist/esm-es5/nano-input.entry.js.map +1 -1
  139. package/dist/esm-es5/nano-nav-item_2.entry.js +1 -1
  140. package/dist/esm-es5/nano-nav-item_2.entry.js.map +1 -1
  141. package/dist/esm-es5/nano-resize-observe_2.entry.js +2 -2
  142. package/dist/esm-es5/nano-resize-observe_2.entry.js.map +1 -1
  143. package/dist/esm-es5/nano-tooltip.entry.js +1 -1
  144. package/dist/esm-es5/{popover-7639005b.js → popover-a03563f3.js} +2 -2
  145. package/dist/esm-es5/popover-a03563f3.js.map +1 -0
  146. package/dist/nano-components/nano-components.esm.js +1 -1
  147. package/dist/nano-components/nano-components.esm.js.map +1 -1
  148. package/dist/nano-components/p-096682d9.system.js +1 -1
  149. package/dist/nano-components/p-096682d9.system.js.map +1 -1
  150. package/dist/nano-components/{p-820d9e23.system.entry.js → p-09e38c5f.system.entry.js} +2 -2
  151. package/dist/nano-components/p-09e38c5f.system.entry.js.map +1 -0
  152. package/dist/nano-components/p-10a6216d.system.entry.js +5 -0
  153. package/dist/nano-components/p-10a6216d.system.entry.js.map +1 -0
  154. package/dist/nano-components/p-1ca46443.entry.js +5 -0
  155. package/dist/nano-components/p-1ca46443.entry.js.map +1 -0
  156. package/dist/nano-components/{p-e7fdc62d.entry.js → p-1e8321ea.entry.js} +2 -2
  157. package/dist/nano-components/{p-e7fdc62d.entry.js.map → p-1e8321ea.entry.js.map} +0 -0
  158. package/dist/nano-components/{p-f9e30f31.system.entry.js → p-2057d480.system.entry.js} +2 -2
  159. package/dist/nano-components/p-2057d480.system.entry.js.map +1 -0
  160. package/dist/nano-components/{p-9acc4596.system.entry.js → p-2ae4918d.system.entry.js} +3 -3
  161. package/dist/nano-components/{p-9acc4596.system.entry.js.map → p-2ae4918d.system.entry.js.map} +0 -0
  162. package/dist/nano-components/{p-c9d09839.entry.js → p-313970ff.entry.js} +2 -2
  163. package/dist/nano-components/{p-c9d09839.entry.js.map → p-313970ff.entry.js.map} +0 -0
  164. package/dist/nano-components/p-39a5280e.system.entry.js +5 -0
  165. package/dist/nano-components/p-39a5280e.system.entry.js.map +1 -0
  166. package/dist/nano-components/{p-178c34e3.js → p-3de7735c.js} +2 -2
  167. package/dist/nano-components/p-3de7735c.js.map +1 -0
  168. package/dist/nano-components/{p-93448bcd.system.entry.js → p-4265cf95.system.entry.js} +2 -2
  169. package/dist/nano-components/{p-93448bcd.system.entry.js.map → p-4265cf95.system.entry.js.map} +0 -0
  170. package/dist/nano-components/p-44c08842.system.entry.js +5 -0
  171. package/dist/nano-components/p-44c08842.system.entry.js.map +1 -0
  172. package/dist/nano-components/{p-f3bf942d.entry.js → p-457d4893.entry.js} +2 -2
  173. package/dist/nano-components/p-457d4893.entry.js.map +1 -0
  174. package/dist/nano-components/{p-383fda90.system.entry.js → p-4870e76d.system.entry.js} +2 -2
  175. package/dist/nano-components/{p-383fda90.system.entry.js.map → p-4870e76d.system.entry.js.map} +0 -0
  176. package/dist/nano-components/{p-20db18f3.entry.js → p-5a315696.entry.js} +2 -2
  177. package/dist/nano-components/{p-20db18f3.entry.js.map → p-5a315696.entry.js.map} +0 -0
  178. package/dist/nano-components/p-6eb25600.system.js +5 -0
  179. package/dist/nano-components/p-6eb25600.system.js.map +1 -0
  180. package/dist/nano-components/p-6f94d755.entry.js +5 -0
  181. package/dist/nano-components/p-6f94d755.entry.js.map +1 -0
  182. package/dist/nano-components/p-802e1416.system.entry.js +5 -0
  183. package/dist/nano-components/{p-ef4e0912.system.entry.js.map → p-802e1416.system.entry.js.map} +1 -1
  184. package/dist/nano-components/p-84767e87.entry.js +5 -0
  185. package/dist/nano-components/p-84767e87.entry.js.map +1 -0
  186. package/dist/nano-components/p-933c35a6.system.entry.js +5 -0
  187. package/dist/nano-components/p-933c35a6.system.entry.js.map +1 -0
  188. package/dist/nano-components/p-971b40a4.system.entry.js +5 -0
  189. package/dist/nano-components/p-971b40a4.system.entry.js.map +1 -0
  190. package/dist/nano-components/p-9d35768b.entry.js +5 -0
  191. package/dist/nano-components/p-9d35768b.entry.js.map +1 -0
  192. package/dist/nano-components/p-9ea13fbe.entry.js +5 -0
  193. package/dist/nano-components/p-9ea13fbe.entry.js.map +1 -0
  194. package/dist/nano-components/p-a6c84740.js +5 -0
  195. package/dist/nano-components/p-a6c84740.js.map +1 -0
  196. package/dist/nano-components/{p-8de6e276.entry.js → p-b4f8e541.entry.js} +2 -2
  197. package/dist/nano-components/p-b4f8e541.entry.js.map +1 -0
  198. package/dist/nano-components/{p-9745d44e.system.js → p-e43ec257.system.js} +2 -2
  199. package/dist/nano-components/p-e43ec257.system.js.map +1 -0
  200. package/dist/nano-components/p-e7c69d4f.entry.js +5 -0
  201. package/dist/nano-components/{p-d6569144.entry.js.map → p-e7c69d4f.entry.js.map} +1 -1
  202. package/dist/types/components/form-control/form-control.d.ts +2 -0
  203. package/dist/types/components/global-nav/global-nav.d.ts +10 -3
  204. package/dist/types/components/input/input.d.ts +3 -0
  205. package/dist/types/components/resize-observe/resize-observe.d.ts +0 -1
  206. package/dist/types/components/select/select.d.ts +2 -1
  207. package/dist/types/components.d.ts +11 -3
  208. package/docs-json.json +51 -17
  209. package/docs-vscode.json +6 -2
  210. package/package.json +4 -3
  211. package/dist/cjs/form-control-3bc82e3e.js +0 -80
  212. package/dist/cjs/form-control-3bc82e3e.js.map +0 -1
  213. package/dist/esm/form-control-67eeb108.js +0 -77
  214. package/dist/esm/form-control-67eeb108.js.map +0 -1
  215. package/dist/esm-es5/form-control-67eeb108.js +0 -5
  216. package/dist/esm-es5/form-control-67eeb108.js.map +0 -1
  217. package/dist/esm-es5/popover-7639005b.js.map +0 -1
  218. package/dist/nano-components/p-0618fac6.system.entry.js +0 -5
  219. package/dist/nano-components/p-0618fac6.system.entry.js.map +0 -1
  220. package/dist/nano-components/p-173bae15.system.entry.js +0 -5
  221. package/dist/nano-components/p-173bae15.system.entry.js.map +0 -1
  222. package/dist/nano-components/p-178c34e3.js.map +0 -1
  223. package/dist/nano-components/p-2559e9c1.entry.js +0 -5
  224. package/dist/nano-components/p-2559e9c1.entry.js.map +0 -1
  225. package/dist/nano-components/p-2be7aab0.system.entry.js +0 -5
  226. package/dist/nano-components/p-2be7aab0.system.entry.js.map +0 -1
  227. package/dist/nano-components/p-2e38a927.entry.js +0 -5
  228. package/dist/nano-components/p-2e38a927.entry.js.map +0 -1
  229. package/dist/nano-components/p-3a13948a.system.entry.js +0 -5
  230. package/dist/nano-components/p-3a13948a.system.entry.js.map +0 -1
  231. package/dist/nano-components/p-4ee978ff.entry.js +0 -5
  232. package/dist/nano-components/p-4ee978ff.entry.js.map +0 -1
  233. package/dist/nano-components/p-5e7c7d3d.entry.js +0 -5
  234. package/dist/nano-components/p-5e7c7d3d.entry.js.map +0 -1
  235. package/dist/nano-components/p-672e5547.js +0 -5
  236. package/dist/nano-components/p-672e5547.js.map +0 -1
  237. package/dist/nano-components/p-820d9e23.system.entry.js.map +0 -1
  238. package/dist/nano-components/p-8de6e276.entry.js.map +0 -1
  239. package/dist/nano-components/p-9745d44e.system.js.map +0 -1
  240. package/dist/nano-components/p-99acaa4f.system.entry.js +0 -5
  241. package/dist/nano-components/p-99acaa4f.system.entry.js.map +0 -1
  242. package/dist/nano-components/p-d4dfa4c5.entry.js +0 -5
  243. package/dist/nano-components/p-d4dfa4c5.entry.js.map +0 -1
  244. package/dist/nano-components/p-d6569144.entry.js +0 -5
  245. package/dist/nano-components/p-ea5eb591.system.js +0 -5
  246. package/dist/nano-components/p-ea5eb591.system.js.map +0 -1
  247. package/dist/nano-components/p-ef4e0912.system.entry.js +0 -5
  248. package/dist/nano-components/p-f3bf942d.entry.js.map +0 -1
  249. package/dist/nano-components/p-f9e30f31.system.entry.js.map +0 -1
@@ -9,12 +9,14 @@ let inputIds = 0;
9
9
  * The input component is a wrapper to the HTML input element with custom styling and additional functionality. It accepts most of the same properties as the HTML [input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input), but works great on desktop devices and integrates with the keyboard on mobile devices.
10
10
 
11
11
  It is meant for text type inputs only, such as "text", "password", "email", "number", "search", "tel", and "url". It supports all standard text input events including keyup, keydown, keypress, and more.
12
+ The default styling reference comes from the [ONT styleguide](https://nanoporetech.zeroheight.com/styleguide/s/31282/p/230c74-text-input--textarea/b/942ee4)
12
13
  * @slot start - suitable for inline action buttons or icons that may add extra contextual information
13
14
  * @slot end - suitable for inline action buttons or icons that may add extra contextual information
14
15
  * @slot value-start - similar to 'start', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist
15
16
  * @slot value-end - similar to 'end', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist
16
17
  * @slot label - if you do not set a label attribute, you can use this slot for more complex markup
17
18
  * @slot helper - helper text to accompany the form field underneath.
19
+ * @slot helper-end - helper text to accompany the form field on the side.
18
20
  * @slot - can be used with a `nano-datalist`. See the `nano-datalist` docs for more information
19
21
  */
20
22
  export class Input {
@@ -27,6 +29,7 @@ export class Input {
27
29
  this.hasFocus = false;
28
30
  this.hasLabelSlot = false;
29
31
  this.hasHelperSlot = false;
32
+ this.hasHelperEndSlot = false;
30
33
  this.errorMessage = '';
31
34
  this.datalist = null;
32
35
  this._invalid = false;
@@ -131,8 +134,7 @@ export class Input {
131
134
  };
132
135
  this.onInput = (ev) => {
133
136
  const input = ev.target;
134
- if (input)
135
- this.value = input.value || '';
137
+ this.value = (input === null || input === void 0 ? void 0 : input.value) || '';
136
138
  this.nanoInput.emit(ev);
137
139
  };
138
140
  this.onBlur = () => {
@@ -310,6 +312,7 @@ export class Input {
310
312
  // see if we have label / button content
311
313
  this.hasLabelSlot = !!this.el.querySelectorAll('[slot="label"]');
312
314
  this.hasHelperSlot = !!this.el.querySelector('[slot="helper"]');
315
+ this.hasHelperEndSlot = !!this.el.querySelector('[slot="helper-end"]');
313
316
  this.datalist = this.el.querySelector('nano-datalist:not([slot])');
314
317
  // breaking change introduced in v2. Rm in v3
315
318
  if (!!this.el.querySelector('[slot="inline-button"]')) {
@@ -350,8 +353,9 @@ export class Input {
350
353
  const value = this.getValue();
351
354
  const labelId = this.inputId + '-lbl';
352
355
  const moreId = this.showInlineError || this.hasHelperSlot ? this.inputId + '-more' : '';
356
+ const helperEndId = this.hasHelperEndSlot ? this.inputId + '-helper' : '';
353
357
  this.rtl = this.el.ownerDocument.dir === 'rtl';
354
- const compWrapOptions = (({ el, floatLabel, label, errorMessage, type, showInlineError, hasHelperSlot, hasLabelSlot, hideLabel, placeholder, maxlength, charCount, showCharCount, rtl, }) => ({
358
+ const compWrapOptions = (({ el, floatLabel, label, errorMessage, type, showInlineError, hasHelperSlot, hasLabelSlot, hideLabel, placeholder, maxlength, charCount, showCharCount, rtl, hasHelperEndSlot, }) => ({
355
359
  el,
356
360
  floatLabel,
357
361
  label,
@@ -366,9 +370,11 @@ export class Input {
366
370
  charCount,
367
371
  showCharCount,
368
372
  rtl,
373
+ hasHelperEndSlot,
369
374
  }))(this);
370
375
  const wrapOptions = Object.assign(Object.assign({}, compWrapOptions), { labelId,
371
- moreId, hasValue: this.hasValue(), controlId: this.inputId });
376
+ moreId,
377
+ helperEndId, hasValue: this.hasValue(), controlId: this.inputId });
372
378
  const controlOptions = (({ clearInput, readonly, disabled }) => ({
373
379
  clearInput,
374
380
  readonly,
@@ -378,11 +384,11 @@ export class Input {
378
384
  return (h(Host, { "aria-disabled": this.disabled ? 'true' : null, dir: this.rtl ? 'rtl' : null, class: Object.assign(Object.assign({}, createColorClasses(this.color)), { 'has-value': this.hasValue(), 'has-focus': this.hasFocus, 'is-invalid': this._invalid }) },
379
385
  h(FormControlWrap, Object.assign({}, wrapOptions),
380
386
  h(FormControl, Object.assign({}, controlOptions, { onClearText: this.clearTextInput, control: this.el, ref: (el) => (this.nativeInputWrap = el) }),
381
- this.type !== 'textarea' && (h("input", { id: this.inputId, class: "native-input", ref: (input) => (this.nativeInput = input), "aria-labelledby": labelId + ' ' + moreId, disabled: this.disabled, accept: this.accept, autoCapitalize: this.autocapitalise, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, inputMode: this.inputmode, form: this.form, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: !this.floatLabel && this.placeholder ? this.placeholder : '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onChange: this.onInput, onFocus: this.onFocus, onKeyDown: this.onKeydown, onInvalid: this.validate })),
387
+ this.type !== 'textarea' && (h("input", { id: this.inputId, class: "input__native-ctrl", ref: (input) => (this.nativeInput = input), "aria-labelledby": labelId + ' ' + moreId + ' ' + helperEndId, disabled: this.disabled, accept: this.accept, autoCapitalize: this.autocapitalise, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, inputMode: this.inputmode, form: this.form, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder, readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onChange: this.onInput, onFocus: this.onFocus, onKeyDown: this.onKeydown, onInvalid: this.validate })),
382
388
  this.type === 'textarea' && (h("textarea", { rows: this.floatLabel ? 1 : this.rows, id: this.inputId, class: {
383
- 'native-input': true,
384
- resizable: this.resize === 'true',
385
- }, ref: (input) => (this.nativeInput = input), "aria-labelledby": labelId + ' ' + moreId, disabled: this.disabled, autoCapitalize: this.autocapitalise, autoCorrect: this.autocorrect, autoFocus: this.autofocus, inputMode: this.inputmode, form: this.form, minLength: this.minlength, maxLength: this.maxlength, name: this.name, placeholder: !this.floatLabel && this.placeholder ? this.placeholder : '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, value: value, onInput: this.onInput, onChange: this.onInput, onFocus: this.onFocus, onKeyDown: this.onKeydown, onInvalid: this.validate }))),
389
+ 'input__native-ctrl': true,
390
+ input__resizable: this.resize === 'true',
391
+ }, ref: (input) => (this.nativeInput = input), "aria-labelledby": labelId + ' ' + moreId + ' ' + helperEndId, disabled: this.disabled, autoCapitalize: this.autocapitalise, autoCorrect: this.autocorrect, autoFocus: this.autofocus, inputMode: this.inputmode, form: this.form, minLength: this.minlength, maxLength: this.maxlength, name: this.name, placeholder: this.placeholder, readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, value: value, onInput: this.onInput, onChange: this.onInput, onFocus: this.onFocus, onKeyDown: this.onKeydown, onInvalid: this.validate }))),
386
392
  h("slot", null))));
387
393
  }
388
394
  static get is() { return "nano-input"; }
@@ -423,7 +429,7 @@ export class Input {
423
429
  "references": {
424
430
  "Color": {
425
431
  "location": "import",
426
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
432
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
427
433
  }
428
434
  }
429
435
  },
@@ -994,7 +1000,7 @@ export class Input {
994
1000
  "references": {
995
1001
  "TextFieldTypes": {
996
1002
  "location": "import",
997
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
1003
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
998
1004
  }
999
1005
  }
1000
1006
  },
@@ -1007,7 +1013,7 @@ export class Input {
1007
1013
  "getter": false,
1008
1014
  "setter": false,
1009
1015
  "attribute": "type",
1010
- "reflect": false,
1016
+ "reflect": true,
1011
1017
  "defaultValue": "'text'"
1012
1018
  },
1013
1019
  "form": {
@@ -1114,6 +1120,7 @@ export class Input {
1114
1120
  "hasFocus": {},
1115
1121
  "hasLabelSlot": {},
1116
1122
  "hasHelperSlot": {},
1123
+ "hasHelperEndSlot": {},
1117
1124
  "errorMessage": {},
1118
1125
  "datalist": {},
1119
1126
  "_invalid": {}
@@ -1153,7 +1160,7 @@ export class Input {
1153
1160
  "references": {
1154
1161
  "InputChangeEventDetail": {
1155
1162
  "location": "import",
1156
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
1163
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
1157
1164
  }
1158
1165
  }
1159
1166
  }
@@ -1242,7 +1249,7 @@ export class Input {
1242
1249
  "references": {
1243
1250
  "ControlValidityEventDetail": {
1244
1251
  "location": "import",
1245
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
1252
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
1246
1253
  }
1247
1254
  }
1248
1255
  }
@@ -1264,7 +1271,7 @@ export class Input {
1264
1271
  },
1265
1272
  "ControlValidity": {
1266
1273
  "location": "import",
1267
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
1274
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
1268
1275
  }
1269
1276
  },
1270
1277
  "return": "Promise<ControlValidity>"
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EAET,OAAO,EACP,KAAK,EAEL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,CAAC,EACD,MAAM,GACP,MAAM,eAAe,CAAC;AASvB,OAAO,EACL,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,GAAG,GACJ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE5E,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;;;;;;;;;;GAWG;AAMH,MAAM,OAAO,KAAK;EALlB;IAOU,YAAO,GAAG,cAAc,QAAQ,EAAE,EAAE,CAAC;IACrC,qBAAgB,GAAG,KAAK,CAAC;IACzB,QAAG,GAAY,KAAK,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Build,\n Component,\n ComponentInterface,\n Element,\n Event,\n EventEmitter,\n Host,\n Method,\n Prop,\n State,\n Watch,\n h,\n Listen,\n} from '@stencil/core';\n\nimport {\n Color,\n ControlValidity,\n ControlValidityEventDetail,\n InputChangeEventDetail,\n TextFieldTypes,\n} from '../../interface';\nimport {\n debounceEvent,\n closestElement,\n createColorClasses,\n raf,\n} from '../../utils';\nimport { FormControl, FormControlWrap } from '../form-control/form-control';\n\nlet inputIds = 0;\n\n/**\n * The input component is a wrapper to the HTML input element with custom styling and additional functionality. It accepts most of the same properties as the HTML [input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input), but works great on desktop devices and integrates with the keyboard on mobile devices.\n\nIt is meant for text type inputs only, such as \"text\", \"password\", \"email\", \"number\", \"search\", \"tel\", and \"url\". It supports all standard text input events including keyup, keydown, keypress, and more.\n * @slot start - suitable for inline action buttons or icons that may add extra contextual information\n * @slot end - suitable for inline action buttons or icons that may add extra contextual information\n * @slot value-start - similar to 'start', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist\n * @slot value-end - similar to 'end', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist\n * @slot label - if you do not set a label attribute, you can use this slot for more complex markup\n * @slot helper - helper text to accompany the form field underneath.\n * @slot - can be used with a `nano-datalist`. See the `nano-datalist` docs for more information\n */\n@Component({\n tag: 'nano-input',\n styleUrl: 'input.scss',\n scoped: true,\n})\nexport class Input implements ComponentInterface {\n private nativeInput?: HTMLInputElement | HTMLTextAreaElement;\n private inputId = `nano-input-${inputIds++}`;\n private didBlurAfterEdit = false;\n private rtl: boolean = false;\n private mo?: MutationObserver;\n private charCount = 0;\n private hasRendered = false;\n\n // we don't want these rendered eles decorated with @State\n // because that will cause re-renders. User get/set to set datalist options\n private _nativeInputWrap: HTMLElement;\n private get nativeInputWrap() {\n return this._nativeInputWrap;\n }\n private set nativeInputWrap(ele: HTMLElement) {\n if (this._nativeInputWrap === ele) return;\n this._nativeInputWrap = ele;\n this.setDataListOpts();\n }\n\n @State() hasFocus = false;\n @State() hasLabelSlot = false;\n @State() hasHelperSlot = false;\n @State() errorMessage: string = '';\n @State() datalist: HTMLNanoDatalistElement = null;\n\n @Watch('datalist')\n setDataListOpts() {\n if (!this.datalist) return;\n const currDWConfig = this.datalist.dropDownConfig || {};\n this.datalist.dropDownConfig = {\n ...currDWConfig,\n skidding: -1,\n tetherTo: this.nativeInputWrap,\n };\n }\n\n @Element() el!: HTMLNanoInputElement;\n\n /**\n * This will be true when the control is in an invalid state.\n * Validity is determined by the `required` prop. Or if custom validity message is set. @readonly\n */\n @Prop({ reflect: true })\n get invalid() {\n return this._invalid;\n }\n @State() _invalid = false;\n\n /**\n * The color to use from the application's color palette.\n */\n @Prop() color?: Color;\n\n /**\n * If the value of the type attribute is `\"file\"`, then this attribute will indicate the types of files that the server accepts, otherwise it will be ignored. The value must be a comma-separated list of unique content type specifiers.\n */\n @Prop() accept?: string;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalise: 'none' | 'sentences' | 'words' | 'characters' =\n 'none';\n\n /**\n * Indicates whether the value of the control can be automatically completed by the browser.\n */\n @Prop() autocomplete: 'on' | 'off' = 'off';\n\n /**\n * Whether auto correction should be enabled when the user is entering/editing the text value.\n */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, a clear icon will appear in the input when there is a value. Clicking it clears the input.\n */\n @Prop() clearInput = false;\n\n /**\n * If `true`, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `\"password\"`, `false` for all other types.\n */\n @Prop() clearOnEdit?: boolean;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `nanoChange` event after each keystroke.\n */\n @Prop() debounce = 0;\n\n /**\n * If `true`, the user cannot interact with the input.\n */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * A hint to the browser for which keyboard to display.\n * Possible values: `\"none\"`, `\"text\"`, `\"tel\"`, `\"url\"`,\n * `\"email\"`, `\"numeric\"`, `\"decimal\"`, and `\"search\"`.\n */\n @Prop() inputmode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search';\n\n /**\n * When should the field perform validation\n */\n @Prop({ mutable: true }) validateOn: 'dirty' | 'submit' | 'submitThenDirty' =\n 'submit';\n\n /**\n * Whether to show validation errors underneath input\n */\n @Prop({ reflect: true }) showInlineError = true;\n\n /**\n * String to place within a label element. Alternatively you may use a label slot.\n */\n @Prop() label!: string;\n\n /**\n * Visually hide the label - but make it accessible.\n */\n @Prop() hideLabel?: boolean = false;\n\n /**\n * Enable floating label behaviour. Will disable placeholder if set.\n */\n @Prop() floatLabel: boolean = false;\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * If `true`, the user can enter more than one value. This attribute applies when the type attribute is set to `\"email\"` or `\"file\"`, otherwise it is ignored.\n */\n @Prop() multiple?: boolean;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * A regular expression that the value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() pattern?: string;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string | null;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop({ reflect: true }) readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The initial size of the control. This value is in pixels unless the value of the type attribute is `\"text\"` or `\"password\"`, in which case it is an integer number of characters. This attribute applies only when the `type` attribute is set to `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() size?: number;\n\n /**\n * The type of control to display. The default type is text.\n */\n @Prop() type: TextFieldTypes = 'text';\n\n /**\n * The form element to associate the select with (its form owner). Must be the id of a form.\n */\n @Prop() form?: string | null;\n\n /**\n * The value of the input.\n */\n @Prop({ mutable: true }) value?: string | null = '';\n\n /**\n * relevant to type=\"textarea\". Vertical resizing - enable / disable or make automatic.\n */\n @Prop() resize: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * relevant to type=\"textarea\". Default number of rows to show\n */\n @Prop() rows = 2;\n\n /**\n * relevant to type=\"textarea\".\n */\n @Prop() showCharCount = false;\n\n @Watch('minlength')\n @Watch('maxlength')\n @Watch('min')\n @Watch('max')\n @Watch('required')\n @Watch('disabled')\n @Watch('validateOn')\n @Watch('readonly')\n @Watch('pattern')\n @Watch('inputmode')\n protected shouldValidate() {\n if (!this.hasRendered) return;\n setTimeout(() => {\n if (this.validateOn === 'dirty') this.validate();\n }, 20);\n }\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n this.nanoChange.emit({ value: this.value });\n this.charCount = this.value.length;\n\n if (this.type === 'textarea' && this.resize === 'auto') {\n this.nativeInput.style.height = 'auto';\n if (this.value.length)\n this.nativeInput.style.height = this.nativeInput.scrollHeight + 'px';\n }\n\n setTimeout(() => {\n if (this.validateOn === 'dirty') this.validate();\n }, 20);\n }\n\n @Watch('debounce')\n protected debounceChanged() {\n this.nanoChange = debounceEvent(this.nanoChange, this.debounce);\n }\n\n /**\n * Emitted when a keyboard input occurred.\n */\n @Event() nanoInput!: EventEmitter<InputEvent>;\n\n /**\n * Emitted when the value has changed.\n */\n @Event() nanoChange!: EventEmitter<InputChangeEventDetail>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() nanoBlur!: EventEmitter<void>;\n\n /**\n * Emitted when the input has focus.\n */\n @Event() nanoFocus!: EventEmitter<void>;\n\n /**\n * Emitted when the input has been created.\n * @internal\n */\n @Event() nanoDidLoad!: EventEmitter<void>;\n\n /**\n * Emitted when the input has been removed.\n * @internal\n */\n @Event() nanoDidUnload!: EventEmitter<void>;\n\n /**\n * Called when validation is performed (which depends on `validateOn`).\n * @returns event.detail: `{ isValid: boolean, errorMessage: string, originalEvent: Event }`.\n */\n @Event() nanoValidate: EventEmitter<ControlValidityEventDetail>;\n\n /**\n * Get the current state of the control.\n * @param validateFirst - perform validation first before reporting\n * @returns `{ isValid: boolean, errorMessage: string }`\n */\n @Method()\n async reportValidity(validateFirst: boolean): Promise<ControlValidity> {\n if (validateFirst) this.validate();\n return {\n isValid: !this._invalid,\n errorMessage: this.nativeInput.validationMessage,\n };\n }\n\n /**\n * Sets focus on the specified `nano-input`. Use this method instead of the global\n * `input.focus()`.\n */\n @Method()\n async setFocus() {\n if (this.nativeInput) {\n this.nativeInput.focus();\n this.nativeInput.click();\n }\n }\n\n /**\n * Returns the native `<input>` element used under the hood.\n */\n @Method()\n getInputElement(): Promise<HTMLInputElement | HTMLTextAreaElement> {\n return Promise.resolve(this.nativeInput);\n }\n\n /**\n * Invalidate the field and show a custom error message. To clear the error you will need to re-call this method with an empty string.\n */\n @Method()\n async showError(message: string) {\n if (this.nativeInput) {\n this.nativeInput.setCustomValidity(message);\n this.validate();\n }\n }\n\n @Listen('reset', { target: 'body' })\n onReset(e) {\n const form = this.form\n ? document.querySelector('#' + this.form)\n : this.el.closest('form');\n if (!form || e.target !== this.el.closest('form')) return;\n\n this.value = '';\n }\n\n @Listen('mousedown', { target: 'body' })\n @Listen('keydown')\n handleBlur(e: KeyboardEvent | MouseEvent) {\n if (!this.hasFocus) return;\n\n const kev = e as KeyboardEvent;\n let target: Element;\n\n raf(() => {\n if (kev.key) {\n if (kev.key !== 'Tab') return;\n target = document.activeElement;\n } else target = e.target as Element;\n\n if (closestElement(this.el.tagName.toLowerCase(), target) !== this.el) {\n this.onBlur();\n }\n });\n }\n\n private shouldClearOnEdit() {\n const { type, clearOnEdit } = this;\n return clearOnEdit === undefined ? type === 'password' : clearOnEdit;\n }\n\n private getValue(): string {\n return this.value || '';\n }\n\n private validate = (ev?: Event) => {\n if (this.validateOn === 'submitThenDirty') this.validateOn = 'dirty';\n\n if (!this.nativeInput.validity.valid) {\n if (this.showInlineError) {\n if (ev) ev.preventDefault();\n this.errorMessage = this.nativeInput.validationMessage;\n }\n this._invalid = true;\n } else this._invalid = false;\n\n this.nanoValidate.emit({\n isValid: !this._invalid,\n errorMessage: this.nativeInput.validationMessage,\n originalEvent: ev,\n });\n };\n\n private onInput = (ev: InputEvent) => {\n const input = ev.target as HTMLInputElement | null;\n if (input) this.value = input.value || '';\n this.nanoInput.emit(ev);\n };\n\n private onBlur = () => {\n this.hasFocus = false;\n this.focusChanged();\n if (this.validateOn === 'dirty') this.validate();\n this.nanoBlur.emit();\n };\n\n private onFocus = () => {\n this.hasFocus = true;\n this.focusChanged();\n this.nanoFocus.emit();\n };\n\n private onKeydown = () => {\n if (this.shouldClearOnEdit()) {\n // Did the input value change after it was blurred and edited?\n if (this.didBlurAfterEdit && this.hasValue()) {\n // Clear the input\n this.clearTextInput();\n }\n\n // Reset the flag\n this.didBlurAfterEdit = false;\n }\n };\n\n private clearTextInput = (ev?: Event) => {\n if (this.clearInput && !this.readonly && !this.disabled && ev) {\n ev.preventDefault();\n ev.stopPropagation();\n }\n\n this.value = '';\n this.nativeInput.value = '';\n const event = new window.Event('change');\n this.nativeInput.dispatchEvent(event);\n };\n\n private focusChanged() {\n // If clearOnEdit is enabled and the input blurred but has a value, set a flag\n if (!this.hasFocus && this.shouldClearOnEdit() && this.hasValue()) {\n this.didBlurAfterEdit = true;\n }\n }\n\n private hasValue(): boolean {\n return this.getValue().length > 0;\n }\n\n private slotChangeObserver() {\n if (!Build.isBrowser) return;\n\n if (this.mo) this.mo.disconnect();\n const mo = (this.mo = new MutationObserver(() =>\n this.processSlottedContent()\n ));\n mo.observe(this.el, { childList: true, subtree: true });\n }\n\n private processSlottedContent() {\n // see if we have label / button content\n this.hasLabelSlot = !!this.el.querySelectorAll('[slot=\"label\"]');\n this.hasHelperSlot = !!this.el.querySelector('[slot=\"helper\"]');\n this.datalist = this.el.querySelector('nano-datalist:not([slot])');\n\n // breaking change introduced in v2. Rm in v3\n if (!!this.el.querySelector('[slot=\"inline-button\"]')) {\n console.warn(\n 'The `inline-button` slot was renamed to `end` in v2 - please update your code',\n this.el\n );\n }\n\n // breaking change introduced in v2. Rm in v3\n if (!!this.el.querySelector('[slot=\"legacy\"]')) {\n console.warn(\n 'The `legacy` slot has been removed. Please update your code',\n this.el\n );\n }\n }\n\n connectedCallback() {\n this.debounceChanged();\n if (Build.isBrowser) {\n this.el.dispatchEvent(\n new CustomEvent('nanoDidLoad', {\n detail: this.el,\n })\n );\n }\n }\n\n disconnectedCallback() {\n if (Build.isBrowser) {\n document.dispatchEvent(\n new CustomEvent('nanoDidUnload', {\n detail: this.el,\n })\n );\n }\n if (this.mo) this.mo.disconnect();\n }\n\n componentDidLoad() {\n this.slotChangeObserver();\n this.hasRendered = true;\n if (this.autofocus) setTimeout((_) => this.setFocus(), 300);\n }\n\n componentWillLoad() {\n this.processSlottedContent();\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-lbl';\n const moreId =\n this.showInlineError || this.hasHelperSlot ? this.inputId + '-more' : '';\n this.rtl = (this.el.ownerDocument as Document).dir === 'rtl';\n\n const compWrapOptions = (({\n el,\n floatLabel,\n label,\n errorMessage,\n type,\n showInlineError,\n hasHelperSlot,\n hasLabelSlot,\n hideLabel,\n placeholder,\n maxlength,\n charCount,\n showCharCount,\n rtl,\n }) => ({\n el,\n floatLabel,\n label,\n errorMessage,\n type,\n showInlineError,\n hasHelperSlot,\n hasLabelSlot,\n hideLabel,\n placeholder,\n maxlength,\n charCount,\n showCharCount,\n rtl,\n }))(this);\n const wrapOptions = {\n ...compWrapOptions,\n labelId,\n moreId,\n hasValue: this.hasValue(),\n controlId: this.inputId,\n };\n\n const controlOptions = (({ clearInput, readonly, disabled }) => ({\n clearInput,\n readonly,\n disabled,\n clearControl: this.clearInput,\n }))(this);\n\n return (\n <Host\n aria-disabled={this.disabled ? 'true' : null}\n dir={this.rtl ? 'rtl' : null}\n class={{\n ...createColorClasses(this.color),\n 'has-value': this.hasValue(),\n 'has-focus': this.hasFocus,\n 'is-invalid': this._invalid,\n }}\n >\n <FormControlWrap {...wrapOptions}>\n <FormControl\n {...controlOptions}\n onClearText={this.clearTextInput}\n control={this.el}\n ref={(el) => (this.nativeInputWrap = el)}\n >\n {this.type !== 'textarea' && (\n <input\n id={this.inputId}\n class=\"native-input\"\n ref={(input) => (this.nativeInput = input)}\n aria-labelledby={labelId + ' ' + moreId}\n disabled={this.disabled}\n accept={this.accept}\n autoCapitalize={this.autocapitalise}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n form={this.form}\n min={this.min}\n max={this.max}\n minLength={this.minlength}\n maxLength={this.maxlength}\n multiple={this.multiple}\n name={this.name}\n pattern={this.pattern}\n placeholder={\n !this.floatLabel && this.placeholder ? this.placeholder : ''\n }\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n step={this.step}\n size={this.size}\n type={this.type}\n value={value}\n onInput={this.onInput}\n onChange={this.onInput}\n onFocus={this.onFocus}\n onKeyDown={this.onKeydown}\n onInvalid={this.validate}\n />\n )}\n {this.type === 'textarea' && (\n <textarea\n rows={this.floatLabel ? 1 : this.rows}\n id={this.inputId}\n class={{\n 'native-input': true,\n resizable: this.resize === 'true',\n }}\n ref={(input) => (this.nativeInput = input)}\n aria-labelledby={labelId + ' ' + moreId}\n disabled={this.disabled}\n autoCapitalize={this.autocapitalise}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n form={this.form}\n minLength={this.minlength}\n maxLength={this.maxlength}\n name={this.name}\n placeholder={\n !this.floatLabel && this.placeholder ? this.placeholder : ''\n }\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n value={value}\n onInput={this.onInput}\n onChange={this.onInput}\n onFocus={this.onFocus}\n onKeyDown={this.onKeydown}\n onInvalid={this.validate}\n ></textarea>\n )}\n </FormControl>\n <slot />\n </FormControlWrap>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EAET,OAAO,EACP,KAAK,EAEL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,CAAC,EACD,MAAM,GACP,MAAM,eAAe,CAAC;AASvB,OAAO,EACL,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,GAAG,GACJ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE5E,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;;;;;;;;;;;;GAaG;AAMH,MAAM,OAAO,KAAK;EALlB;IAOU,YAAO,GAAG,cAAc,QAAQ,EAAE,EAAE,CAAC;IACrC,qBAAgB,GAAG,KAAK,CAAC;IACzB,QAAG,GAAY,KAAK,CAAC;IAErB,cAAS,GAAG,CAAC,CAAC;IACd,gBAAW,GAAG,KAAK,CAAC;IAcnB,aAAQ,GAAG,KAAK,CAAC;IACjB,iBAAY,GAAG,KAAK,CAAC;IACrB,kBAAa,GAAG,KAAK,CAAC;IACtB,qBAAgB,GAAG,KAAK,CAAC;IACzB,iBAAY,GAAW,EAAE,CAAC;IAC1B,aAAQ,GAA4B,IAAI,CAAC;IAuBzC,aAAQ,GAAG,KAAK,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Build,\n Component,\n ComponentInterface,\n Element,\n Event,\n EventEmitter,\n Host,\n Method,\n Prop,\n State,\n Watch,\n h,\n Listen,\n} from '@stencil/core';\n\nimport {\n Color,\n ControlValidity,\n ControlValidityEventDetail,\n InputChangeEventDetail,\n TextFieldTypes,\n} from '../../interface';\nimport {\n debounceEvent,\n closestElement,\n createColorClasses,\n raf,\n} from '../../utils';\nimport { FormControl, FormControlWrap } from '../form-control/form-control';\n\nlet inputIds = 0;\n\n/**\n * The input component is a wrapper to the HTML input element with custom styling and additional functionality. It accepts most of the same properties as the HTML [input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input), but works great on desktop devices and integrates with the keyboard on mobile devices.\n\nIt is meant for text type inputs only, such as \"text\", \"password\", \"email\", \"number\", \"search\", \"tel\", and \"url\". It supports all standard text input events including keyup, keydown, keypress, and more.\nThe default styling reference comes from the [ONT styleguide](https://nanoporetech.zeroheight.com/styleguide/s/31282/p/230c74-text-input--textarea/b/942ee4)\n * @slot start - suitable for inline action buttons or icons that may add extra contextual information\n * @slot end - suitable for inline action buttons or icons that may add extra contextual information\n * @slot value-start - similar to 'start', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist\n * @slot value-end - similar to 'end', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist\n * @slot label - if you do not set a label attribute, you can use this slot for more complex markup\n * @slot helper - helper text to accompany the form field underneath.\n * @slot helper-end - helper text to accompany the form field on the side.\n * @slot - can be used with a `nano-datalist`. See the `nano-datalist` docs for more information\n */\n@Component({\n tag: 'nano-input',\n styleUrl: 'input.scss',\n scoped: true,\n})\nexport class Input implements ComponentInterface {\n private nativeInput?: HTMLInputElement | HTMLTextAreaElement;\n private inputId = `nano-input-${inputIds++}`;\n private didBlurAfterEdit = false;\n private rtl: boolean = false;\n private mo?: MutationObserver;\n private charCount = 0;\n private hasRendered = false;\n\n // we don't want these rendered eles decorated with @State\n // because that will cause re-renders. User get/set to set datalist options\n private _nativeInputWrap: HTMLElement;\n private get nativeInputWrap() {\n return this._nativeInputWrap;\n }\n private set nativeInputWrap(ele: HTMLElement) {\n if (this._nativeInputWrap === ele) return;\n this._nativeInputWrap = ele;\n this.setDataListOpts();\n }\n\n @State() hasFocus = false;\n @State() hasLabelSlot = false;\n @State() hasHelperSlot = false;\n @State() hasHelperEndSlot = false;\n @State() errorMessage: string = '';\n @State() datalist: HTMLNanoDatalistElement = null;\n\n @Watch('datalist')\n setDataListOpts() {\n if (!this.datalist) return;\n const currDWConfig = this.datalist.dropDownConfig || {};\n this.datalist.dropDownConfig = {\n ...currDWConfig,\n skidding: -1,\n tetherTo: this.nativeInputWrap,\n };\n }\n\n @Element() el!: HTMLNanoInputElement;\n\n /**\n * This will be true when the control is in an invalid state.\n * Validity is determined by the `required` prop. Or if custom validity message is set. @readonly\n */\n @Prop({ reflect: true })\n get invalid() {\n return this._invalid;\n }\n @State() _invalid = false;\n\n /**\n * The color to use from the application's color palette.\n */\n @Prop() color?: Color;\n\n /**\n * If the value of the type attribute is `\"file\"`, then this attribute will indicate the types of files that the server accepts, otherwise it will be ignored. The value must be a comma-separated list of unique content type specifiers.\n */\n @Prop() accept?: string;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalise: 'none' | 'sentences' | 'words' | 'characters' =\n 'none';\n\n /**\n * Indicates whether the value of the control can be automatically completed by the browser.\n */\n @Prop() autocomplete: 'on' | 'off' = 'off';\n\n /**\n * Whether auto correction should be enabled when the user is entering/editing the text value.\n */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, a clear icon will appear in the input when there is a value. Clicking it clears the input.\n */\n @Prop() clearInput = false;\n\n /**\n * If `true`, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `\"password\"`, `false` for all other types.\n */\n @Prop() clearOnEdit?: boolean;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `nanoChange` event after each keystroke.\n */\n @Prop() debounce = 0;\n\n /**\n * If `true`, the user cannot interact with the input.\n */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * A hint to the browser for which keyboard to display.\n * Possible values: `\"none\"`, `\"text\"`, `\"tel\"`, `\"url\"`,\n * `\"email\"`, `\"numeric\"`, `\"decimal\"`, and `\"search\"`.\n */\n @Prop() inputmode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search';\n\n /**\n * When should the field perform validation\n */\n @Prop({ mutable: true }) validateOn: 'dirty' | 'submit' | 'submitThenDirty' =\n 'submit';\n\n /**\n * Whether to show validation errors underneath input\n */\n @Prop({ reflect: true }) showInlineError = true;\n\n /**\n * String to place within a label element. Alternatively you may use a label slot.\n */\n @Prop() label!: string;\n\n /**\n * Visually hide the label - but make it accessible.\n */\n @Prop() hideLabel?: boolean = false;\n\n /**\n * Enable floating label behaviour. Will disable placeholder if set.\n */\n @Prop() floatLabel: boolean = false;\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * If `true`, the user can enter more than one value. This attribute applies when the type attribute is set to `\"email\"` or `\"file\"`, otherwise it is ignored.\n */\n @Prop() multiple?: boolean;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * A regular expression that the value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() pattern?: string;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string | null;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop({ reflect: true }) readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The initial size of the control. This value is in pixels unless the value of the type attribute is `\"text\"` or `\"password\"`, in which case it is an integer number of characters. This attribute applies only when the `type` attribute is set to `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() size?: number;\n\n /**\n * The type of control to display. The default type is text.\n */\n @Prop({ reflect: true }) type: TextFieldTypes = 'text';\n\n /**\n * The form element to associate the select with (its form owner). Must be the id of a form.\n */\n @Prop() form?: string | null;\n\n /**\n * The value of the input.\n */\n @Prop({ mutable: true }) value?: string | null = '';\n\n /**\n * relevant to type=\"textarea\". Vertical resizing - enable / disable or make automatic.\n */\n @Prop() resize: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * relevant to type=\"textarea\". Default number of rows to show\n */\n @Prop() rows = 2;\n\n /**\n * relevant to type=\"textarea\".\n */\n @Prop() showCharCount = false;\n\n @Watch('minlength')\n @Watch('maxlength')\n @Watch('min')\n @Watch('max')\n @Watch('required')\n @Watch('disabled')\n @Watch('validateOn')\n @Watch('readonly')\n @Watch('pattern')\n @Watch('inputmode')\n protected shouldValidate() {\n if (!this.hasRendered) return;\n setTimeout(() => {\n if (this.validateOn === 'dirty') this.validate();\n }, 20);\n }\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n this.nanoChange.emit({ value: this.value });\n this.charCount = this.value.length;\n\n if (this.type === 'textarea' && this.resize === 'auto') {\n this.nativeInput.style.height = 'auto';\n if (this.value.length)\n this.nativeInput.style.height = this.nativeInput.scrollHeight + 'px';\n }\n\n setTimeout(() => {\n if (this.validateOn === 'dirty') this.validate();\n }, 20);\n }\n\n @Watch('debounce')\n protected debounceChanged() {\n this.nanoChange = debounceEvent(this.nanoChange, this.debounce);\n }\n\n /**\n * Emitted when a keyboard input occurred.\n */\n @Event() nanoInput!: EventEmitter<InputEvent>;\n\n /**\n * Emitted when the value has changed.\n */\n @Event() nanoChange!: EventEmitter<InputChangeEventDetail>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() nanoBlur!: EventEmitter<void>;\n\n /**\n * Emitted when the input has focus.\n */\n @Event() nanoFocus!: EventEmitter<void>;\n\n /**\n * Emitted when the input has been created.\n * @internal\n */\n @Event() nanoDidLoad!: EventEmitter<void>;\n\n /**\n * Emitted when the input has been removed.\n * @internal\n */\n @Event() nanoDidUnload!: EventEmitter<void>;\n\n /**\n * Called when validation is performed (which depends on `validateOn`).\n * @returns event.detail: `{ isValid: boolean, errorMessage: string, originalEvent: Event }`.\n */\n @Event() nanoValidate: EventEmitter<ControlValidityEventDetail>;\n\n /**\n * Get the current state of the control.\n * @param validateFirst - perform validation first before reporting\n * @returns `{ isValid: boolean, errorMessage: string }`\n */\n @Method()\n async reportValidity(validateFirst: boolean): Promise<ControlValidity> {\n if (validateFirst) this.validate();\n return {\n isValid: !this._invalid,\n errorMessage: this.nativeInput.validationMessage,\n };\n }\n\n /**\n * Sets focus on the specified `nano-input`. Use this method instead of the global\n * `input.focus()`.\n */\n @Method()\n async setFocus() {\n if (this.nativeInput) {\n this.nativeInput.focus();\n this.nativeInput.click();\n }\n }\n\n /**\n * Returns the native `<input>` element used under the hood.\n */\n @Method()\n getInputElement(): Promise<HTMLInputElement | HTMLTextAreaElement> {\n return Promise.resolve(this.nativeInput);\n }\n\n /**\n * Invalidate the field and show a custom error message. To clear the error you will need to re-call this method with an empty string.\n */\n @Method()\n async showError(message: string) {\n if (this.nativeInput) {\n this.nativeInput.setCustomValidity(message);\n this.validate();\n }\n }\n\n @Listen('reset', { target: 'body' })\n onReset(e) {\n const form = this.form\n ? document.querySelector('#' + this.form)\n : this.el.closest('form');\n if (!form || e.target !== this.el.closest('form')) return;\n\n this.value = '';\n }\n\n @Listen('mousedown', { target: 'body' })\n @Listen('keydown')\n handleBlur(e: KeyboardEvent | MouseEvent) {\n if (!this.hasFocus) return;\n\n const kev = e as KeyboardEvent;\n let target: Element;\n\n raf(() => {\n if (kev.key) {\n if (kev.key !== 'Tab') return;\n target = document.activeElement;\n } else target = e.target as Element;\n\n if (closestElement(this.el.tagName.toLowerCase(), target) !== this.el) {\n this.onBlur();\n }\n });\n }\n\n private shouldClearOnEdit() {\n const { type, clearOnEdit } = this;\n return clearOnEdit === undefined ? type === 'password' : clearOnEdit;\n }\n\n private getValue(): string {\n return this.value || '';\n }\n\n private validate = (ev?: Event) => {\n if (this.validateOn === 'submitThenDirty') this.validateOn = 'dirty';\n\n if (!this.nativeInput.validity.valid) {\n if (this.showInlineError) {\n if (ev) ev.preventDefault();\n this.errorMessage = this.nativeInput.validationMessage;\n }\n this._invalid = true;\n } else this._invalid = false;\n\n this.nanoValidate.emit({\n isValid: !this._invalid,\n errorMessage: this.nativeInput.validationMessage,\n originalEvent: ev,\n });\n };\n\n private onInput = (ev: InputEvent) => {\n const input = ev.target as HTMLInputElement | null;\n this.value = input?.value || '';\n this.nanoInput.emit(ev);\n };\n\n private onBlur = () => {\n this.hasFocus = false;\n this.focusChanged();\n if (this.validateOn === 'dirty') this.validate();\n this.nanoBlur.emit();\n };\n\n private onFocus = () => {\n this.hasFocus = true;\n this.focusChanged();\n this.nanoFocus.emit();\n };\n\n private onKeydown = () => {\n if (this.shouldClearOnEdit()) {\n // Did the input value change after it was blurred and edited?\n if (this.didBlurAfterEdit && this.hasValue()) {\n // Clear the input\n this.clearTextInput();\n }\n\n // Reset the flag\n this.didBlurAfterEdit = false;\n }\n };\n\n private clearTextInput = (ev?: Event) => {\n if (this.clearInput && !this.readonly && !this.disabled && ev) {\n ev.preventDefault();\n ev.stopPropagation();\n }\n\n this.value = '';\n this.nativeInput.value = '';\n const event = new window.Event('change');\n this.nativeInput.dispatchEvent(event);\n };\n\n private focusChanged() {\n // If clearOnEdit is enabled and the input blurred but has a value, set a flag\n if (!this.hasFocus && this.shouldClearOnEdit() && this.hasValue()) {\n this.didBlurAfterEdit = true;\n }\n }\n\n private hasValue(): boolean {\n return this.getValue().length > 0;\n }\n\n private slotChangeObserver() {\n if (!Build.isBrowser) return;\n\n if (this.mo) this.mo.disconnect();\n const mo = (this.mo = new MutationObserver(() =>\n this.processSlottedContent()\n ));\n mo.observe(this.el, { childList: true, subtree: true });\n }\n\n private processSlottedContent() {\n // see if we have label / button content\n this.hasLabelSlot = !!this.el.querySelectorAll('[slot=\"label\"]');\n this.hasHelperSlot = !!this.el.querySelector('[slot=\"helper\"]');\n this.hasHelperEndSlot = !!this.el.querySelector('[slot=\"helper-end\"]');\n this.datalist = this.el.querySelector('nano-datalist:not([slot])');\n\n // breaking change introduced in v2. Rm in v3\n if (!!this.el.querySelector('[slot=\"inline-button\"]')) {\n console.warn(\n 'The `inline-button` slot was renamed to `end` in v2 - please update your code',\n this.el\n );\n }\n\n // breaking change introduced in v2. Rm in v3\n if (!!this.el.querySelector('[slot=\"legacy\"]')) {\n console.warn(\n 'The `legacy` slot has been removed. Please update your code',\n this.el\n );\n }\n }\n\n connectedCallback() {\n this.debounceChanged();\n if (Build.isBrowser) {\n this.el.dispatchEvent(\n new CustomEvent('nanoDidLoad', {\n detail: this.el,\n })\n );\n }\n }\n\n disconnectedCallback() {\n if (Build.isBrowser) {\n document.dispatchEvent(\n new CustomEvent('nanoDidUnload', {\n detail: this.el,\n })\n );\n }\n if (this.mo) this.mo.disconnect();\n }\n\n componentDidLoad() {\n this.slotChangeObserver();\n this.hasRendered = true;\n if (this.autofocus) setTimeout((_) => this.setFocus(), 300);\n }\n\n componentWillLoad() {\n this.processSlottedContent();\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-lbl';\n const moreId =\n this.showInlineError || this.hasHelperSlot ? this.inputId + '-more' : '';\n const helperEndId = this.hasHelperEndSlot ? this.inputId + '-helper' : '';\n this.rtl = (this.el.ownerDocument as Document).dir === 'rtl';\n\n const compWrapOptions = (({\n el,\n floatLabel,\n label,\n errorMessage,\n type,\n showInlineError,\n hasHelperSlot,\n hasLabelSlot,\n hideLabel,\n placeholder,\n maxlength,\n charCount,\n showCharCount,\n rtl,\n hasHelperEndSlot,\n }) => ({\n el,\n floatLabel,\n label,\n errorMessage,\n type,\n showInlineError,\n hasHelperSlot,\n hasLabelSlot,\n hideLabel,\n placeholder,\n maxlength,\n charCount,\n showCharCount,\n rtl,\n hasHelperEndSlot,\n }))(this);\n const wrapOptions = {\n ...compWrapOptions,\n labelId,\n moreId,\n helperEndId,\n hasValue: this.hasValue(),\n controlId: this.inputId,\n };\n\n const controlOptions = (({ clearInput, readonly, disabled }) => ({\n clearInput,\n readonly,\n disabled,\n clearControl: this.clearInput,\n }))(this);\n\n return (\n <Host\n aria-disabled={this.disabled ? 'true' : null}\n dir={this.rtl ? 'rtl' : null}\n class={{\n ...createColorClasses(this.color),\n 'has-value': this.hasValue(),\n 'has-focus': this.hasFocus,\n 'is-invalid': this._invalid,\n }}\n >\n <FormControlWrap {...wrapOptions}>\n <FormControl\n {...controlOptions}\n onClearText={this.clearTextInput}\n control={this.el}\n ref={(el) => (this.nativeInputWrap = el)}\n >\n {this.type !== 'textarea' && (\n <input\n id={this.inputId}\n class=\"input__native-ctrl\"\n ref={(input) => (this.nativeInput = input)}\n aria-labelledby={labelId + ' ' + moreId + ' ' + helperEndId}\n disabled={this.disabled}\n accept={this.accept}\n autoCapitalize={this.autocapitalise}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n form={this.form}\n min={this.min}\n max={this.max}\n minLength={this.minlength}\n maxLength={this.maxlength}\n multiple={this.multiple}\n name={this.name}\n pattern={this.pattern}\n placeholder={this.placeholder}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n step={this.step}\n size={this.size}\n type={this.type}\n value={value}\n onInput={this.onInput}\n onChange={this.onInput}\n onFocus={this.onFocus}\n onKeyDown={this.onKeydown}\n onInvalid={this.validate}\n />\n )}\n {this.type === 'textarea' && (\n <textarea\n rows={this.floatLabel ? 1 : this.rows}\n id={this.inputId}\n class={{\n 'input__native-ctrl': true,\n input__resizable: this.resize === 'true',\n }}\n ref={(input) => (this.nativeInput = input)}\n aria-labelledby={labelId + ' ' + moreId + ' ' + helperEndId}\n disabled={this.disabled}\n autoCapitalize={this.autocapitalise}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n form={this.form}\n minLength={this.minlength}\n maxLength={this.maxlength}\n name={this.name}\n placeholder={this.placeholder}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n value={value}\n onInput={this.onInput}\n onChange={this.onInput}\n onFocus={this.onFocus}\n onKeyDown={this.onKeydown}\n onInvalid={this.validate}\n ></textarea>\n )}\n </FormControl>\n <slot />\n </FormControlWrap>\n </Host>\n );\n }\n}\n"]}
@@ -148,8 +148,7 @@ export class Menu {
148
148
  i.classList.contains('has-focus'));
149
149
  }
150
150
  get selectedItem() {
151
- const activeElement = getActiveElement();
152
- return this.getItems.find((i) => i.selected || i === activeElement);
151
+ return this.getItems.find((i) => i.selected);
153
152
  }
154
153
  async setActiveFocusItem(item, focus = true) {
155
154
  const items = this.getItems;
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../../src/components/menu/menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EAEL,MAAM,EACN,CAAC,EACD,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,MAAM,SAAS,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;AAK/C;;;;GAIG;AAMH,MAAM,OAAO,IAAI;EALjB;IAMU,sBAAiB,GAAG,KAAK,CAAC;IAG1B,iBAAY,GAAG,EAAE,CAAC;IAYlB,cAAS,GAAG,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AI,EAAE,IAAI,CAAC,IAAI,EACf,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,EAC7B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;UACL,IAAI,EAAE,IAAI;UACV,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;UAC5B,iBAAiB,EAAE,IAAI,CAAC,QAAQ;SACjC,EACD,QAAQ,EAAE,CAAC,CAAC;QAEZ,eAAQ,CACJ,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Event,\n EventEmitter,\n Method,\n h,\n Host,\n Element,\n Prop,\n Listen,\n} from '@stencil/core';\nimport {\n getTextContent,\n getDirectChildren,\n getActiveElement,\n} from '../../utils';\n\nconst CANSHADOW = !!document.head.attachShadow;\n\ntype ValidElement = HTMLNanoNavItemElement | HTMLNanoOptionElement;\ntype NNI = HTMLNanoNavItemElement;\n\n/**\n * Menu element. Commonly wrapped by `nano-dropdown` with `nano-option` and `nano-nav-item` elements nested.\n * Manages focus state / active.\n * @slot - The menu's content; `nano-option`, `nano-nav-item` elements as well as <hr> and more.\n */\n@Component({\n tag: 'nano-menu',\n styleUrl: 'menu.scss',\n shadow: true,\n})\nexport class Menu {\n private ignoreMouseEvents = false;\n private ignoreMouseTimeout: any;\n private menu: HTMLElement;\n private typeToSelect = '';\n private typeToSelectTimeout: any;\n\n @Element() private el: HTMLNanoMenuElement;\n\n // Public API\n\n /** get the focus state of the menu @readonly */\n @Prop()\n get hasFocus() {\n return this._hasFocus;\n }\n private _hasFocus = false;\n\n /** changes the role of the underlying control - sometimes required for semantics */\n @Prop() type: 'menu' | 'listbox' = 'menu';\n\n /** an accessible label */\n @Prop() label: string;\n\n // Events\n\n /** Emitted when the menu gains focus. */\n @Event() nanoFocus: EventEmitter;\n\n /** Emitted when the menu loses focus. */\n @Event() nanoBlur: EventEmitter;\n\n /** Emitted when a menu item is selected. */\n @Event() nanoSelect: EventEmitter<\n HTMLNanoOptionElement | HTMLNanoNavItemElement\n >;\n\n // Public Methods\n\n /** Sets focus on the menu. */\n @Method()\n async setFocus() {\n if (this.menu?.focus) this.menu.focus({ preventScroll: true });\n }\n\n /** Removes focus from the menu. */\n @Method()\n async removeFocus() {\n if (this.menu?.blur) this.menu.blur();\n }\n\n /** Sets the current active item */\n @Method()\n async showActiveElement() {\n if (this.selectedItem)\n this.selectedItem.scrollIntoView({ block: 'nearest' });\n }\n\n /** Removes any active item's state */\n @Method()\n async resetActiveItem() {\n this.getItems\n .filter((i) => i.tagName.toLowerCase() === 'nano-option')\n .map((i) => i.setAttribute('tabindex', '-1'));\n }\n\n // Private methods\n\n get getItems() {\n let items: ValidElement[];\n let opened = this.el.querySelectorAll('nano-nav-item.secondary-open');\n if (opened.length) {\n const ctx = opened[opened.length - 1] as HTMLNanoNavItemElement;\n items = Array.from(ctx.querySelectorAll('nano-nav-item, nano-option'));\n } else {\n items = getDirectChildren(\n this.el,\n 'nano-nav-item, nano-option',\n 'slot'\n ) as ValidElement[];\n }\n return items.filter((el) => !el.disabled && !el.hidden);\n }\n\n get activeItem() {\n const activeElement = getActiveElement();\n return this.getItems.find(\n (i) =>\n i.getAttribute('tabindex') === '0' ||\n i === activeElement ||\n i.classList.contains('has-focus')\n );\n }\n\n get selectedItem() {\n const activeElement = getActiveElement();\n return this.getItems.find((i) => i.selected || i === activeElement);\n }\n\n private async setActiveFocusItem(item?: ValidElement, focus = true) {\n const items = this.getItems;\n let activeItem =\n !item || item.disabled ? items.find((i) => i.selected) || items[0] : item;\n\n items\n .filter((i) => i.tagName.toLowerCase() === 'nano-option')\n .map((i: HTMLNanoOptionElement) =>\n i.setAttribute('tabindex', i === activeItem ? '0' : '-1')\n );\n\n if (!focus) return;\n\n if (activeItem) {\n (activeItem as NNI).setFocus\n ? (activeItem as NNI).setFocus()\n : activeItem.focus();\n } else this.menu.focus();\n }\n\n // Event Handlers\n\n @Listen('mousedown', { target: 'body' })\n @Listen('keydown')\n handleBlur(e: KeyboardEvent | MouseEvent) {\n if (!this.hasFocus) return;\n\n const kev = e as KeyboardEvent;\n let found: boolean;\n\n if (kev.key) {\n if (kev.key !== 'Tab') return;\n found =\n getActiveElement() &&\n getActiveElement().closest(this.el.tagName.toLowerCase()) === this.el;\n } else found = !!e.composedPath().find((el) => el === this.el);\n\n if (!found) {\n this.resetActiveItem();\n this._hasFocus = false;\n this.nanoBlur.emit();\n }\n }\n\n private handleFocus = () => {\n this.setActiveFocusItem(this.selectedItem || this.getItems[0]);\n\n this._hasFocus = true;\n this.nanoFocus.emit();\n };\n\n private handleClick = (event: MouseEvent) => {\n const target = event.target as HTMLElement;\n const item = target.closest('nano-nav-item');\n\n if (item && !item.disabled) {\n this.nanoSelect.emit(item);\n }\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n // When keying through the menu, if the mouse happens to be hovering over a menu item and the menu scrolls, the\n // mouseout/mouseover event will fire causing the selection to be different than what the user expects. This gives\n // us a way to temporarily ignore mouse events while the user is interacting with a keyboard.\n clearTimeout(this.ignoreMouseTimeout);\n this.ignoreMouseTimeout = setTimeout(\n () => (this.ignoreMouseEvents = false),\n 500\n );\n this.ignoreMouseEvents = true;\n\n // Make a selection when pressing enter\n switch (event.key) {\n case ' ':\n if (this.activeItem) this.activeItem.click();\n break;\n case 'ArrowDown':\n case 'ArrowUp':\n case 'PageDown':\n case 'PageUp':\n case 'Home':\n case 'End':\n const items = this.getItems;\n const selectedItem = this.activeItem;\n let index = items.indexOf(selectedItem);\n\n if (items.length) {\n event.preventDefault();\n\n if (event.key === 'ArrowDown') {\n index++;\n } else if (event.key === 'ArrowUp') {\n index--;\n } else if (event.key === 'Home' || event.key === 'PageUp') {\n index = 0;\n } else if (event.key === 'End' || event.key === 'PageDown') {\n index = items.length - 1;\n }\n\n if (index < 0) index = items.length - 1;\n if (index > items.length - 1) index = 0;\n\n this.setActiveFocusItem(items[index]);\n if (items[index]) items[index].scrollIntoView({ block: 'nearest' });\n return;\n }\n break;\n }\n\n // Handle type-to-search behavior when non-control characters are entered\n if (event.key === ' ' || /^[a-z0-9]+$/i.test(event.key)) {\n clearTimeout(this.typeToSelectTimeout);\n this.typeToSelectTimeout = setTimeout(\n () => (this.typeToSelect = ''),\n 750\n );\n this.typeToSelect += event.key;\n\n const items = this.getItems;\n for (const item of items) {\n const slot = item.shadowRoot.querySelector(\n 'slot:not([name])'\n ) as HTMLSlotElement;\n const label = getTextContent(slot).toLowerCase().trim();\n if (\n label.substring(0, this.typeToSelect.length) === this.typeToSelect\n ) {\n this.setActiveFocusItem(item);\n break;\n }\n }\n }\n };\n\n private handleMouseOver = (event: MouseEvent) => {\n const target = event.target as HTMLElement;\n const item =\n target.closest('nano-nav-item') || target.closest('nano-option');\n\n if (item && !this.ignoreMouseEvents) {\n this.setActiveFocusItem(item);\n }\n };\n\n // Component Lifecycle\n\n render() {\n return (\n <Host\n class={{\n legacy: !CANSHADOW,\n }}\n >\n <div\n onClick={this.handleClick}\n onKeyDown={this.handleKeyDown}\n onMouseOver={this.handleMouseOver}\n onFocus={this.handleFocus}\n aria-label={this.label ? this.label : undefined}\n role={this.type}\n ref={(el) => (this.menu = el)}\n part=\"base\"\n class={{\n menu: true,\n ['menu--' + this.type]: true,\n 'menu--has-focus': this.hasFocus,\n }}\n tabIndex={-1}\n >\n <slot />\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../../src/components/menu/menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EA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IAAI,IACH,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,SAAS;OACnB;MAED,WACE,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,SAAS,EAAE,IAAI,CAAC,aAAa,EAC7B,WAAW,EAAE,IAAI,CAAC,eAAe,EACjC,OAAO,EAAE,IAAI,CAAC,WAAW,gBACb,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAC/C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,EAC7B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;UACL,IAAI,EAAE,IAAI;UACV,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;UAC5B,iBAAiB,EAAE,IAAI,CAAC,QAAQ;SACjC,EACD,QAAQ,EAAE,CAAC,CAAC;QAEZ,eAAQ,CACJ,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Event,\n EventEmitter,\n Method,\n h,\n Host,\n Element,\n Prop,\n Listen,\n} from '@stencil/core';\nimport {\n getTextContent,\n getDirectChildren,\n getActiveElement,\n} from '../../utils';\n\nconst CANSHADOW = !!document.head.attachShadow;\n\ntype ValidElement = HTMLNanoNavItemElement | HTMLNanoOptionElement;\ntype NNI = HTMLNanoNavItemElement;\n\n/**\n * Menu element. Commonly wrapped by `nano-dropdown` with `nano-option` and `nano-nav-item` elements nested.\n * Manages focus state / active.\n * @slot - The menu's content; `nano-option`, `nano-nav-item` elements as well as <hr> and more.\n */\n@Component({\n tag: 'nano-menu',\n styleUrl: 'menu.scss',\n shadow: true,\n})\nexport class Menu {\n private ignoreMouseEvents = false;\n private ignoreMouseTimeout: any;\n private menu: HTMLElement;\n private typeToSelect = '';\n private typeToSelectTimeout: any;\n\n @Element() private el: HTMLNanoMenuElement;\n\n // Public API\n\n /** get the focus state of the menu @readonly */\n @Prop()\n get hasFocus() {\n return this._hasFocus;\n }\n private _hasFocus = false;\n\n /** changes the role of the underlying control - sometimes required for semantics */\n @Prop() type: 'menu' | 'listbox' = 'menu';\n\n /** an accessible label */\n @Prop() label: string;\n\n // Events\n\n /** Emitted when the menu gains focus. */\n @Event() nanoFocus: EventEmitter;\n\n /** Emitted when the menu loses focus. */\n @Event() nanoBlur: EventEmitter;\n\n /** Emitted when a menu item is selected. */\n @Event() nanoSelect: EventEmitter<\n HTMLNanoOptionElement | HTMLNanoNavItemElement\n >;\n\n // Public Methods\n\n /** Sets focus on the menu. */\n @Method()\n async setFocus() {\n if (this.menu?.focus) this.menu.focus({ preventScroll: true });\n }\n\n /** Removes focus from the menu. */\n @Method()\n async removeFocus() {\n if (this.menu?.blur) this.menu.blur();\n }\n\n /** Sets the current active item */\n @Method()\n async showActiveElement() {\n if (this.selectedItem)\n this.selectedItem.scrollIntoView({ block: 'nearest' });\n }\n\n /** Removes any active item's state */\n @Method()\n async resetActiveItem() {\n this.getItems\n .filter((i) => i.tagName.toLowerCase() === 'nano-option')\n .map((i) => i.setAttribute('tabindex', '-1'));\n }\n\n // Private methods\n\n get getItems() {\n let items: ValidElement[];\n let opened = this.el.querySelectorAll('nano-nav-item.secondary-open');\n if (opened.length) {\n const ctx = opened[opened.length - 1] as HTMLNanoNavItemElement;\n items = Array.from(ctx.querySelectorAll('nano-nav-item, nano-option'));\n } else {\n items = getDirectChildren(\n this.el,\n 'nano-nav-item, nano-option',\n 'slot'\n ) as ValidElement[];\n }\n return items.filter((el) => !el.disabled && !el.hidden);\n }\n\n get activeItem() {\n const activeElement = getActiveElement();\n return this.getItems.find(\n (i) =>\n i.getAttribute('tabindex') === '0' ||\n i === activeElement ||\n i.classList.contains('has-focus')\n );\n }\n\n get selectedItem() {\n return this.getItems.find((i) => i.selected);\n }\n\n private async setActiveFocusItem(item?: ValidElement, focus = true) {\n const items = this.getItems;\n let activeItem =\n !item || item.disabled ? items.find((i) => i.selected) || items[0] : item;\n\n items\n .filter((i) => i.tagName.toLowerCase() === 'nano-option')\n .map((i: HTMLNanoOptionElement) =>\n i.setAttribute('tabindex', i === activeItem ? '0' : '-1')\n );\n\n if (!focus) return;\n\n if (activeItem) {\n (activeItem as NNI).setFocus\n ? (activeItem as NNI).setFocus()\n : activeItem.focus();\n } else this.menu.focus();\n }\n\n // Event Handlers\n\n @Listen('mousedown', { target: 'body' })\n @Listen('keydown')\n handleBlur(e: KeyboardEvent | MouseEvent) {\n if (!this.hasFocus) return;\n\n const kev = e as KeyboardEvent;\n let found: boolean;\n\n if (kev.key) {\n if (kev.key !== 'Tab') return;\n found =\n getActiveElement() &&\n getActiveElement().closest(this.el.tagName.toLowerCase()) === this.el;\n } else found = !!e.composedPath().find((el) => el === this.el);\n\n if (!found) {\n this.resetActiveItem();\n this._hasFocus = false;\n this.nanoBlur.emit();\n }\n }\n\n private handleFocus = () => {\n this.setActiveFocusItem(this.selectedItem || this.getItems[0]);\n\n this._hasFocus = true;\n this.nanoFocus.emit();\n };\n\n private handleClick = (event: MouseEvent) => {\n const target = event.target as HTMLElement;\n const item = target.closest('nano-nav-item');\n\n if (item && !item.disabled) {\n this.nanoSelect.emit(item);\n }\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n // When keying through the menu, if the mouse happens to be hovering over a menu item and the menu scrolls, the\n // mouseout/mouseover event will fire causing the selection to be different than what the user expects. This gives\n // us a way to temporarily ignore mouse events while the user is interacting with a keyboard.\n clearTimeout(this.ignoreMouseTimeout);\n this.ignoreMouseTimeout = setTimeout(\n () => (this.ignoreMouseEvents = false),\n 500\n );\n this.ignoreMouseEvents = true;\n\n // Make a selection when pressing enter\n switch (event.key) {\n case ' ':\n if (this.activeItem) this.activeItem.click();\n break;\n case 'ArrowDown':\n case 'ArrowUp':\n case 'PageDown':\n case 'PageUp':\n case 'Home':\n case 'End':\n const items = this.getItems;\n const selectedItem = this.activeItem;\n let index = items.indexOf(selectedItem);\n\n if (items.length) {\n event.preventDefault();\n\n if (event.key === 'ArrowDown') {\n index++;\n } else if (event.key === 'ArrowUp') {\n index--;\n } else if (event.key === 'Home' || event.key === 'PageUp') {\n index = 0;\n } else if (event.key === 'End' || event.key === 'PageDown') {\n index = items.length - 1;\n }\n\n if (index < 0) index = items.length - 1;\n if (index > items.length - 1) index = 0;\n\n this.setActiveFocusItem(items[index]);\n if (items[index]) items[index].scrollIntoView({ block: 'nearest' });\n return;\n }\n break;\n }\n\n // Handle type-to-search behavior when non-control characters are entered\n if (event.key === ' ' || /^[a-z0-9]+$/i.test(event.key)) {\n clearTimeout(this.typeToSelectTimeout);\n this.typeToSelectTimeout = setTimeout(\n () => (this.typeToSelect = ''),\n 750\n );\n this.typeToSelect += event.key;\n\n const items = this.getItems;\n for (const item of items) {\n const slot = item.shadowRoot.querySelector(\n 'slot:not([name])'\n ) as HTMLSlotElement;\n const label = getTextContent(slot).toLowerCase().trim();\n if (\n label.substring(0, this.typeToSelect.length) === this.typeToSelect\n ) {\n this.setActiveFocusItem(item);\n break;\n }\n }\n }\n };\n\n private handleMouseOver = (event: MouseEvent) => {\n const target = event.target as HTMLElement;\n const item =\n target.closest('nano-nav-item') || target.closest('nano-option');\n\n if (item && !this.ignoreMouseEvents) {\n this.setActiveFocusItem(item);\n }\n };\n\n // Component Lifecycle\n\n render() {\n return (\n <Host\n class={{\n legacy: !CANSHADOW,\n }}\n >\n <div\n onClick={this.handleClick}\n onKeyDown={this.handleKeyDown}\n onMouseOver={this.handleMouseOver}\n onFocus={this.handleFocus}\n aria-label={this.label ? this.label : undefined}\n role={this.type}\n ref={(el) => (this.menu = el)}\n part=\"base\"\n class={{\n menu: true,\n ['menu--' + this.type]: true,\n 'menu--has-focus': this.hasFocus,\n }}\n tabIndex={-1}\n >\n <slot />\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -516,7 +516,7 @@ export class NavItem {
516
516
  "references": {
517
517
  "NavItemEventDetail": {
518
518
  "location": "import",
519
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
519
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
520
520
  }
521
521
  }
522
522
  }
@@ -536,7 +536,7 @@ export class NavItem {
536
536
  "references": {
537
537
  "NavItemEventDetail": {
538
538
  "location": "import",
539
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
539
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
540
540
  }
541
541
  }
542
542
  }
@@ -556,7 +556,7 @@ export class NavItem {
556
556
  "references": {
557
557
  "NavItemEventDetail": {
558
558
  "location": "import",
559
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
559
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
560
560
  }
561
561
  }
562
562
  }
@@ -576,7 +576,7 @@ export class NavItem {
576
576
  "references": {
577
577
  "NavItemEventDetail": {
578
578
  "location": "import",
579
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
579
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
580
580
  }
581
581
  }
582
582
  }
@@ -370,7 +370,7 @@ export class Range {
370
370
  "references": {
371
371
  "Color": {
372
372
  "location": "import",
373
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
373
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
374
374
  }
375
375
  }
376
376
  },
@@ -594,7 +594,7 @@ export class Range {
594
594
  "references": {
595
595
  "RangeValue": {
596
596
  "location": "import",
597
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
597
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
598
598
  }
599
599
  }
600
600
  },
@@ -632,7 +632,7 @@ export class Range {
632
632
  "references": {
633
633
  "RangeChangeEventDetail": {
634
634
  "location": "import",
635
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
635
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
636
636
  }
637
637
  }
638
638
  }
@@ -655,7 +655,7 @@ export class Range {
655
655
  "references": {
656
656
  "StyleEventDetail": {
657
657
  "location": "import",
658
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
658
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
659
659
  }
660
660
  }
661
661
  }
@@ -38,6 +38,8 @@ export class ResizeObserve {
38
38
  });
39
39
  if (hasChanged)
40
40
  this.applyChanges(changedStates);
41
+ else if (!this.classNames.includes('is-ready'))
42
+ this.classNames = ['is-ready'];
41
43
  };
42
44
  }
43
45
  dimensionChanged() {
@@ -84,7 +86,7 @@ export class ResizeObserve {
84
86
  });
85
87
  });
86
88
  });
87
- this.classNames = classNames;
89
+ this.classNames = ['is-ready', ...classNames];
88
90
  this.nanoResizeStateChange.emit(this.toSimpleObj(changes));
89
91
  }
90
92
  toSimpleObj(stateMaps) {
@@ -103,7 +105,7 @@ export class ResizeObserve {
103
105
  this.currentHeight = entry.contentRect.height;
104
106
  }
105
107
  });
106
- this.ro.observe(this.el);
108
+ this.ro.observe(this.host);
107
109
  }
108
110
  connectedCallback() {
109
111
  this.assessChanges = debounce(this.assessChanges, 50);
@@ -113,7 +115,7 @@ export class ResizeObserve {
113
115
  return;
114
116
  if (!this.currentWidth || !this.currentHeight) {
115
117
  readTask(() => {
116
- const { width, height } = this.el.getBoundingClientRect();
118
+ const { width, height } = this.host.getBoundingClientRect();
117
119
  this.currentWidth = width;
118
120
  this.currentHeight = height;
119
121
  });
@@ -128,8 +130,7 @@ export class ResizeObserve {
128
130
  return (h(Host, { class: {
129
131
  [this.classNames.join(' ')]: true,
130
132
  } },
131
- h("div", { ref: (div) => (this.el = div) },
132
- h("slot", null))));
133
+ h("slot", null)));
133
134
  }
134
135
  static get is() { return "nano-resize-observe"; }
135
136
  static get encapsulation() { return "shadow"; }
@@ -176,7 +177,7 @@ export class ResizeObserve {
176
177
  "references": {
177
178
  "ResizeStateChangeEventDetail": {
178
179
  "location": "import",
179
- "path": "/builds/zfg2rJd-/0/Digital/nano-components/packages/components/src/interface.d.ts"
180
+ "path": "/builds/99mRzSBj/0/Digital/nano-components/packages/components/src/interface.d.ts"
180
181
  }
181
182
  }
182
183
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resize-observe.js","sourceRoot":"","sources":["../../../src/components/resize-observe/resize-observe.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EAEL,KAAK,EAEL,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AASvC;;;;GAIG;AAMH,MAAM,OAAO,aAAa;EAL1B;IAaW,eAAU,GAAa,EAAE,CAAC;IA2C3B,kBAAa,GAAG,GAAG,EAAE;MAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MACtD,MAAM,aAAa,GAAc,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;MAChE,IAAI,UAAU,GAAG,KAAK,CAAC;MAEvB,MAA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,\n EventEmitter,\n readTask,\n} from '@stencil/core';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport { debounce } from '../../utils';\nimport type { ResizeStateChangeEventDetail } from '../../interface';\n\ntype ResizeObserverState = { states?: string[]; applied?: boolean };\ninterface StateMaps {\n h: Map<number, ResizeObserverState>;\n w: Map<number, ResizeObserverState>;\n}\n\n/**\n * A Resize-Observer utility component.\n * Takes a string list of sizes and optional class-names. Adds class-names and fires `nanoResizeStateChange` events when the component reaches those sizes.\n * @slot - Main slot for any content.\n */\n@Component({\n tag: 'nano-resize-observe',\n shadow: true,\n styles: `:host { display: inline-block } div { height: 100%; }`,\n})\nexport class ResizeObserve implements ComponentInterface {\n private ro: ResizeObserver;\n private appliedStates: StateMaps;\n private el: HTMLDivElement;\n\n @Element() host: HTMLNanoResizeObserveElement;\n @State() currentWidth: number;\n @State() currentHeight: number;\n @State() classNames: string[] = [];\n\n /** string list of sizes and optional class-names. Adds class-names and fires nanoResizeStateChange events. Upon hitting breakpoints.\n * Format: `states=\"800w, 300h class1 class2\"` */\n @Prop() states: string;\n\n /** A resize break point is switched on or off */\n @Event() nanoResizeStateChange!: EventEmitter<ResizeStateChangeEventDetail>;\n\n @Watch('currentHeight')\n @Watch('currentWidth')\n dimensionChanged() {\n this.assessChanges();\n }\n\n @Watch('states')\n statesChanged() {\n if (!this.states) return;\n if (!this.ro) this.attachRO();\n\n const toBpDir = (bpDir: string) => {\n const bpDirSpl = bpDir.split(/(\\d+)/).filter((bs) => bs.length);\n return { bp: parseInt(bpDirSpl[0]), dir: bpDirSpl[1] };\n };\n this.appliedStates = { h: new Map(), w: new Map() };\n\n // parse state string\n this.states.split(',').map((st) => {\n st = st.trim();\n if (st.includes(' ')) {\n const [key, ...classes] = st.split(' ');\n const { bp, dir } = toBpDir(key);\n this.appliedStates[dir as keyof StateMaps].set(bp, {\n states: classes,\n applied: false,\n });\n } else {\n const { bp, dir } = toBpDir(st);\n this.appliedStates[dir as keyof StateMaps].set(bp, { applied: false });\n }\n });\n }\n\n private assessChanges = () => {\n if (!this.currentWidth && !this.currentHeight) return;\n const changedStates: StateMaps = { h: new Map(), w: new Map() };\n let hasChanged = false;\n\n Object.keys(this.appliedStates).forEach((dimType) => {\n let dim: number;\n if (dimType === 'h') dim = this.currentHeight;\n else dim = this.currentWidth;\n\n this.appliedStates[dimType].forEach(\n (state: ResizeObserverState, bp: number) => {\n if (dim >= bp && state.applied === false) {\n state.applied = true;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n } else if (dim < bp && state.applied === true) {\n state.applied = false;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n }\n }\n );\n });\n if (hasChanged) this.applyChanges(changedStates);\n };\n\n private applyChanges(changes: StateMaps) {\n let classNames = [...this.classNames];\n Object.keys(changes).forEach((dimType: keyof StateMaps) => {\n changes[dimType].forEach((state) => {\n if (!state.states) return;\n state.states.map((st) => {\n if (state.applied) classNames.push(st);\n else classNames = classNames.filter((cl) => cl !== st);\n });\n });\n });\n this.classNames = classNames;\n this.nanoResizeStateChange.emit(this.toSimpleObj(changes));\n }\n\n private toSimpleObj(stateMaps: StateMaps) {\n const retObj = {};\n Object.keys(stateMaps).forEach((dimType: keyof StateMaps) => {\n stateMaps[dimType].forEach((state: ResizeObserverState, bp: number) => {\n retObj[bp + dimType] = state.applied;\n });\n });\n return retObj;\n }\n\n private attachRO() {\n this.ro = new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.currentWidth = entry.contentRect.width;\n this.currentHeight = entry.contentRect.height;\n }\n });\n this.ro.observe(this.el);\n }\n\n connectedCallback() {\n this.assessChanges = debounce(this.assessChanges, 50);\n }\n\n componentDidLoad() {\n if (!this.states) return;\n if (!this.currentWidth || !this.currentHeight) {\n readTask(() => {\n const { width, height } = this.el.getBoundingClientRect();\n this.currentWidth = width;\n this.currentHeight = height;\n });\n }\n this.statesChanged();\n }\n\n disconnectedCallback() {\n if (this.ro) this.ro.disconnect();\n }\n\n render() {\n return (\n <Host\n class={{\n [this.classNames.join(' ')]: true,\n }}\n >\n <div ref={(div) => (this.el = div)}>\n <slot />\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"resize-observe.js","sourceRoot":"","sources":["../../../src/components/resize-observe/resize-observe.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EAEL,KAAK,EAEL,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AASvC;;;;GAIG;AAMH,MAAM,OAAO,aAAa;EAL1B;IAYW,eAAU,GAAa,EAAE,CAAC;IA2C3B,kBAAa,GAAG,GAAG,EAAE;MAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MACtD,MAAM,aAAa,GAAc,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;MAChE,IAAI,UAAU,GAAG,KAAK,CAAC;MAEvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAClD,IAAI,GAAW,CAAC;QAChB,IAAI,OAAO,KAAK,GAAG;UAAE,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;;UACzC,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC;QAE7B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CACjC,CAAC,KAA0B,EAAE,EAAU,EAAE,EAAE;UACzC,IAAI,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,EAAE;YACxC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;YACrB,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAA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ACzB,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;MAC7C,QAAQ,CAAC,GAAG,EAAE;QACZ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;MAC9B,CAAC,CAAC,CAAC;KACJ;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;EACvB,CAAC;EAED,oBAAoB;IAClB,IAAI,IAAI,CAAC,EAAE;MAAE,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;EACpC,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI,IACH,KAAK,EAAE;QACL,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI;OAClC;MAED,eAAQ,CACH,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n h,\n Prop,\n Element,\n Host,\n State,\n Watch,\n ComponentInterface,\n Event,\n EventEmitter,\n readTask,\n} from '@stencil/core';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport { debounce } from '../../utils';\nimport type { ResizeStateChangeEventDetail } from '../../interface';\n\ntype ResizeObserverState = { states?: string[]; applied?: boolean };\ninterface StateMaps {\n h: Map<number, ResizeObserverState>;\n w: Map<number, ResizeObserverState>;\n}\n\n/**\n * A Resize-Observer utility component.\n * Takes a string list of sizes and optional class-names. Adds class-names and fires `nanoResizeStateChange` events when the component reaches those sizes.\n * @slot - Main slot for any content.\n */\n@Component({\n tag: 'nano-resize-observe',\n shadow: true,\n styles: `:host { display: inline-block } div { height: 100%; }`,\n})\nexport class ResizeObserve implements ComponentInterface {\n private ro: ResizeObserver;\n private appliedStates: StateMaps;\n\n @Element() host: HTMLNanoResizeObserveElement;\n @State() currentWidth: number;\n @State() currentHeight: number;\n @State() classNames: string[] = [];\n\n /** string list of sizes and optional class-names. Adds class-names and fires nanoResizeStateChange events. Upon hitting breakpoints.\n * Format: `states=\"800w, 300h class1 class2\"` */\n @Prop() states: string;\n\n /** A resize break point is switched on or off */\n @Event() nanoResizeStateChange!: EventEmitter<ResizeStateChangeEventDetail>;\n\n @Watch('currentHeight')\n @Watch('currentWidth')\n dimensionChanged() {\n this.assessChanges();\n }\n\n @Watch('states')\n statesChanged() {\n if (!this.states) return;\n if (!this.ro) this.attachRO();\n\n const toBpDir = (bpDir: string) => {\n const bpDirSpl = bpDir.split(/(\\d+)/).filter((bs) => bs.length);\n return { bp: parseInt(bpDirSpl[0]), dir: bpDirSpl[1] };\n };\n this.appliedStates = { h: new Map(), w: new Map() };\n\n // parse state string\n this.states.split(',').map((st) => {\n st = st.trim();\n if (st.includes(' ')) {\n const [key, ...classes] = st.split(' ');\n const { bp, dir } = toBpDir(key);\n this.appliedStates[dir as keyof StateMaps].set(bp, {\n states: classes,\n applied: false,\n });\n } else {\n const { bp, dir } = toBpDir(st);\n this.appliedStates[dir as keyof StateMaps].set(bp, { applied: false });\n }\n });\n }\n\n private assessChanges = () => {\n if (!this.currentWidth && !this.currentHeight) return;\n const changedStates: StateMaps = { h: new Map(), w: new Map() };\n let hasChanged = false;\n\n Object.keys(this.appliedStates).forEach((dimType) => {\n let dim: number;\n if (dimType === 'h') dim = this.currentHeight;\n else dim = this.currentWidth;\n\n this.appliedStates[dimType].forEach(\n (state: ResizeObserverState, bp: number) => {\n if (dim >= bp && state.applied === false) {\n state.applied = true;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n } else if (dim < bp && state.applied === true) {\n state.applied = false;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n }\n }\n );\n });\n if (hasChanged) this.applyChanges(changedStates);\n else if (!this.classNames.includes('is-ready'))\n this.classNames = ['is-ready'];\n };\n\n private applyChanges(changes: StateMaps) {\n let classNames = [...this.classNames];\n Object.keys(changes).forEach((dimType: keyof StateMaps) => {\n changes[dimType].forEach((state) => {\n if (!state.states) return;\n state.states.map((st) => {\n if (state.applied) classNames.push(st);\n else classNames = classNames.filter((cl) => cl !== st);\n });\n });\n });\n this.classNames = ['is-ready', ...classNames];\n this.nanoResizeStateChange.emit(this.toSimpleObj(changes));\n }\n\n private toSimpleObj(stateMaps: StateMaps) {\n const retObj = {};\n Object.keys(stateMaps).forEach((dimType: keyof StateMaps) => {\n stateMaps[dimType].forEach((state: ResizeObserverState, bp: number) => {\n retObj[bp + dimType] = state.applied;\n });\n });\n return retObj;\n }\n\n private attachRO() {\n this.ro = new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.currentWidth = entry.contentRect.width;\n this.currentHeight = entry.contentRect.height;\n }\n });\n this.ro.observe(this.host);\n }\n\n connectedCallback() {\n this.assessChanges = debounce(this.assessChanges, 50);\n }\n\n componentDidLoad() {\n if (!this.states) return;\n if (!this.currentWidth || !this.currentHeight) {\n readTask(() => {\n const { width, height } = this.host.getBoundingClientRect();\n this.currentWidth = width;\n this.currentHeight = height;\n });\n }\n this.statesChanged();\n }\n\n disconnectedCallback() {\n if (this.ro) this.ro.disconnect();\n }\n\n render() {\n return (\n <Host\n class={{\n [this.classNames.join(' ')]: true,\n }}\n >\n <slot />\n </Host>\n );\n }\n}\n"]}