@dxc-technology/halstack-react 0.0.0-8d633bd → 0.0.0-8ded8ca

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