q2-tecton-elements 1.51.0 → 1.52.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 (613) hide show
  1. package/dist/cjs/click-elsewhere_2.cjs.entry.js +16 -5
  2. package/dist/cjs/click-elsewhere_2.cjs.entry.js.map +1 -1
  3. package/dist/cjs/{index-9aa4a776.js → index-07285783.js} +86 -2
  4. package/dist/cjs/index-07285783.js.map +1 -0
  5. package/dist/cjs/{index-14c3693c.js → index-e7e68b1e.js} +40 -5
  6. package/dist/cjs/index-e7e68b1e.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/q2-action-group.cjs.entry.js +2 -2
  9. package/dist/cjs/q2-action-sheet.cjs.entry.js +3 -3
  10. package/dist/cjs/q2-avatar.cjs.entry.js +2 -2
  11. package/dist/cjs/q2-badge_7.cjs.entry.js +49 -44
  12. package/dist/cjs/q2-badge_7.cjs.entry.js.map +1 -1
  13. package/dist/cjs/q2-calendar.cjs.entry.js +17 -20
  14. package/dist/cjs/q2-calendar.cjs.entry.js.map +1 -1
  15. package/dist/cjs/q2-card.cjs.entry.js +4 -2
  16. package/dist/cjs/q2-card.cjs.entry.js.map +1 -1
  17. package/dist/cjs/q2-carousel-pane.cjs.entry.js +4 -4
  18. package/dist/cjs/q2-carousel.cjs.entry.js +2 -2
  19. package/dist/cjs/q2-chart-area.cjs.entry.js +16 -3
  20. package/dist/cjs/q2-chart-area.cjs.entry.js.map +1 -1
  21. package/dist/cjs/q2-chart-bar.cjs.entry.js +3 -3
  22. package/dist/cjs/q2-chart-donut.cjs.entry.js +19 -3
  23. package/dist/cjs/q2-chart-donut.cjs.entry.js.map +1 -1
  24. package/dist/cjs/q2-checkbox-group.cjs.entry.js +6 -5
  25. package/dist/cjs/q2-checkbox-group.cjs.entry.js.map +1 -1
  26. package/dist/cjs/q2-checkbox.cjs.entry.js +2 -2
  27. package/dist/cjs/q2-currency.cjs.entry.js +14 -2
  28. package/dist/cjs/q2-currency.cjs.entry.js.map +1 -1
  29. package/dist/cjs/q2-data-table.cjs.entry.js +3 -3
  30. package/dist/cjs/q2-data-table.cjs.entry.js.map +1 -1
  31. package/dist/cjs/q2-detail.cjs.entry.js +3 -3
  32. package/dist/cjs/q2-dropdown-item.cjs.entry.js +12 -14
  33. package/dist/cjs/q2-dropdown-item.cjs.entry.js.map +1 -1
  34. package/dist/cjs/q2-dropdown.cjs.entry.js +7 -5
  35. package/dist/cjs/q2-dropdown.cjs.entry.js.map +1 -1
  36. package/dist/cjs/q2-editable-field.cjs.entry.js +3 -3
  37. package/dist/cjs/q2-example.cjs.entry.js +145 -0
  38. package/dist/cjs/q2-example.cjs.entry.js.map +1 -0
  39. package/dist/cjs/q2-formatted-text.cjs.entry.js +2 -2
  40. package/dist/cjs/q2-item.cjs.entry.js +3 -3
  41. package/dist/cjs/q2-legend.cjs.entry.js +2 -2
  42. package/dist/cjs/q2-link.cjs.entry.js +4 -4
  43. package/dist/cjs/q2-link.cjs.entry.js.map +1 -1
  44. package/dist/cjs/q2-list.cjs.entry.js +6 -7
  45. package/dist/cjs/q2-list.cjs.entry.js.map +1 -1
  46. package/dist/cjs/q2-loading-element.cjs.entry.js +2 -2
  47. package/dist/cjs/q2-loc.cjs.entry.js +52 -3
  48. package/dist/cjs/q2-loc.cjs.entry.js.map +1 -1
  49. package/dist/cjs/q2-message.cjs.entry.js +3 -3
  50. package/dist/cjs/q2-month-picker.cjs.entry.js +4 -4
  51. package/dist/cjs/q2-optgroup.cjs.entry.js +5 -4
  52. package/dist/cjs/q2-optgroup.cjs.entry.js.map +1 -1
  53. package/dist/cjs/q2-option-list.cjs.entry.js +2 -2
  54. package/dist/cjs/q2-option.cjs.entry.js +50 -33
  55. package/dist/cjs/q2-option.cjs.entry.js.map +1 -1
  56. package/dist/cjs/q2-pagination.cjs.entry.js +11 -7
  57. package/dist/cjs/q2-pagination.cjs.entry.js.map +1 -1
  58. package/dist/cjs/q2-pill.cjs.entry.js +19 -18
  59. package/dist/cjs/q2-pill.cjs.entry.js.map +1 -1
  60. package/dist/cjs/q2-radio-group.cjs.entry.js +5 -5
  61. package/dist/cjs/q2-radio-group.cjs.entry.js.map +1 -1
  62. package/dist/cjs/q2-radio.cjs.entry.js +3 -3
  63. package/dist/cjs/q2-relative-time.cjs.entry.js +3 -3
  64. package/dist/cjs/q2-resize-observer.cjs.entry.js +2 -2
  65. package/dist/cjs/q2-section.cjs.entry.js +8 -6
  66. package/dist/cjs/q2-section.cjs.entry.js.map +1 -1
  67. package/dist/cjs/q2-select.cjs.entry.js +6 -5
  68. package/dist/cjs/q2-select.cjs.entry.js.map +1 -1
  69. package/dist/cjs/q2-stepper-pane.cjs.entry.js +5 -4
  70. package/dist/cjs/q2-stepper-pane.cjs.entry.js.map +1 -1
  71. package/dist/cjs/q2-stepper-vertical.cjs.entry.js +16 -4
  72. package/dist/cjs/q2-stepper-vertical.cjs.entry.js.map +1 -1
  73. package/dist/cjs/q2-stepper.cjs.entry.js +6 -4
  74. package/dist/cjs/q2-stepper.cjs.entry.js.map +1 -1
  75. package/dist/cjs/q2-tag.cjs.entry.js +6 -4
  76. package/dist/cjs/q2-tag.cjs.entry.js.map +1 -1
  77. package/dist/cjs/q2-tecton-elements.cjs.js +2 -2
  78. package/dist/cjs/q2-textarea.cjs.entry.js +3 -3
  79. package/dist/cjs/q2-tooltip.cjs.entry.js +2 -2
  80. package/dist/cjs/{shapes-be198cc0.js → shapes-5d45fc11.js} +2 -2
  81. package/dist/cjs/{shapes-be198cc0.js.map → shapes-5d45fc11.js.map} +1 -1
  82. package/dist/cjs/tecton-tab-pane.cjs.entry.js +3 -3
  83. package/dist/collection/collection-manifest.json +1 -0
  84. package/dist/collection/components/q2-action-group/q2-action-group.js +1 -1
  85. package/dist/collection/components/q2-action-sheet/q2-action-sheet.js +1 -1
  86. package/dist/collection/components/q2-avatar/q2-avatar.js +1 -1
  87. package/dist/collection/components/q2-calendar/q2-calendar.js +16 -18
  88. package/dist/collection/components/q2-calendar/q2-calendar.js.map +1 -1
  89. package/dist/collection/components/q2-calendar/q2-month-picker.js +2 -2
  90. package/dist/collection/components/q2-calendar/test/q2-calendar-test.e2e.js +27 -0
  91. package/dist/collection/components/q2-calendar/test/q2-calendar-test.e2e.js.map +1 -1
  92. package/dist/collection/components/q2-card/q2-card.js +2 -0
  93. package/dist/collection/components/q2-card/q2-card.js.map +1 -1
  94. package/dist/collection/components/q2-carousel-pane/q2-carousel-pane.js +2 -2
  95. package/dist/collection/components/q2-chart-area/q2-chart-area.js +42 -1
  96. package/dist/collection/components/q2-chart-area/q2-chart-area.js.map +1 -1
  97. package/dist/collection/components/q2-chart-area/test/q2-chart-area-test.e2e.js +15 -0
  98. package/dist/collection/components/q2-chart-area/test/q2-chart-area-test.e2e.js.map +1 -1
  99. package/dist/collection/components/q2-chart-bar/q2-chart-bar.js +1 -1
  100. package/dist/collection/components/q2-chart-donut/q2-chart-donut.js +41 -1
  101. package/dist/collection/components/q2-chart-donut/q2-chart-donut.js.map +1 -1
  102. package/dist/collection/components/q2-chart-donut/test/q2-chart-donut-test.e2e.js +11 -0
  103. package/dist/collection/components/q2-chart-donut/test/q2-chart-donut-test.e2e.js.map +1 -1
  104. package/dist/collection/components/q2-checkbox-group/q2-checkbox-group.css +30 -23
  105. package/dist/collection/components/q2-checkbox-group/q2-checkbox-group.js +4 -3
  106. package/dist/collection/components/q2-checkbox-group/q2-checkbox-group.js.map +1 -1
  107. package/dist/collection/components/q2-currency/q2-currency.js +37 -1
  108. package/dist/collection/components/q2-currency/q2-currency.js.map +1 -1
  109. package/dist/collection/components/q2-currency/test/q2-currency-test.e2e.js +34 -23
  110. package/dist/collection/components/q2-currency/test/q2-currency-test.e2e.js.map +1 -1
  111. package/dist/collection/components/q2-data-table/q2-data-table.js +1 -1
  112. package/dist/collection/components/q2-data-table/q2-data-table.js.map +1 -1
  113. package/dist/collection/components/q2-data-table/test/q2-data-table-test.e2e.js +6 -4
  114. package/dist/collection/components/q2-data-table/test/q2-data-table-test.e2e.js.map +1 -1
  115. package/dist/collection/components/q2-detail/q2-detail.js +1 -1
  116. package/dist/collection/components/q2-dropdown/q2-dropdown.css +5 -0
  117. package/dist/collection/components/q2-dropdown/q2-dropdown.js +10 -4
  118. package/dist/collection/components/q2-dropdown/q2-dropdown.js.map +1 -1
  119. package/dist/collection/components/q2-dropdown/test/q2-dropdown-test.e2e.js +59 -14
  120. package/dist/collection/components/q2-dropdown/test/q2-dropdown-test.e2e.js.map +1 -1
  121. package/dist/collection/components/q2-dropdown-item/q2-dropdown-item.css +29 -11
  122. package/dist/collection/components/q2-dropdown-item/q2-dropdown-item.js +9 -11
  123. package/dist/collection/components/q2-dropdown-item/q2-dropdown-item.js.map +1 -1
  124. package/dist/collection/components/q2-dropdown-item/test/q2-dropdown-item-test.e2e.js +108 -74
  125. package/dist/collection/components/q2-dropdown-item/test/q2-dropdown-item-test.e2e.js.map +1 -1
  126. package/dist/collection/components/q2-editable-field/q2-editable-field.js +1 -1
  127. package/dist/collection/components/q2-example/q2-example.css +66 -0
  128. package/dist/collection/components/q2-example/q2-example.js +312 -0
  129. package/dist/collection/components/q2-example/q2-example.js.map +1 -0
  130. package/dist/collection/components/q2-example/test/q2-example.e2e.js +27 -0
  131. package/dist/collection/components/q2-example/test/q2-example.e2e.js.map +1 -0
  132. package/dist/collection/components/q2-example/test/q2-example.spec.js +126 -0
  133. package/dist/collection/components/q2-example/test/q2-example.spec.js.map +1 -0
  134. package/dist/collection/components/q2-formatted-text/q2-formatted-text.js +1 -1
  135. package/dist/collection/components/q2-input/formatting/alpha.spec.js +10 -0
  136. package/dist/collection/components/q2-input/formatting/alpha.spec.js.map +1 -0
  137. package/dist/collection/components/q2-input/formatting/alphanumeric.spec.js +7 -0
  138. package/dist/collection/components/q2-input/formatting/alphanumeric.spec.js.map +1 -0
  139. package/dist/collection/components/q2-input/formatting/currency.spec.js +20 -0
  140. package/dist/collection/components/q2-input/formatting/currency.spec.js.map +1 -0
  141. package/dist/collection/components/q2-input/formatting/date.js +1 -1
  142. package/dist/collection/components/q2-input/formatting/date.js.map +1 -1
  143. package/dist/collection/components/q2-input/formatting/date.spec.js +17 -0
  144. package/dist/collection/components/q2-input/formatting/date.spec.js.map +1 -0
  145. package/dist/collection/components/q2-input/formatting/numeric.spec.js +32 -0
  146. package/dist/collection/components/q2-input/formatting/numeric.spec.js.map +1 -0
  147. package/dist/collection/components/q2-input/formatting/phone.spec.js +16 -0
  148. package/dist/collection/components/q2-input/formatting/phone.spec.js.map +1 -0
  149. package/dist/collection/components/q2-input/formatting/postal.js +1 -1
  150. package/dist/collection/components/q2-input/formatting/postal.js.map +1 -1
  151. package/dist/collection/components/q2-input/formatting/postal.spec.js +28 -0
  152. package/dist/collection/components/q2-input/formatting/postal.spec.js.map +1 -0
  153. package/dist/collection/components/q2-input/formatting/ssn.spec.js +7 -0
  154. package/dist/collection/components/q2-input/formatting/ssn.spec.js.map +1 -0
  155. package/dist/collection/components/q2-input/formatting/tin.spec.js +7 -0
  156. package/dist/collection/components/q2-input/formatting/tin.spec.js.map +1 -0
  157. package/dist/collection/components/q2-input/q2-input.js +58 -44
  158. package/dist/collection/components/q2-input/q2-input.js.map +1 -1
  159. package/dist/collection/components/q2-input/test/q2-input-test.e2e.js +259 -2106
  160. package/dist/collection/components/q2-input/test/q2-input-test.e2e.js.map +1 -1
  161. package/dist/collection/components/q2-input/test/q2-input-test.spec.js +4035 -0
  162. package/dist/collection/components/q2-input/test/q2-input-test.spec.js.map +1 -0
  163. package/dist/collection/components/q2-item/q2-item.js +1 -1
  164. package/dist/collection/components/q2-legend/q2-legend.js +1 -1
  165. package/dist/collection/components/q2-link/q2-link.css +17 -20
  166. package/dist/collection/components/q2-link/q2-link.js +2 -2
  167. package/dist/collection/components/q2-link/q2-link.js.map +1 -1
  168. package/dist/collection/components/q2-link/test/q2-link-test.e2e.js +6 -6
  169. package/dist/collection/components/q2-link/test/q2-link-test.e2e.js.map +1 -1
  170. package/dist/collection/components/q2-list/q2-list.js +4 -5
  171. package/dist/collection/components/q2-list/q2-list.js.map +1 -1
  172. package/dist/collection/components/q2-loc/q2-loc.js +66 -4
  173. package/dist/collection/components/q2-loc/q2-loc.js.map +1 -1
  174. package/dist/collection/components/q2-loc/test/q2-loc-test.e2e.js +19 -30
  175. package/dist/collection/components/q2-loc/test/q2-loc-test.e2e.js.map +1 -1
  176. package/dist/collection/components/q2-loc/test/q2-loc-test.spec.js +164 -0
  177. package/dist/collection/components/q2-loc/test/q2-loc-test.spec.js.map +1 -0
  178. package/dist/collection/components/q2-message/q2-message.js +1 -1
  179. package/dist/collection/components/q2-optgroup/q2-optgroup.js +3 -2
  180. package/dist/collection/components/q2-optgroup/q2-optgroup.js.map +1 -1
  181. package/dist/collection/components/q2-option/q2-option.css +1 -1
  182. package/dist/collection/components/q2-option/q2-option.js +57 -34
  183. package/dist/collection/components/q2-option/q2-option.js.map +1 -1
  184. package/dist/collection/components/q2-option/test/q2-option-test.e2e.js +110 -106
  185. package/dist/collection/components/q2-option/test/q2-option-test.e2e.js.map +1 -1
  186. package/dist/collection/components/q2-option/test/q2-option-test.spec.js +532 -0
  187. package/dist/collection/components/q2-option/test/q2-option-test.spec.js.map +1 -0
  188. package/dist/collection/components/q2-pagination/q2-pagination.js +9 -5
  189. package/dist/collection/components/q2-pagination/q2-pagination.js.map +1 -1
  190. package/dist/collection/components/q2-pagination/test/q2-pagination-test.e2e.js +18 -1
  191. package/dist/collection/components/q2-pagination/test/q2-pagination-test.e2e.js.map +1 -1
  192. package/dist/collection/components/q2-pill/q2-pill.js +18 -17
  193. package/dist/collection/components/q2-pill/q2-pill.js.map +1 -1
  194. package/dist/collection/components/q2-pill/test/q2-pill-test.e2e.js +128 -57
  195. package/dist/collection/components/q2-pill/test/q2-pill-test.e2e.js.map +1 -1
  196. package/dist/collection/components/q2-popover/q2-popover.js +17 -4
  197. package/dist/collection/components/q2-popover/q2-popover.js.map +1 -1
  198. package/dist/collection/components/q2-radio/q2-radio.js +1 -1
  199. package/dist/collection/components/q2-radio-group/q2-radio-group.css +19 -9
  200. package/dist/collection/components/q2-radio-group/q2-radio-group.js +2 -2
  201. package/dist/collection/components/q2-radio-group/q2-radio-group.js.map +1 -1
  202. package/dist/collection/components/q2-relative-time/q2-relative-time.js +1 -1
  203. package/dist/collection/components/q2-resize-observer/q2-resize-observer.js +1 -1
  204. package/dist/collection/components/q2-section/q2-section.js +6 -4
  205. package/dist/collection/components/q2-section/q2-section.js.map +1 -1
  206. package/dist/collection/components/q2-select/q2-select.js +5 -3
  207. package/dist/collection/components/q2-select/q2-select.js.map +1 -1
  208. package/dist/collection/components/q2-select/test/q2-select-test.e2e.js +123 -62
  209. package/dist/collection/components/q2-select/test/q2-select-test.e2e.js.map +1 -1
  210. package/dist/collection/components/q2-stepper/q2-stepper.js +4 -2
  211. package/dist/collection/components/q2-stepper/q2-stepper.js.map +1 -1
  212. package/dist/collection/components/q2-stepper-pane/q2-stepper-pane.js +3 -2
  213. package/dist/collection/components/q2-stepper-pane/q2-stepper-pane.js.map +1 -1
  214. package/dist/collection/components/q2-stepper-vertical/q2-stepper-vertical.js +46 -2
  215. package/dist/collection/components/q2-stepper-vertical/q2-stepper-vertical.js.map +1 -1
  216. package/dist/collection/components/q2-stepper-vertical/test/q2-stepper-vertical-test.e2e.js +26 -0
  217. package/dist/collection/components/q2-stepper-vertical/test/q2-stepper-vertical-test.e2e.js.map +1 -1
  218. package/dist/collection/components/q2-tab-container/q2-tab-container.js +4 -3
  219. package/dist/collection/components/q2-tab-container/q2-tab-container.js.map +1 -1
  220. package/dist/collection/components/q2-tab-pane/q2-tab-pane.js +1 -1
  221. package/dist/collection/components/q2-tag/q2-tag.js +5 -2
  222. package/dist/collection/components/q2-tag/q2-tag.js.map +1 -1
  223. package/dist/collection/components/q2-tag/test/q2-tag-test.e2e.js +55 -4
  224. package/dist/collection/components/q2-tag/test/q2-tag-test.e2e.js.map +1 -1
  225. package/dist/collection/components/q2-textarea/q2-textarea.js +1 -1
  226. package/dist/collection/components/tecton-tab-pane/tecton-tab-pane.js +2 -2
  227. package/dist/collection/utils/helpers.js +63 -41
  228. package/dist/collection/utils/helpers.js.map +1 -1
  229. package/dist/collection/utils/index.js +83 -0
  230. package/dist/collection/utils/index.js.map +1 -1
  231. package/dist/components/index.js +2 -0
  232. package/dist/components/index.js.map +1 -1
  233. package/dist/components/index2.js +84 -1
  234. package/dist/components/index2.js.map +1 -1
  235. package/dist/components/q2-action-group.js +1 -1
  236. package/dist/components/q2-action-sheet.js +1 -1
  237. package/dist/components/q2-avatar2.js +1 -1
  238. package/dist/components/q2-calendar.js +16 -18
  239. package/dist/components/q2-calendar.js.map +1 -1
  240. package/dist/components/q2-card.js +2 -0
  241. package/dist/components/q2-card.js.map +1 -1
  242. package/dist/components/q2-carousel-pane.js +2 -2
  243. package/dist/components/q2-chart-area.js +16 -2
  244. package/dist/components/q2-chart-area.js.map +1 -1
  245. package/dist/components/q2-chart-bar.js +1 -1
  246. package/dist/components/q2-chart-donut.js +19 -2
  247. package/dist/components/q2-chart-donut.js.map +1 -1
  248. package/dist/components/q2-checkbox-group.js +5 -4
  249. package/dist/components/q2-checkbox-group.js.map +1 -1
  250. package/dist/components/q2-currency.js +15 -2
  251. package/dist/components/q2-currency.js.map +1 -1
  252. package/dist/components/q2-data-table.js +1 -1
  253. package/dist/components/q2-data-table.js.map +1 -1
  254. package/dist/components/q2-detail.js +1 -1
  255. package/dist/components/q2-dropdown-item2.js +12 -26
  256. package/dist/components/q2-dropdown-item2.js.map +1 -1
  257. package/dist/components/q2-dropdown.js +6 -3
  258. package/dist/components/q2-dropdown.js.map +1 -1
  259. package/dist/components/q2-editable-field.js +1 -1
  260. package/dist/components/q2-example.d.ts +11 -0
  261. package/dist/components/q2-example.js +170 -0
  262. package/dist/components/q2-example.js.map +1 -0
  263. package/dist/components/q2-formatted-text.js +1 -1
  264. package/dist/components/q2-input2.js +41 -37
  265. package/dist/components/q2-input2.js.map +1 -1
  266. package/dist/components/q2-item.js +1 -1
  267. package/dist/components/q2-legend2.js +1 -1
  268. package/dist/components/q2-link.js +3 -3
  269. package/dist/components/q2-link.js.map +1 -1
  270. package/dist/components/q2-list.js +4 -5
  271. package/dist/components/q2-list.js.map +1 -1
  272. package/dist/components/q2-loc.js +55 -2
  273. package/dist/components/q2-loc.js.map +1 -1
  274. package/dist/components/q2-message2.js +1 -1
  275. package/dist/components/q2-month-picker.js +2 -2
  276. package/dist/components/q2-optgroup2.js +3 -2
  277. package/dist/components/q2-optgroup2.js.map +1 -1
  278. package/dist/components/q2-option-list2.js +1 -1
  279. package/dist/components/q2-option2.js +52 -33
  280. package/dist/components/q2-option2.js.map +1 -1
  281. package/dist/components/q2-pagination.js +9 -5
  282. package/dist/components/q2-pagination.js.map +1 -1
  283. package/dist/components/q2-pill.js +18 -17
  284. package/dist/components/q2-pill.js.map +1 -1
  285. package/dist/components/q2-popover2.js +16 -4
  286. package/dist/components/q2-popover2.js.map +1 -1
  287. package/dist/components/q2-radio-group.js +3 -3
  288. package/dist/components/q2-radio-group.js.map +1 -1
  289. package/dist/components/q2-radio.js +1 -1
  290. package/dist/components/q2-relative-time.js +1 -1
  291. package/dist/components/q2-resize-observer2.js +1 -1
  292. package/dist/components/q2-section.js +6 -4
  293. package/dist/components/q2-section.js.map +1 -1
  294. package/dist/components/q2-select2.js +6 -4
  295. package/dist/components/q2-select2.js.map +1 -1
  296. package/dist/components/q2-stepper-pane.js +3 -2
  297. package/dist/components/q2-stepper-pane.js.map +1 -1
  298. package/dist/components/q2-stepper-vertical.js +16 -3
  299. package/dist/components/q2-stepper-vertical.js.map +1 -1
  300. package/dist/components/q2-stepper.js +4 -2
  301. package/dist/components/q2-stepper.js.map +1 -1
  302. package/dist/components/q2-tab-container.js +4 -3
  303. package/dist/components/q2-tab-container.js.map +1 -1
  304. package/dist/components/q2-tab-pane.js +1 -1
  305. package/dist/components/q2-tag.js +5 -2
  306. package/dist/components/q2-tag.js.map +1 -1
  307. package/dist/components/q2-textarea.js +1 -1
  308. package/dist/components/tecton-tab-pane.js +2 -2
  309. package/dist/esm/click-elsewhere_2.entry.js +16 -5
  310. package/dist/esm/click-elsewhere_2.entry.js.map +1 -1
  311. package/dist/esm/{index-1e1ce94e.js → index-7a5365e2.js} +40 -5
  312. package/dist/esm/index-7a5365e2.js.map +1 -0
  313. package/dist/esm/{index-844fc010.js → index-d18e2a20.js} +86 -3
  314. package/dist/esm/index-d18e2a20.js.map +1 -0
  315. package/dist/esm/loader.js +3 -3
  316. package/dist/esm/q2-action-group.entry.js +2 -2
  317. package/dist/esm/q2-action-sheet.entry.js +3 -3
  318. package/dist/esm/q2-avatar.entry.js +2 -2
  319. package/dist/esm/q2-badge_7.entry.js +49 -44
  320. package/dist/esm/q2-badge_7.entry.js.map +1 -1
  321. package/dist/esm/q2-calendar.entry.js +17 -20
  322. package/dist/esm/q2-calendar.entry.js.map +1 -1
  323. package/dist/esm/q2-card.entry.js +4 -2
  324. package/dist/esm/q2-card.entry.js.map +1 -1
  325. package/dist/esm/q2-carousel-pane.entry.js +4 -4
  326. package/dist/esm/q2-carousel.entry.js +2 -2
  327. package/dist/esm/q2-chart-area.entry.js +16 -3
  328. package/dist/esm/q2-chart-area.entry.js.map +1 -1
  329. package/dist/esm/q2-chart-bar.entry.js +3 -3
  330. package/dist/esm/q2-chart-donut.entry.js +19 -3
  331. package/dist/esm/q2-chart-donut.entry.js.map +1 -1
  332. package/dist/esm/q2-checkbox-group.entry.js +6 -5
  333. package/dist/esm/q2-checkbox-group.entry.js.map +1 -1
  334. package/dist/esm/q2-checkbox.entry.js +2 -2
  335. package/dist/esm/q2-currency.entry.js +14 -2
  336. package/dist/esm/q2-currency.entry.js.map +1 -1
  337. package/dist/esm/q2-data-table.entry.js +3 -3
  338. package/dist/esm/q2-data-table.entry.js.map +1 -1
  339. package/dist/esm/q2-detail.entry.js +3 -3
  340. package/dist/esm/q2-dropdown-item.entry.js +12 -14
  341. package/dist/esm/q2-dropdown-item.entry.js.map +1 -1
  342. package/dist/esm/q2-dropdown.entry.js +7 -5
  343. package/dist/esm/q2-dropdown.entry.js.map +1 -1
  344. package/dist/esm/q2-editable-field.entry.js +3 -3
  345. package/dist/esm/q2-example.entry.js +141 -0
  346. package/dist/esm/q2-example.entry.js.map +1 -0
  347. package/dist/esm/q2-formatted-text.entry.js +2 -2
  348. package/dist/esm/q2-item.entry.js +3 -3
  349. package/dist/esm/q2-legend.entry.js +2 -2
  350. package/dist/esm/q2-link.entry.js +4 -4
  351. package/dist/esm/q2-link.entry.js.map +1 -1
  352. package/dist/esm/q2-list.entry.js +6 -7
  353. package/dist/esm/q2-list.entry.js.map +1 -1
  354. package/dist/esm/q2-loading-element.entry.js +2 -2
  355. package/dist/esm/q2-loc.entry.js +52 -3
  356. package/dist/esm/q2-loc.entry.js.map +1 -1
  357. package/dist/esm/q2-message.entry.js +3 -3
  358. package/dist/esm/q2-month-picker.entry.js +4 -4
  359. package/dist/esm/q2-optgroup.entry.js +5 -4
  360. package/dist/esm/q2-optgroup.entry.js.map +1 -1
  361. package/dist/esm/q2-option-list.entry.js +2 -2
  362. package/dist/esm/q2-option.entry.js +50 -33
  363. package/dist/esm/q2-option.entry.js.map +1 -1
  364. package/dist/esm/q2-pagination.entry.js +11 -7
  365. package/dist/esm/q2-pagination.entry.js.map +1 -1
  366. package/dist/esm/q2-pill.entry.js +19 -18
  367. package/dist/esm/q2-pill.entry.js.map +1 -1
  368. package/dist/esm/q2-radio-group.entry.js +5 -5
  369. package/dist/esm/q2-radio-group.entry.js.map +1 -1
  370. package/dist/esm/q2-radio.entry.js +3 -3
  371. package/dist/esm/q2-relative-time.entry.js +3 -3
  372. package/dist/esm/q2-resize-observer.entry.js +2 -2
  373. package/dist/esm/q2-section.entry.js +8 -6
  374. package/dist/esm/q2-section.entry.js.map +1 -1
  375. package/dist/esm/q2-select.entry.js +6 -5
  376. package/dist/esm/q2-select.entry.js.map +1 -1
  377. package/dist/esm/q2-stepper-pane.entry.js +5 -4
  378. package/dist/esm/q2-stepper-pane.entry.js.map +1 -1
  379. package/dist/esm/q2-stepper-vertical.entry.js +16 -4
  380. package/dist/esm/q2-stepper-vertical.entry.js.map +1 -1
  381. package/dist/esm/q2-stepper.entry.js +6 -4
  382. package/dist/esm/q2-stepper.entry.js.map +1 -1
  383. package/dist/esm/q2-tag.entry.js +6 -4
  384. package/dist/esm/q2-tag.entry.js.map +1 -1
  385. package/dist/esm/q2-tecton-elements.js +3 -3
  386. package/dist/esm/q2-textarea.entry.js +3 -3
  387. package/dist/esm/q2-tooltip.entry.js +2 -2
  388. package/dist/esm/{shapes-36183b2a.js → shapes-c7e1a3fa.js} +2 -2
  389. package/dist/esm/{shapes-36183b2a.js.map → shapes-c7e1a3fa.js.map} +1 -1
  390. package/dist/esm/tecton-tab-pane.entry.js +3 -3
  391. package/dist/q2-tecton-elements/action-sheet-e64cb6f7.js +77 -0
  392. package/dist/q2-tecton-elements/{p-b7554a79.js.map → action-sheet-e64cb6f7.js.map} +1 -1
  393. package/dist/q2-tecton-elements/app-globals-0f993ce5.js +4 -0
  394. package/dist/q2-tecton-elements/{p-e1255160.js.map → app-globals-0f993ce5.js.map} +1 -1
  395. package/dist/q2-tecton-elements/charting-1abfb877.js +34872 -0
  396. package/dist/q2-tecton-elements/{p-2941aafa.js.map → charting-1abfb877.js.map} +1 -1
  397. package/dist/q2-tecton-elements/click-elsewhere_2.entry.js +410 -0
  398. package/dist/q2-tecton-elements/click-elsewhere_2.entry.js.map +1 -0
  399. package/dist/q2-tecton-elements/dataSample-7b62e101.js +2602 -0
  400. package/dist/q2-tecton-elements/{p-ad80aef0.js.map → dataSample-7b62e101.js.map} +1 -1
  401. package/dist/q2-tecton-elements/index-3184c760.js +18168 -0
  402. package/dist/q2-tecton-elements/{p-f1e887f5.js.map → index-3184c760.js.map} +1 -1
  403. package/dist/q2-tecton-elements/index-7a5365e2.js +1792 -0
  404. package/dist/q2-tecton-elements/index-7a5365e2.js.map +1 -0
  405. package/dist/q2-tecton-elements/index-d18e2a20.js +323 -0
  406. package/dist/q2-tecton-elements/index-d18e2a20.js.map +1 -0
  407. package/dist/q2-tecton-elements/q2-action-group.entry.js +56 -0
  408. package/dist/q2-tecton-elements/{p-5637c486.entry.js.map → q2-action-group.entry.js.map} +1 -1
  409. package/dist/q2-tecton-elements/q2-action-sheet.entry.js +1480 -0
  410. package/dist/q2-tecton-elements/{p-188eb162.entry.js.map → q2-action-sheet.entry.js.map} +1 -1
  411. package/dist/q2-tecton-elements/q2-avatar.entry.js +101 -0
  412. package/dist/q2-tecton-elements/{p-07d1c3ae.entry.js.map → q2-avatar.entry.js.map} +1 -1
  413. package/dist/q2-tecton-elements/q2-badge_7.entry.js +5449 -0
  414. package/dist/q2-tecton-elements/q2-badge_7.entry.js.map +1 -0
  415. package/dist/q2-tecton-elements/q2-calendar.entry.js +1313 -0
  416. package/dist/q2-tecton-elements/q2-calendar.entry.js.map +1 -0
  417. package/dist/q2-tecton-elements/q2-card.entry.js +170 -0
  418. package/dist/q2-tecton-elements/q2-card.entry.js.map +1 -0
  419. package/dist/q2-tecton-elements/q2-carousel-pane.entry.js +130 -0
  420. package/dist/q2-tecton-elements/{p-7aef0c08.entry.js.map → q2-carousel-pane.entry.js.map} +1 -1
  421. package/dist/q2-tecton-elements/q2-carousel.entry.js +4613 -0
  422. package/dist/q2-tecton-elements/{p-e216ef3f.entry.js.map → q2-carousel.entry.js.map} +1 -1
  423. package/dist/q2-tecton-elements/q2-chart-area.entry.js +4330 -0
  424. package/dist/q2-tecton-elements/q2-chart-area.entry.js.map +1 -0
  425. package/dist/q2-tecton-elements/q2-chart-bar.entry.js +1479 -0
  426. package/dist/q2-tecton-elements/{p-7906f49e.entry.js.map → q2-chart-bar.entry.js.map} +1 -1
  427. package/dist/q2-tecton-elements/q2-chart-donut.entry.js +4537 -0
  428. package/dist/q2-tecton-elements/q2-chart-donut.entry.js.map +1 -0
  429. package/dist/q2-tecton-elements/q2-checkbox-group.entry.js +166 -0
  430. package/dist/q2-tecton-elements/q2-checkbox-group.entry.js.map +1 -0
  431. package/dist/q2-tecton-elements/q2-checkbox.entry.js +223 -0
  432. package/dist/q2-tecton-elements/{p-b7de110e.entry.js.map → q2-checkbox.entry.js.map} +1 -1
  433. package/dist/q2-tecton-elements/q2-currency.entry.js +153 -0
  434. package/dist/q2-tecton-elements/q2-currency.entry.js.map +1 -0
  435. package/dist/q2-tecton-elements/q2-data-table.entry.js +622 -0
  436. package/dist/q2-tecton-elements/{p-7903cd15.entry.js.map → q2-data-table.entry.js.map} +1 -1
  437. package/dist/q2-tecton-elements/q2-detail.entry.js +128 -0
  438. package/dist/q2-tecton-elements/{p-f5f23659.entry.js.map → q2-detail.entry.js.map} +1 -1
  439. package/dist/q2-tecton-elements/q2-dropdown-item.entry.js +146 -0
  440. package/dist/q2-tecton-elements/q2-dropdown-item.entry.js.map +1 -0
  441. package/dist/q2-tecton-elements/q2-dropdown.entry.js +432 -0
  442. package/dist/q2-tecton-elements/q2-dropdown.entry.js.map +1 -0
  443. package/dist/q2-tecton-elements/q2-editable-field.entry.js +296 -0
  444. package/dist/q2-tecton-elements/{p-896c7008.entry.js.map → q2-editable-field.entry.js.map} +1 -1
  445. package/dist/q2-tecton-elements/q2-example.entry.js +152 -0
  446. package/dist/q2-tecton-elements/q2-example.entry.js.map +1 -0
  447. package/dist/q2-tecton-elements/q2-formatted-text.entry.js +73 -0
  448. package/dist/q2-tecton-elements/{p-7c9f8b62.entry.js.map → q2-formatted-text.entry.js.map} +1 -1
  449. package/dist/q2-tecton-elements/q2-item.entry.js +158 -0
  450. package/dist/q2-tecton-elements/{p-7c9a0122.entry.js.map → q2-item.entry.js.map} +1 -1
  451. package/dist/q2-tecton-elements/q2-legend.entry.js +146 -0
  452. package/dist/q2-tecton-elements/{p-ff8f1a32.entry.js.map → q2-legend.entry.js.map} +1 -1
  453. package/dist/q2-tecton-elements/q2-link.entry.js +83 -0
  454. package/dist/q2-tecton-elements/q2-link.entry.js.map +1 -0
  455. package/dist/q2-tecton-elements/q2-list.entry.js +100 -0
  456. package/dist/q2-tecton-elements/q2-list.entry.js.map +1 -0
  457. package/dist/q2-tecton-elements/q2-loading-element.entry.js +36 -0
  458. package/dist/q2-tecton-elements/{p-a068c84c.entry.js.map → q2-loading-element.entry.js.map} +1 -1
  459. package/dist/q2-tecton-elements/q2-loc.entry.js +82 -0
  460. package/dist/q2-tecton-elements/q2-loc.entry.js.map +1 -0
  461. package/dist/q2-tecton-elements/q2-message.entry.js +99 -0
  462. package/dist/q2-tecton-elements/{p-8d2b02e1.entry.js.map → q2-message.entry.js.map} +1 -1
  463. package/dist/q2-tecton-elements/q2-month-picker.entry.js +198 -0
  464. package/dist/q2-tecton-elements/{p-8d07cf91.entry.js.map → q2-month-picker.entry.js.map} +1 -1
  465. package/dist/q2-tecton-elements/q2-optgroup.entry.js +88 -0
  466. package/dist/q2-tecton-elements/q2-optgroup.entry.js.map +1 -0
  467. package/dist/q2-tecton-elements/q2-option-list.entry.js +585 -0
  468. package/dist/q2-tecton-elements/{p-a5d0e252.entry.js.map → q2-option-list.entry.js.map} +1 -1
  469. package/dist/q2-tecton-elements/q2-option.entry.js +110 -0
  470. package/dist/q2-tecton-elements/q2-option.entry.js.map +1 -0
  471. package/dist/q2-tecton-elements/q2-pagination.entry.js +377 -0
  472. package/dist/q2-tecton-elements/q2-pagination.entry.js.map +1 -0
  473. package/dist/q2-tecton-elements/q2-pill.entry.js +434 -0
  474. package/dist/q2-tecton-elements/q2-pill.entry.js.map +1 -0
  475. package/dist/q2-tecton-elements/q2-radio-group.entry.js +227 -0
  476. package/dist/q2-tecton-elements/q2-radio-group.entry.js.map +1 -0
  477. package/dist/q2-tecton-elements/q2-radio.entry.js +144 -0
  478. package/dist/q2-tecton-elements/{p-c235ab3f.entry.js.map → q2-radio.entry.js.map} +1 -1
  479. package/dist/q2-tecton-elements/q2-relative-time.entry.js +162 -0
  480. package/dist/q2-tecton-elements/{p-95a7c042.entry.js.map → q2-relative-time.entry.js.map} +1 -1
  481. package/dist/q2-tecton-elements/q2-resize-observer.entry.js +100 -0
  482. package/dist/q2-tecton-elements/{p-e2c800ef.entry.js.map → q2-resize-observer.entry.js.map} +1 -1
  483. package/dist/q2-tecton-elements/q2-section.entry.js +256 -0
  484. package/dist/q2-tecton-elements/q2-section.entry.js.map +1 -0
  485. package/dist/q2-tecton-elements/q2-select.entry.js +684 -0
  486. package/dist/q2-tecton-elements/q2-select.entry.js.map +1 -0
  487. package/dist/q2-tecton-elements/q2-stepper-pane.entry.js +124 -0
  488. package/dist/q2-tecton-elements/q2-stepper-pane.entry.js.map +1 -0
  489. package/dist/q2-tecton-elements/q2-stepper-vertical.entry.js +356 -0
  490. package/dist/q2-tecton-elements/q2-stepper-vertical.entry.js.map +1 -0
  491. package/dist/q2-tecton-elements/q2-stepper.entry.js +332 -0
  492. package/dist/q2-tecton-elements/q2-stepper.entry.js.map +1 -0
  493. package/dist/q2-tecton-elements/q2-tag.entry.js +213 -0
  494. package/dist/q2-tecton-elements/q2-tag.entry.js.map +1 -0
  495. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +21 -1
  496. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js.map +1 -1
  497. package/dist/q2-tecton-elements/q2-textarea.entry.js +364 -0
  498. package/dist/q2-tecton-elements/{p-f135b265.entry.js.map → q2-textarea.entry.js.map} +1 -1
  499. package/dist/q2-tecton-elements/q2-tooltip.entry.js +105 -0
  500. package/dist/q2-tecton-elements/{p-c5667d5d.entry.js.map → q2-tooltip.entry.js.map} +1 -1
  501. package/dist/q2-tecton-elements/sectorHelper-183cedd0.js +949 -0
  502. package/dist/q2-tecton-elements/{p-eea5aa01.js.map → sectorHelper-183cedd0.js.map} +1 -1
  503. package/dist/q2-tecton-elements/shapes-c7e1a3fa.js +132 -0
  504. package/dist/q2-tecton-elements/{p-50b425de.js.map → shapes-c7e1a3fa.js.map} +1 -1
  505. package/dist/q2-tecton-elements/tecton-tab-pane.entry.js +134 -0
  506. package/dist/q2-tecton-elements/{p-96b1406c.entry.js.map → tecton-tab-pane.entry.js.map} +1 -1
  507. package/dist/types/components/q2-calendar/q2-calendar.d.ts +4 -5
  508. package/dist/types/components/q2-chart-area/q2-chart-area.d.ts +6 -0
  509. package/dist/types/components/q2-chart-donut/q2-chart-donut.d.ts +6 -0
  510. package/dist/types/components/q2-currency/q2-currency.d.ts +7 -0
  511. package/dist/types/components/q2-dropdown/q2-dropdown.d.ts +1 -1
  512. package/dist/types/components/q2-dropdown-item/q2-dropdown-item.d.ts +2 -2
  513. package/dist/types/components/q2-example/q2-example.d.ts +119 -0
  514. package/dist/types/components/q2-input/formatting/date.d.ts +22 -0
  515. package/dist/types/components/q2-input/formatting/postal.d.ts +197 -0
  516. package/dist/types/components/q2-input/q2-input.d.ts +15 -12
  517. package/dist/types/components/q2-loc/q2-loc.d.ts +15 -1
  518. package/dist/types/components/q2-option/q2-option.d.ts +11 -3
  519. package/dist/types/components/q2-pill/q2-pill.d.ts +3 -3
  520. package/dist/types/components/q2-popover/q2-popover.d.ts +1 -0
  521. package/dist/types/components/q2-select/q2-select.d.ts +1 -1
  522. package/dist/types/components/q2-stepper-vertical/q2-stepper-vertical.d.ts +6 -0
  523. package/dist/types/components/q2-tag/q2-tag.d.ts +1 -1
  524. package/dist/types/components.d.ts +104 -14
  525. package/dist/types/utils/helpers.d.ts +13 -0
  526. package/dist/types/utils/index.d.ts +11 -0
  527. package/package.json +7 -7
  528. package/dist/cjs/index-14c3693c.js.map +0 -1
  529. package/dist/cjs/index-9aa4a776.js.map +0 -1
  530. package/dist/esm/index-1e1ce94e.js.map +0 -1
  531. package/dist/esm/index-844fc010.js.map +0 -1
  532. package/dist/q2-tecton-elements/p-06701928.entry.js +0 -2
  533. package/dist/q2-tecton-elements/p-06701928.entry.js.map +0 -1
  534. package/dist/q2-tecton-elements/p-07d1c3ae.entry.js +0 -2
  535. package/dist/q2-tecton-elements/p-15ac45d6.js +0 -2
  536. package/dist/q2-tecton-elements/p-15ac45d6.js.map +0 -1
  537. package/dist/q2-tecton-elements/p-16910682.entry.js +0 -2
  538. package/dist/q2-tecton-elements/p-16910682.entry.js.map +0 -1
  539. package/dist/q2-tecton-elements/p-188eb162.entry.js +0 -3
  540. package/dist/q2-tecton-elements/p-1c760a89.entry.js +0 -2
  541. package/dist/q2-tecton-elements/p-1c760a89.entry.js.map +0 -1
  542. package/dist/q2-tecton-elements/p-1c88d057.entry.js +0 -2
  543. package/dist/q2-tecton-elements/p-1c88d057.entry.js.map +0 -1
  544. package/dist/q2-tecton-elements/p-20a3d6ed.entry.js +0 -2
  545. package/dist/q2-tecton-elements/p-20a3d6ed.entry.js.map +0 -1
  546. package/dist/q2-tecton-elements/p-2733583e.entry.js +0 -2
  547. package/dist/q2-tecton-elements/p-2733583e.entry.js.map +0 -1
  548. package/dist/q2-tecton-elements/p-2941aafa.js +0 -39
  549. package/dist/q2-tecton-elements/p-3e428290.entry.js +0 -2
  550. package/dist/q2-tecton-elements/p-3e428290.entry.js.map +0 -1
  551. package/dist/q2-tecton-elements/p-4774e5b3.entry.js +0 -2
  552. package/dist/q2-tecton-elements/p-4774e5b3.entry.js.map +0 -1
  553. package/dist/q2-tecton-elements/p-490ef8e5.entry.js +0 -2
  554. package/dist/q2-tecton-elements/p-490ef8e5.entry.js.map +0 -1
  555. package/dist/q2-tecton-elements/p-4e10550d.entry.js +0 -2
  556. package/dist/q2-tecton-elements/p-4e10550d.entry.js.map +0 -1
  557. package/dist/q2-tecton-elements/p-50b425de.js +0 -2
  558. package/dist/q2-tecton-elements/p-50f7328f.entry.js +0 -2
  559. package/dist/q2-tecton-elements/p-50f7328f.entry.js.map +0 -1
  560. package/dist/q2-tecton-elements/p-5637c486.entry.js +0 -2
  561. package/dist/q2-tecton-elements/p-56df21b0.entry.js +0 -2
  562. package/dist/q2-tecton-elements/p-56df21b0.entry.js.map +0 -1
  563. package/dist/q2-tecton-elements/p-5a834214.entry.js +0 -2
  564. package/dist/q2-tecton-elements/p-5a834214.entry.js.map +0 -1
  565. package/dist/q2-tecton-elements/p-5f99a4a8.entry.js +0 -2
  566. package/dist/q2-tecton-elements/p-5f99a4a8.entry.js.map +0 -1
  567. package/dist/q2-tecton-elements/p-72d948b4.entry.js +0 -2
  568. package/dist/q2-tecton-elements/p-72d948b4.entry.js.map +0 -1
  569. package/dist/q2-tecton-elements/p-7903cd15.entry.js +0 -2
  570. package/dist/q2-tecton-elements/p-7906f49e.entry.js +0 -2
  571. package/dist/q2-tecton-elements/p-7aef0c08.entry.js +0 -2
  572. package/dist/q2-tecton-elements/p-7c9a0122.entry.js +0 -2
  573. package/dist/q2-tecton-elements/p-7c9f8b62.entry.js +0 -2
  574. package/dist/q2-tecton-elements/p-81fbe718.entry.js +0 -2
  575. package/dist/q2-tecton-elements/p-81fbe718.entry.js.map +0 -1
  576. package/dist/q2-tecton-elements/p-896c7008.entry.js +0 -2
  577. package/dist/q2-tecton-elements/p-8d07cf91.entry.js +0 -2
  578. package/dist/q2-tecton-elements/p-8d2b02e1.entry.js +0 -2
  579. package/dist/q2-tecton-elements/p-95a7c042.entry.js +0 -2
  580. package/dist/q2-tecton-elements/p-96b1406c.entry.js +0 -2
  581. package/dist/q2-tecton-elements/p-a068c84c.entry.js +0 -2
  582. package/dist/q2-tecton-elements/p-a47597dd.entry.js +0 -2
  583. package/dist/q2-tecton-elements/p-a47597dd.entry.js.map +0 -1
  584. package/dist/q2-tecton-elements/p-a5d0e252.entry.js +0 -2
  585. package/dist/q2-tecton-elements/p-a5f18e27.js +0 -3
  586. package/dist/q2-tecton-elements/p-a5f18e27.js.map +0 -1
  587. package/dist/q2-tecton-elements/p-ac6aa392.entry.js +0 -2
  588. package/dist/q2-tecton-elements/p-ac6aa392.entry.js.map +0 -1
  589. package/dist/q2-tecton-elements/p-ad057d10.entry.js +0 -2
  590. package/dist/q2-tecton-elements/p-ad057d10.entry.js.map +0 -1
  591. package/dist/q2-tecton-elements/p-ad798287.entry.js +0 -2
  592. package/dist/q2-tecton-elements/p-ad798287.entry.js.map +0 -1
  593. package/dist/q2-tecton-elements/p-ad80aef0.js +0 -2
  594. package/dist/q2-tecton-elements/p-b0e5e9dc.entry.js +0 -2
  595. package/dist/q2-tecton-elements/p-b0e5e9dc.entry.js.map +0 -1
  596. package/dist/q2-tecton-elements/p-b1784be3.entry.js +0 -2
  597. package/dist/q2-tecton-elements/p-b1784be3.entry.js.map +0 -1
  598. package/dist/q2-tecton-elements/p-b7554a79.js +0 -2
  599. package/dist/q2-tecton-elements/p-b7de110e.entry.js +0 -2
  600. package/dist/q2-tecton-elements/p-c235ab3f.entry.js +0 -2
  601. package/dist/q2-tecton-elements/p-c5667d5d.entry.js +0 -2
  602. package/dist/q2-tecton-elements/p-e1255160.js +0 -2
  603. package/dist/q2-tecton-elements/p-e216ef3f.entry.js +0 -2
  604. package/dist/q2-tecton-elements/p-e2c800ef.entry.js +0 -2
  605. package/dist/q2-tecton-elements/p-eea5aa01.js +0 -2
  606. package/dist/q2-tecton-elements/p-f135b265.entry.js +0 -2
  607. package/dist/q2-tecton-elements/p-f1e887f5.js +0 -2
  608. package/dist/q2-tecton-elements/p-f5f23659.entry.js +0 -2
  609. package/dist/q2-tecton-elements/p-f7867f21.entry.js +0 -2
  610. package/dist/q2-tecton-elements/p-f7867f21.entry.js.map +0 -1
  611. package/dist/q2-tecton-elements/p-ff8f1a32.entry.js +0 -2
  612. package/dist/q2-tecton-elements/p-fff01dc1.entry.js +0 -2
  613. package/dist/q2-tecton-elements/p-fff01dc1.entry.js.map +0 -1
@@ -1,1370 +1,164 @@
1
- import { evaluateA11y, setTestStrings, setup, dispatchEvent, testDeprecatedAriaLabel, getActiveElementTestId, getNestedAssignedElementLength, getNestedElementStyle, getListOfStyleCompilationIssues, getNestedElementAttribute, } from "../../../utils/helpers";
1
+ import { evaluateA11y, setup, dispatchEvent, getNestedAssignedElementLength, getNestedElementStyle, getListOfStyleCompilationIssues, getNestedElementAttribute, } from "../../../utils/helpers";
2
2
  describe('q2-input', () => {
3
- it('properly compiles CSS vars and functions', async () => {
4
- const page = await setup({ html: '<q2-input></q2-input>' });
5
- expect(await getListOfStyleCompilationIssues(page, 'q2-input')).toHaveLength(0);
6
- });
7
3
  async function getInnerInputDimensions(page) {
8
4
  return page.$eval('body', () => document.querySelector('q2-input').shadowRoot.querySelector('input').getClientRects()[0].toJSON());
9
5
  }
10
- it('should be registered in the dom and accept values', async function () {
11
- const page = await setup({ html: '<q2-input label="platform is awesome" />' });
12
- const label = await page.find('q2-input >>> label');
13
- expect(label.innerText.trim()).toEqual('platform is awesome');
14
- });
15
- describe('focus', () => {
16
- let page;
17
- let input;
18
- let fieldContainer;
19
- beforeEach(async () => {
20
- page = await setup({ html: `<q2-input></q2-input>` });
21
- input = await page.find('q2-input');
22
- fieldContainer = await page.find('q2-input >>> .field-container');
23
- expect(await innerActiveTestId(page)).toBeUndefined();
24
- expect(fieldContainer).not.toHaveClass('has-focus');
25
- });
26
- const innerActiveTestId = async (page) => {
27
- return page.$eval('q2-input', el => { var _a; return (_a = el.shadowRoot.activeElement) === null || _a === void 0 ? void 0 : _a.getAttribute('test-id'); });
28
- };
29
- it('focuses inner button when focus event is dispatched', async function () {
30
- await input.triggerEvent('focus');
31
- await page.waitForChanges();
32
- expect(await innerActiveTestId(page)).toEqual('inputField');
33
- expect(fieldContainer).toHaveClass('has-focus');
34
- });
35
- it('focuses inner button when element.focus() is called', async function () {
36
- await input.focus();
37
- await page.waitForChanges();
38
- expect(await innerActiveTestId(page)).toEqual('inputField');
39
- expect(fieldContainer).toHaveClass('has-focus');
40
- });
41
- it('adds has-focus to fieldContainer when input focused', async () => {
42
- const innerInput = await page.find('q2-input >>> input.input-field');
43
- await innerInput.focus();
44
- await page.waitForChanges();
45
- expect(await innerActiveTestId(page)).toEqual('inputField');
46
- expect(fieldContainer).toHaveClass('has-focus');
6
+ describe('Styling', () => {
7
+ it('properly compiles CSS vars and functions', async () => {
8
+ const page = await setup({ html: '<q2-input></q2-input>' });
9
+ expect(await getListOfStyleCompilationIssues(page, 'q2-input')).toHaveLength(0);
47
10
  });
48
- describe('when pseudo is true', () => {
49
- beforeEach(async () => {
50
- await input.setProperty('pseudo', true);
51
- await page.waitForChanges();
52
- fieldContainer = await page.find('q2-input >>> .field-container');
53
- expect(fieldContainer).not.toHaveClass('has-focus');
54
- });
55
- it('focuses inner button when focus event is dispatched', async function () {
56
- await input.triggerEvent('focus');
57
- await page.waitForChanges();
58
- expect(await innerActiveTestId(page)).toEqual('q2InputInnerClearButton');
59
- expect(fieldContainer).toHaveClass('has-focus');
11
+ describe('pseudo', () => {
12
+ let page;
13
+ beforeEach(async function () {
14
+ page = await setup({ html: '<q2-input label="label text" value="value" pseudo />' });
60
15
  });
61
- it('focuses inner button when element.focus() is called', async function () {
62
- await input.focus();
16
+ it('should not extend beyond the container when the value is long', async () => {
17
+ const input = await page.find('q2-input');
18
+ await input.setProperty('value', 'This is a very very very very very very very very very very very very very very very very very long value that should be truncated');
63
19
  await page.waitForChanges();
64
- expect(await innerActiveTestId(page)).toEqual('q2InputInnerClearButton');
65
- expect(fieldContainer).toHaveClass('has-focus');
20
+ const { clientWidth, scrollWidth } = await page.$eval('q2-input', (el) => {
21
+ const { clientWidth, scrollWidth } = el.shadowRoot.querySelector('.input-container');
22
+ return { clientWidth, scrollWidth };
23
+ });
24
+ expect(clientWidth).toEqual(scrollWidth);
66
25
  });
67
- it('adds has-focus to fieldContainer when button is focused', async () => {
68
- const innerInput = await page.find('q2-input >>> button.input-field');
69
- await innerInput.focus();
26
+ it('should fill the the container when the value is short', async () => {
27
+ const input = await page.find('q2-input');
28
+ await input.setProperty('value', 'Short value');
70
29
  await page.waitForChanges();
71
- expect(await innerActiveTestId(page)).toEqual('q2InputInnerClearButton');
72
- expect(fieldContainer).toHaveClass('has-focus');
73
- });
74
- });
75
- });
76
- it('when readonly label text should include (read only) ', async function () {
77
- const readonlyText = '(read only)';
78
- const page = await setup({ html: `<q2-input label="label text"></q2-input>` });
79
- await setTestStrings(page, {
80
- 'tecton.element.input.readonly': readonlyText,
81
- });
82
- const element = await page.find('q2-input');
83
- await element.setProperty('readonly', true);
84
- await page.waitForChanges();
85
- const label = await page.find('q2-input >>> label');
86
- expect(label.textContent).toEqual(`label text${readonlyText}`);
87
- });
88
- it('should show errors when the element has focus if error array is populated', async function () {
89
- const page = await setup({ html: '<q2-input label="foo" />' });
90
- const input = await page.find('q2-input');
91
- input.setProperty('errors', ['broke']);
92
- await page.waitForChanges();
93
- const { messagesHeight, hasErrorClass } = await page.$eval('q2-input', element => {
94
- return {
95
- messagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
96
- hasErrorClass: !!element.shadowRoot.querySelector('.has-error'),
97
- };
98
- });
99
- // errors are not visible when not in focus
100
- expect(messagesHeight).toEqual(0);
101
- // error indicator is present
102
- expect(hasErrorClass).toBe(true);
103
- await dispatchEvent(page, ['q2-input', '.input-field'], 'focus');
104
- const { expandedMessagesHeight, messagesText } = await page.$eval('q2-input', element => {
105
- const messageContainer = element.shadowRoot.querySelector('.messages-container');
106
- return {
107
- expandedMessagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
108
- messagesText: messageContainer.innerText.trim(),
109
- };
110
- });
111
- // errors are displayed when in focus
112
- expect(expandedMessagesHeight).toBeGreaterThan(0);
113
- // error message is correct
114
- expect(messagesText).toEqual('broke');
115
- });
116
- it('should not show messages when strings are present if hideMessages is true', async function () {
117
- const page = await setup({ html: '<q2-input label="foo" hide-messages />' });
118
- const input = await page.find('q2-input');
119
- input.setProperty('errors', ['broke']);
120
- await page.waitForChanges();
121
- await dispatchEvent(page, ['q2-input', '.input-field'], 'focus');
122
- const { messagesHeight, hasErrorClass } = await page.$eval('q2-input', element => {
123
- return {
124
- messagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
125
- hasErrorClass: !!element.shadowRoot.querySelector('.has-error'),
126
- };
127
- });
128
- // errors are not displayed WHILE in focus
129
- expect(messagesHeight).toEqual(0);
130
- // indicator is still shown
131
- expect(hasErrorClass).toBe(true);
132
- });
133
- it('should show error message when error icon is clicked', async function () {
134
- const page = await setup({ html: '<q2-input label="foo" />' });
135
- const input = await page.find('q2-input');
136
- input.setProperty('errors', ['broke']);
137
- await page.waitForChanges();
138
- const { messagesHeight, hasErrorClass } = await page.$eval('q2-input', element => {
139
- return {
140
- messagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
141
- hasErrorClass: !!element.shadowRoot.querySelector('.has-error'),
142
- };
143
- });
144
- // errors are not visible when not in focus
145
- expect(messagesHeight).toEqual(0);
146
- // error indicator is present
147
- expect(hasErrorClass).toBe(true);
148
- await dispatchEvent(page, ['q2-input', '[test-id="divIconError"]'], 'click');
149
- const { expandedMessagesHeight, messagesText } = await page.$eval('q2-input', element => {
150
- const messageContainer = element.shadowRoot.querySelector('.messages-container');
151
- return {
152
- expandedMessagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
153
- messagesText: messageContainer.innerText.trim(),
154
- };
155
- });
156
- // errors are displayed when in focus
157
- expect(expandedMessagesHeight).toBeGreaterThan(0);
158
- // error message is correct
159
- expect(messagesText).toEqual('broke');
160
- });
161
- it('should show error message when error icon is clicked and input is currency type', async function () {
162
- const page = await setup({ html: '<q2-input type="currency" label="foo" />' });
163
- const input = await page.find('q2-input');
164
- input.setProperty('errors', ['broke']);
165
- await page.waitForChanges();
166
- const { messagesHeight, hasErrorClass } = await page.$eval('q2-input', element => {
167
- return {
168
- messagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
169
- hasErrorClass: !!element.shadowRoot.querySelector('.has-error'),
170
- };
171
- });
172
- // errors are not visible when not in focus
173
- expect(messagesHeight).toEqual(0);
174
- // error indicator is present
175
- expect(hasErrorClass).toBe(true);
176
- await dispatchEvent(page, ['q2-input', '[test-id="divIconError"]'], 'click');
177
- const { expandedMessagesHeight, messagesText } = await page.$eval('q2-input', element => {
178
- const messageContainer = element.shadowRoot.querySelector('.messages-container');
179
- return {
180
- expandedMessagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
181
- messagesText: messageContainer.innerText.trim(),
182
- };
183
- });
184
- // errors are displayed when in focus
185
- expect(expandedMessagesHeight).toBeGreaterThan(0);
186
- // error message is correct
187
- expect(messagesText).toEqual('broke');
188
- });
189
- it('does not allow invalid input types', async function () {
190
- const page = await setup({ html: '<q2-input label="foo" type="fire" />' });
191
- const innerInput = await page.find('q2-input >>> .input-field');
192
- // sets input type to text if invalid type is passed in
193
- expect(await innerInput.getProperty('type')).toEqual('text');
194
- });
195
- it('should allow input types to be passed in', async function () {
196
- const page = await setup({ html: '<q2-input label="foo" type="tel" />' });
197
- const innerInput = await page.find('q2-input >>> .input-field');
198
- // sets input to type tel
199
- expect(await innerInput.getProperty('type')).toEqual('tel');
200
- expect(await innerInput.getAttribute('inputmode')).toBeNull();
201
- });
202
- it('maintains formattedValue on load', async () => {
203
- const page = await setup({
204
- html: `<q2-input type='phone' value='1234567890'></q2-input>`,
205
- });
206
- const inputField = await page.find('q2-input');
207
- const formattedVal = await inputField.getProperty('formattedValue');
208
- await page.waitForChanges();
209
- expect(formattedVal).toBe('(123) 456-7890');
210
- });
211
- it('should default to text if no type is passed in', async function () {
212
- const page = await setup({ html: '<q2-input label="foo" />' });
213
- const innerInput = await page.find('q2-input >>> .input-field');
214
- // defaults input to type text
215
- expect(await innerInput.getProperty('type')).toEqual('text');
216
- expect(await innerInput.getAttribute('inputmode')).toBeNull();
217
- });
218
- it('should fire input event that proxies inner input event', async function () {
219
- const page = await setup({ html: '<q2-input label="foo" />' });
220
- const input = await page.find('q2-input');
221
- const innerInput = await page.find('q2-input >>> .input-field');
222
- const inputSpy = await input.spyOnEvent('input');
223
- await innerInput.press('f');
224
- await page.waitForChanges();
225
- // should receive a formatted input event
226
- expect(inputSpy).toHaveReceivedEventDetail({
227
- value: 'f',
228
- formattedValue: 'f',
229
- // minFormattedLength: undefined /* This present but filtered out by the test helper */
230
- });
231
- });
232
- it('should fire change event that proxies change(blur) input event', async function () {
233
- const page = await setup({ html: '<q2-input label="foo" value="test inpu"/>' });
234
- const input = await page.find('q2-input');
235
- const innerInput = await page.find('q2-input >>> .input-field');
236
- await innerInput.press('t');
237
- const changeSpy = await input.spyOnEvent('change');
238
- await dispatchEvent(page, ['q2-input', '.input-field'], 'blur');
239
- // should receive formatted change event
240
- expect(changeSpy).toHaveReceivedEventDetail({
241
- value: 'test input',
242
- formattedValue: 'test input',
243
- });
244
- expect(changeSpy).toHaveReceivedEventTimes(1);
245
- await dispatchEvent(page, ['q2-input', '.input-field'], 'focus');
246
- await innerInput.press(' ');
247
- await dispatchEvent(page, ['q2-input', '.input-field'], 'input');
248
- await dispatchEvent(page, ['q2-input', '.input-field'], 'keydown', { key: 'Enter' });
249
- expect(changeSpy).toHaveReceivedEventDetail({
250
- value: 'test input ',
251
- formattedValue: 'test input ',
252
- });
253
- expect(changeSpy).toHaveReceivedEventTimes(2);
254
- const onInput = (event) => {
255
- event.target.value = event.detail.value;
256
- };
257
- input.setProperty('oninput', onInput);
258
- await page.waitForChanges();
259
- await dispatchEvent(page, ['q2-input', '.input-field'], 'focus');
260
- await innerInput.press(' ');
261
- expect(changeSpy).toHaveReceivedEventTimes(2);
262
- await dispatchEvent(page, ['q2-input', '.input-field'], 'keydown', { key: 'Enter' });
263
- expect(changeSpy).toHaveReceivedEventDetail({
264
- value: 'test input ',
265
- formattedValue: 'test input ',
266
- });
267
- expect(changeSpy).toHaveReceivedEventTimes(3);
268
- });
269
- it('should fire input event after content pasted into field', async function () {
270
- const page = await setup({ html: '<q2-input label="foo" value="test" />' });
271
- const input = await page.find('q2-input');
272
- const innerInput = await page.find('q2-input >>> .input-field');
273
- const inputSpy = await input.spyOnEvent('input');
274
- expect(await innerInput.getProperty('value')).toEqual('test');
275
- // fully replaces value on paste if nothing selected
276
- await dispatchEvent(page, ['q2-input', '.input-field'], 'paste', {
277
- pastedValue: 'pasted value',
278
- });
279
- expect(await innerInput.getProperty('value')).toEqual('testpasted value');
280
- await page.waitForChanges();
281
- expect(inputSpy).toHaveReceivedEventTimes(1);
282
- expect(inputSpy).toHaveReceivedEventDetail({
283
- value: 'testpasted value',
284
- formattedValue: 'testpasted value',
285
- // minFormattedLength: undefined /* This present but filtered out by the test helper */
286
- });
287
- // only replaces selected content on paste
288
- await input.setProperty('value', 'reset');
289
- await page.$eval('q2-input', element => {
290
- const inputEl = element.shadowRoot.querySelector('.input-field');
291
- inputEl.setSelectionRange(5, 7);
292
- });
293
- await page.waitForChanges();
294
- // in practice, the paste event triggers the input event tested above
295
- // this segment validates that the paste flow follows native browser behavior if an incomplete selection is made
296
- expect(inputSpy).toHaveReceivedEventTimes(1);
297
- });
298
- it('should fire input event after content pasted into currency field', async function () {
299
- const page = await setup({ html: '<q2-input label="foo" value="4.44" type="currency" />' });
300
- const input = await page.find('q2-input');
301
- const innerInput = await page.find('q2-input >>> .input-field');
302
- const inputSpy = await input.spyOnEvent('input');
303
- expect(await innerInput.getProperty('value')).toEqual('4.44');
304
- // fully replaces value on paste if nothing selected
305
- await dispatchEvent(page, ['q2-input', '.input-field'], 'paste', {
306
- pastedValue: '2.3',
307
- });
308
- expect(await innerInput.getProperty('value')).toEqual('2.30');
309
- await page.waitForChanges();
310
- expect(inputSpy).toHaveReceivedEventTimes(1);
311
- expect(inputSpy).toHaveReceivedEventDetail({
312
- value: '2.30',
313
- formattedValue: '$2.30',
314
- // minFormattedLength: undefined /* This present but filtered out by the test helper */
315
- });
316
- // only replaces selected content on paste
317
- await input.setProperty('value', 'reset');
318
- await page.$eval('q2-input', element => {
319
- const inputEl = element.shadowRoot.querySelector('.input-field');
320
- inputEl.setSelectionRange(5, 7);
321
- });
322
- await page.waitForChanges();
323
- // in practice, the paste event triggers the input event tested above
324
- // this segment validates that the paste flow follows native browser behavior if an incomplete selection is made
325
- expect(inputSpy).toHaveReceivedEventTimes(1);
326
- });
327
- it('should show hints when hints are present and error array is empty', async function () {
328
- const page = await setup({ html: '<q2-input label="foo"/>' });
329
- const input = await page.find('q2-input');
330
- await input.setProperty('hints', ['try harder']);
331
- await input.setProperty('errors', []);
332
- await page.waitForChanges();
333
- const messagesContainer = await page.find('q2-input >>> .messages-container');
334
- // hints are shown when errors are empty
335
- expect(messagesContainer.innerText.trim()).toEqual('try harder');
336
- await input.setProperty('errors', ['you did it wrong']);
337
- await page.waitForChanges();
338
- // errors shown instead of hints when errors are present
339
- expect(messagesContainer.innerText.trim()).toEqual('you did it wrong');
340
- });
341
- it('should render a localized optional string when the optional attribute is passed', async function () {
342
- const page = await setup({ html: '<q2-input label="foo" optional />' });
343
- const inputLabel = await page.find('q2-input >>> label');
344
- // a localized optional is shown in the label
345
- expect(inputLabel.innerText.trim()).toEqual('footecton.element.input.optional');
346
- });
347
- describe('pseudo', () => {
348
- let page;
349
- let innerInput;
350
- let inputLabel;
351
- beforeEach(async function () {
352
- page = await setup({ html: '<q2-input label="label text" value="value" pseudo />' });
353
- innerInput = await page.find('q2-input >>> .input-field');
354
- inputLabel = await page.find('q2-input >>> .input-label');
355
- });
356
- it('should correctly render pseudo state', async function () {
357
- // pseudo input should be a button
358
- expect(innerInput.tagName).toEqual('BUTTON');
359
- expect(await innerInput.getProperty('type')).toEqual('button');
360
- expect(inputLabel.innerText).toEqual('label text');
361
- });
362
- it('should not extend beyond the container when the value is long', async () => {
363
- const input = await page.find('q2-input');
364
- await input.setProperty('value', 'This is a very very very very very very very very very very very very very very very very very long value that should be truncated');
365
- await page.waitForChanges();
366
- const { clientWidth, scrollWidth } = await page.$eval('q2-input', (el) => {
367
- const { clientWidth, scrollWidth } = el.shadowRoot.querySelector('.input-container');
368
- return { clientWidth, scrollWidth };
30
+ const { clientWidth, scrollWidth } = await page.$eval('q2-input', (el) => {
31
+ const { clientWidth, scrollWidth } = el.shadowRoot.querySelector('.input-container');
32
+ return { clientWidth, scrollWidth };
33
+ });
34
+ expect(clientWidth).toEqual(scrollWidth);
369
35
  });
370
- expect(clientWidth).toEqual(scrollWidth);
371
36
  });
372
- it('should fill the the container when the value is short', async () => {
373
- const input = await page.find('q2-input');
374
- await input.setProperty('value', 'Short value');
375
- await page.waitForChanges();
376
- const { clientWidth, scrollWidth } = await page.$eval('q2-input', (el) => {
377
- const { clientWidth, scrollWidth } = el.shadowRoot.querySelector('.input-container');
378
- return { clientWidth, scrollWidth };
37
+ describe('clearable', () => {
38
+ describe('when false (default)', () => {
39
+ it('starts observing width when added at runtime', async () => {
40
+ const page = await setup({ html: '<q2-input value="Tony" />' });
41
+ await page.evaluate(() => {
42
+ document.body.style.margin = '0';
43
+ });
44
+ await page.waitForChanges();
45
+ const input = await page.find('q2-input');
46
+ input.setProperty('clearable', true);
47
+ await page.waitForChanges();
48
+ let clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
49
+ expect(clearButtonWidth).toBe('44px');
50
+ await page.setViewport({ width: 189, height: 400 });
51
+ await page.waitForChanges();
52
+ clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
53
+ expect(clearButtonWidth).toBe('20px');
54
+ });
379
55
  });
380
- expect(clientWidth).toEqual(scrollWidth);
381
- });
382
- describe('when optional', () => {
383
- it('should correctly render pseudo state', async function () {
384
- await setTestStrings(page, {
385
- 'tecton.element.input.optional': '(Optional)',
56
+ describe('when true', () => {
57
+ it('clear button is 44px when component is more than 190px wide', async () => {
58
+ const page = await setup({ html: '<q2-input value="Tony" clearable/>' });
59
+ await page.setViewport({ width: 193, height: 400 });
60
+ await page.evaluate(() => {
61
+ document.body.style.margin = '0';
62
+ });
63
+ await page.waitForChanges();
64
+ const clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
65
+ expect(clearButtonWidth).toBe('44px');
66
+ });
67
+ it('clear button is 20px when component is less than 190px wide', async () => {
68
+ const page = await setup({ html: '<q2-input value="Tony" clearable/>' });
69
+ await page.setViewport({ width: 189, height: 400 });
70
+ await page.evaluate(() => {
71
+ document.body.style.margin = '0';
72
+ });
73
+ await page.waitForChanges();
74
+ const clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
75
+ expect(clearButtonWidth).toBe('20px');
386
76
  });
387
- const element = await page.find('q2-input');
388
- element.setProperty('optional', true);
389
- await page.waitForChanges();
390
- expect(inputLabel.innerText).toEqual('label text(Optional)');
391
77
  });
392
78
  });
393
79
  });
394
- it('should localize appropriate attribute strings', async function () {
395
- const page = await setup({ html: '<q2-input />' });
396
- await setTestStrings(page, {
397
- 'q2-input.label': 'Label Text',
398
- 'tecton.element.input.optional': '(Optional)',
399
- 'q2-input.ariaLabel': 'Aria-Label Text',
400
- 'q2-input.placeholder': 'Placeholder Text',
401
- 'q2-input.hint1': 'Hint 1 Text',
402
- 'q2-input.error1': 'Error 1 Text',
403
- });
404
- const input = await page.find('q2-input');
405
- input.setProperty('label', 'q2-input.label');
406
- input.setProperty('placeholder', 'q2-input.placeholder');
407
- input.setProperty('hints', ['q2-input.hint1']);
408
- await page.waitForChanges();
409
- const label = await page.find('q2-input >>> label');
410
- const labelText = label.innerText;
411
- const innerInput = await page.find('q2-input >>> .input-field');
412
- let ariaLabel = innerInput.getAttribute('aria-label');
413
- // label bound correctly
414
- expect(labelText).toEqual('Label Text');
415
- expect(ariaLabel).toEqual(null);
416
- input.setProperty('ariaLabel', 'q2-input.ariaLabel');
417
- await page.waitForChanges();
418
- const messageContainer = await page.find('q2-input >>> .messages-container');
419
- ariaLabel = innerInput.getAttribute('aria-label');
420
- const placeholder = innerInput.getAttribute('placeholder');
421
- // label is updated, hide-label is added, and aria-label is removed
422
- expect(await input.getProperty('aria-label')).toEqual(undefined);
423
- expect(await input.getProperty('label')).toEqual('Aria-Label Text');
424
- expect(await input.getProperty('hideLabel')).toEqual(true);
425
- // expect placeholder to be bound correctly
426
- expect(placeholder).toEqual('Placeholder Text');
427
- // expect localized hint to be shown since errors are not present
428
- expect(messageContainer.innerText).toEqual('Hint 1 Text');
429
- input.setProperty('hints', []);
430
- input.setProperty('errors', ['q2-input.error1']);
431
- await page.waitForChanges();
432
- // expect errors to be localized
433
- expect(messageContainer.innerText).toEqual('Error 1 Text');
434
- });
435
- /* Masking */
436
- // Currency
437
- it('should handle currency masking', async function () {
438
- const page = await setup({
439
- html: '<q2-input type="currency" label="Amount" value="10" autocomplete="on" />',
440
- });
441
- const input = await page.find('q2-input');
442
- const innerInput = await page.find('q2-input >>> .input-field');
443
- const inputSpy = await input.spyOnEvent('input');
444
- let inputValue = await innerInput.getProperty('value');
445
- const inputPrefix = await page.find('q2-input >>> .input-prefix');
446
- await page.waitForChanges();
447
- expect(await innerInput.getProperty('type')).toEqual('text');
448
- expect(await innerInput.getAttribute('inputmode')).toEqual('numeric');
449
- expect(await innerInput.getProperty('autocomplete')).toEqual('transaction-amount');
450
- expect(inputPrefix).not.toBeNull();
451
- expect(inputPrefix.innerText).toEqual('$');
452
- // formats value on initial input
453
- expect(inputValue).toEqual('10.00');
454
- await innerInput.press('3');
455
- // input value gets reformatted correctly and emits value and formattedValue
456
- expect(inputSpy).toHaveReceivedEventDetail({
457
- value: '100.03',
458
- formattedValue: '$100.03',
459
- });
460
- inputValue = await innerInput.getProperty('value');
461
- // formatted value is set back on inner input
462
- expect(inputValue).toEqual('100.03');
463
- await innerInput.press('4');
464
- await innerInput.press('5');
465
- await innerInput.press('6');
466
- await innerInput.press('7');
467
- await innerInput.press('8');
468
- await innerInput.press('9');
469
- // input value is formatted correctly with thousands
470
- expect(inputSpy).toHaveReceivedEventDetail({
471
- value: '100034567.89',
472
- formattedValue: '$100,034,567.89',
473
- });
474
- // formatted value is set correctly back on inner input
475
- inputValue = await innerInput.getProperty('value');
476
- expect(inputValue).toEqual('100,034,567.89');
477
- await innerInput.press('e');
478
- await innerInput.press('a');
479
- await innerInput.press('0');
480
- await innerInput.press('1');
481
- await innerInput.press('2');
482
- // invalid input is ignored
483
- expect(inputSpy).toHaveReceivedEventDetail({
484
- value: '100034567890.12',
485
- formattedValue: '$100,034,567,890.12',
486
- });
487
- inputValue = await innerInput.getProperty('value');
488
- // input value is reset to formatted value removing invalid input
489
- expect(inputValue).toEqual('100,034,567,890.12');
490
- await input.setProperty('value', '50');
491
- await page.waitForChanges();
492
- inputValue = await innerInput.getProperty('value');
493
- // setting value programatically from property allows numeric interpretation
494
- expect(inputValue).toEqual('50.00');
495
- await dispatchEvent(page, ['q2-input', '.input-field'], 'paste', {
496
- pastedValue: '2.3',
497
- });
498
- await page.waitForChanges();
499
- inputValue = await innerInput.getProperty('value');
500
- // setting value from paste allows numeric interpretation
501
- expect(inputValue).toEqual('2.30');
502
- });
503
- it('should reformat currency on format modifier change', async function () {
504
- const page = await setup({
505
- html: '<q2-input type="currency" label="Amount" value="10" />',
506
- });
507
- const input = await page.find('q2-input');
508
- const innerInput = await page.find('q2-input >>> .input-field');
509
- const inputSpy = await input.spyOnEvent('input');
510
- let inputPrefix = await page.find('q2-input >>> .input-prefix');
511
- expect(inputPrefix).not.toBeNull();
512
- expect(inputPrefix.innerText).toEqual('$');
513
- input.setProperty('formatModifier', 'EUR');
514
- await page.waitForChanges();
515
- await innerInput.press('0');
516
- // format modifier property change will update formatting
517
- expect(inputSpy).toHaveReceivedEventDetail({
518
- value: '100.00',
519
- formattedValue: '€100.00',
520
- });
521
- inputPrefix = await page.find('q2-input >>> .input-prefix');
522
- expect(inputPrefix).not.toBeNull();
523
- expect(inputPrefix.innerText).toEqual('€');
524
- });
525
- it('should convert value property to string to prevent non string values from blowing up, especially for currency', async function () {
526
- const page = await setup({ html: '<q2-input type="currency" />' });
527
- const input = await page.find('q2-input');
528
- input.setProperty('value', 50);
529
- await page.waitForChanges();
530
- const innerInput = await page.find('q2-input >>> input');
531
- const innerInputValue = await innerInput.getProperty('value');
532
- expect(innerInputValue).toEqual('50.00');
533
- });
534
- it('should remove decimals if "-integer" appended to currency code', async function () {
535
- const page = await setup({
536
- html: '<q2-input type="currency" label="Amount" value="10" format-modifier="BHD-integer" />',
537
- });
538
- const input = await page.find('q2-input');
539
- const innerInput = await page.find('q2-input >>> .input-field');
540
- const inputSpy = await input.spyOnEvent('input');
541
- let inputValue = await innerInput.getProperty('value');
542
- const inputPrefix = await page.find('q2-input >>> .input-prefix');
543
- await page.waitForChanges();
544
- expect(inputPrefix.innerText).toEqual('ب.د');
545
- expect(inputValue).toEqual('10');
546
- await innerInput.press('3');
547
- // input value gets reformatted correctly and emits value and formattedValue
548
- expect(inputSpy).toHaveReceivedEventDetail({
549
- value: '103',
550
- formattedValue: '103ب.د',
551
- });
552
- inputValue = await innerInput.getProperty('value');
553
- // formatted value is set back on inner input
554
- expect(inputValue).toEqual('103');
555
- });
556
- // Phone Number
557
- it('handles phone number masking', async function () {
558
- const page = await setup({
559
- html: '<q2-input type="phone" label="Phone Number" value="10" />',
560
- });
561
- const input = await page.find('q2-input');
562
- const innerInput = await page.find('q2-input >>> .input-field');
563
- const inputSpy = await input.spyOnEvent('input');
564
- const inputPrefix = await page.find('q2-input >>> .input-prefix');
565
- await page.waitForChanges();
566
- expect(await innerInput.getProperty('type')).toEqual('tel');
567
- expect(await innerInput.getAttribute('inputmode')).toBeNull;
568
- // Prefix not rendered for US/default
569
- expect(inputPrefix).toBeNull();
570
- // formats value on initial input
571
- expect(await innerInput.getProperty('value')).toEqual('(10');
572
- await innerInput.press('3');
573
- expect(inputSpy).toHaveReceivedEventDetail({
574
- value: '103',
575
- formattedValue: '(103',
576
- minFormattedLength: 14,
577
- });
578
- expect(await innerInput.getProperty('value')).toEqual('(103');
579
- // correct formatting character allowed
580
- await innerInput.press(')');
581
- expect(await innerInput.getProperty('value')).toEqual('(103)');
582
- // incorrect formatting character replaced by correct one
583
- await innerInput.press('-');
584
- expect(await innerInput.getProperty('value')).toEqual('(103) ');
585
- await innerInput.press('4');
586
- expect(await innerInput.getProperty('value')).toEqual('(103) 4');
587
- // letter ignored
588
- await innerInput.press('a');
589
- expect(await innerInput.getProperty('value')).toEqual('(103) 4');
590
- // invalid characters ignored
591
- await innerInput.press('!');
592
- await innerInput.press('@');
593
- await innerInput.press('#');
594
- await innerInput.press('$');
595
- await innerInput.press('%');
596
- await innerInput.press('^');
597
- await innerInput.press('*');
598
- expect(await innerInput.getProperty('value')).toEqual('(103) 4');
599
- await innerInput.press('5');
600
- expect(await innerInput.getProperty('value')).toEqual('(103) 45');
601
- await innerInput.press('6');
602
- expect(await innerInput.getProperty('value')).toEqual('(103) 456');
603
- await innerInput.press('7');
604
- expect(await innerInput.getProperty('value')).toEqual('(103) 456-7');
605
- await innerInput.press('8');
606
- expect(await innerInput.getProperty('value')).toEqual('(103) 456-78');
607
- await innerInput.press('9');
608
- expect(await innerInput.getProperty('value')).toEqual('(103) 456-789');
609
- await innerInput.press('0');
610
- expect(await innerInput.getProperty('value')).toEqual('(103) 456-7890');
611
- // Excess character not added
612
- await innerInput.press('0');
613
- expect(await innerInput.getProperty('value')).toEqual('(103) 456-7890');
614
- input.setProperty('value', '1234567890');
615
- await page.waitForChanges();
616
- expect(await innerInput.getProperty('value')).toEqual('(123) 456-7890');
617
- input.setProperty('value', '(098) 765-4321');
618
- await page.waitForChanges();
619
- expect(await innerInput.getProperty('value')).toEqual('(098) 765-4321');
620
- input.setProperty('value', '(123) 45678-90');
621
- await page.waitForChanges();
622
- expect(await innerInput.getProperty('value')).toEqual('(123) 456-7890');
623
- input.setProperty('value', '(1) 234-567890');
624
- await page.waitForChanges();
625
- expect(await innerInput.getProperty('value')).toEqual('(123) 456-7890');
626
- });
627
- // Brazil land phone number (xx) xxxx-xxxx
628
- it('handles brazil mobile phone number masking', async function () {
629
- const page = await setup({
630
- html: '<q2-input type="phone" label="Phone Number" format-modifier="BR" />',
631
- });
632
- const input = await page.find('q2-input');
633
- const innerInput = await page.find('q2-input >>> .input-field');
634
- input.setProperty('value', '2233334444');
635
- await page.waitForChanges();
636
- expect(await innerInput.getProperty('value')).toEqual('(22) 3333-4444');
637
- });
638
- // Brazil mobile number (xx) xxxxx-xxxx
639
- it('handles brazil mobile phone number masking', async function () {
640
- const page = await setup({
641
- html: '<q2-input type="phone" label="Phone Number" format-modifier="BR" />',
642
- });
643
- const input = await page.find('q2-input');
644
- const innerInput = await page.find('q2-input >>> .input-field');
645
- input.setProperty('value', '22333334444');
646
- await page.waitForChanges();
647
- expect(await innerInput.getProperty('value')).toEqual('(22) 33333-4444');
648
- expect(await innerInput.getProperty('value')).not.toEqual('(22) 3333-34444');
649
- });
650
- // UK land phone number https://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom
651
- it('handles UK mobile phone number masking', async function () {
652
- const page = await setup({
653
- html: '<q2-input label="label text" type="phone" format-modifier="US" value="1" />',
654
- });
655
- const innerInput = await page.find('q2-input >>> .input-field');
656
- const input = await page.find('q2-input');
657
- const inputSpy = await input.spyOnEvent('input');
658
- await innerInput.press('0');
659
- expect(inputSpy).toHaveReceivedEventDetail({
660
- value: '10',
661
- formattedValue: '(10',
662
- minFormattedLength: 14,
663
- });
664
- input.setProperty('value', '10');
665
- input.setProperty('formatModifier', 'GB');
666
- await page.waitForChanges();
667
- await innerInput.press('3');
668
- expect(inputSpy).toHaveReceivedEventDetail({
669
- value: '103',
670
- formattedValue: '+44 103',
671
- minFormattedLength: 13, // 9 + '+44 '
672
- });
673
- });
674
- it('handles alternate format modifiers for phone number masking', async function () {
675
- const page = await setup({
676
- html: '<q2-input type="phone" label="Amount" value="1234567890" />',
677
- });
678
- const input = await page.find('q2-input');
679
- const innerInput = await page.find('q2-input >>> .input-field');
680
- let inputPrefix = await page.find('q2-input >>> .input-prefix');
681
- // Prefix not rendered for US/default
682
- expect(inputPrefix).toBeNull();
683
- expect(await innerInput.getProperty('value')).toEqual('(123) 456-7890');
684
- input.setProperty('formatModifier', 'MX');
685
- await page.waitForChanges();
686
- inputPrefix = await page.find('q2-input >>> .input-prefix');
687
- expect(inputPrefix).not.toBeNull();
688
- expect(inputPrefix.innerText).toEqual('+52');
689
- expect(await innerInput.getProperty('value')).toEqual('(123) 456-7890');
690
- input.setProperty('formatModifier', 'MT');
691
- input.setProperty('value', '12345678');
692
- await page.waitForChanges();
693
- inputPrefix = await page.find('q2-input >>> .input-prefix');
694
- expect(inputPrefix.innerText).toEqual('+356');
695
- expect(await innerInput.getProperty('value')).toEqual('12-34-56-78');
696
- });
697
- it('should incorporate phone prefix characters into minFormattedLength', async function () {
698
- const page = await setup({
699
- html: '<q2-input label="label text" type="phone" format-modifier="US" value="1" />',
700
- });
701
- const innerInput = await page.find('q2-input >>> .input-field');
702
- const input = await page.find('q2-input');
703
- const inputSpy = await input.spyOnEvent('input');
704
- await innerInput.press('0');
705
- expect(inputSpy).toHaveReceivedEventDetail({
706
- value: '10',
707
- formattedValue: '(10',
708
- minFormattedLength: 14,
709
- });
710
- input.setProperty('value', '10');
711
- input.setProperty('formatModifier', 'MX');
712
- await page.waitForChanges();
713
- await innerInput.press('3');
714
- expect(inputSpy).toHaveReceivedEventDetail({
715
- value: '103',
716
- formattedValue: '+52 (103',
717
- minFormattedLength: 18, // 14 + '+52 '
718
- });
719
- });
720
- // SSN
721
- it('handles ssn masking', async function () {
722
- const page = await setup({
723
- html: '<q2-input type="ssn" label="SSN" value="123456789" ></q2-input>',
724
- });
725
- const input = await page.find('q2-input');
726
- const innerInput = await page.find('q2-input >>> .input-field');
727
- const inputSpy = await input.spyOnEvent('input');
728
- await page.waitForChanges();
729
- expect(await innerInput.getProperty('type')).toEqual('text');
730
- expect(await innerInput.getAttribute('inputmode')).toEqual('numeric');
731
- // formats value on initial input
732
- expect(await innerInput.getProperty('value')).toEqual('123-45-6789');
733
- input.setProperty('value', '123');
734
- await page.waitForChanges();
735
- await innerInput.press('4');
736
- expect(inputSpy).toHaveReceivedEventDetail({
737
- value: '1234',
738
- formattedValue: '123-4',
739
- minFormattedLength: 11,
740
- });
741
- expect(await innerInput.getProperty('value')).toEqual('123-4');
742
- await innerInput.press('5');
743
- expect(await innerInput.getProperty('value')).toEqual('123-45');
744
- // correct formatting character allowed
745
- await innerInput.press('-');
746
- expect(await innerInput.getProperty('value')).toEqual('123-45-');
747
- // letter ignored
748
- await innerInput.press('a');
749
- expect(await innerInput.getProperty('value')).toEqual('123-45-');
750
- // invalid characters ignored
751
- await innerInput.press('!');
752
- await innerInput.press('@');
753
- await innerInput.press('#');
754
- await innerInput.press('$');
755
- await innerInput.press('%');
756
- await innerInput.press('^');
757
- await innerInput.press('*');
758
- expect(await innerInput.getProperty('value')).toEqual('123-45-');
759
- await innerInput.press('6');
760
- expect(await innerInput.getProperty('value')).toEqual('123-45-6');
761
- await innerInput.press('7');
762
- expect(await innerInput.getProperty('value')).toEqual('123-45-67');
763
- await innerInput.press('8');
764
- expect(await innerInput.getProperty('value')).toEqual('123-45-678');
765
- await innerInput.press('9');
766
- expect(await innerInput.getProperty('value')).toEqual('123-45-6789');
767
- // Excess character not added
768
- await innerInput.press('0');
769
- expect(await innerInput.getProperty('value')).toEqual('123-45-6789');
770
- input.setProperty('value', '987654321');
771
- await page.waitForChanges();
772
- expect(await innerInput.getProperty('value')).toEqual('987-65-4321');
773
- input.setProperty('value', '123-45-6789');
774
- await page.waitForChanges();
775
- expect(await innerInput.getProperty('value')).toEqual('123-45-6789');
776
- input.setProperty('value', '1-2345678-9');
777
- await page.waitForChanges();
778
- expect(await innerInput.getProperty('value')).toEqual('123-45-6789');
779
- input.setProperty('value', '123-4-5678-9');
780
- await page.waitForChanges();
781
- expect(await innerInput.getProperty('value')).toEqual('123-45-6789');
782
- });
783
- // TIN
784
- it('handles tin masking', async function () {
785
- const page = await setup({
786
- html: '<q2-input type="tin" label="Tax Identification Number" value="123456789" ></q2-input>',
787
- });
788
- const input = await page.find('q2-input');
789
- const innerInput = await page.find('q2-input >>> .input-field');
790
- const inputSpy = await input.spyOnEvent('input');
791
- await page.waitForChanges();
792
- expect(await innerInput.getProperty('type')).toEqual('text');
793
- expect(await innerInput.getAttribute('inputmode')).toEqual('numeric');
794
- // formats value on initial input
795
- expect(await innerInput.getProperty('value')).toEqual('12-3456789');
796
- input.setProperty('value', '12');
797
- await page.waitForChanges();
798
- await innerInput.press('3');
799
- expect(inputSpy).toHaveReceivedEventDetail({
800
- value: '123',
801
- formattedValue: '12-3',
802
- minFormattedLength: 10,
803
- });
804
- expect(await innerInput.getProperty('value')).toEqual('12-3');
805
- // ignore non numeric
806
- await innerInput.press('@');
807
- expect(await innerInput.getProperty('value')).toEqual('12-3');
808
- await innerInput.press('4');
809
- await innerInput.press('5');
810
- await innerInput.press('6');
811
- await innerInput.press('7');
812
- await innerInput.press('8');
813
- await innerInput.press('9');
814
- expect(await innerInput.getProperty('value')).toEqual('12-3456789');
815
- });
816
- // Alphanumeric
817
- it('handles alphanumeric masking', async function () {
818
- const page = await setup({
819
- html: '<q2-input type="alphanumeric" label="Alphanumeric" value="" ></q2-input>',
820
- });
821
- const input = await page.find('q2-input');
822
- const innerInput = await page.find('q2-input >>> .input-field');
823
- const inputSpy = await input.spyOnEvent('input');
824
- expect(await innerInput.getProperty('type')).toEqual('text');
825
- await innerInput.press('1');
826
- // Allows numbers
827
- expect(inputSpy).toHaveReceivedEventDetail({
828
- value: '1',
829
- formattedValue: '1',
830
- });
831
- expect(await innerInput.getProperty('value')).toEqual('1');
832
- // Allows lowercase letters
833
- await innerInput.press('a');
834
- expect(await innerInput.getProperty('value')).toEqual('1a');
835
- // Allows uppercase letters
836
- await innerInput.press('A');
837
- expect(await innerInput.getProperty('value')).toEqual('1aA');
838
- // invalid characters ignored
839
- await innerInput.press('!');
840
- await innerInput.press('@');
841
- await innerInput.press('#');
842
- await innerInput.press('$');
843
- await innerInput.press('%');
844
- await innerInput.press('^');
845
- await innerInput.press('*');
846
- expect(await innerInput.getProperty('value')).toEqual('1aA');
847
- });
848
- // Alpha
849
- it('handles alpha masking', async function () {
850
- const page = await setup({
851
- html: '<q2-input type="alpha" label="Alpha" value="" ></q2-input>',
852
- });
853
- const input = await page.find('q2-input');
854
- const innerInput = await page.find('q2-input >>> .input-field');
855
- const inputSpy = await input.spyOnEvent('input');
856
- expect(await innerInput.getProperty('type')).toEqual('text');
857
- await innerInput.press('a');
858
- // Allows lowercase letters
859
- expect(inputSpy).toHaveReceivedEventDetail({
860
- value: 'a',
861
- formattedValue: 'a',
862
- });
863
- expect(await innerInput.getProperty('value')).toEqual('a');
864
- // Allows uppercase letters
865
- await innerInput.press('A');
866
- expect(await innerInput.getProperty('value')).toEqual('aA');
867
- // invalid characters ignored
868
- await innerInput.press('1');
869
- await innerInput.press('!');
870
- await innerInput.press('@');
871
- await innerInput.press('#');
872
- await innerInput.press('$');
873
- await innerInput.press('%');
874
- await innerInput.press('^');
875
- await innerInput.press('*');
876
- expect(await innerInput.getProperty('value')).toEqual('aA');
877
- });
878
- // Numeric
879
- it('handles numeric masking', async function () {
880
- const page = await setup({
881
- html: '<q2-input type="numeric" label="Numeric" value="" ></q2-input>',
882
- });
883
- const input = await page.find('q2-input');
884
- const innerInput = await page.find('q2-input >>> .input-field');
885
- const inputSpy = await input.spyOnEvent('input');
886
- expect(await innerInput.getProperty('type')).toEqual('text');
887
- expect(await innerInput.getAttribute('inputmode')).toEqual('decimal');
888
- await innerInput.press('-');
889
- // Allows hyphen for negative
890
- expect(await innerInput.getProperty('value')).toEqual('-');
891
- // Allows numbers
892
- await innerInput.press('1');
893
- expect(inputSpy).toHaveReceivedEventDetail({
894
- value: '-1',
895
- formattedValue: '-1',
896
- });
897
- expect(await innerInput.getProperty('value')).toEqual('-1');
898
- // Allows period
899
- await innerInput.press('.');
900
- expect(await innerInput.getProperty('value')).toEqual('-1.');
901
- // Allows comma and invalid value.
902
- await innerInput.press(',');
903
- expect(await innerInput.getProperty('value')).toEqual('-1.,');
904
- // invalid characters ignored
905
- await innerInput.press('a');
906
- await innerInput.press('A');
907
- await innerInput.press('!');
908
- await innerInput.press('@');
909
- await innerInput.press('#');
910
- await innerInput.press('$');
911
- await innerInput.press('%');
912
- await innerInput.press('^');
913
- await innerInput.press('*');
914
- expect(await innerInput.getProperty('value')).toEqual('-1.,');
915
- });
916
- it('handles alternate format modifiers for numeric masking', async function () {
917
- const page = await setup({
918
- html: '<q2-input type="numeric" label="Numeric" value="" ></q2-input>',
919
- });
920
- const input = await page.find('q2-input');
921
- const innerInput = await page.find('q2-input >>> .input-field');
922
- const inputSpy = await input.spyOnEvent('input');
923
- input.setProperty('formatModifier', 'delimited');
924
- await page.waitForChanges();
925
- await innerInput.press('-');
926
- // Allows hyphen for negative
927
- expect(inputSpy).toHaveReceivedEventDetail({
928
- value: '-',
929
- formattedValue: '-',
930
- });
931
- expect(await innerInput.getProperty('value')).toEqual('-');
932
- // Allows numbers
933
- await innerInput.press('1');
934
- expect(await innerInput.getProperty('value')).toEqual('-1');
935
- await innerInput.press('2');
936
- expect(await innerInput.getProperty('value')).toEqual('-12');
937
- await innerInput.press('3');
938
- expect(await innerInput.getProperty('value')).toEqual('-123');
939
- await innerInput.press('4');
940
- expect(await innerInput.getProperty('value')).toEqual('-1,234');
941
- await innerInput.press('5');
942
- await innerInput.press('6');
943
- await innerInput.press('7');
944
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567');
945
- // invalid characters ignored
946
- await innerInput.press('.');
947
- await innerInput.press(',');
948
- await innerInput.press('a');
949
- await innerInput.press('A');
950
- await innerInput.press('!');
951
- await innerInput.press('@');
952
- await innerInput.press('#');
953
- await innerInput.press('$');
954
- await innerInput.press('%');
955
- await innerInput.press('^');
956
- await innerInput.press('*');
957
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567');
958
- input.setProperty('formatModifier', 'integer');
959
- input.setProperty('value', '-1,234,567');
960
- await page.waitForChanges();
961
- expect(await innerInput.getProperty('value')).toEqual('-1234567');
962
- input.setProperty('formatModifier', '1dec');
963
- await page.waitForChanges();
964
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567.0');
965
- input.setProperty('formatModifier', '4dec');
966
- await page.waitForChanges();
967
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567.0000');
968
- });
969
- // Percentage
970
- it('handles percentage masking', async function () {
971
- const page = await setup({
972
- html: '<q2-input type="percentage" label="Percentage" value="" ></q2-input>',
973
- });
974
- const input = await page.find('q2-input');
975
- const innerInput = await page.find('q2-input >>> .input-field');
976
- const inputSpy = await input.spyOnEvent('input');
977
- const inputPrefix = await page.find('q2-input >>> .input-prefix');
978
- expect(await innerInput.getProperty('type')).toEqual('text');
979
- expect(await innerInput.getAttribute('inputmode')).toEqual('decimal');
980
- expect(inputPrefix).not.toBeNull();
981
- expect(inputPrefix.innerText).toEqual('%');
982
- await innerInput.press('-');
983
- // Allows hyphen for negative
984
- expect(await innerInput.getProperty('value')).toEqual('-');
985
- // Allows numbers
986
- await innerInput.press('1');
987
- expect(inputSpy).toHaveReceivedEventDetail({
988
- value: '-1',
989
- formattedValue: '-1%',
990
- });
991
- expect(await innerInput.getProperty('value')).toEqual('-1');
992
- // Allows period
993
- await innerInput.press('.');
994
- expect(await innerInput.getProperty('value')).toEqual('-1.');
995
- // Allows comma and invalid value.
996
- await innerInput.press(',');
997
- expect(await innerInput.getProperty('value')).toEqual('-1.,');
998
- // invalid characters ignored
999
- await innerInput.press('a');
1000
- await innerInput.press('A');
1001
- await innerInput.press('!');
1002
- await innerInput.press('@');
1003
- await innerInput.press('#');
1004
- await innerInput.press('$');
1005
- await innerInput.press('%');
1006
- await innerInput.press('^');
1007
- await innerInput.press('*');
1008
- expect(await innerInput.getProperty('value')).toEqual('-1.,');
1009
- });
1010
- it('handles alternate format modifiers for percentage masking', async function () {
1011
- const page = await setup({
1012
- html: '<q2-input type="percentage" label="Percentage" value="" ></q2-input>',
1013
- });
1014
- const input = await page.find('q2-input');
1015
- const innerInput = await page.find('q2-input >>> .input-field');
1016
- const inputSpy = await input.spyOnEvent('input');
1017
- const inputPrefix = await page.find('q2-input >>> .input-prefix');
1018
- expect(inputPrefix).not.toBeNull();
1019
- expect(inputPrefix.innerText).toEqual('%');
1020
- input.setProperty('formatModifier', 'delimited');
1021
- await page.waitForChanges();
1022
- await innerInput.press('-');
1023
- // Allows hyphen for negative
1024
- expect(await innerInput.getProperty('value')).toEqual('-');
1025
- // Allows numbers
1026
- await innerInput.press('1');
1027
- expect(inputSpy).toHaveReceivedEventDetail({
1028
- value: '-1',
1029
- formattedValue: '-1%',
1030
- });
1031
- expect(await innerInput.getProperty('value')).toEqual('-1');
1032
- await innerInput.press('2');
1033
- expect(await innerInput.getProperty('value')).toEqual('-12');
1034
- await innerInput.press('3');
1035
- expect(await innerInput.getProperty('value')).toEqual('-123');
1036
- await innerInput.press('4');
1037
- expect(await innerInput.getProperty('value')).toEqual('-1,234');
1038
- await innerInput.press('5');
1039
- await innerInput.press('6');
1040
- await innerInput.press('7');
1041
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567');
1042
- // invalid characters ignored
1043
- await innerInput.press('.');
1044
- await innerInput.press(',');
1045
- await innerInput.press('a');
1046
- await innerInput.press('A');
1047
- await innerInput.press('!');
1048
- await innerInput.press('@');
1049
- await innerInput.press('#');
1050
- await innerInput.press('$');
1051
- await innerInput.press('%');
1052
- await innerInput.press('^');
1053
- await innerInput.press('*');
1054
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567');
1055
- input.setProperty('formatModifier', 'integer');
1056
- input.setProperty('value', '-1,234,567');
1057
- await page.waitForChanges();
1058
- expect(await innerInput.getProperty('value')).toEqual('-1234567');
1059
- input.setProperty('formatModifier', '1dec');
1060
- await page.waitForChanges();
1061
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567.0');
1062
- input.setProperty('formatModifier', '4dec');
1063
- await page.waitForChanges();
1064
- expect(await innerInput.getProperty('value')).toEqual('-1,234,567.0000');
1065
- });
1066
- // Postal
1067
- it('handles postal code masking', async function () {
1068
- const page = await setup({
1069
- html: '<q2-input type="postal" label="Postal Code" value="12345" ></q2-input>',
1070
- });
1071
- const input = await page.find('q2-input');
1072
- const innerInput = await page.find('q2-input >>> .input-field');
1073
- const inputSpy = await input.spyOnEvent('input');
1074
- await page.waitForChanges();
1075
- expect(await innerInput.getProperty('type')).toEqual('text');
1076
- expect(innerInput.getAttribute('inputmode')).toBeNull();
1077
- // formats value on initial input
1078
- expect(await innerInput.getProperty('value')).toEqual('12345');
1079
- input.setProperty('value', '123');
1080
- await page.waitForChanges();
1081
- await innerInput.press('4');
1082
- expect(inputSpy).toHaveReceivedEventDetail({
1083
- value: '1234',
1084
- formattedValue: '1234',
1085
- minFormattedLength: 5,
1086
- });
1087
- expect(await innerInput.getProperty('value')).toEqual('1234');
1088
- // letter ignored
1089
- await innerInput.press('a');
1090
- expect(await innerInput.getProperty('value')).toEqual('1234');
1091
- // invalid characters ignored
1092
- await innerInput.press('!');
1093
- await innerInput.press('@');
1094
- await innerInput.press('#');
1095
- await innerInput.press('$');
1096
- await innerInput.press('%');
1097
- await innerInput.press('^');
1098
- await innerInput.press('*');
1099
- expect(await innerInput.getProperty('value')).toEqual('1234');
1100
- await innerInput.press('5');
1101
- expect(await innerInput.getProperty('value')).toEqual('12345');
1102
- input.setProperty('value', '12345sdfg');
1103
- await page.waitForChanges();
1104
- expect(await innerInput.getProperty('value')).toEqual('12345');
1105
- });
1106
- it('handles alternate format modifiers for postal code masking', async function () {
1107
- const page = await setup({
1108
- html: '<q2-input type="postal" label="Postal Code" value="12345" ></q2-input>',
1109
- });
1110
- const input = await page.find('q2-input');
1111
- const innerInput = await page.find('q2-input >>> .input-field');
1112
- await page.waitForChanges();
1113
- // formats value on initial input
1114
- expect(await innerInput.getProperty('value')).toEqual('12345');
1115
- input.setProperty('formatModifier', 'US+4');
1116
- await page.waitForChanges();
1117
- await innerInput.press('6');
1118
- await innerInput.press('7');
1119
- await innerInput.press('8');
1120
- await innerInput.press('9');
1121
- expect(await innerInput.getProperty('value')).toEqual('12345-6789');
1122
- });
1123
- it('should not set inputmode for postal code', async function () {
1124
- const page = await setup({
1125
- html: '<q2-input type="postal" label="Postal Code" value="A1A 1A1" ></q2-input>',
1126
- });
1127
- const input = await page.find('q2-input');
1128
- const innerInput = await page.find('q2-input >>> .input-field');
1129
- input.setProperty('formatModifier', 'CA');
1130
- await page.waitForChanges();
1131
- // formats value on initial input
1132
- expect(await innerInput.getProperty('value')).toEqual('A1A 1A1');
1133
- expect(innerInput.getAttribute('inputmode')).toBeNull();
1134
- });
1135
- // Date
1136
- it('handles date masking', async function () {
1137
- const page = await setup({
1138
- html: '<q2-input type="date" label="Date" value="10102019" ></q2-input>',
1139
- });
1140
- const input = await page.find('q2-input');
1141
- const innerInput = await page.find('q2-input >>> .input-field');
1142
- const inputSpy = await input.spyOnEvent('input');
1143
- await page.waitForChanges();
1144
- expect(await innerInput.getProperty('type')).toEqual('text');
1145
- expect(await innerInput.getAttribute('inputmode')).toEqual('numeric');
1146
- // formats value on initial input
1147
- expect(await innerInput.getProperty('value')).toEqual('10/10/2019');
1148
- input.setProperty('value', '1234');
1149
- await page.waitForChanges();
1150
- await innerInput.press('5');
1151
- expect(inputSpy).toHaveReceivedEventDetail({
1152
- value: '12/34/5',
1153
- formattedValue: '12/34/5',
1154
- minFormattedLength: 10,
1155
- });
1156
- expect(await innerInput.getProperty('value')).toEqual('12/34/5');
1157
- // letter ignored
1158
- await innerInput.press('a');
1159
- expect(await innerInput.getProperty('value')).toEqual('12/34/5');
1160
- // invalid characters ignored
1161
- await innerInput.press('!');
1162
- await innerInput.press('@');
1163
- await innerInput.press('#');
1164
- await innerInput.press('$');
1165
- await innerInput.press('%');
1166
- await innerInput.press('^');
1167
- await innerInput.press('*');
1168
- expect(await innerInput.getProperty('value')).toEqual('12/34/5');
1169
- await innerInput.press('6');
1170
- await innerInput.press('7');
1171
- await innerInput.press('8');
1172
- expect(await innerInput.getProperty('value')).toEqual('12/34/5678');
1173
- await innerInput.press('8');
1174
- expect(await innerInput.getProperty('value')).toEqual('12/34/5678');
1175
- });
1176
- it('handles alternate format modifiers for date masking', async function () {
1177
- const page = await setup({
1178
- html: '<q2-input type="date" label="Date" value="10102019" ></q2-input>',
1179
- });
1180
- const input = await page.find('q2-input');
1181
- const innerInput = await page.find('q2-input >>> .input-field');
1182
- await page.waitForChanges();
1183
- expect(await innerInput.getProperty('value')).toEqual('10/10/2019');
1184
- input.setProperty('formatModifier', 'M-D-YYYY');
1185
- await page.waitForChanges();
1186
- expect(await innerInput.getProperty('value')).toEqual('10-10-2019');
1187
- input.setProperty('value', '');
1188
- await page.waitForChanges();
1189
- await innerInput.press('1');
1190
- expect(await innerInput.getProperty('value')).toEqual('1');
1191
- // incorrect formatting char ignored
1192
- await innerInput.press('/');
1193
- expect(await innerInput.getProperty('value')).toEqual('1');
1194
- // correct formatting char accepted
1195
- await innerInput.press('-');
1196
- expect(await innerInput.getProperty('value')).toEqual('1-');
1197
- await innerInput.press('1');
1198
- await innerInput.press('0');
1199
- await innerInput.press('2');
1200
- await innerInput.press('0');
1201
- await innerInput.press('1');
1202
- await innerInput.press('9');
1203
- expect(await innerInput.getProperty('value')).toEqual('1-10-2019');
1204
- });
1205
- it('should only allow permitted, nonformatting characters up to maxlength', async () => {
1206
- const page = await setup({
1207
- html: '<q2-input type="date" maxlength="3" label="Date"></q2-input>',
1208
- });
1209
- const innerInput = await page.find('q2-input >>> .input-field');
1210
- await page.waitForChanges();
1211
- await innerInput.press('1');
1212
- await innerInput.press('0');
1213
- await innerInput.press('2');
1214
- expect(await innerInput.getProperty('value')).toEqual('10/2');
1215
- await innerInput.press('2');
1216
- expect(await innerInput.getProperty('value')).toEqual('10/2');
1217
- await page.waitForChanges();
1218
- // correct formatting char accepted
1219
- await innerInput.press('Backspace');
1220
- expect(await innerInput.getProperty('value')).toEqual('10/');
1221
- await innerInput.press('/');
1222
- await innerInput.press('1');
1223
- expect(await innerInput.getProperty('value')).toEqual('10/1');
1224
- });
1225
- it('should allow inserting permitted characters up to maxlength when our input provides a placeholder', async () => {
1226
- const page = await setup({
1227
- html: '<q2-input type="currency" maxlength="2" label="Amount"></q2-input>',
1228
- });
1229
- const innerInput = await page.find('q2-input >>> .input-field');
1230
- await page.waitForChanges();
1231
- await innerInput.press('1');
1232
- await innerInput.press('0');
1233
- await innerInput.press('2');
1234
- expect(await innerInput.getProperty('value')).toEqual('0.10');
1235
- });
1236
- it('should allow pasting text up to the character limit and truncate whatever is left over', async function () {
1237
- const page = await setup({
1238
- html: '<q2-input type="text" maxlength=10 label="text-test"></q2input>',
1239
- });
1240
- const innerInput = await page.find('q2-input >>> .input-field');
1241
- await page.waitForChanges();
1242
- const pasteValue = '01234567890123456789';
1243
- const expectedValue = '0123456789';
1244
- await dispatchEvent(page, ['q2-input', '.input-field'], 'paste', {
1245
- pastedValue: pasteValue,
1246
- });
1247
- expect(await innerInput.getProperty('value')).toEqual(expectedValue);
1248
- });
1249
- describe('cursor', () => {
1250
- it('does not allow type when the length of value is greater than equal the maxlength', async () => {
1251
- const maxlength = 4;
1252
- const page = await setup({
1253
- html: '<q2-input maxlength="' + maxlength.toString() + '" ></q2input>',
1254
- });
1255
- const innerInput = await page.find('q2-input >>> .input-field');
1256
- await page.waitForChanges();
1257
- // max length is 4, so we should be able to enter 4 characters
1258
- for (let i = 0; i < maxlength; i++) {
1259
- await innerInput.press('a');
1260
- }
1261
- // move the cursor to the middle of the string
1262
- await innerInput.press('ArrowLeft');
1263
- await innerInput.press('ArrowLeft');
1264
- // add characters to the middle of the string
1265
- await innerInput.press('f');
1266
- await innerInput.press('o');
1267
- expect(await innerInput.getProperty('value')).toEqual('aaaa');
1268
- });
1269
- it('does not move the cursor position when first character is deleted', async () => {
1270
- const page = await setup({
1271
- html: '<q2-input type="text" value="abcde 12345"></q2input>',
1272
- });
1273
- const innerInput = await page.find('q2-input >>> .input-field');
1274
- await page.waitForChanges();
1275
- const currentPosition = await innerInput.getProperty('selectionStart');
1276
- for (let i = 0; i < currentPosition - 1; i++) {
1277
- await innerInput.press('ArrowLeft');
1278
- }
1279
- await innerInput.press('Backspace');
1280
- await page.waitForChanges();
1281
- const newPosition = await innerInput.getProperty('selectionStart');
1282
- expect(newPosition).toEqual(0);
1283
- });
1284
- it('sets the cursor to where the user clicks to focus', async () => {
1285
- const page = await setup({
1286
- html: '<q2-input type="text" value="Tony Stark"></q2input>',
1287
- });
1288
- const innerInput = await page.find('q2-input >>> .input-field');
1289
- const valueLength = (await innerInput.getProperty('value')).length;
1290
- const dimensions = await getInnerInputDimensions(page);
1291
- // Simulate clicking a character in the middle of the input
1292
- await page.mouse.click(dimensions.left + 50, dimensions.top + dimensions.height / 2);
1293
- await page.waitForChanges();
1294
- expect(await innerInput.getProperty('selectionStart')).toBeLessThan(valueLength);
1295
- });
1296
- it('sets the cursor to where the user clicks if the input is already focused', async () => {
1297
- const page = await setup({
1298
- html: '<q2-input type="text" value="Tony Stark"></q2input>',
1299
- });
1300
- const innerInput = await page.find('q2-input >>> .input-field');
1301
- const valueLength = (await innerInput.getProperty('value')).length;
1302
- const dimensions = await getInnerInputDimensions(page);
1303
- await innerInput.focus();
1304
- await page.waitForChanges();
1305
- // Simulate clicking a character in the middle of the input
1306
- await page.mouse.click(dimensions.left + 50, dimensions.top + dimensions.height / 2);
80
+ describe('User Interactions', () => {
81
+ it('should show error message when error icon is clicked', async function () {
82
+ const page = await setup({ html: '<q2-input label="foo" />' });
83
+ const input = await page.find('q2-input');
84
+ input.setProperty('errors', ['broke']);
1307
85
  await page.waitForChanges();
1308
- expect(await innerInput.getProperty('selectionStart')).toBeLessThan(valueLength);
1309
- });
1310
- describe("when type is 'currency'", () => {
1311
- it('does not move the cursor to the end when first character is deleted', async () => {
86
+ const { messagesHeight, hasErrorClass } = await page.$eval('q2-input', element => {
87
+ return {
88
+ messagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
89
+ hasErrorClass: !!element.shadowRoot.querySelector('.has-error'),
90
+ };
91
+ });
92
+ // errors are not visible when not in focus
93
+ expect(messagesHeight).toEqual(0);
94
+ // error indicator is present
95
+ expect(hasErrorClass).toBe(true);
96
+ await dispatchEvent(page, ['q2-input', '[test-id="divIconError"]'], 'click');
97
+ const { expandedMessagesHeight, messagesText } = await page.$eval('q2-input', element => {
98
+ const messageContainer = element.shadowRoot.querySelector('.messages-container');
99
+ return {
100
+ expandedMessagesHeight: element.shadowRoot.querySelector('.messages-container').clientHeight,
101
+ messagesText: messageContainer.innerText.trim(),
102
+ };
103
+ });
104
+ // errors are displayed when in focus
105
+ expect(expandedMessagesHeight).toBeGreaterThan(0);
106
+ // error message is correct
107
+ expect(messagesText).toEqual('broke');
108
+ });
109
+ describe('Cursor Behavior', () => {
110
+ it('does not allow type when the length of value is greater than equal the maxlength', async () => {
111
+ const maxlength = 4;
1312
112
  const page = await setup({
1313
- html: '<q2-input type="currency" value="123"></q2input>',
113
+ html: '<q2-input maxlength="' + maxlength.toString() + '" ></q2input>',
1314
114
  });
1315
115
  const innerInput = await page.find('q2-input >>> .input-field');
1316
116
  await page.waitForChanges();
1317
- const currentPosition = await innerInput.getProperty('selectionStart');
1318
- // For loop pushes cursor to left end position of input.value
1319
- for (let i = 0; i < currentPosition - 1; i++) {
1320
- await innerInput.press('ArrowLeft');
117
+ // max length is 4, so we should be able to enter 4 characters
118
+ for (let i = 0; i < maxlength; i++) {
119
+ await innerInput.press('a');
1321
120
  await page.waitForChanges();
1322
121
  }
1323
- await innerInput.press('Backspace');
122
+ // move the cursor to the middle of the string
123
+ await innerInput.press('ArrowLeft');
124
+ await innerInput.press('ArrowLeft');
125
+ // add characters to the middle of the string
126
+ await innerInput.press('f');
127
+ await innerInput.press('o');
1324
128
  await page.waitForChanges();
1325
- const newPosition = await innerInput.getProperty('selectionStart');
1326
- // 0 represents that cursor stays at far left (beginning position of input.value)
1327
- expect(newPosition).toEqual(0);
129
+ expect(await innerInput.getProperty('value')).toEqual('aaaa');
1328
130
  });
1329
- it('moves the cursor to the left and right when pressing the arrow keys', async () => {
131
+ it('does not move the cursor position when first character is deleted', async () => {
1330
132
  const page = await setup({
1331
- html: '<q2-input type="currency" value="185940958"></q2input>',
133
+ html: '<q2-input type="text" value="abcde 12345"></q2input>',
1332
134
  });
1333
135
  const innerInput = await page.find('q2-input >>> .input-field');
1334
136
  await page.waitForChanges();
1335
- let value = await innerInput.getProperty('value');
1336
- // move the cursor to the middle of the string
1337
- const pressTimes = 4;
1338
- for (let i = 0; i < pressTimes; i++) {
137
+ const currentPosition = await innerInput.getProperty('selectionStart');
138
+ for (let i = 0; i < currentPosition - 1; i++) {
1339
139
  await innerInput.press('ArrowLeft');
1340
140
  await page.waitForChanges();
1341
141
  }
1342
- expect(await innerInput.getProperty('selectionStart')).toEqual(value.length - pressTimes);
1343
- // add characters to the middle of the string
1344
- await innerInput.press('3');
1345
- await innerInput.press('3');
1346
- expect(await innerInput.getProperty('value')).toEqual('18,594,095,338.00');
1347
- // move the cursor back to the end of the string
1348
- for (let i = 0; i < pressTimes; i++)
1349
- await innerInput.press('ArrowRight');
1350
- value = await innerInput.getProperty('value');
1351
- expect(await innerInput.getProperty('selectionStart')).toEqual(value.length);
142
+ await innerInput.press('Backspace');
143
+ await page.waitForChanges();
144
+ const newPosition = await innerInput.getProperty('selectionStart');
145
+ expect(newPosition).toEqual(0);
1352
146
  });
1353
- it('sets the cursor to the end regardless of where the user clicks to focus', async () => {
147
+ it('sets the cursor to where the user clicks to focus', async () => {
1354
148
  const page = await setup({
1355
- html: '<q2-input type="currency" value="185940958"></q2input>',
149
+ html: '<q2-input type="text" value="Tony Stark"></q2input>',
1356
150
  });
1357
151
  const innerInput = await page.find('q2-input >>> .input-field');
1358
152
  const valueLength = (await innerInput.getProperty('value')).length;
1359
153
  const dimensions = await getInnerInputDimensions(page);
1360
154
  // Simulate clicking a character in the middle of the input
1361
- await page.mouse.click(dimensions.right - 50, dimensions.top + dimensions.height / 2);
155
+ await page.mouse.click(dimensions.left + 50, dimensions.top + dimensions.height / 2);
1362
156
  await page.waitForChanges();
1363
- expect(await innerInput.getProperty('selectionStart')).toEqual(valueLength);
157
+ expect(await innerInput.getProperty('selectionStart')).toBeLessThan(valueLength);
1364
158
  });
1365
159
  it('sets the cursor to where the user clicks if the input is already focused', async () => {
1366
160
  const page = await setup({
1367
- html: '<q2-input type="currency" value="185940958"></q2input>',
161
+ html: '<q2-input type="text" value="Tony Stark"></q2input>',
1368
162
  });
1369
163
  const innerInput = await page.find('q2-input >>> .input-field');
1370
164
  const valueLength = (await innerInput.getProperty('value')).length;
@@ -1372,10 +166,83 @@ describe('q2-input', () => {
1372
166
  await innerInput.focus();
1373
167
  await page.waitForChanges();
1374
168
  // Simulate clicking a character in the middle of the input
1375
- await page.mouse.click(dimensions.right - 50, dimensions.top + dimensions.height / 2);
169
+ await page.mouse.click(dimensions.left + 50, dimensions.top + dimensions.height / 2);
1376
170
  await page.waitForChanges();
1377
171
  expect(await innerInput.getProperty('selectionStart')).toBeLessThan(valueLength);
1378
172
  });
173
+ describe("when type is 'currency'", () => {
174
+ it('does not move the cursor to the end when first character is deleted', async () => {
175
+ const page = await setup({
176
+ html: '<q2-input type="currency" value="123"></q2input>',
177
+ });
178
+ const innerInput = await page.find('q2-input >>> .input-field');
179
+ await page.waitForChanges();
180
+ const currentPosition = await innerInput.getProperty('selectionStart');
181
+ // For loop pushes cursor to left end position of input.value
182
+ for (let i = 0; i < currentPosition - 1; i++) {
183
+ await innerInput.press('ArrowLeft');
184
+ await page.waitForChanges();
185
+ }
186
+ await innerInput.press('Backspace');
187
+ await page.waitForChanges();
188
+ const newPosition = await innerInput.getProperty('selectionStart');
189
+ // 0 represents that cursor stays at far left (beginning position of input.value)
190
+ expect(newPosition).toEqual(0);
191
+ });
192
+ it('moves the cursor to the left and right when pressing the arrow keys', async () => {
193
+ const page = await setup({
194
+ html: '<q2-input type="currency" value="185940958"></q2input>',
195
+ });
196
+ const innerInput = await page.find('q2-input >>> .input-field');
197
+ await page.waitForChanges();
198
+ let value = await innerInput.getProperty('value');
199
+ // move the cursor to the middle of the string
200
+ const pressTimes = 4;
201
+ for (let i = 0; i < pressTimes; i++) {
202
+ await innerInput.press('ArrowLeft');
203
+ await page.waitForChanges();
204
+ }
205
+ expect(await innerInput.getProperty('selectionStart')).toEqual(value.length - pressTimes);
206
+ // add characters to the middle of the string
207
+ await innerInput.press('3');
208
+ await innerInput.press('3');
209
+ await page.waitForChanges();
210
+ expect(await innerInput.getProperty('value')).toEqual('18,594,095,338.00');
211
+ // move the cursor back to the end of the string
212
+ for (let i = 0; i < pressTimes; i++) {
213
+ await innerInput.press('ArrowRight');
214
+ await page.waitForChanges();
215
+ }
216
+ value = await innerInput.getProperty('value');
217
+ expect(await innerInput.getProperty('selectionStart')).toEqual(value.length);
218
+ });
219
+ it('sets the cursor to the end regardless of where the user clicks to focus', async () => {
220
+ const page = await setup({
221
+ html: '<q2-input type="currency" value="185940958"></q2input>',
222
+ });
223
+ const innerInput = await page.find('q2-input >>> .input-field');
224
+ const valueLength = (await innerInput.getProperty('value')).length;
225
+ const dimensions = await getInnerInputDimensions(page);
226
+ // Simulate clicking a character in the middle of the input
227
+ await page.mouse.click(dimensions.right - 50, dimensions.top + dimensions.height / 2);
228
+ await page.waitForChanges();
229
+ expect(await innerInput.getProperty('selectionStart')).toEqual(valueLength);
230
+ });
231
+ it('sets the cursor to where the user clicks if the input is already focused', async () => {
232
+ const page = await setup({
233
+ html: '<q2-input type="currency" value="185940958"></q2input>',
234
+ });
235
+ const innerInput = await page.find('q2-input >>> .input-field');
236
+ const valueLength = (await innerInput.getProperty('value')).length;
237
+ const dimensions = await getInnerInputDimensions(page);
238
+ await innerInput.focus();
239
+ await page.waitForChanges();
240
+ // Simulate clicking a character in the middle of the input
241
+ await page.mouse.click(dimensions.right - 50, dimensions.top + dimensions.height / 2);
242
+ await page.waitForChanges();
243
+ expect(await innerInput.getProperty('selectionStart')).toBeLessThan(valueLength);
244
+ });
245
+ });
1379
246
  });
1380
247
  describe('when on mobile', () => {
1381
248
  let page;
@@ -1395,39 +262,47 @@ describe('q2-input', () => {
1395
262
  });
1396
263
  it('moves the cursor when ArrowLeft is pressed', async () => {
1397
264
  const pressTimes = 4;
1398
- for (let i = 0; i < pressTimes; i++)
265
+ for (let i = 0; i < pressTimes; i++) {
1399
266
  await innerInput.press('ArrowLeft');
267
+ await page.waitForChanges();
268
+ }
1400
269
  expect(await innerInput.getProperty('selectionStart')).toEqual(3);
1401
270
  });
1402
271
  it('moves the cursor when ArrowRight is pressed', async () => {
1403
272
  await innerInput.press('ArrowRight');
273
+ await page.waitForChanges();
1404
274
  expect(await innerInput.getProperty('selectionStart')).toEqual(8);
1405
275
  });
1406
276
  it('moves the cursor to the beginning when ArrowUp is pressed', async () => {
1407
277
  await innerInput.press('ArrowUp');
278
+ await page.waitForChanges();
1408
279
  expect(await innerInput.getProperty('selectionStart')).toEqual(0);
1409
280
  });
1410
281
  it('moves the cursor to the end when ArrowDown is pressed', async () => {
1411
282
  await innerInput.press('ArrowDown');
283
+ await page.waitForChanges();
1412
284
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1413
285
  });
1414
286
  it('moves the cursor to the end when End is pressed', async () => {
1415
287
  await innerInput.press('End');
288
+ await page.waitForChanges();
1416
289
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1417
290
  });
1418
291
  it('moves the cursor to the beginning when Home is pressed', async () => {
1419
292
  await innerInput.press('Home');
293
+ await page.waitForChanges();
1420
294
  expect(await innerInput.getProperty('selectionStart')).toEqual(0);
1421
295
  });
1422
296
  describe("when type is 'currency'", () => {
1423
297
  beforeEach(async () => {
1424
298
  const input = await page.find('q2-input');
1425
- await input.setProperty('type', 'currency');
1426
- await input.setProperty('value', '1234567890');
299
+ input.setProperty('type', 'currency');
300
+ input.setProperty('value', '1234567890');
1427
301
  await page.waitForChanges();
1428
302
  innerInput = await page.find('q2-input >>> .input-field');
1429
303
  inputValueLength = (await innerInput.getProperty('value')).length;
1430
304
  await innerInput.focus();
305
+ await page.waitForChanges();
1431
306
  const dimensions = await getInnerInputDimensions(page);
1432
307
  await page.touchscreen.tap(dimensions.left - 50, dimensions.top + dimensions.height / 2);
1433
308
  await page.waitForChanges();
@@ -1435,28 +310,35 @@ describe('q2-input', () => {
1435
310
  });
1436
311
  it('does not move the cursor when ArrowLeft is pressed', async () => {
1437
312
  const pressTimes = 4;
1438
- for (let i = 0; i < pressTimes; i++)
313
+ for (let i = 0; i < pressTimes; i++) {
1439
314
  await innerInput.press('ArrowLeft');
315
+ await page.waitForChanges();
316
+ }
1440
317
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1441
318
  });
1442
319
  it('does not move the cursor when ArrowRight is pressed', async () => {
1443
320
  await innerInput.press('ArrowRight');
321
+ await page.waitForChanges();
1444
322
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1445
323
  });
1446
324
  it('does not move the cursor when ArrowUp is pressed', async () => {
1447
325
  await innerInput.press('ArrowUp');
326
+ await page.waitForChanges();
1448
327
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1449
328
  });
1450
329
  it('does not move the cursor when ArrowDown is pressed', async () => {
1451
330
  await innerInput.press('ArrowDown');
331
+ await page.waitForChanges();
1452
332
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1453
333
  });
1454
334
  it('does not move the cursor when End is pressed', async () => {
1455
335
  await innerInput.press('End');
336
+ await page.waitForChanges();
1456
337
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1457
338
  });
1458
339
  it('does not move the cursor when Home is pressed', async () => {
1459
340
  await innerInput.press('Home');
341
+ await page.waitForChanges();
1460
342
  expect(await innerInput.getProperty('selectionStart')).toEqual(inputValueLength);
1461
343
  });
1462
344
  it('sets the cursor at the end regardless of where the user clicks', async () => {
@@ -1469,775 +351,31 @@ describe('q2-input', () => {
1469
351
  });
1470
352
  });
1471
353
  });
1472
- it('does not allow invalid autocomplete types', async function () {
1473
- const page = await setup({ html: '<q2-input autocomplete />' });
1474
- const input = await page.find('q2-input');
1475
- const innerInput = await page.find('q2-input >>> .input-field');
1476
- // sets input autocomplete to nothing to make sure 'off' is returned
1477
- expect(await innerInput.getProperty('autocomplete')).toEqual('off');
1478
- input.setProperty('autocomplete', '');
1479
- await page.waitForChanges();
1480
- // sets input autocomplete to empty string to make sure 'off' is returned
1481
- expect(await innerInput.getProperty('autocomplete')).toEqual('off');
1482
- });
1483
- it('allows autocomplete types', async function () {
1484
- const page = await setup({ html: '<q2-input autocomplete="name" />' });
1485
- const input = await page.find('q2-input');
1486
- const innerInput = await page.find('q2-input >>> .input-field');
1487
- // sets input autocomplete to null to make sure 'off' is returned
1488
- expect(await innerInput.getProperty('autocomplete')).toEqual('name');
1489
- input.setProperty('autocomplete', 'on');
1490
- await page.waitForChanges();
1491
- // sets input autocomplete to null to make sure 'off' is returned
1492
- expect(await innerInput.getProperty('autocomplete')).toEqual('on');
1493
- });
1494
- describe(' when show-toggle visibility is set ', () => {
1495
- it('should show toggle button when visibility toggle is enabled and pass localized aria-label to innerButton', async function () {
1496
- const page = await setup({ html: '' });
1497
- await setTestStrings(page, {
1498
- 'tecton.element.input.toggleAriaLabel.hide': 'Hide {label}',
1499
- 'tecton.element.input.toggleAriaLabel.show': 'Show {label}',
1500
- });
1501
- await page.setContent('<q2-input type="text" label="foo" show-visibility-toggle />');
1502
- await page.waitForChanges();
1503
- const toggleButton = await page.find('q2-input >>> [test-id="toggleVisibilityButton"]');
1504
- expect(toggleButton).not.toBeNull();
1505
- const innerButtonAriaLabelHide = await getNestedElementAttribute(page, ['q2-input', "[test-id='toggleVisibilityButton']", 'button'], 'aria-label');
1506
- expect(innerButtonAriaLabelHide).toBe('Hide foo');
1507
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1508
- await page.waitForChanges();
1509
- const innerButtonAriaLabelShow = await getNestedElementAttribute(page, ['q2-input', "[test-id='toggleVisibilityButton']", 'button'], 'aria-label');
1510
- expect(innerButtonAriaLabelShow).toBe('Show foo');
1511
- });
1512
- it('should not show toggle button when visibility toggle is not enabled', async function () {
1513
- const page = await setup({ html: '<q2-input />' });
1514
- const toggleButton = await page.find('q2-input >>> [test-id="toggleVisibilityButton"]');
1515
- expect(toggleButton).toBeNull();
1516
- });
1517
- it('should not show toggle button even if visibility toggle is enabled but the type is not text/password', async function () {
1518
- const page = await setup({ html: '<q2-input show-visibility-toggle type="number" />' });
1519
- const toggleButton = await page.find('q2-input >>> [test-id="toggleVisibilityButton"]');
1520
- expect(toggleButton).toBeNull();
1521
- });
1522
- it('should switch inner input type to "password" when visibility toggle is clicked for type=text', async function () {
1523
- const page = await setup({ html: '<q2-input type="text" show-visibility-toggle />' });
1524
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1525
- const innerInput = await page.find('q2-input >>> .input-field');
1526
- expect(await innerInput.getProperty('type')).toEqual('password');
1527
- // clicking again should change it back to "text"
1528
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1529
- expect(await innerInput.getProperty('type')).toEqual('text');
1530
- });
1531
- it('should switch inner input type to "text" when visibility toggle is clicked for type=password', async function () {
1532
- const page = await setup({ html: '<q2-input type="password" show-visibility-toggle />' });
1533
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1534
- const innerInput = await page.find('q2-input >>> .input-field');
1535
- expect(await innerInput.getProperty('type')).toEqual('text');
1536
- // clicking again should change it back to "password"
1537
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1538
- expect(await innerInput.getProperty('type')).toEqual('password');
1539
- });
1540
- it('should move focus to q2-input when visibility toggle is clicked for type=password', async function () {
1541
- const page = await setup({ html: '<q2-input type="password" show-visibility-toggle />' });
1542
- const innerInput = await page.find('q2-input >>> .input-field');
1543
- const inputFocusSpy = await innerInput.spyOnEvent('focus');
1544
- expect(await innerInput.getProperty('type')).toEqual('password');
1545
- expect(inputFocusSpy).toHaveReceivedEventTimes(0);
1546
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1547
- expect(await innerInput.getProperty('type')).toEqual('text');
1548
- expect(inputFocusSpy).toHaveReceivedEventTimes(1);
1549
- });
1550
- it('should switch inner input type to "password" when visibility toggle is clicked for type=ssn', async function () {
1551
- const page = await setup({ html: '<q2-input type="ssn" show-visibility-toggle />' });
1552
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1553
- const innerInput = await page.find('q2-input >>> .input-field');
1554
- expect(await innerInput.getProperty('type')).toEqual('password');
1555
- expect(await innerInput.getAttribute('inputmode')).toEqual('numeric');
1556
- // clicking again should change it back to "tel"
1557
- await dispatchEvent(page, ['q2-input', '[test-id="toggleVisibilityButton"]'], 'click');
1558
- expect(await innerInput.getProperty('type')).toEqual('text');
1559
- expect(await innerInput.getAttribute('inputmode')).toEqual('numeric');
1560
- });
1561
- });
1562
- it('should match the input entered when the user types quickly', async () => {
1563
- const page = await setup({ html: '<q2-input type="currency" />' });
1564
- const innerInput = await page.find('q2-input >>> [test-id="inputField"]');
1565
- await innerInput.type('12233445678', { delay: 5 });
1566
- const innerInputValue = await innerInput.getProperty('value');
1567
- expect(innerInputValue).toEqual('122,334,456.78');
1568
- });
1569
- // Number
1570
- it('handles number type', async function () {
1571
- const page = await setup({
1572
- html: '<q2-input type="number" label="Number" value="1" ></q2-input>',
1573
- });
1574
- const innerInput = await page.find('q2-input >>> .input-field');
1575
- await page.waitForChanges();
1576
- expect(await innerInput.getProperty('type')).toEqual('number');
1577
- await innerInput.press('ArrowUp');
1578
- await page.waitForChanges();
1579
- expect(await innerInput.getProperty('value')).toEqual('2');
1580
- });
1581
- it('handles number type with valid positive decimal number', async function () {
1582
- const page = await setup({
1583
- html: '<q2-input type="number" label="Number" ></q2-input>',
1584
- });
1585
- const innerInput = await page.find('q2-input >>> .input-field');
1586
- await page.waitForChanges();
1587
- expect(await innerInput.getProperty('type')).toEqual('number');
1588
- await innerInput.press('1');
1589
- await innerInput.press('.');
1590
- await innerInput.press('2');
1591
- await page.waitForChanges();
1592
- expect(await innerInput.getProperty('value')).toEqual('1.2');
1593
- });
1594
- it('handles number type with incomplete positive decimal number (ends with period)', async function () {
1595
- const page = await setup({
1596
- html: '<q2-input type="number" label="Number" ></q2-input>',
1597
- });
1598
- const innerInput = await page.find('q2-input >>> .input-field');
1599
- await page.waitForChanges();
1600
- expect(await innerInput.getProperty('type')).toEqual('number');
1601
- await innerInput.press('1');
1602
- await innerInput.press('.');
1603
- await page.waitForChanges();
1604
- expect(await innerInput.getProperty('value')).toEqual('1');
1605
- });
1606
- it('handles number type with negative decimal number', async function () {
1607
- const page = await setup({
1608
- html: '<q2-input type="number" label="Number" ></q2-input>',
1609
- });
1610
- const innerInput = await page.find('q2-input >>> .input-field');
1611
- await page.waitForChanges();
1612
- expect(await innerInput.getProperty('type')).toEqual('number');
1613
- await innerInput.type('-1.2');
1614
- await page.waitForChanges();
1615
- expect(await innerInput.getProperty('value')).toEqual('-1.2');
1616
- });
1617
- it('handles number type with step', async function () {
1618
- const page = await setup({
1619
- html: '<q2-input type="number" label="Number" value="10" step="5" ></q2-input>',
1620
- });
1621
- const innerInput = await page.find('q2-input >>> .input-field');
1622
- await page.waitForChanges();
1623
- expect(await innerInput.getProperty('type')).toEqual('number');
1624
- await innerInput.press('ArrowUp');
1625
- await page.waitForChanges();
1626
- expect(await innerInput.getProperty('value')).toEqual('15');
1627
- await innerInput.press('ArrowDown');
1628
- await innerInput.press('ArrowDown');
1629
- await page.waitForChanges();
1630
- expect(await innerInput.getProperty('value')).toEqual('5');
1631
- });
1632
- describe('Events', () => {
1633
- let page;
1634
- let innerInput;
1635
- let input;
1636
- beforeEach(async () => {
1637
- page = await setup({ html: '<q2-input/>' });
1638
- input = await page.find('q2-input');
1639
- innerInput = await page.find('q2-input >>> .input-field');
1640
- });
1641
- describe('Standard events', () => {
1642
- it('events all necessary events when printable keys are pressed', async () => {
1643
- const keydownSpy = await input.spyOnEvent('keydown');
1644
- const inputSpy = await input.spyOnEvent('input');
1645
- const keyupSpy = await input.spyOnEvent('keyup');
1646
- await innerInput.press('a');
1647
- await page.waitForChanges();
1648
- expect(keydownSpy).toHaveReceivedEventTimes(1);
1649
- expect(keydownSpy).toHaveReceivedEventDetail(0);
1650
- expect(inputSpy).toHaveReceivedEventTimes(1);
1651
- expect(inputSpy).toHaveReceivedEventDetail({ value: 'a', formattedValue: 'a' });
1652
- expect(keyupSpy).toHaveReceivedEventTimes(1);
1653
- expect(keyupSpy).toHaveReceivedEventDetail(0);
1654
- });
1655
- it('events all necessary events when non-printable keys are pressed', async () => {
1656
- const keydownSpy = await input.spyOnEvent('keydown');
1657
- const inputSpy = await input.spyOnEvent('input');
1658
- const keyupSpy = await input.spyOnEvent('keyup');
1659
- await innerInput.press('Home');
1660
- await page.waitForChanges();
1661
- expect(keydownSpy).toHaveReceivedEventTimes(1);
1662
- expect(keydownSpy).toHaveReceivedEventDetail(0);
1663
- expect(inputSpy).toHaveReceivedEventTimes(0);
1664
- expect(keyupSpy).toHaveReceivedEventTimes(1);
1665
- expect(keyupSpy).toHaveReceivedEventDetail(0);
1666
- });
1667
- });
1668
- });
1669
- describe('Props', () => {
1670
- describe('ariaExpanded', () => {
1671
- it('uses "true" as value when provided', async () => {
1672
- const page = await setup({
1673
- html: `<q2-input aria-expanded="true" value="Tony" />`,
1674
- });
1675
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1676
- expect(innerButton).toEqualAttribute('aria-expanded', 'true');
1677
- });
1678
- it('uses "false" as value when provided', async () => {
1679
- const page = await setup({
1680
- html: `<q2-input aria-expanded="false" value="Tony" />`,
1681
- });
1682
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1683
- expect(innerButton).toEqualAttribute('aria-expanded', 'false');
1684
- });
1685
- it('is not added when it is not provided', async () => {
1686
- const page = await setup({
1687
- html: `<q2-input value="Tony" />`,
1688
- });
1689
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1690
- expect(innerButton).not.toHaveAttribute('aria-expanded');
1691
- });
1692
- it('no value unless explicitly set', async () => {
1693
- const page = await setup({
1694
- html: `<q2-input aria-expanded value="Tony" />`,
1695
- });
1696
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1697
- expect(innerButton).toEqualAttribute('aria-expanded', '');
1698
- });
1699
- });
1700
- describe('ariaHasPopup', () => {
1701
- it('uses "true" as value when provided', async () => {
1702
- const page = await setup({
1703
- html: `<q2-input aria-haspopup="true" value="Tony" />`,
1704
- });
1705
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1706
- expect(innerButton).toEqualAttribute('aria-haspopup', 'true');
1707
- });
1708
- it('uses "false" as value when provided', async () => {
1709
- const page = await setup({
1710
- html: `<q2-input aria-haspopup="false" value="Tony" />`,
1711
- });
1712
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1713
- expect(innerButton).toEqualAttribute('aria-haspopup', 'false');
1714
- });
1715
- it('is not added when it is not provided', async () => {
1716
- const page = await setup({
1717
- html: `<q2-input value="Tony" />`,
1718
- });
1719
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1720
- expect(innerButton).not.toHaveAttribute('aria-haspopup');
1721
- });
1722
- it('translates to empty string if not passed a value', async () => {
1723
- const page = await setup({
1724
- html: `<q2-input aria-haspopup value="Tony" />`,
1725
- });
1726
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1727
- expect(innerButton).toEqualAttribute('aria-haspopup', '');
1728
- });
1729
- const hasPopupValues = ['true', 'false', 'menu', 'listbox', 'tree', 'grid', 'dialog'];
1730
- hasPopupValues.forEach(async (value) => {
1731
- it(`sets aria-haspopup to "${value}" when passed value "${value}"`, async () => {
1732
- const page = await setup({
1733
- html: `<q2-input aria-haspopup='${value}' value="Tony" />`,
1734
- });
1735
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1736
- expect(innerButton).toEqualAttribute('aria-haspopup', value);
1737
- });
1738
- });
1739
- it('sets aria-haspopup to `null` when not provided a valid string', async () => {
1740
- const page = await setup({
1741
- html: `<q2-input aria-haspopup='foo' value="Tony" />`,
1742
- });
1743
- const innerButton = await page.find('q2-input >>> [test-id="inputField"]');
1744
- expect(innerButton).toEqualAttribute('aria-haspopup', null);
1745
- });
1746
- });
1747
- describe('clearable', () => {
1748
- describe('when false (default)', () => {
1749
- it('does not display the clear icon when not provided (default)', async () => {
1750
- const page = await setup({ html: '<q2-input value="Tony"/>' });
1751
- const clearButton = await page.find('q2-input >>> [test-id="clearButton"]');
1752
- expect(clearButton).toHaveClass('hidden');
1753
- });
1754
- it('starts observing width when added at runtime', async () => {
1755
- const page = await setup({ html: '<q2-input value="Tony" />' });
1756
- await page.evaluate(() => {
1757
- document.body.style.margin = '0';
1758
- });
1759
- await page.waitForChanges();
1760
- const input = await page.find('q2-input');
1761
- await input.setProperty('clearable', true);
1762
- await page.waitForChanges();
1763
- let clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
1764
- expect(clearButtonWidth).toBe('44px');
1765
- await page.setViewport({ width: 189, height: 400 });
1766
- await page.waitForChanges();
1767
- clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
1768
- expect(clearButtonWidth).toBe('20px');
1769
- });
1770
- });
1771
- describe('when true', () => {
1772
- it('displays the clear button when there is a value', async () => {
1773
- const page = await setup({ html: '<q2-input value="Tony" clearable/>' });
1774
- const clearButton = await page.find('q2-input >>> [test-id="clearButton"]');
1775
- expect(clearButton).toBeTruthy();
1776
- });
1777
- it('clears the value and emits events when the clear button is clicked', async () => {
1778
- const page = await setup({ html: '<q2-input value="Tony" clearable/>' });
1779
- const input = await page.find('q2-input');
1780
- const innerInput = await page.find('q2-input >>> input');
1781
- const clearButton = await page.find('q2-input >>> [test-id="clearButton"]');
1782
- const inputSpy = await input.spyOnEvent('input');
1783
- const changeSpy = await input.spyOnEvent('change');
1784
- const clearSpy = await input.spyOnEvent('clear');
1785
- expect(await innerInput.getProperty('value')).toEqual('Tony');
1786
- expect(inputSpy).toHaveReceivedEventTimes(0);
1787
- expect(changeSpy).toHaveReceivedEventTimes(0);
1788
- expect(clearSpy).toHaveReceivedEventTimes(0);
1789
- await clearButton.click();
1790
- await page.waitForChanges();
1791
- const eventDetail = { value: '', formattedValue: '' };
1792
- expect(await innerInput.getProperty('value')).toEqual('');
1793
- expect(inputSpy).toHaveReceivedEventDetail(eventDetail);
1794
- expect(changeSpy).toHaveReceivedEventDetail(eventDetail);
1795
- expect(clearSpy).toHaveReceivedEventTimes(1);
1796
- });
1797
- it('clear button is 44px when component is more than 190px wide', async () => {
1798
- const page = await setup({ html: '<q2-input value="Tony" clearable/>' });
1799
- await page.setViewport({ width: 193, height: 400 });
1800
- await page.evaluate(() => {
1801
- document.body.style.margin = '0';
1802
- });
1803
- await page.waitForChanges();
1804
- const clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
1805
- expect(clearButtonWidth).toBe('44px');
1806
- });
1807
- it('clear button is 20px when component is less than 190px wide', async () => {
1808
- const page = await setup({ html: '<q2-input value="Tony" clearable/>' });
1809
- await page.setViewport({ width: 189, height: 400 });
1810
- await page.evaluate(() => {
1811
- document.body.style.margin = '0';
1812
- });
1813
- await page.waitForChanges();
1814
- const clearButtonWidth = await getNestedElementStyle(page, ['q2-input', '[test-id="clearButton"]'], 'width');
1815
- expect(clearButtonWidth).toBe('20px');
1816
- });
1817
- });
1818
- });
1819
- describe('autofocus', () => {
1820
- describe('when autofocus is enabled', () => {
1821
- it('focuses on input element on page load', async () => {
1822
- const page = await setup({
1823
- html: `<q2-input autofocus></q2-input>`,
1824
- });
1825
- const q2Input = await page.find('q2-input >>> input');
1826
- expect(q2Input).toHaveAttribute('autofocus');
1827
- expect(await getActiveElementTestId(page)).toBe('inputField');
1828
- });
1829
- });
1830
- describe('when autofocus is disabled', () => {
1831
- it('does not focus on input element on page load', async () => {
1832
- const page = await setup({
1833
- html: `<q2-input></q2-input>`,
1834
- });
1835
- const q2Input = await page.find('q2-input >>> input');
1836
- expect(q2Input).not.toHaveAttribute('autofocus');
1837
- expect(await getActiveElementTestId(page)).toBeNull();
1838
- });
1839
- });
1840
- });
1841
- describe('badgeValue', () => {
1842
- describe('when not provided', () => {
1843
- it('does not add the badge element', async () => {
1844
- const page = await setup({ html: '<q2-input />' });
1845
- const badge = await page.find('q2-input >>> q2-badge');
1846
- expect(badge).toBeNull();
1847
- });
1848
- });
1849
- describe('when provided', () => {
1850
- it('adds badge element', async () => {
1851
- const page = await setup({ html: '<q2-input badge-value="5"/>' });
1852
- const badge = await page.find('q2-input >>> q2-badge');
1853
- expect(badge.textContent).toEqual('5');
1854
- });
1855
- });
1856
- });
1857
- describe('badgeTheme', () => {
1858
- let page;
1859
- let input;
1860
- let badge;
1861
- beforeEach(async () => {
1862
- page = await setup({ html: '<q2-input badge-value="5"/>' });
1863
- input = await page.find('q2-input');
1864
- badge = await page.find('q2-input >>> q2-badge');
1865
- });
1866
- describe('when not provided', () => {
1867
- it('does not add the badge element', async () => {
1868
- expect(badge).not.toHaveAttribute('theme');
1869
- });
1870
- });
1871
- describe('when provided', () => {
1872
- beforeEach(async () => {
1873
- await input.setProperty('badgeTheme', 'primary');
1874
- await page.waitForChanges();
1875
- });
1876
- it('adds badge element', async () => {
1877
- expect(badge).toEqualAttribute('theme', 'primary');
1878
- });
1879
- });
1880
- });
1881
- describe('textHidden', () => {
1882
- describe('when not provided', () => {
1883
- it('is not automatically added', async () => {
1884
- const page = await setup({ html: '<q2-input />' });
1885
- const input = await page.find('q2-input');
1886
- expect(await input).not.toHaveAttribute('text-hidden');
1887
- });
1888
- it('is automatically added when type="password"', async () => {
1889
- const page = await setup({ html: '<q2-input type="password"/>' });
1890
- const input = await page.find('q2-input');
1891
- expect(await input).toHaveAttribute('text-hidden');
1892
- });
1893
- });
1894
- describe('when provided', () => {
1895
- it('persists after render', async () => {
1896
- const page = await setup({ html: '<q2-input text-hidden/>' });
1897
- const input = await page.find('q2-input');
1898
- expect(await input).toHaveAttribute('text-hidden');
1899
- });
1900
- });
1901
- });
1902
- describe('hideLabel', () => {
1903
- describe('when hideLabel is provided', () => {
1904
- it('hides the label element', async () => {
1905
- const page = await setup({ html: '<q2-input hide-label/>' });
1906
- const input = await page.find('q2-input');
1907
- expect(input).toHaveAttribute('hide-label');
1908
- input.setProperty('label', 'My Label');
1909
- await page.waitForChanges();
1910
- expect(input).toHaveAttribute('hide-label');
1911
- input.setAttribute('label', 'Your Label');
1912
- await page.waitForChanges();
1913
- expect(input).toHaveAttribute('hide-label');
1914
- const inputStyle = await input.getComputedStyle();
1915
- expect(parseInt(inputStyle.height)).toBe(46);
1916
- });
1917
- });
1918
- describe('when hideLabel is NOT provided', () => {
1919
- it('when optional is provided, it hides the label element', async () => {
1920
- const page = await setup({ html: '<q2-input optional/>' });
1921
- const input = await page.find('q2-input');
1922
- const label = await page.find('q2-input >>> label');
1923
- const hasSRClass = label.classList.contains('sr');
1924
- expect(hasSRClass).toBeTruthy();
1925
- const inputStyle = await input.getComputedStyle();
1926
- expect(parseInt(inputStyle.height)).toBe(46);
1927
- });
1928
- it('when readonly is provided, it hides the label element', async () => {
1929
- const page = await setup({ html: '<q2-input readonly/>' });
1930
- const input = await page.find('q2-input');
1931
- const label = await page.find('q2-input >>> label');
1932
- const hasSRClass = label.classList.contains('sr');
1933
- expect(hasSRClass).toBeTruthy();
1934
- const inputStyle = await input.getComputedStyle();
1935
- expect(parseInt(inputStyle.height)).toBe(46);
1936
- });
1937
- it('when label is provided, it shows the label element', async () => {
1938
- const page = await setup({ html: '<q2-input label="My Label"/>' });
1939
- const input = await page.find('q2-input');
1940
- const label = await page.find('q2-input >>> label');
1941
- const hasSRClass = label.classList.contains('sr');
1942
- expect(hasSRClass).toBeFalsy();
1943
- const inputStyle = await input.getComputedStyle();
1944
- expect(parseInt(inputStyle.height)).toBe(69);
1945
- });
1946
- it('when label is not provided, it hides the label element', async () => {
1947
- const page = await setup({ html: '<q2-input />' });
1948
- const input = await page.find('q2-input');
1949
- const label = await page.find('q2-input >>> label');
1950
- const hasSRClass = label.classList.contains('sr');
1951
- expect(hasSRClass).toBeTruthy();
1952
- const inputStyle = await input.getComputedStyle();
1953
- expect(parseInt(inputStyle.height)).toBe(46);
1954
- });
1955
- });
1956
- });
1957
- describe('type', () => {
1958
- describe('numeric', () => {
1959
- describe('format-modifier', () => {
1960
- const formatModifierTest = [
1961
- {
1962
- modifier: 'integer',
1963
- value: '-1000.00',
1964
- expected: '-1000',
1965
- },
1966
- {
1967
- modifier: 'integer-delimited',
1968
- value: '1000000.00',
1969
- expected: '1,000,000',
1970
- },
1971
- {
1972
- modifier: 'integer-positive',
1973
- value: '-1000.00',
1974
- expected: '1000',
1975
- },
1976
- {
1977
- modifier: 'integer-delimited-positive',
1978
- value: '-1000000.00',
1979
- expected: '1,000,000',
1980
- },
1981
- {
1982
- modifier: '2decimal',
1983
- value: '-1000.000',
1984
- expected: '-1000.00',
1985
- },
1986
- {
1987
- modifier: '2decimal-delimited',
1988
- value: '1000000.000',
1989
- expected: '1,000,000.00',
1990
- },
1991
- {
1992
- modifier: '2decimal-positive',
1993
- value: '-1000.000',
1994
- expected: '1000.00',
1995
- },
1996
- {
1997
- modifier: '2decimal-delimited-positive',
1998
- value: '-1000000.000',
1999
- expected: '1,000,000.00',
2000
- },
2001
- {
2002
- modifier: '3decimal',
2003
- value: '1000.00',
2004
- expected: '1000.000',
2005
- },
2006
- {
2007
- modifier: '2dec',
2008
- value: '-1000.000',
2009
- expected: '-1,000.00',
2010
- },
2011
- {
2012
- modifier: 'delimited',
2013
- value: '1000000.00',
2014
- expected: '1,000,000',
2015
- },
2016
- ];
2017
- formatModifierTest.forEach(test => {
2018
- const { modifier, value, expected } = test;
2019
- it(`on load formats correctly when set to "${modifier}" and value set to "${value}"`, async function () {
2020
- const page = await setup({
2021
- html: `<q2-input type="numeric" format-modifier="${modifier}" label="Number" value="${value}"></q2-input>`,
2022
- });
2023
- const innerInput = await page.find('q2-input >>> .input-field');
2024
- const innerInputValue = await innerInput.getProperty('value');
2025
- expect(innerInputValue).toEqual(expected);
2026
- });
2027
- it(`after load formats correctly when set to "${modifier}" and value set to "${value}"`, async function () {
2028
- const page = await setup({
2029
- html: `<q2-input type="numeric" format-modifier="${modifier}" label="Number"></q2-input>`,
2030
- });
2031
- const q2Input = await page.find('q2-input');
2032
- const innerInput = await page.find('q2-input >>> .input-field');
2033
- q2Input.setProperty('value', value);
2034
- await page.waitForChanges();
2035
- const innerInputValue = await innerInput.getProperty('value');
2036
- expect(innerInputValue).toEqual(expected);
2037
- });
2038
- });
2039
- });
2040
- });
2041
- });
2042
- });
2043
- describe('Methods', () => {
2044
- describe('setValue', () => {
2045
- it('sets the value of the input', async () => {
2046
- const page = await setup({ html: '<q2-input label="My input" />' });
2047
- const input = await page.find('q2-input');
2048
- const innerInput = await page.find('q2-input >>> input');
2049
- const inputChangeSpy = await input.spyOnEvent('change');
2050
- const inputInputSpy = await input.spyOnEvent('input');
2051
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2052
- expect(inputInputSpy).toHaveReceivedEventTimes(0);
2053
- expect(await getActiveElementTestId(page)).toBeNull();
2054
- const newValue = 'The truth is, I am Iron Man.';
2055
- await input.callMethod('setValue', newValue);
2056
- await page.waitForChanges();
2057
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2058
- expect(inputInputSpy).toHaveReceivedEventTimes(1);
2059
- expect(inputInputSpy).toHaveReceivedEventDetail({
2060
- formattedValue: newValue,
2061
- value: newValue,
2062
- });
2063
- expect(await input.getProperty('value')).toBeUndefined();
2064
- expect(await innerInput.getProperty('value')).toEqual(newValue);
2065
- expect(await getActiveElementTestId(page)).toEqual('inputField');
2066
- await innerInput.press('Tab');
2067
- await page.waitForChanges();
2068
- expect(inputChangeSpy).toHaveReceivedEventTimes(1);
2069
- expect(inputChangeSpy).toHaveReceivedEventDetail({
2070
- formattedValue: newValue,
2071
- value: newValue,
2072
- });
2073
- expect(await input.getProperty('value')).toEqual(newValue);
2074
- expect(await getActiveElementTestId(page)).toBeNull();
2075
- });
2076
- it('sets the masked value of the input', async () => {
2077
- const page = await setup({ html: '<q2-input label="My input" type="phone" />' });
2078
- const input = await page.find('q2-input');
2079
- const innerInput = await page.find('q2-input >>> input');
2080
- const inputChangeSpy = await input.spyOnEvent('change');
2081
- const inputInputSpy = await input.spyOnEvent('input');
2082
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2083
- expect(inputInputSpy).toHaveReceivedEventTimes(0);
2084
- expect(await getActiveElementTestId(page)).toBeNull();
2085
- const newValue = '5558675309';
2086
- const formattedValue = '(555) 867-5309';
2087
- await input.callMethod('setValue', newValue);
2088
- await page.waitForChanges();
2089
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2090
- expect(inputInputSpy).toHaveReceivedEventTimes(1);
2091
- expect(inputInputSpy).toHaveReceivedEventDetail({
2092
- formattedValue,
2093
- minFormattedLength: formattedValue.length,
2094
- value: newValue,
2095
- });
2096
- expect(await input.getProperty('value')).toBeUndefined();
2097
- expect(await innerInput.getProperty('value')).toEqual(formattedValue);
2098
- expect(await getActiveElementTestId(page)).toEqual('inputField');
2099
- await innerInput.press('Tab');
2100
- await page.waitForChanges();
2101
- expect(inputChangeSpy).toHaveReceivedEventTimes(1);
2102
- expect(inputChangeSpy).toHaveReceivedEventDetail({
2103
- formattedValue,
2104
- minFormattedLength: formattedValue.length,
2105
- value: newValue,
2106
- });
2107
- expect(await input.getProperty('value')).toEqual(newValue);
2108
- expect(await getActiveElementTestId(page)).toBeNull();
2109
- });
2110
- });
2111
- describe('clearValue', () => {
2112
- it('clears the value of the input', async () => {
2113
- const page = await setup({ html: '<q2-input label="My input" value="My value" clearable />' });
2114
- const input = await page.find('q2-input');
2115
- const innerInput = await page.find('q2-input >>> input');
2116
- const inputChangeSpy = await input.spyOnEvent('change');
2117
- const inputInputSpy = await input.spyOnEvent('input');
2118
- const inputClearSpy = await input.spyOnEvent('clear');
2119
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2120
- expect(inputInputSpy).toHaveReceivedEventTimes(0);
2121
- expect(inputClearSpy).toHaveReceivedEventTimes(0);
2122
- expect(await innerInput.getProperty('value')).toEqual('My value');
2123
- expect(await getActiveElementTestId(page)).toBeNull();
2124
- await input.callMethod('clearValue');
2125
- await page.waitForChanges();
2126
- expect(inputChangeSpy).toHaveReceivedEventTimes(1);
2127
- expect(inputInputSpy).toHaveReceivedEventTimes(1);
2128
- expect(inputClearSpy).toHaveReceivedEventTimes(1);
2129
- expect(inputChangeSpy).toHaveReceivedEventDetail({
2130
- formattedValue: '',
2131
- value: '',
2132
- });
2133
- expect(inputInputSpy).toHaveReceivedEventDetail({
2134
- formattedValue: '',
2135
- value: '',
2136
- });
2137
- expect(await input.getProperty('value')).toEqual('');
2138
- expect(await innerInput.getProperty('value')).toEqual('');
2139
- expect(await getActiveElementTestId(page)).toEqual('inputField');
2140
- });
2141
- it('does not clear the value of the input when not clearable', async () => {
2142
- const page = await setup({ html: '<q2-input label="My input" value="My value" />' });
2143
- const input = await page.find('q2-input');
2144
- const innerInput = await page.find('q2-input >>> input');
2145
- const inputChangeSpy = await input.spyOnEvent('change');
2146
- const inputInputSpy = await input.spyOnEvent('input');
2147
- const inputClearSpy = await input.spyOnEvent('clear');
2148
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2149
- expect(inputInputSpy).toHaveReceivedEventTimes(0);
2150
- expect(inputClearSpy).toHaveReceivedEventTimes(0);
2151
- expect(await innerInput.getProperty('value')).toEqual('My value');
2152
- expect(await getActiveElementTestId(page)).toBeNull();
2153
- await input.callMethod('clearValue');
2154
- await page.waitForChanges();
2155
- expect(inputChangeSpy).toHaveReceivedEventTimes(0);
2156
- expect(inputInputSpy).toHaveReceivedEventTimes(0);
2157
- expect(inputClearSpy).toHaveReceivedEventTimes(0);
2158
- expect(await input.getProperty('value')).toEqual('My value');
2159
- expect(await innerInput.getProperty('value')).toEqual('My value');
2160
- expect(await getActiveElementTestId(page)).toBeNull();
2161
- });
2162
- });
2163
- describe('checkValidity', () => {
2164
- it('emits invalid event when type=email with incorrect email', async () => {
2165
- const page = await setup({ html: '<q2-input label="My input" type="email" />' });
2166
- const input = await page.find('q2-input');
2167
- const inputInvalidSpy = await input.spyOnEvent('invalid');
2168
- const innerInput = await page.find('q2-input >>> .input-field');
2169
- expect(inputInvalidSpy).toHaveReceivedEventTimes(0);
2170
- expect(await getActiveElementTestId(page)).toBeNull();
2171
- // should fire invalid event when incorrect email is provided
2172
- await innerInput.press('f');
2173
- await page.waitForChanges();
2174
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2175
- // should not fire invalid event when correct email is provided
2176
- await input.callMethod('setValue', 'a@b.c');
2177
- await page.waitForChanges();
2178
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2179
- // should fire invalid event when incorrect email is provided
2180
- await input.callMethod('setValue', 'a@b.c@');
2181
- await page.waitForChanges();
2182
- expect(inputInvalidSpy).toHaveReceivedEventTimes(2);
2183
- });
2184
- });
2185
- describe('pattern', () => {
2186
- it('should fire invalid when pattern mismatches', async () => {
2187
- const pattern = '[A-Za-z]{3}';
2188
- const page = await setup({ html: `<q2-input label="My input" pattern="${pattern}" />` });
2189
- const input = await page.find('q2-input');
2190
- const inputInvalidSpy = await input.spyOnEvent('invalid');
2191
- const innerInput = await page.find('q2-input >>> .input-field');
2192
- await innerInput.press('f');
2193
- await page.waitForChanges();
2194
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2195
- expect(await innerInput.getProperty('pattern')).toBe(pattern);
2196
- });
2197
- it('should not fire invalid when pattern matches', async () => {
2198
- const pattern = '[A-Za-z]{2,4}';
2199
- const page = await setup({ html: `<q2-input label="My input" pattern="${pattern}" />` });
2200
- const input = await page.find('q2-input');
2201
- const inputInvalidSpy = await input.spyOnEvent('invalid');
2202
- const innerInput = await page.find('q2-input >>> .input-field');
2203
- await innerInput.press('a');
2204
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2205
- await innerInput.press('b');
2206
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2207
- await innerInput.press('c');
2208
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2209
- await innerInput.press('d');
2210
- expect(inputInvalidSpy).toHaveReceivedEventTimes(1);
2211
- await innerInput.press('e');
2212
- expect(inputInvalidSpy).toHaveReceivedEventTimes(2);
2213
- });
2214
- });
2215
- });
2216
354
  describe('Slots', () => {
2217
355
  describe('input-right', () => {
2218
356
  it('does not have any nodes assigned to it when not provided', async () => {
2219
357
  const page = await setup({
2220
358
  html: `
2221
- <q2-input></q2-input>
2222
- `,
359
+ <q2-input></q2-input>
360
+ `,
2223
361
  });
2224
362
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=input-right]'])).toBeUndefined();
2225
363
  });
2226
364
  it('has a node assigned to it when provided', async () => {
2227
365
  const page = await setup({
2228
366
  html: `
2229
- <q2-input>
2230
- <div slot="input-right">Test</div>
2231
- </q2-input>
2232
- `,
367
+ <q2-input>
368
+ <div slot="input-right">Test</div>
369
+ </q2-input>
370
+ `,
2233
371
  });
2234
372
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=input-right]'])).toEqual(1);
2235
373
  });
2236
374
  it('automatically updates when added at runtime', async () => {
2237
375
  const page = await setup({
2238
376
  html: `
2239
- <q2-input></q2-input>
2240
- `,
377
+ <q2-input></q2-input>
378
+ `,
2241
379
  });
2242
380
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=input-right]'])).toBeUndefined();
2243
381
  await page.$eval('q2-input', (element) => {
@@ -2259,26 +397,26 @@ describe('q2-input', () => {
2259
397
  it('does not have any nodes assigned to it when not provided', async () => {
2260
398
  const page = await setup({
2261
399
  html: `
2262
- <q2-input></q2-input>
2263
- `,
400
+ <q2-input></q2-input>
401
+ `,
2264
402
  });
2265
403
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=input-left]'])).toBeUndefined();
2266
404
  });
2267
405
  it('has a node assigned to it when provided', async () => {
2268
406
  const page = await setup({
2269
407
  html: `
2270
- <q2-input>
2271
- <div slot="input-left">Test</div>
2272
- </q2-input>
2273
- `,
408
+ <q2-input>
409
+ <div slot="input-left">Test</div>
410
+ </q2-input>
411
+ `,
2274
412
  });
2275
413
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=input-left]'])).toEqual(1);
2276
414
  });
2277
415
  it('automatically updates when added at runtime', async () => {
2278
416
  const page = await setup({
2279
417
  html: `
2280
- <q2-input></q2-input>
2281
- `,
418
+ <q2-input></q2-input>
419
+ `,
2282
420
  });
2283
421
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=input-left]'])).toBeUndefined();
2284
422
  await page.$eval('q2-input', (element) => {
@@ -2300,34 +438,24 @@ describe('q2-input', () => {
2300
438
  it('does not have any nodes assigned to it when not provided', async () => {
2301
439
  const page = await setup({
2302
440
  html: `
2303
- <q2-input></q2-input>
2304
- `,
441
+ <q2-input></q2-input>
442
+ `,
2305
443
  });
2306
444
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=label]'])).toEqual(0);
2307
445
  });
2308
446
  it('has a node assigned to it when provided', async () => {
2309
447
  const page = await setup({
2310
448
  html: `
2311
- <q2-input>
2312
- <div slot="label">Test</div>
2313
- </q2-input>
2314
- `,
449
+ <q2-input>
450
+ <div slot="label">Test</div>
451
+ </q2-input>
452
+ `,
2315
453
  });
2316
454
  expect(await getNestedAssignedElementLength(page, ['q2-input', 'slot[name=label]'])).toEqual(1);
2317
455
  expect(await getNestedElementAttribute(page, ['q2-input', 'label'], 'class')).toEqual('input-label');
2318
456
  });
2319
457
  });
2320
458
  });
2321
- describe('Deprecations', () => {
2322
- it('handles deprecated `ariaLabel` prop', async () => {
2323
- const label = 'My Label';
2324
- const page = await setup({ html: `<q2-input aria-label="${label}" />` });
2325
- await page.waitForChanges();
2326
- await testDeprecatedAriaLabel(await page.find('q2-input'), label);
2327
- // aria label no longer exists on the <input> element, so this will be null
2328
- expect(await page.find('q2-input >>> input')).toEqualAttribute('aria-label', null);
2329
- });
2330
- });
2331
459
  describe('Regressions', () => {
2332
460
  describe('TCT-2169', () => {
2333
461
  it('Limits the width of long values when pseudo is true', async () => {
@@ -2384,7 +512,32 @@ describe('q2-input', () => {
2384
512
  });
2385
513
  });
2386
514
  describe('Accessibility Tree', () => { });
2387
- describe('Keyboard Controls', () => { });
515
+ describe('Keyboard Controls', () => {
516
+ it('should match the input entered when the user types quickly', async () => {
517
+ const page = await setup({ html: '<q2-input type="currency" />' });
518
+ const innerInput = await page.find('q2-input >>> [test-id="inputField"]');
519
+ await innerInput.type('12233445678', { delay: 5 });
520
+ await page.waitForChanges();
521
+ const innerInputValue = await innerInput.getProperty('value');
522
+ expect(innerInputValue).toEqual('122,334,456.78');
523
+ });
524
+ describe('When type is number', () => {
525
+ it('Increments value with Arrow keys', async function () {
526
+ const page = await setup({
527
+ html: '<q2-input type="number" label="Number" value="1" ></q2-input>',
528
+ });
529
+ const innerInput = await page.find('q2-input >>> .input-field');
530
+ await page.waitForChanges();
531
+ expect(await innerInput.getProperty('type')).toEqual('number');
532
+ await innerInput.press('ArrowUp');
533
+ await page.waitForChanges();
534
+ expect(await innerInput.getProperty('value')).toEqual('2');
535
+ await innerInput.press('ArrowDown');
536
+ await page.waitForChanges();
537
+ expect(await innerInput.getProperty('value')).toEqual('1');
538
+ });
539
+ });
540
+ });
2388
541
  describe('Other', () => { });
2389
542
  });
2390
543
  });