@dxc-technology/halstack-react 0.0.0-34d2259 → 0.0.0-35a1d38

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 (702) hide show
  1. package/BackgroundColorContext.d.ts +1 -0
  2. package/BackgroundColorContext.js +30 -0
  3. package/HalstackContext.d.ts +1246 -0
  4. package/HalstackContext.js +306 -0
  5. package/README.md +28 -47
  6. package/accordion/Accordion.accessibility.test.d.ts +1 -0
  7. package/accordion/Accordion.accessibility.test.js +71 -0
  8. package/accordion/Accordion.d.ts +4 -0
  9. package/accordion/Accordion.js +168 -0
  10. package/accordion/Accordion.stories.tsx +241 -0
  11. package/accordion/Accordion.test.d.ts +1 -0
  12. package/accordion/Accordion.test.js +56 -0
  13. package/accordion/types.d.ts +57 -0
  14. package/accordion/types.js +5 -0
  15. package/accordion-group/AccordionGroup.accessibility.test.d.ts +1 -0
  16. package/accordion-group/AccordionGroup.accessibility.test.js +82 -0
  17. package/accordion-group/AccordionGroup.d.ts +7 -0
  18. package/accordion-group/AccordionGroup.js +101 -0
  19. package/accordion-group/AccordionGroup.stories.tsx +252 -0
  20. package/accordion-group/AccordionGroup.test.d.ts +1 -0
  21. package/accordion-group/AccordionGroup.test.js +94 -0
  22. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  23. package/accordion-group/AccordionGroupAccordion.js +31 -0
  24. package/accordion-group/AccordionGroupContext.d.ts +3 -0
  25. package/accordion-group/AccordionGroupContext.js +8 -0
  26. package/accordion-group/types.d.ts +67 -0
  27. package/accordion-group/types.js +5 -0
  28. package/action-icon/ActionIcon.accessibility.test.d.ts +1 -0
  29. package/action-icon/ActionIcon.accessibility.test.js +63 -0
  30. package/action-icon/ActionIcon.d.ts +4 -0
  31. package/action-icon/ActionIcon.js +48 -0
  32. package/action-icon/ActionIcon.stories.tsx +41 -0
  33. package/action-icon/ActionIcon.test.d.ts +1 -0
  34. package/action-icon/ActionIcon.test.js +64 -0
  35. package/action-icon/types.d.ts +26 -0
  36. package/action-icon/types.js +5 -0
  37. package/alert/Alert.accessibility.test.d.ts +1 -0
  38. package/alert/Alert.accessibility.test.js +95 -0
  39. package/alert/Alert.d.ts +4 -0
  40. package/alert/Alert.js +203 -0
  41. package/alert/Alert.stories.tsx +198 -0
  42. package/alert/Alert.test.d.ts +1 -0
  43. package/alert/Alert.test.js +75 -0
  44. package/alert/types.d.ts +49 -0
  45. package/alert/types.js +5 -0
  46. package/badge/Badge.accessibility.test.d.ts +1 -0
  47. package/badge/Badge.accessibility.test.js +129 -0
  48. package/badge/Badge.d.ts +4 -0
  49. package/badge/Badge.js +161 -0
  50. package/badge/Badge.stories.tsx +210 -0
  51. package/badge/Badge.test.d.ts +1 -0
  52. package/badge/Badge.test.js +30 -0
  53. package/badge/types.d.ts +54 -0
  54. package/badge/types.js +5 -0
  55. package/bleed/Bleed.d.ts +3 -0
  56. package/bleed/Bleed.js +43 -0
  57. package/bleed/Bleed.stories.tsx +342 -0
  58. package/bleed/types.d.ts +37 -0
  59. package/bleed/types.js +5 -0
  60. package/box/Box.accessibility.test.d.ts +1 -0
  61. package/box/Box.accessibility.test.js +33 -0
  62. package/box/Box.d.ts +4 -0
  63. package/box/Box.js +75 -0
  64. package/box/Box.stories.tsx +119 -0
  65. package/box/Box.test.d.ts +1 -0
  66. package/box/Box.test.js +13 -0
  67. package/box/types.d.ts +32 -0
  68. package/box/types.js +5 -0
  69. package/breadcrumbs/Breadcrumbs.accessibility.test.d.ts +1 -0
  70. package/breadcrumbs/Breadcrumbs.accessibility.test.js +96 -0
  71. package/breadcrumbs/Breadcrumbs.d.ts +4 -0
  72. package/breadcrumbs/Breadcrumbs.js +79 -0
  73. package/breadcrumbs/Breadcrumbs.stories.tsx +194 -0
  74. package/breadcrumbs/Breadcrumbs.test.d.ts +1 -0
  75. package/breadcrumbs/Breadcrumbs.test.js +169 -0
  76. package/breadcrumbs/Item.d.ts +4 -0
  77. package/breadcrumbs/Item.js +52 -0
  78. package/breadcrumbs/dropdownTheme.d.ts +53 -0
  79. package/breadcrumbs/dropdownTheme.js +62 -0
  80. package/breadcrumbs/types.d.ts +16 -0
  81. package/breadcrumbs/types.js +5 -0
  82. package/bulleted-list/BulletedList.accessibility.test.d.ts +1 -0
  83. package/bulleted-list/BulletedList.accessibility.test.js +119 -0
  84. package/bulleted-list/BulletedList.d.ts +7 -0
  85. package/bulleted-list/BulletedList.js +92 -0
  86. package/bulleted-list/BulletedList.stories.tsx +115 -0
  87. package/bulleted-list/types.d.ts +38 -0
  88. package/bulleted-list/types.js +5 -0
  89. package/button/Button.accessibility.test.d.ts +1 -0
  90. package/button/Button.accessibility.test.js +127 -0
  91. package/button/Button.d.ts +4 -0
  92. package/button/Button.js +121 -0
  93. package/button/Button.stories.tsx +325 -0
  94. package/button/Button.test.d.ts +1 -0
  95. package/button/Button.test.js +38 -0
  96. package/button/types.d.ts +57 -0
  97. package/button/types.js +5 -0
  98. package/card/Card.accessibility.test.d.ts +1 -0
  99. package/card/Card.accessibility.test.js +36 -0
  100. package/card/Card.d.ts +4 -0
  101. package/card/Card.js +121 -0
  102. package/card/Card.stories.tsx +171 -0
  103. package/card/Card.test.d.ts +1 -0
  104. package/card/Card.test.js +39 -0
  105. package/card/types.d.ts +62 -0
  106. package/card/types.js +5 -0
  107. package/checkbox/Checkbox.accessibility.test.d.ts +1 -0
  108. package/checkbox/Checkbox.accessibility.test.js +87 -0
  109. package/checkbox/Checkbox.d.ts +4 -0
  110. package/checkbox/Checkbox.js +212 -0
  111. package/checkbox/Checkbox.stories.tsx +222 -0
  112. package/checkbox/Checkbox.test.d.ts +1 -0
  113. package/checkbox/Checkbox.test.js +199 -0
  114. package/checkbox/types.d.ts +72 -0
  115. package/checkbox/types.js +5 -0
  116. package/chip/Chip.accessibility.test.d.ts +1 -0
  117. package/chip/Chip.accessibility.test.js +67 -0
  118. package/chip/Chip.d.ts +4 -0
  119. package/chip/Chip.js +126 -0
  120. package/chip/Chip.stories.tsx +199 -0
  121. package/chip/Chip.test.d.ts +1 -0
  122. package/chip/Chip.test.js +41 -0
  123. package/chip/types.d.ts +45 -0
  124. package/chip/types.js +5 -0
  125. package/common/coreTokens.d.ts +237 -0
  126. package/common/coreTokens.js +184 -0
  127. package/common/fonts.css +2 -0
  128. package/common/utils.d.ts +1 -0
  129. package/{dist/common → common}/utils.js +6 -12
  130. package/common/variables.d.ts +1392 -0
  131. package/common/variables.js +1264 -0
  132. package/container/Container.d.ts +4 -0
  133. package/container/Container.js +194 -0
  134. package/container/Container.stories.tsx +214 -0
  135. package/container/types.d.ts +74 -0
  136. package/container/types.js +5 -0
  137. package/contextual-menu/ContextualMenu.accessibility.test.d.ts +1 -0
  138. package/contextual-menu/ContextualMenu.accessibility.test.js +98 -0
  139. package/contextual-menu/ContextualMenu.d.ts +5 -0
  140. package/contextual-menu/ContextualMenu.js +88 -0
  141. package/contextual-menu/ContextualMenu.stories.tsx +232 -0
  142. package/contextual-menu/ContextualMenu.test.d.ts +1 -0
  143. package/contextual-menu/ContextualMenu.test.js +205 -0
  144. package/contextual-menu/GroupItem.d.ts +4 -0
  145. package/contextual-menu/GroupItem.js +67 -0
  146. package/contextual-menu/ItemAction.d.ts +4 -0
  147. package/contextual-menu/ItemAction.js +51 -0
  148. package/contextual-menu/MenuItem.d.ts +4 -0
  149. package/contextual-menu/MenuItem.js +29 -0
  150. package/contextual-menu/SingleItem.d.ts +4 -0
  151. package/contextual-menu/SingleItem.js +38 -0
  152. package/contextual-menu/types.d.ts +58 -0
  153. package/contextual-menu/types.js +5 -0
  154. package/date-input/Calendar.d.ts +4 -0
  155. package/date-input/Calendar.js +214 -0
  156. package/date-input/DateInput.accessibility.test.d.ts +1 -0
  157. package/date-input/DateInput.accessibility.test.js +230 -0
  158. package/date-input/DateInput.d.ts +4 -0
  159. package/date-input/DateInput.js +222 -0
  160. package/date-input/DateInput.stories.tsx +292 -0
  161. package/date-input/DateInput.test.d.ts +1 -0
  162. package/date-input/DateInput.test.js +809 -0
  163. package/date-input/DatePicker.d.ts +4 -0
  164. package/date-input/DatePicker.js +121 -0
  165. package/date-input/YearPicker.d.ts +4 -0
  166. package/date-input/YearPicker.js +100 -0
  167. package/date-input/types.d.ts +164 -0
  168. package/date-input/types.js +5 -0
  169. package/dialog/Dialog.accessibility.test.d.ts +1 -0
  170. package/dialog/Dialog.accessibility.test.js +69 -0
  171. package/dialog/Dialog.d.ts +4 -0
  172. package/dialog/Dialog.js +93 -0
  173. package/dialog/Dialog.stories.tsx +370 -0
  174. package/dialog/Dialog.test.d.ts +1 -0
  175. package/dialog/Dialog.test.js +371 -0
  176. package/dialog/types.d.ts +36 -0
  177. package/dialog/types.js +5 -0
  178. package/divider/Divider.accessibility.test.d.ts +1 -0
  179. package/divider/Divider.accessibility.test.js +33 -0
  180. package/divider/Divider.d.ts +4 -0
  181. package/divider/Divider.js +36 -0
  182. package/divider/Divider.stories.tsx +223 -0
  183. package/divider/Divider.test.d.ts +1 -0
  184. package/divider/Divider.test.js +38 -0
  185. package/divider/types.d.ts +21 -0
  186. package/divider/types.js +5 -0
  187. package/dropdown/Dropdown.accessibility.test.d.ts +1 -0
  188. package/dropdown/Dropdown.accessibility.test.js +184 -0
  189. package/dropdown/Dropdown.d.ts +4 -0
  190. package/dropdown/Dropdown.js +320 -0
  191. package/dropdown/Dropdown.stories.tsx +427 -0
  192. package/dropdown/Dropdown.test.d.ts +1 -0
  193. package/dropdown/Dropdown.test.js +629 -0
  194. package/dropdown/DropdownMenu.d.ts +4 -0
  195. package/dropdown/DropdownMenu.js +63 -0
  196. package/dropdown/DropdownMenuItem.d.ts +4 -0
  197. package/dropdown/DropdownMenuItem.js +71 -0
  198. package/dropdown/types.d.ts +96 -0
  199. package/dropdown/types.js +5 -0
  200. package/file-input/FileInput.accessibility.test.d.ts +1 -0
  201. package/file-input/FileInput.accessibility.test.js +167 -0
  202. package/file-input/FileInput.d.ts +4 -0
  203. package/file-input/FileInput.js +440 -0
  204. package/file-input/FileInput.stories.tsx +618 -0
  205. package/file-input/FileInput.test.d.ts +1 -0
  206. package/file-input/FileInput.test.js +404 -0
  207. package/file-input/FileItem.d.ts +4 -0
  208. package/file-input/FileItem.js +125 -0
  209. package/file-input/types.d.ts +129 -0
  210. package/file-input/types.js +5 -0
  211. package/flex/Flex.d.ts +4 -0
  212. package/flex/Flex.js +57 -0
  213. package/flex/Flex.stories.tsx +112 -0
  214. package/flex/types.d.ts +97 -0
  215. package/flex/types.js +5 -0
  216. package/footer/Footer.accessibility.test.d.ts +1 -0
  217. package/footer/Footer.accessibility.test.js +125 -0
  218. package/footer/Footer.d.ts +4 -0
  219. package/footer/Footer.js +140 -0
  220. package/footer/Footer.stories.tsx +208 -0
  221. package/footer/Footer.test.d.ts +1 -0
  222. package/footer/Footer.test.js +85 -0
  223. package/footer/Icons.d.ts +3 -0
  224. package/footer/Icons.js +108 -0
  225. package/footer/types.d.ts +64 -0
  226. package/footer/types.js +5 -0
  227. package/grid/Grid.d.ts +7 -0
  228. package/grid/Grid.js +76 -0
  229. package/grid/Grid.stories.tsx +219 -0
  230. package/grid/types.d.ts +115 -0
  231. package/grid/types.js +5 -0
  232. package/header/Header.accessibility.test.d.ts +1 -0
  233. package/header/Header.accessibility.test.js +94 -0
  234. package/header/Header.d.ts +8 -0
  235. package/header/Header.js +210 -0
  236. package/header/Header.stories.tsx +267 -0
  237. package/header/Header.test.d.ts +1 -0
  238. package/header/Header.test.js +66 -0
  239. package/header/Icons.d.ts +2 -0
  240. package/header/Icons.js +24 -0
  241. package/header/types.d.ts +33 -0
  242. package/header/types.js +5 -0
  243. package/heading/Heading.accessibility.test.d.ts +1 -0
  244. package/heading/Heading.accessibility.test.js +33 -0
  245. package/heading/Heading.d.ts +4 -0
  246. package/{dist/heading → heading}/Heading.js +34 -115
  247. package/heading/Heading.stories.tsx +54 -0
  248. package/heading/Heading.test.d.ts +1 -0
  249. package/heading/Heading.test.js +156 -0
  250. package/heading/types.d.ts +33 -0
  251. package/heading/types.js +5 -0
  252. package/icon/Icon.accessibility.test.d.ts +1 -0
  253. package/icon/Icon.accessibility.test.js +30 -0
  254. package/icon/Icon.d.ts +4 -0
  255. package/icon/Icon.js +33 -0
  256. package/icon/Icon.stories.tsx +28 -0
  257. package/icon/types.d.ts +4 -0
  258. package/icon/types.js +5 -0
  259. package/image/Image.accessibility.test.d.ts +1 -0
  260. package/image/Image.accessibility.test.js +56 -0
  261. package/image/Image.d.ts +4 -0
  262. package/image/Image.js +70 -0
  263. package/image/Image.stories.tsx +129 -0
  264. package/image/types.d.ts +72 -0
  265. package/image/types.js +5 -0
  266. package/inset/Inset.d.ts +3 -0
  267. package/inset/Inset.js +43 -0
  268. package/inset/Inset.stories.tsx +230 -0
  269. package/inset/types.d.ts +37 -0
  270. package/inset/types.js +5 -0
  271. package/layout/ApplicationLayout.d.ts +20 -0
  272. package/layout/ApplicationLayout.js +137 -0
  273. package/layout/ApplicationLayout.stories.tsx +162 -0
  274. package/layout/Icons.d.ts +7 -0
  275. package/layout/Icons.js +48 -0
  276. package/layout/types.d.ts +41 -0
  277. package/layout/types.js +5 -0
  278. package/link/Link.accessibility.test.d.ts +1 -0
  279. package/link/Link.accessibility.test.js +108 -0
  280. package/link/Link.d.ts +4 -0
  281. package/link/Link.js +117 -0
  282. package/link/Link.stories.tsx +253 -0
  283. package/link/Link.test.d.ts +1 -0
  284. package/link/Link.test.js +63 -0
  285. package/link/types.d.ts +54 -0
  286. package/link/types.js +5 -0
  287. package/main.d.ts +51 -0
  288. package/{dist/main.js → main.js} +149 -151
  289. package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
  290. package/nav-tabs/NavTabs.accessibility.test.js +44 -0
  291. package/nav-tabs/NavTabs.d.ts +7 -0
  292. package/nav-tabs/NavTabs.js +108 -0
  293. package/nav-tabs/NavTabs.stories.tsx +294 -0
  294. package/nav-tabs/NavTabs.test.d.ts +1 -0
  295. package/nav-tabs/NavTabs.test.js +77 -0
  296. package/nav-tabs/NavTabsContext.d.ts +3 -0
  297. package/nav-tabs/NavTabsContext.js +8 -0
  298. package/nav-tabs/Tab.d.ts +4 -0
  299. package/nav-tabs/Tab.js +117 -0
  300. package/nav-tabs/types.d.ts +52 -0
  301. package/nav-tabs/types.js +5 -0
  302. package/number-input/NumberInput.accessibility.test.d.ts +1 -0
  303. package/number-input/NumberInput.accessibility.test.js +228 -0
  304. package/number-input/NumberInput.d.ts +4 -0
  305. package/number-input/NumberInput.js +86 -0
  306. package/number-input/NumberInput.stories.tsx +131 -0
  307. package/number-input/NumberInput.test.d.ts +1 -0
  308. package/number-input/NumberInput.test.js +989 -0
  309. package/number-input/NumberInputContext.d.ts +3 -0
  310. package/number-input/NumberInputContext.js +8 -0
  311. package/number-input/types.d.ts +136 -0
  312. package/number-input/types.js +5 -0
  313. package/package.json +66 -56
  314. package/paginator/Paginator.accessibility.test.d.ts +1 -0
  315. package/paginator/Paginator.accessibility.test.js +79 -0
  316. package/paginator/Paginator.d.ts +4 -0
  317. package/paginator/Paginator.js +138 -0
  318. package/paginator/Paginator.stories.tsx +87 -0
  319. package/paginator/Paginator.test.d.ts +1 -0
  320. package/paginator/Paginator.test.js +335 -0
  321. package/paginator/types.d.ts +38 -0
  322. package/paginator/types.js +5 -0
  323. package/paragraph/Paragraph.accessibility.test.d.ts +1 -0
  324. package/paragraph/Paragraph.accessibility.test.js +28 -0
  325. package/paragraph/Paragraph.d.ts +5 -0
  326. package/paragraph/Paragraph.js +22 -0
  327. package/paragraph/Paragraph.stories.tsx +27 -0
  328. package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
  329. package/password-input/PasswordInput.accessibility.test.js +153 -0
  330. package/password-input/PasswordInput.d.ts +4 -0
  331. package/password-input/PasswordInput.js +97 -0
  332. package/password-input/PasswordInput.stories.tsx +99 -0
  333. package/password-input/PasswordInput.test.d.ts +1 -0
  334. package/password-input/PasswordInput.test.js +198 -0
  335. package/password-input/types.d.ts +111 -0
  336. package/password-input/types.js +5 -0
  337. package/progress-bar/ProgressBar.accessibility.test.d.ts +1 -0
  338. package/progress-bar/ProgressBar.accessibility.test.js +35 -0
  339. package/progress-bar/ProgressBar.d.ts +4 -0
  340. package/progress-bar/ProgressBar.js +146 -0
  341. package/progress-bar/ProgressBar.stories.tsx +93 -0
  342. package/progress-bar/ProgressBar.test.d.ts +1 -0
  343. package/progress-bar/ProgressBar.test.js +93 -0
  344. package/progress-bar/types.d.ts +37 -0
  345. package/progress-bar/types.js +5 -0
  346. package/quick-nav/QuickNav.accessibility.test.d.ts +1 -0
  347. package/quick-nav/QuickNav.accessibility.test.js +57 -0
  348. package/quick-nav/QuickNav.d.ts +4 -0
  349. package/quick-nav/QuickNav.js +94 -0
  350. package/quick-nav/QuickNav.stories.tsx +356 -0
  351. package/quick-nav/types.d.ts +21 -0
  352. package/quick-nav/types.js +5 -0
  353. package/radio-group/Radio.d.ts +4 -0
  354. package/radio-group/Radio.js +121 -0
  355. package/radio-group/RadioGroup.accessibility.test.d.ts +1 -0
  356. package/radio-group/RadioGroup.accessibility.test.js +97 -0
  357. package/radio-group/RadioGroup.d.ts +4 -0
  358. package/radio-group/RadioGroup.js +233 -0
  359. package/radio-group/RadioGroup.stories.tsx +214 -0
  360. package/radio-group/RadioGroup.test.d.ts +1 -0
  361. package/radio-group/RadioGroup.test.js +754 -0
  362. package/radio-group/types.d.ts +114 -0
  363. package/radio-group/types.js +5 -0
  364. package/resultset-table/Icons.d.ts +7 -0
  365. package/resultset-table/Icons.js +47 -0
  366. package/resultset-table/ResultsetTable.accessibility.test.d.ts +1 -0
  367. package/resultset-table/ResultsetTable.accessibility.test.js +285 -0
  368. package/resultset-table/ResultsetTable.d.ts +7 -0
  369. package/resultset-table/ResultsetTable.js +171 -0
  370. package/resultset-table/ResultsetTable.stories.tsx +413 -0
  371. package/resultset-table/ResultsetTable.test.d.ts +1 -0
  372. package/resultset-table/ResultsetTable.test.js +380 -0
  373. package/resultset-table/types.d.ts +100 -0
  374. package/resultset-table/types.js +5 -0
  375. package/select/Listbox.d.ts +4 -0
  376. package/select/Listbox.js +151 -0
  377. package/select/Option.d.ts +4 -0
  378. package/select/Option.js +89 -0
  379. package/select/Select.accessibility.test.d.ts +1 -0
  380. package/select/Select.accessibility.test.js +228 -0
  381. package/select/Select.d.ts +4 -0
  382. package/select/Select.js +600 -0
  383. package/select/Select.stories.tsx +919 -0
  384. package/select/Select.test.d.ts +1 -0
  385. package/select/Select.test.js +2268 -0
  386. package/select/types.d.ts +209 -0
  387. package/select/types.js +5 -0
  388. package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
  389. package/sidenav/Sidenav.accessibility.test.js +59 -0
  390. package/sidenav/Sidenav.d.ts +10 -0
  391. package/sidenav/Sidenav.js +201 -0
  392. package/sidenav/Sidenav.stories.tsx +277 -0
  393. package/sidenav/Sidenav.test.d.ts +1 -0
  394. package/sidenav/Sidenav.test.js +37 -0
  395. package/sidenav/SidenavContext.d.ts +5 -0
  396. package/sidenav/SidenavContext.js +13 -0
  397. package/sidenav/types.d.ts +76 -0
  398. package/sidenav/types.js +5 -0
  399. package/slider/Slider.accessibility.test.d.ts +1 -0
  400. package/slider/Slider.accessibility.test.js +104 -0
  401. package/slider/Slider.d.ts +4 -0
  402. package/slider/Slider.js +283 -0
  403. package/slider/Slider.stories.tsx +180 -0
  404. package/slider/Slider.test.d.ts +1 -0
  405. package/slider/Slider.test.js +257 -0
  406. package/slider/types.d.ts +86 -0
  407. package/slider/types.js +5 -0
  408. package/spinner/Spinner.accessibility.test.d.ts +1 -0
  409. package/spinner/Spinner.accessibility.test.js +96 -0
  410. package/spinner/Spinner.d.ts +4 -0
  411. package/spinner/Spinner.js +210 -0
  412. package/spinner/Spinner.stories.tsx +129 -0
  413. package/spinner/Spinner.test.d.ts +1 -0
  414. package/spinner/Spinner.test.js +55 -0
  415. package/spinner/types.d.ts +32 -0
  416. package/spinner/types.js +5 -0
  417. package/status-light/StatusLight.accessibility.test.d.ts +1 -0
  418. package/status-light/StatusLight.accessibility.test.js +157 -0
  419. package/status-light/StatusLight.d.ts +4 -0
  420. package/status-light/StatusLight.js +51 -0
  421. package/status-light/StatusLight.stories.tsx +74 -0
  422. package/status-light/StatusLight.test.d.ts +1 -0
  423. package/status-light/StatusLight.test.js +25 -0
  424. package/status-light/types.d.ts +17 -0
  425. package/status-light/types.js +5 -0
  426. package/switch/Switch.accessibility.test.d.ts +1 -0
  427. package/switch/Switch.accessibility.test.js +98 -0
  428. package/switch/Switch.d.ts +4 -0
  429. package/switch/Switch.js +211 -0
  430. package/switch/Switch.stories.tsx +149 -0
  431. package/switch/Switch.test.d.ts +1 -0
  432. package/switch/Switch.test.js +180 -0
  433. package/switch/types.d.ts +66 -0
  434. package/switch/types.js +5 -0
  435. package/table/DropdownTheme.js +62 -0
  436. package/table/Table.accessibility.test.d.ts +1 -0
  437. package/table/Table.accessibility.test.js +93 -0
  438. package/table/Table.d.ts +8 -0
  439. package/table/Table.js +161 -0
  440. package/table/Table.stories.tsx +663 -0
  441. package/table/Table.test.d.ts +1 -0
  442. package/table/Table.test.js +112 -0
  443. package/table/types.d.ts +49 -0
  444. package/table/types.js +5 -0
  445. package/tabs/Tab.d.ts +4 -0
  446. package/tabs/Tab.js +117 -0
  447. package/tabs/Tabs.accessibility.test.d.ts +1 -0
  448. package/tabs/Tabs.accessibility.test.js +56 -0
  449. package/tabs/Tabs.d.ts +4 -0
  450. package/tabs/Tabs.js +373 -0
  451. package/tabs/Tabs.stories.tsx +230 -0
  452. package/tabs/Tabs.test.d.ts +1 -0
  453. package/tabs/Tabs.test.js +276 -0
  454. package/tabs/types.d.ts +92 -0
  455. package/tabs/types.js +5 -0
  456. package/tag/Tag.accessibility.test.d.ts +1 -0
  457. package/tag/Tag.accessibility.test.js +69 -0
  458. package/tag/Tag.d.ts +4 -0
  459. package/tag/Tag.js +151 -0
  460. package/tag/Tag.stories.tsx +152 -0
  461. package/tag/Tag.test.d.ts +1 -0
  462. package/tag/Tag.test.js +41 -0
  463. package/tag/types.d.ts +69 -0
  464. package/tag/types.js +5 -0
  465. package/text-input/Suggestion.d.ts +4 -0
  466. package/text-input/Suggestion.js +67 -0
  467. package/text-input/Suggestions.d.ts +4 -0
  468. package/text-input/Suggestions.js +94 -0
  469. package/text-input/TextInput.accessibility.test.d.ts +1 -0
  470. package/text-input/TextInput.accessibility.test.js +321 -0
  471. package/text-input/TextInput.d.ts +4 -0
  472. package/text-input/TextInput.js +569 -0
  473. package/text-input/TextInput.stories.tsx +474 -0
  474. package/text-input/TextInput.test.d.ts +1 -0
  475. package/text-input/TextInput.test.js +1756 -0
  476. package/text-input/types.d.ts +205 -0
  477. package/text-input/types.js +5 -0
  478. package/textarea/Textarea.accessibility.test.d.ts +1 -0
  479. package/textarea/Textarea.accessibility.test.js +155 -0
  480. package/textarea/Textarea.d.ts +4 -0
  481. package/textarea/Textarea.js +235 -0
  482. package/textarea/Textarea.stories.tsx +174 -0
  483. package/textarea/Textarea.test.d.ts +1 -0
  484. package/textarea/Textarea.test.js +406 -0
  485. package/textarea/types.d.ts +141 -0
  486. package/textarea/types.js +5 -0
  487. package/toggle-group/ToggleGroup.accessibility.test.d.ts +1 -0
  488. package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
  489. package/toggle-group/ToggleGroup.d.ts +4 -0
  490. package/toggle-group/ToggleGroup.js +199 -0
  491. package/toggle-group/ToggleGroup.stories.tsx +218 -0
  492. package/toggle-group/ToggleGroup.test.d.ts +1 -0
  493. package/toggle-group/ToggleGroup.test.js +137 -0
  494. package/toggle-group/types.d.ts +114 -0
  495. package/toggle-group/types.js +5 -0
  496. package/typography/Typography.accessibility.test.d.ts +1 -0
  497. package/typography/Typography.accessibility.test.js +339 -0
  498. package/typography/Typography.d.ts +4 -0
  499. package/typography/Typography.js +23 -0
  500. package/typography/Typography.stories.tsx +198 -0
  501. package/typography/types.d.ts +18 -0
  502. package/typography/types.js +5 -0
  503. package/useTheme.d.ts +1145 -0
  504. package/{dist/useTheme.js → useTheme.js} +4 -11
  505. package/useTranslatedLabels.d.ts +85 -0
  506. package/useTranslatedLabels.js +14 -0
  507. package/utils/BaseTypography.d.ts +21 -0
  508. package/utils/BaseTypography.js +94 -0
  509. package/utils/FocusLock.d.ts +13 -0
  510. package/utils/FocusLock.js +124 -0
  511. package/wizard/Wizard.accessibility.test.d.ts +1 -0
  512. package/wizard/Wizard.accessibility.test.js +55 -0
  513. package/wizard/Wizard.d.ts +4 -0
  514. package/wizard/Wizard.js +239 -0
  515. package/wizard/Wizard.stories.tsx +272 -0
  516. package/wizard/Wizard.test.d.ts +1 -0
  517. package/wizard/Wizard.test.js +114 -0
  518. package/wizard/types.d.ts +64 -0
  519. package/wizard/types.js +5 -0
  520. package/babel.config.js +0 -8
  521. package/dist/BackgroundColorContext.js +0 -46
  522. package/dist/ThemeContext.js +0 -248
  523. package/dist/accordion/Accordion.js +0 -353
  524. package/dist/accordion-group/AccordionGroup.js +0 -186
  525. package/dist/alert/Alert.js +0 -403
  526. package/dist/alert/index.d.ts +0 -51
  527. package/dist/badge/Badge.js +0 -63
  528. package/dist/box/Box.js +0 -156
  529. package/dist/button/Button.js +0 -238
  530. package/dist/card/Card.js +0 -254
  531. package/dist/checkbox/Checkbox.js +0 -300
  532. package/dist/checkbox/Checkbox.stories.js +0 -144
  533. package/dist/checkbox/readme.md +0 -116
  534. package/dist/chip/Chip.js +0 -265
  535. package/dist/common/OpenSans.css +0 -81
  536. package/dist/common/RequiredComponent.js +0 -40
  537. package/dist/common/fonts/OpenSans-Bold.ttf +0 -0
  538. package/dist/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  539. package/dist/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  540. package/dist/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  541. package/dist/common/fonts/OpenSans-Italic.ttf +0 -0
  542. package/dist/common/fonts/OpenSans-Light.ttf +0 -0
  543. package/dist/common/fonts/OpenSans-LightItalic.ttf +0 -0
  544. package/dist/common/fonts/OpenSans-Regular.ttf +0 -0
  545. package/dist/common/fonts/OpenSans-SemiBold.ttf +0 -0
  546. package/dist/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  547. package/dist/common/variables.js +0 -1528
  548. package/dist/date/Date.js +0 -379
  549. package/dist/date/Date.stories.js +0 -205
  550. package/dist/date/readme.md +0 -73
  551. package/dist/dialog/Dialog.js +0 -218
  552. package/dist/dropdown/Dropdown.js +0 -544
  553. package/dist/file-input/FileInput.js +0 -644
  554. package/dist/file-input/FileItem.js +0 -280
  555. package/dist/file-input/index.d.ts +0 -81
  556. package/dist/footer/Footer.js +0 -395
  557. package/dist/footer/Footer.stories.js +0 -94
  558. package/dist/footer/dxc_logo.svg +0 -15
  559. package/dist/footer/readme.md +0 -41
  560. package/dist/header/Header.js +0 -403
  561. package/dist/header/Header.stories.js +0 -176
  562. package/dist/header/close_icon.svg +0 -1
  563. package/dist/header/dxc_logo_black.svg +0 -8
  564. package/dist/header/hamb_menu_black.svg +0 -1
  565. package/dist/header/hamb_menu_white.svg +0 -1
  566. package/dist/header/readme.md +0 -33
  567. package/dist/input-text/InputText.js +0 -707
  568. package/dist/input-text/InputText.stories.js +0 -209
  569. package/dist/input-text/error.svg +0 -1
  570. package/dist/input-text/readme.md +0 -91
  571. package/dist/layout/ApplicationLayout.js +0 -331
  572. package/dist/layout/facebook.svg +0 -45
  573. package/dist/layout/linkedin.svg +0 -50
  574. package/dist/layout/twitter.svg +0 -53
  575. package/dist/link/Link.js +0 -237
  576. package/dist/link/readme.md +0 -51
  577. package/dist/main.d.ts +0 -8
  578. package/dist/new-date/NewDate.js +0 -400
  579. package/dist/new-date/index.d.ts +0 -95
  580. package/dist/new-input-text/NewInputText.js +0 -967
  581. package/dist/new-input-text/index.d.ts +0 -135
  582. package/dist/new-select/NewSelect.js +0 -836
  583. package/dist/new-select/index.d.ts +0 -53
  584. package/dist/new-textarea/NewTextarea.js +0 -365
  585. package/dist/new-textarea/index.d.ts +0 -117
  586. package/dist/number/Number.js +0 -136
  587. package/dist/number/NumberContext.js +0 -16
  588. package/dist/number/index.d.ts +0 -113
  589. package/dist/paginator/Paginator.js +0 -289
  590. package/dist/paginator/images/next.svg +0 -3
  591. package/dist/paginator/images/nextPage.svg +0 -3
  592. package/dist/paginator/images/previous.svg +0 -3
  593. package/dist/paginator/images/previousPage.svg +0 -3
  594. package/dist/paginator/readme.md +0 -50
  595. package/dist/password/Password.js +0 -200
  596. package/dist/password/index.d.ts +0 -94
  597. package/dist/password/styles.css +0 -3
  598. package/dist/progress-bar/ProgressBar.js +0 -242
  599. package/dist/progress-bar/ProgressBar.stories.js +0 -280
  600. package/dist/progress-bar/readme.md +0 -63
  601. package/dist/radio/Radio.js +0 -209
  602. package/dist/radio/Radio.stories.js +0 -166
  603. package/dist/radio/readme.md +0 -70
  604. package/dist/resultsetTable/ResultsetTable.js +0 -358
  605. package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
  606. package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
  607. package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
  608. package/dist/select/Select.js +0 -549
  609. package/dist/sidenav/Sidenav.js +0 -179
  610. package/dist/slider/Slider.js +0 -319
  611. package/dist/slider/Slider.stories.js +0 -241
  612. package/dist/slider/readme.md +0 -64
  613. package/dist/spinner/Spinner.js +0 -381
  614. package/dist/spinner/Spinner.stories.js +0 -183
  615. package/dist/spinner/readme.md +0 -65
  616. package/dist/switch/Switch.js +0 -222
  617. package/dist/switch/Switch.stories.js +0 -134
  618. package/dist/switch/readme.md +0 -133
  619. package/dist/table/Table.js +0 -132
  620. package/dist/tabs/Tabs.js +0 -343
  621. package/dist/tabs/Tabs.stories.js +0 -130
  622. package/dist/tabs/readme.md +0 -78
  623. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  624. package/dist/tabs-for-sections/readme.md +0 -78
  625. package/dist/tag/Tag.js +0 -282
  626. package/dist/textarea/Textarea.js +0 -264
  627. package/dist/toggle/Toggle.js +0 -220
  628. package/dist/toggle/Toggle.stories.js +0 -297
  629. package/dist/toggle/readme.md +0 -80
  630. package/dist/toggle-group/ToggleGroup.js +0 -223
  631. package/dist/upload/Upload.js +0 -205
  632. package/dist/upload/Upload.stories.js +0 -72
  633. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -139
  634. package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
  635. package/dist/upload/buttons-upload/upload-button.svg +0 -1
  636. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
  637. package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
  638. package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
  639. package/dist/upload/file-upload/FileToUpload.js +0 -184
  640. package/dist/upload/file-upload/audio-icon.svg +0 -4
  641. package/dist/upload/file-upload/close.svg +0 -4
  642. package/dist/upload/file-upload/file-icon.svg +0 -4
  643. package/dist/upload/file-upload/video-icon.svg +0 -4
  644. package/dist/upload/files-upload/FilesToUpload.js +0 -123
  645. package/dist/upload/readme.md +0 -37
  646. package/dist/upload/transaction/Transaction.js +0 -175
  647. package/dist/upload/transaction/audio-icon-err.svg +0 -4
  648. package/dist/upload/transaction/audio-icon.svg +0 -4
  649. package/dist/upload/transaction/error-icon.svg +0 -4
  650. package/dist/upload/transaction/file-icon-err.svg +0 -4
  651. package/dist/upload/transaction/file-icon.svg +0 -4
  652. package/dist/upload/transaction/image-icon-err.svg +0 -4
  653. package/dist/upload/transaction/image-icon.svg +0 -4
  654. package/dist/upload/transaction/success-icon.svg +0 -4
  655. package/dist/upload/transaction/video-icon-err.svg +0 -4
  656. package/dist/upload/transaction/video-icon.svg +0 -4
  657. package/dist/upload/transactions/Transactions.js +0 -138
  658. package/dist/wizard/Wizard.js +0 -411
  659. package/dist/wizard/invalid_icon.svg +0 -5
  660. package/dist/wizard/valid_icon.svg +0 -5
  661. package/dist/wizard/validation-wrong.svg +0 -6
  662. package/test/Accordion.test.js +0 -33
  663. package/test/AccordionGroup.test.js +0 -125
  664. package/test/Alert.test.js +0 -53
  665. package/test/Box.test.js +0 -10
  666. package/test/Button.test.js +0 -18
  667. package/test/Card.test.js +0 -30
  668. package/test/Checkbox.test.js +0 -45
  669. package/test/Chip.test.js +0 -25
  670. package/test/Date.test.js +0 -393
  671. package/test/Dialog.test.js +0 -23
  672. package/test/Dropdown.test.js +0 -145
  673. package/test/FileInput.test.js +0 -201
  674. package/test/Footer.test.js +0 -99
  675. package/test/Header.test.js +0 -39
  676. package/test/Heading.test.js +0 -35
  677. package/test/InputText.test.js +0 -240
  678. package/test/Link.test.js +0 -43
  679. package/test/NewDate.test.js +0 -232
  680. package/test/NewInputText.test.js +0 -734
  681. package/test/NewTextarea.test.js +0 -195
  682. package/test/Number.test.js +0 -257
  683. package/test/Paginator.test.js +0 -177
  684. package/test/Password.test.js +0 -83
  685. package/test/ProgressBar.test.js +0 -35
  686. package/test/Radio.test.js +0 -37
  687. package/test/ResultsetTable.test.js +0 -329
  688. package/test/Select.test.js +0 -212
  689. package/test/Sidenav.test.js +0 -45
  690. package/test/Slider.test.js +0 -82
  691. package/test/Spinner.test.js +0 -32
  692. package/test/Switch.test.js +0 -45
  693. package/test/Table.test.js +0 -36
  694. package/test/Tabs.test.js +0 -109
  695. package/test/TabsForSections.test.js +0 -34
  696. package/test/Tag.test.js +0 -32
  697. package/test/TextArea.test.js +0 -52
  698. package/test/ToggleGroup.test.js +0 -81
  699. package/test/Upload.test.js +0 -60
  700. package/test/Wizard.test.js +0 -130
  701. package/test/mocks/pngMock.js +0 -1
  702. package/test/mocks/svgMock.js +0 -1
@@ -1,734 +0,0 @@
1
- import React from "react";
2
- import { render, fireEvent, waitForElementToBeRemoved } from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
-
5
- import DxcNewInputText from "../src/new-input-text/NewInputText";
6
-
7
- const countries = [
8
- "Afghanistan",
9
- "Albania",
10
- "Algeria",
11
- "Andorra",
12
- "Angola",
13
- "Antigua and Barbuda",
14
- "Bahamas",
15
- "Bahrain",
16
- "Bangladesh",
17
- "Barbados",
18
- "Cabo Verde",
19
- "Cambodia",
20
- "Cameroon",
21
- "Canada",
22
- "Cayman Islands, The",
23
- "Central African Republic",
24
- "Chad",
25
- "Democratic Republic of the Congo",
26
- "Dominican Republic",
27
- "Dominica",
28
- "Denmark",
29
- "Djibouti",
30
- ];
31
-
32
- describe("NewInputText component tests", () => {
33
- test("Renders with correct label", () => {
34
- const { getByText } = render(<DxcNewInputText label="Example label" />);
35
- expect(getByText("Example label")).toBeTruthy();
36
- });
37
- test("Renders with correct label and helper text", () => {
38
- const { getByText } = render(<DxcNewInputText label="Example label" helperText="Example helper text" />);
39
- expect(getByText("Example label")).toBeTruthy();
40
- expect(getByText("Example helper text")).toBeTruthy();
41
- });
42
- test("Renders with correct label and optional", () => {
43
- const { getByText } = render(<DxcNewInputText label="Example label" helperText="Example helper text" optional />);
44
- expect(getByText("Example label")).toBeTruthy();
45
- expect(getByText("(Optional)")).toBeTruthy();
46
- expect(getByText("Example helper text")).toBeTruthy();
47
- });
48
- test("Renders with correct placeholder", () => {
49
- const { getByRole } = render(<DxcNewInputText label="Example label" placeholder="Placeholder" />);
50
- const input = getByRole("textbox");
51
- expect(input.getAttribute("placeholder")).toBe("Placeholder");
52
- });
53
- test("Renders with error message", () => {
54
- const { getByText } = render(
55
- <DxcNewInputText label="Error label" placeholder="Placeholder" error="Error message." />
56
- );
57
- expect(getByText("Error message.")).toBeTruthy();
58
- });
59
- test("Not optional constraint (onBlur)", () => {
60
- const onChange = jest.fn();
61
- const onBlur = jest.fn();
62
- const { getByRole } = render(
63
- <DxcNewInputText label="Input label" placeholder="Placeholder" onChange={onChange} onBlur={onBlur} clearable />
64
- );
65
- const input = getByRole("textbox");
66
-
67
- fireEvent.focus(input);
68
- fireEvent.blur(input);
69
- expect(onBlur).toHaveBeenCalled();
70
- expect(onBlur).toHaveBeenCalledWith({ value: "", error: "This field is required. Please, enter a value." });
71
- fireEvent.change(input, { target: { value: "Test" } });
72
- fireEvent.blur(input);
73
- expect(onBlur).toHaveBeenCalled();
74
- expect(onBlur).toHaveBeenCalledWith({ value: "Test", error: null });
75
- });
76
- test("Not optional constraint (onChange)", () => {
77
- const onChange = jest.fn();
78
- const { getByRole } = render(
79
- <DxcNewInputText label="Input label" placeholder="Placeholder" onChange={onChange} clearable />
80
- );
81
- const input = getByRole("textbox");
82
-
83
- fireEvent.change(input, { target: { value: "Test" } });
84
- expect(onChange).toHaveBeenCalled();
85
- expect(onChange).toHaveBeenCalledWith({ value: "Test", error: null });
86
- userEvent.clear(input);
87
- expect(onChange).toHaveBeenCalled();
88
- expect(onChange).toHaveBeenCalledWith({ value: "", error: "This field is required. Please, enter a value." });
89
- });
90
- test("Pattern constraint", () => {
91
- const onChange = jest.fn();
92
- const onBlur = jest.fn();
93
- const { getByRole, getByText, queryByText } = render(
94
- <DxcNewInputText
95
- label="Input label"
96
- placeholder="Placeholder"
97
- onChange={onChange}
98
- onBlur={onBlur}
99
- margin={{ left: "medium", right: "medium" }}
100
- clearable
101
- pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
102
- />
103
- );
104
- const input = getByRole("textbox");
105
-
106
- fireEvent.change(input, { target: { value: "pattern test" } });
107
- expect(onChange).toHaveBeenCalled();
108
- expect(onChange).toHaveBeenCalledWith({ value: "pattern test", error: "Please match the format requested." });
109
- fireEvent.blur(input);
110
- expect(onBlur).toHaveBeenCalled();
111
- expect(onBlur).toHaveBeenCalledWith({ value: "pattern test", error: "Please match the format requested." });
112
- userEvent.clear(input);
113
- fireEvent.change(input, { target: { value: "pattern4&" } });
114
- expect(onChange).toHaveBeenCalled();
115
- expect(onChange).toHaveBeenCalledWith({ value: "pattern4&", error: null });
116
- fireEvent.blur(input);
117
- expect(onBlur).toHaveBeenCalled();
118
- expect(onBlur).toHaveBeenCalledWith({ value: "pattern4&", error: null });
119
- });
120
- test("Length constraint", () => {
121
- const onChange = jest.fn();
122
- const onBlur = jest.fn();
123
- const { getByRole, getByText, queryByText } = render(
124
- <DxcNewInputText
125
- label="Input label"
126
- placeholder="Placeholder"
127
- onChange={onChange}
128
- onBlur={onBlur}
129
- margin={{ left: "medium", right: "medium" }}
130
- clearable
131
- length={{ min: 5, max: 10 }}
132
- />
133
- );
134
- const input = getByRole("textbox");
135
-
136
- fireEvent.change(input, { target: { value: "test" } });
137
- expect(onChange).toHaveBeenCalled();
138
- expect(onChange).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
139
- fireEvent.blur(input);
140
- expect(onBlur).toHaveBeenCalled();
141
- expect(onBlur).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
142
- userEvent.clear(input);
143
- fireEvent.change(input, { target: { value: "length" } });
144
- expect(onChange).toHaveBeenCalled();
145
- expect(onChange).toHaveBeenCalledWith({ value: "length", error: null });
146
- fireEvent.blur(input);
147
- expect(onBlur).toHaveBeenCalled();
148
- expect(onBlur).toHaveBeenCalledWith({ value: "length", error: null });
149
- });
150
- test("Pattern and length constraints", () => {
151
- const onChange = jest.fn();
152
- const onBlur = jest.fn();
153
- const { getByRole, getByText, queryByText } = render(
154
- <DxcNewInputText
155
- label="Input label"
156
- placeholder="Placeholder"
157
- onChange={onChange}
158
- onBlur={onBlur}
159
- margin={{ left: "medium", right: "medium" }}
160
- clearable
161
- pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
162
- length={{ min: 5, max: 10 }}
163
- />
164
- );
165
- const input = getByRole("textbox");
166
-
167
- fireEvent.change(input, { target: { value: "test" } });
168
- expect(onChange).toHaveBeenCalled();
169
- expect(onChange).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
170
- fireEvent.blur(input);
171
- expect(onBlur).toHaveBeenCalled();
172
- expect(onBlur).toHaveBeenCalledWith({ value: "test", error: "Min length 5, max length 10." });
173
- fireEvent.change(input, { target: { value: "tests" } });
174
- expect(onChange).toHaveBeenCalled();
175
- expect(onChange).toHaveBeenCalledWith({ value: "tests", error: "Please match the format requested." });
176
- fireEvent.blur(input);
177
- expect(onBlur).toHaveBeenCalled();
178
- expect(onBlur).toHaveBeenCalledWith({ value: "tests", error: "Please match the format requested." });
179
- fireEvent.change(input, { target: { value: "tests4&" } });
180
- expect(onChange).toHaveBeenCalled();
181
- expect(onChange).toHaveBeenCalledWith({ value: "tests4&", error: null });
182
- fireEvent.blur(input);
183
- expect(onBlur).toHaveBeenCalled();
184
- expect(onBlur).toHaveBeenCalledWith({ value: "tests4&", error: null });
185
- });
186
- test("onChange function is called correctly", () => {
187
- const onChange = jest.fn();
188
- const { getByRole } = render(<DxcNewInputText label="Input label" onChange={onChange} />);
189
- const input = getByRole("textbox");
190
- userEvent.type(input, "onchange event test");
191
- expect(input.value).toBe("onchange event test");
192
- expect(onChange).toHaveBeenCalled();
193
- expect(onChange).toHaveBeenCalledWith({ value: "onchange event test", error: null });
194
- });
195
- test("onBlur function is called correctly", () => {
196
- const onBlur = jest.fn();
197
- const onChange = jest.fn();
198
- const { getByRole } = render(<DxcNewInputText label="Input label" onChange={onChange} onBlur={onBlur} />);
199
- const input = getByRole("textbox");
200
- fireEvent.change(input, { target: { value: "Blur test" } });
201
- fireEvent.blur(input);
202
- expect(onBlur).toHaveBeenCalled();
203
- expect(onBlur).toHaveBeenCalledWith({ value: "Blur test", error: null });
204
- });
205
- test("Clear action onClick cleans the input", () => {
206
- const { getByRole } = render(<DxcNewInputText label="Input label" clearable />);
207
- const input = getByRole("textbox");
208
- userEvent.type(input, "Test");
209
- const closeAction = getByRole("button");
210
- userEvent.click(closeAction);
211
- expect(input.value).toBe("");
212
- });
213
- test("Disabled input (action must be shown but not clickable)", () => {
214
- const onClick = jest.fn();
215
- const action = {
216
- onClick: onClick,
217
- icon: (
218
- <svg
219
- data-testid="image"
220
- xmlns="http://www.w3.org/2000/svg"
221
- height="24px"
222
- viewBox="0 0 24 24"
223
- width="24px"
224
- fill="currentColor"
225
- >
226
- <path d="M0 0h24v24H0V0z" fill="none" />
227
- <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
228
- </svg>
229
- ),
230
- };
231
- const { getByRole } = render(<DxcNewInputText label="Disabled input label" action={action} disabled />);
232
- const input = getByRole("textbox");
233
- expect(input.disabled).toBeTruthy();
234
- userEvent.click(getByRole("button"));
235
- expect(onClick).not.toHaveBeenCalled();
236
- });
237
- test("Disabled input (clear default action should not be displayed, even with text written on the input)", () => {
238
- const { getByRole, queryByRole } = render(
239
- <DxcNewInputText label="Disabled input label" value="Sample text" disabled clearable />
240
- );
241
- const input = getByRole("textbox");
242
- expect(input.disabled).toBeTruthy();
243
- expect(queryByRole("button")).toBeFalsy();
244
- });
245
- test("Disabled input (suffix and preffix must be displayed)", () => {
246
- const { getByRole, getByText } = render(
247
- <DxcNewInputText label="Disabled input label" value="Sample text" prefix="+34" suffix="USD" disabled />
248
- );
249
- const input = getByRole("textbox");
250
- expect(input.disabled).toBeTruthy();
251
- expect(getByText("+34")).toBeTruthy();
252
- expect(getByText("USD")).toBeTruthy();
253
- });
254
- test("Action prop: image displayed and onClick event", () => {
255
- const onClick = jest.fn();
256
- const action = {
257
- onClick: onClick,
258
- icon: (
259
- <svg
260
- data-testid="image"
261
- xmlns="http://www.w3.org/2000/svg"
262
- height="24px"
263
- viewBox="0 0 24 24"
264
- width="24px"
265
- fill="currentColor"
266
- >
267
- <path d="M0 0h24v24H0V0z" fill="none" />
268
- <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
269
- </svg>
270
- ),
271
- };
272
- const { getByRole, getByTestId } = render(<DxcNewInputText label="Input label" action={action} />);
273
- expect(getByTestId("image")).toBeTruthy();
274
- userEvent.click(getByRole("button"));
275
- expect(onClick).toHaveBeenCalled();
276
- });
277
- test("Renders with correct prefix and suffix", () => {
278
- const { getByText } = render(<DxcNewInputText label="Input label" prefix="+34" suffix="USD" />);
279
- expect(getByText("+34")).toBeTruthy();
280
- expect(getByText("USD")).toBeTruthy();
281
- });
282
- test("Input has correct accesibility attributes", () => {
283
- const onClick = jest.fn();
284
- const action = {
285
- onClick: onClick,
286
- icon: (
287
- <svg
288
- data-testid="image"
289
- xmlns="http://www.w3.org/2000/svg"
290
- height="24px"
291
- viewBox="0 0 24 24"
292
- width="24px"
293
- fill="currentColor"
294
- >
295
- <path d="M0 0h24v24H0V0z" fill="none" />
296
- <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
297
- </svg>
298
- ),
299
- };
300
- const { getByRole, getAllByRole } = render(<DxcNewInputText label="Example label" clearable action={action} />);
301
- const input = getByRole("textbox");
302
- expect(input.getAttribute("aria-autocomplete")).toBeNull();
303
- expect(input.getAttribute("aria-controls")).toBeNull();
304
- expect(input.getAttribute("aria-expanded")).toBeNull();
305
- expect(input.getAttribute("aria-activedescendant")).toBeNull();
306
- expect(input.getAttribute("aria-invalid")).toBe("false");
307
- expect(input.getAttribute("aria-describedBy")).toBeNull();
308
- expect(input.getAttribute("aria-required")).toBe("true");
309
- userEvent.type(input, "Text");
310
- const clear = getAllByRole("button")[0];
311
- expect(clear.getAttribute("aria-label")).toBe("Clear");
312
- });
313
- test("Autosuggest has correct accesibility attributes", () => {
314
- const { getByRole, getAllByRole } = render(
315
- <DxcNewInputText label="Autocomplete Countries" optional suggestions={countries} />
316
- );
317
- const input = getByRole("combobox");
318
- const inputId = input.id;
319
- expect(input.getAttribute("aria-autocomplete")).toBe("list");
320
- expect(input.getAttribute("aria-controls")).toBe(inputId);
321
- expect(input.getAttribute("aria-expanded")).toBe("false");
322
- expect(input.getAttribute("aria-required")).toBe("false");
323
- fireEvent.focus(input);
324
- const list = getByRole("listbox");
325
- expect(input.getAttribute("aria-expanded")).toBe("true");
326
- expect(list.getAttribute("aria-label")).toBe("Autocomplete Countries");
327
- const options = getAllByRole("option");
328
- expect(options[0].getAttribute("aria-selected")).toBe("false");
329
- });
330
- });
331
-
332
- describe("NewInputText component synchronous autosuggest tests", () => {
333
- test("Autosuggest is displayed when the input gains focus", async () => {
334
- const onChange = jest.fn();
335
- const { getByRole, getByText } = render(
336
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
337
- );
338
- const input = getByRole("combobox");
339
- fireEvent.focus(input);
340
- const list = getByRole("listbox");
341
- expect(list).toBeTruthy();
342
- expect(getByText("Afghanistan")).toBeTruthy();
343
- expect(getByText("Albania")).toBeTruthy();
344
- expect(getByText("Algeria")).toBeTruthy();
345
- expect(getByText("Andorra")).toBeTruthy();
346
- });
347
- test("Autosuggest is displayed when the user clicks the input", async () => {
348
- const onChange = jest.fn();
349
- const { getByRole, getByText } = render(
350
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
351
- );
352
- const input = getByRole("combobox");
353
- userEvent.click(input);
354
- const list = getByRole("listbox");
355
- expect(list).toBeTruthy();
356
- expect(getByText("Afghanistan")).toBeTruthy();
357
- expect(getByText("Albania")).toBeTruthy();
358
- expect(getByText("Algeria")).toBeTruthy();
359
- expect(getByText("Andorra")).toBeTruthy();
360
- });
361
- test("Autosuggest is displayed while the user is writing (if closed previously, if open stays open)", async () => {
362
- const onChange = jest.fn();
363
- const { getByRole, queryByRole, getByText, getAllByText } = render(
364
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
365
- );
366
- const input = getByRole("combobox");
367
- fireEvent.focus(input);
368
- const list = getByRole("listbox");
369
- expect(list).toBeTruthy();
370
- fireEvent.keyDown(input, { key: "Esc", code: "Esc", keyCode: 27, charCode: 27 });
371
- expect(queryByRole("listbox")).toBeFalsy();
372
- userEvent.type(input, "B");
373
- expect(list).toBeTruthy();
374
- expect(getAllByText("B").length).toBe(4);
375
- expect(getByText("ahamas")).toBeTruthy();
376
- expect(getByText("ahrain")).toBeTruthy();
377
- expect(getByText("angladesh")).toBeTruthy();
378
- expect(getByText("arbados")).toBeTruthy();
379
- });
380
- test("Autosuggest is not displayed when prop suggestions is an empty array", async () => {
381
- const onChange = jest.fn();
382
- const { queryByRole } = render(
383
- <DxcNewInputText label="Autocomplete Countries" suggestions={[]} onChange={onChange} />
384
- );
385
- const input = queryByRole("textbox");
386
- fireEvent.focus(input);
387
- expect(queryByRole("listbox")).toBeFalsy();
388
- });
389
- test("Autosuggest shows 'No results found' message when there are no matches with the user's input", async () => {
390
- const onChange = jest.fn();
391
- const { getByRole, getByText } = render(
392
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
393
- );
394
- const input = getByRole("combobox");
395
- fireEvent.focus(input);
396
- const list = getByRole("listbox");
397
- expect(list).toBeTruthy();
398
- expect(getByText("Afghanistan")).toBeTruthy();
399
- userEvent.type(input, "x");
400
- expect(list).toBeTruthy();
401
- expect(getByText("No results found")).toBeTruthy();
402
- });
403
- test("Autosuggest uncontrolled suggestion selected", async () => {
404
- const onChange = jest.fn();
405
- const { getByRole, getByText, queryByRole } = render(
406
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
407
- );
408
- const input = getByRole("combobox");
409
- fireEvent.focus(input);
410
- userEvent.type(input, "Alba");
411
- expect(onChange).toHaveBeenCalled();
412
- expect(getByText("Alba")).toBeTruthy();
413
- expect(getByText("nia")).toBeTruthy();
414
- fireEvent.mouseDown(getByRole("option"));
415
- fireEvent.mouseUp(getByRole("option"));
416
- expect(input.value).toBe("Albania");
417
- expect(queryByRole("listbox")).toBeFalsy();
418
- });
419
- test("Autosuggest controlled suggestions selected", async () => {
420
- const onChange = jest.fn();
421
- const { getByRole, getByText, queryByRole } = render(
422
- <DxcNewInputText label="Autocomplete Countries" value="Andor" suggestions={countries} onChange={onChange} />
423
- );
424
- const input = getByRole("combobox");
425
- fireEvent.focus(input);
426
- expect(input.value).toBe("Andor");
427
- expect(getByText("Andor")).toBeTruthy();
428
- expect(getByText("ra")).toBeTruthy();
429
- fireEvent.mouseDown(getByRole("option"));
430
- fireEvent.mouseUp(getByRole("option"));
431
- expect(onChange).toHaveBeenCalledWith({ value: "Andorra", error: null });
432
- expect(queryByRole("listbox")).toBeFalsy();
433
- });
434
- test("Autosuggest - Pattern constraint", async () => {
435
- const onChange = jest.fn();
436
- const onBlur = jest.fn();
437
- const { getByRole, getByText } = render(
438
- <DxcNewInputText
439
- label="Autocomplete Countries"
440
- suggestions={countries}
441
- onChange={onChange}
442
- onBlur={onBlur}
443
- pattern='^.*(?=.*[a-zA-Z])(?=.*\d)(?=.*[!&$%&? "]).*$'
444
- />
445
- );
446
- const input = getByRole("combobox");
447
- fireEvent.focus(input);
448
- userEvent.type(input, "Andor");
449
- expect(getByText("Andor")).toBeTruthy();
450
- expect(getByText("ra")).toBeTruthy();
451
- fireEvent.mouseDown(getByRole("option"));
452
- fireEvent.mouseUp(getByRole("option"));
453
- expect(onChange).toHaveBeenCalledWith({ value: "Andorra", error: "Please match the format requested." });
454
- fireEvent.blur(input);
455
- expect(onBlur).toHaveBeenCalledWith({ value: "Andorra", error: "Please match the format requested." });
456
- });
457
- test("Autosuggest - Length constraint", async () => {
458
- const onChange = jest.fn();
459
- const onBlur = jest.fn();
460
- const { getByText, getByRole } = render(
461
- <DxcNewInputText
462
- label="Autocomplete Countries"
463
- suggestions={countries}
464
- onChange={onChange}
465
- onBlur={onBlur}
466
- length={{ min: 5, max: 10 }}
467
- />
468
- );
469
- const input = getByRole("combobox");
470
- fireEvent.focus(input);
471
- userEvent.type(input, "Cha");
472
- expect(getByText("Cha")).toBeTruthy();
473
- expect(getByText("d")).toBeTruthy();
474
- fireEvent.mouseDown(getByRole("option"));
475
- fireEvent.mouseUp(getByRole("option"));
476
- expect(onChange).toHaveBeenCalledWith({ value: "Cha", error: "Min length 5, max length 10." });
477
- fireEvent.blur(input);
478
- expect(onBlur).toHaveBeenCalledWith({ value: "Chad", error: "Min length 5, max length 10." });
479
- });
480
- test("Autosuggest keys: arrow down key opens autosuggest, active first option is selected with Enter and closes the autosuggest", async () => {
481
- Element.prototype.scrollTo = () => {};
482
- const onChange = jest.fn();
483
- const { getByRole, queryByRole } = render(
484
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
485
- );
486
- const input = getByRole("combobox");
487
- fireEvent.keyDown(input, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
488
- const list = getByRole("listbox");
489
- expect(list).toBeTruthy();
490
- fireEvent.keyDown(input, { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
491
- expect(input.value).toBe("Afghanistan");
492
- expect(queryByRole("list")).toBeFalsy();
493
- });
494
- test("Autosuggest keys: arrow up key opens autosuggest, active last option is selected with Enter and closes the autosuggest", async () => {
495
- Element.prototype.scrollTo = () => {};
496
- const onChange = jest.fn();
497
- const { getByRole, queryByRole } = render(
498
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
499
- );
500
- const input = getByRole("combobox");
501
- fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
502
- const list = getByRole("listbox");
503
- expect(list).toBeTruthy();
504
- fireEvent.keyDown(input, { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
505
- expect(input.value).toBe("Djibouti");
506
- expect(queryByRole("list")).toBeFalsy();
507
- });
508
- test("Autosuggest keys: Esc key closes the autosuggest and cleans the input", async () => {
509
- Element.prototype.scrollTo = () => {};
510
- const onChange = jest.fn();
511
- const { getByRole, queryByRole } = render(
512
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
513
- );
514
- const input = getByRole("combobox");
515
- fireEvent.focus(input);
516
- userEvent.type(input, "Bangla");
517
- const list = getByRole("listbox");
518
- expect(list).toBeTruthy();
519
- fireEvent.keyDown(input, { key: "Esc", code: "Esc", keyCode: 27, charCode: 27 });
520
- expect(input.value).toBe("");
521
- expect(queryByRole("listbox")).toBeFalsy();
522
- });
523
- test("Autosuggest keys: Enter, if no active suggestion closes the autosuggest", async () => {
524
- Element.prototype.scrollTo = () => {};
525
- const onChange = jest.fn();
526
- const { getByRole, queryByRole } = render(
527
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
528
- );
529
- const input = getByRole("combobox");
530
- fireEvent.focus(input);
531
- const list = getByRole("listbox");
532
- expect(list).toBeTruthy();
533
- fireEvent.keyDown(input, { key: "Enter", code: "Enter", keyCode: 27, charCode: 27 });
534
- expect(input.value).toBe("");
535
- expect(queryByRole("list")).toBeFalsy();
536
- });
537
- test("Autosuggest complex key secuence: write, arrow up two times, arrow down and select with Enter. Then, clean with Esc.", async () => {
538
- Element.prototype.scrollTo = () => {};
539
- const onChange = jest.fn();
540
- const { getByRole, queryByRole } = render(
541
- <DxcNewInputText label="Autocomplete Countries" suggestions={countries} onChange={onChange} />
542
- );
543
- const input = getByRole("combobox");
544
- fireEvent.focus(input);
545
- userEvent.type(input, "Ba");
546
- fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
547
- fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
548
- fireEvent.keyDown(input, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
549
- fireEvent.keyDown(input, { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
550
- expect(input.value).toBe("Barbados");
551
- expect(queryByRole("listbox")).toBeFalsy();
552
- fireEvent.keyDown(input, { key: "Esc", code: "Esp", keyCode: 27, charCode: 27 });
553
- expect(input.value).toBe("");
554
- expect(queryByRole("listbox")).toBeFalsy();
555
- });
556
- });
557
-
558
- describe("NewInputText component asynchronous autosuggest tests", () => {
559
- test("Autosuggest 'Searching...' message is shown", async () => {
560
- const callbackFunc = jest.fn((newValue) => {
561
- const result = new Promise((resolve) =>
562
- setTimeout(() => {
563
- resolve(
564
- newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
565
- );
566
- }, 1000)
567
- );
568
- return result;
569
- });
570
- const onChange = jest.fn();
571
- const { getByRole, getByText } = render(
572
- <DxcNewInputText label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
573
- );
574
- const input = getByRole("combobox");
575
- fireEvent.focus(input);
576
- expect(getByRole("listbox")).toBeTruthy();
577
- await waitForElementToBeRemoved(() => getByText("Searching..."));
578
- expect(getByText("Afghanistan")).toBeTruthy();
579
- expect(getByText("Albania")).toBeTruthy();
580
- expect(getByText("Algeria")).toBeTruthy();
581
- expect(getByText("Andorra")).toBeTruthy();
582
- userEvent.type(input, "Ab");
583
- await waitForElementToBeRemoved(() => getByText("Searching..."));
584
- expect(getByText("Cabo Verde")).toBeTruthy();
585
- fireEvent.keyDown(input, { key: "ArrowUp", code: "ArrowUp", keyCode: 38, charCode: 38 });
586
- fireEvent.keyDown(input, { key: "Enter", code: "Enter", keyCode: 13, charCode: 13 });
587
- expect(input.value).toBe("Cabo Verde");
588
- });
589
- test("Autosuggest Esc key works while 'Searching...' message is shown", async () => {
590
- const callbackFunc = jest.fn((newValue) => {
591
- const result = new Promise((resolve) =>
592
- setTimeout(() => {
593
- resolve(
594
- newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
595
- );
596
- }, 1000)
597
- );
598
- return result;
599
- });
600
- const onChange = jest.fn();
601
- const { getByRole, queryByText, queryByRole } = render(
602
- <DxcNewInputText label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
603
- );
604
- const input = getByRole("combobox");
605
- fireEvent.focus(input);
606
- expect(getByRole("listbox")).toBeTruthy();
607
- userEvent.type(input, "Ab");
608
- fireEvent.keyDown(input, { key: "Esc", code: "Esc", keyCode: 27, charCode: 27 });
609
- expect(queryByRole("listbox")).toBeFalsy();
610
- expect(queryByText("Searching...")).toBeFalsy();
611
- expect(input.value).toBe("");
612
- });
613
- test("Autosuggest Esc + arrow down working while 'Searching...' message is shown", async () => {
614
- const callbackFunc = jest.fn((newValue) => {
615
- const result = new Promise((resolve) =>
616
- setTimeout(() => {
617
- resolve(
618
- newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
619
- );
620
- }, 1000)
621
- );
622
- return result;
623
- });
624
- const onChange = jest.fn();
625
- const { getByRole, getByText, queryByText, queryByRole } = render(
626
- <DxcNewInputText label="Autosuggest Countries" suggestions={callbackFunc} onChange={onChange} />
627
- );
628
- const input = getByRole("combobox");
629
- fireEvent.focus(input);
630
- const list = getByRole("listbox");
631
- expect(list).toBeTruthy();
632
- userEvent.type(input, "Ab");
633
- fireEvent.keyDown(input, { key: "Esc", code: "Esc", keyCode: 27, charCode: 27 });
634
- expect(queryByRole("listbox")).toBeFalsy();
635
- expect(queryByText("Searching...")).toBeFalsy();
636
- expect(input.value).toBe("");
637
- fireEvent.keyDown(input, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
638
- expect(list).toBeTruthy();
639
- await waitForElementToBeRemoved(() => getByText("Searching..."));
640
- expect(getByText("Afghanistan")).toBeTruthy();
641
- expect(getByText("Albania")).toBeTruthy();
642
- expect(getByText("Algeria")).toBeTruthy();
643
- expect(getByText("Andorra")).toBeTruthy();
644
- });
645
- test("Asynchronous uncontrolled autosuggest test", async () => {
646
- const callbackFunc = jest.fn((newValue) => {
647
- const result = new Promise((resolve) =>
648
- setTimeout(() => {
649
- resolve(
650
- newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
651
- );
652
- }, 1000)
653
- );
654
- return result;
655
- });
656
- const onChange = jest.fn();
657
- const { getByRole, getByText } = render(
658
- <DxcNewInputText label="Autosuggest Countries" onChange={onChange} suggestions={callbackFunc} />
659
- );
660
- const input = getByRole("combobox");
661
- fireEvent.focus(input);
662
- userEvent.type(input, "Den");
663
- await waitForElementToBeRemoved(() => getByText("Searching..."));
664
- expect(getByText("Denmark")).toBeTruthy();
665
- fireEvent.mouseDown(getByRole("option"));
666
- fireEvent.mouseUp(getByRole("option"));
667
- expect(onChange).toHaveBeenCalledWith({ value: "Denmark", error: null });
668
- expect(input.value).toBe("Denmark");
669
- });
670
- test("Asynchronous controlled autosuggest test", async () => {
671
- const callbackFunc = jest.fn((newValue) => {
672
- const result = new Promise((resolve) =>
673
- setTimeout(() => {
674
- resolve(
675
- newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
676
- );
677
- }, 1000)
678
- );
679
- return result;
680
- });
681
- const onChange = jest.fn();
682
- const { getByRole, getByText, queryByRole } = render(
683
- <DxcNewInputText label="Autosuggest Countries" value="Denm" onChange={onChange} suggestions={callbackFunc} />
684
- );
685
- const input = getByRole("combobox");
686
- fireEvent.focus(input);
687
- await waitForElementToBeRemoved(() => getByText("Searching..."));
688
- expect(input.value).toBe("Denm");
689
- expect(getByText("Denmark")).toBeTruthy();
690
- fireEvent.mouseDown(getByRole("option"));
691
- fireEvent.mouseUp(getByRole("option"));
692
- expect(onChange).toHaveBeenCalledWith({ value: "Denmark", error: null });
693
- expect(queryByRole("listbox")).toBeFalsy();
694
- });
695
- test("Asynchronous autosuggest shows 'No results found' after finishing no matches search", async () => {
696
- const callbackFunc = jest.fn((newValue) => {
697
- const result = new Promise((resolve) =>
698
- setTimeout(() => {
699
- resolve(
700
- newValue ? countries.filter((option) => option.toUpperCase().includes(newValue.toUpperCase())) : countries
701
- );
702
- }, 1000)
703
- );
704
- return result;
705
- });
706
- const onChange = jest.fn();
707
- const { getByRole, getByText } = render(
708
- <DxcNewInputText label="Autosuggest Countries" onChange={onChange} suggestions={callbackFunc} />
709
- );
710
- const input = getByRole("combobox");
711
- fireEvent.focus(input);
712
- userEvent.type(input, "Example text");
713
- await waitForElementToBeRemoved(() => getByText("Searching..."));
714
- expect(getByText("No results found")).toBeTruthy();
715
- });
716
- test("Asynchronous autosuggest request failed, shows 'Error fetching data' message", async () => {
717
- const errorCallbackFunc = jest.fn(() => {
718
- const result = new Promise((resolve, reject) =>
719
- setTimeout(() => {
720
- reject("err");
721
- }, 1000)
722
- );
723
- return result;
724
- });
725
- const onChange = jest.fn();
726
- const { getByRole, getByText } = render(
727
- <DxcNewInputText label="Autosuggest Countries" onChange={onChange} suggestions={errorCallbackFunc} />
728
- );
729
- const input = getByRole("combobox");
730
- fireEvent.focus(input);
731
- await waitForElementToBeRemoved(() => getByText("Searching..."));
732
- expect(getByText("Error fetching data")).toBeTruthy();
733
- });
734
- });