@digigov/ui 0.21.2 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (587) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/admin/AutoComplete/AccesibleAutoComplete/index.d.ts +5 -0
  3. package/admin/AutoComplete/AccesibleAutoComplete/index.js +106 -0
  4. package/admin/AutoComplete/AutoComplete.stories.d.ts +13 -0
  5. package/admin/AutoComplete/AutoComplete.stories.js +115 -0
  6. package/admin/AutoComplete/Status/index.d.ts +40 -0
  7. package/admin/AutoComplete/Status/index.js +184 -0
  8. package/{app/CopyToClipboard → admin/AutoComplete}/__stories__/Default.d.ts +0 -0
  9. package/admin/AutoComplete/__stories__/Default.js +34 -0
  10. package/admin/AutoComplete/__stories__/WithAutoSelect.d.ts +3 -0
  11. package/admin/AutoComplete/__stories__/WithAutoSelect.js +35 -0
  12. package/admin/AutoComplete/__stories__/WithDefaultValue.d.ts +3 -0
  13. package/admin/AutoComplete/__stories__/WithDefaultValue.js +33 -0
  14. package/admin/AutoComplete/__stories__/WithInLine.d.ts +3 -0
  15. package/admin/AutoComplete/__stories__/WithInLine.js +33 -0
  16. package/admin/AutoComplete/__stories__/WithMinLength.d.ts +3 -0
  17. package/admin/AutoComplete/__stories__/WithMinLength.js +35 -0
  18. package/admin/AutoComplete/__stories__/WithPlaceHolder.d.ts +3 -0
  19. package/admin/AutoComplete/__stories__/WithPlaceHolder.js +33 -0
  20. package/admin/AutoComplete/__stories__/WithShowAllValues.d.ts +3 -0
  21. package/admin/AutoComplete/__stories__/WithShowAllValues.js +33 -0
  22. package/admin/AutoComplete/index.d.ts +101 -0
  23. package/admin/AutoComplete/index.js +744 -0
  24. package/admin/AutoComplete/index.mdx +46 -0
  25. package/admin/AutoComplete/utils.d.ts +1 -0
  26. package/admin/AutoComplete/utils.js +13 -0
  27. package/admin/CopyToClipboard/CopyToClipboard.stories.d.ts +9 -0
  28. package/admin/CopyToClipboard/CopyToClipboard.stories.js +58 -0
  29. package/admin/CopyToClipboard/__stories__/Banner.d.ts +3 -0
  30. package/admin/CopyToClipboard/__stories__/Banner.js +30 -0
  31. package/admin/CopyToClipboard/__stories__/Default.d.ts +3 -0
  32. package/admin/CopyToClipboard/__stories__/Default.js +32 -0
  33. package/admin/CopyToClipboard/__stories__/MultipleCopies.d.ts +3 -0
  34. package/{app/CopyToClipboard/__stories__/Default.js → admin/CopyToClipboard/__stories__/MultipleCopies.js} +20 -18
  35. package/admin/CopyToClipboard/index.d.ts +1 -1
  36. package/admin/CopyToClipboard/index.js +3 -2
  37. package/admin/CopyToClipboard/index.mdx +22 -0
  38. package/admin/Drawer/__stories__/Default.js +1 -1
  39. package/admin/Drawer/index.mdx +12 -0
  40. package/admin/Dropdown/Dropdown.stories.d.ts +9 -0
  41. package/admin/Dropdown/Dropdown.stories.js +60 -0
  42. package/admin/Dropdown/__stories__/AlignRight.d.ts +3 -0
  43. package/admin/Dropdown/__stories__/AlignRight.js +83 -0
  44. package/admin/Dropdown/__stories__/Default.d.ts +3 -0
  45. package/admin/Dropdown/__stories__/Default.js +75 -0
  46. package/admin/Dropdown/__stories__/PlacementTop.d.ts +3 -0
  47. package/admin/Dropdown/__stories__/PlacementTop.js +83 -0
  48. package/admin/Dropdown/index.d.ts +7 -1
  49. package/admin/Dropdown/index.js +29 -1
  50. package/admin/Dropdown/index.mdx +29 -0
  51. package/admin/FilterSection/index.d.ts +1 -0
  52. package/admin/FilterSection/index.js +14 -0
  53. package/admin/Modal/Modal.stories.d.ts +8 -0
  54. package/admin/Modal/Modal.stories.js +44 -0
  55. package/admin/Modal/__stories__/AlertDialog.d.ts +3 -0
  56. package/admin/Modal/__stories__/AlertDialog.js +80 -0
  57. package/admin/Modal/__stories__/Default.d.ts +3 -0
  58. package/admin/Modal/__stories__/Default.js +79 -0
  59. package/admin/Modal/index.mdx +26 -0
  60. package/admin/Pagination/__stories__/Default.js +57 -16
  61. package/admin/Pagination/index.mdx +12 -0
  62. package/admin/index.d.ts +2 -1
  63. package/admin/index.js +17 -4
  64. package/api/fetchAPI.js +6 -4
  65. package/api/index.spec.js +18 -19
  66. package/api/useResource.js +6 -4
  67. package/api/useResourceAction.js +6 -4
  68. package/api/useResourceQuery.js +7 -4
  69. package/api/utils.js +8 -6
  70. package/app/Confirmation/Confirmation.mdx +9 -0
  71. package/app/Footer/Footer.mdx +27 -0
  72. package/app/Header/index.mdx +18 -0
  73. package/app/I18nText.js +7 -7
  74. package/app/NotFound/index.mdx +12 -0
  75. package/app/PhaseBannerHeader/index.mdx +12 -0
  76. package/core/Accordion/__stories__/Default.js +17 -1
  77. package/core/Accordion/__stories__/WithHints.js +17 -1
  78. package/core/Accordion/index.mdx +16 -84
  79. package/core/BackLink/index.mdx +16 -0
  80. package/core/Blockquote/index.mdx +17 -2
  81. package/core/Breadcrumbs/__stories__/Default.js +13 -1
  82. package/core/Breadcrumbs/breadcrumbs.mdx +22 -0
  83. package/core/Button/Button.stories.d.ts +5 -0
  84. package/core/Button/Button.stories.js +72 -0
  85. package/core/Button/__stories__/Back.d.ts +4 -0
  86. package/core/Button/__stories__/Back.js +26 -0
  87. package/core/Button/__stories__/ButtonLinkButton.d.ts +6 -0
  88. package/core/Button/__stories__/ButtonLinkButton.js +30 -0
  89. package/core/Button/__stories__/CallToActionButton.d.ts +6 -0
  90. package/core/Button/__stories__/CallToActionButton.js +30 -0
  91. package/core/Button/__stories__/Disabled.d.ts +6 -0
  92. package/core/Button/__stories__/Disabled.js +27 -0
  93. package/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
  94. package/core/Button/__stories__/Primary.js +3 -1
  95. package/core/Button/__stories__/Secondary.js +3 -2
  96. package/core/Button/__stories__/Warning.js +2 -1
  97. package/core/Button/__stories__/WithVariantLink.d.ts +6 -0
  98. package/core/Button/__stories__/WithVariantLink.js +29 -0
  99. package/core/Button/index.mdx +97 -0
  100. package/core/Card/Card.stories.d.ts +1 -0
  101. package/core/Card/Card.stories.js +14 -0
  102. package/core/Card/__stories__/WithClickableLink.js +1 -3
  103. package/core/Card/__stories__/WithGroupButton.d.ts +3 -0
  104. package/core/Card/__stories__/WithGroupButton.js +32 -0
  105. package/core/Card/card.mdx +78 -0
  106. package/core/Checkboxes/Checkbox.stories.d.ts +1 -0
  107. package/core/Checkboxes/Checkbox.stories.js +14 -0
  108. package/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
  109. package/core/Checkboxes/__stories__/Default.js +5 -1
  110. package/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
  111. package/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
  112. package/core/Checkboxes/__stories__/NoneAnswerWithError.d.ts +3 -0
  113. package/core/Checkboxes/__stories__/NoneAnswerWithError.js +57 -0
  114. package/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
  115. package/core/Checkboxes/__stories__/WithHint.js +5 -1
  116. package/core/Checkboxes/checkboxes.mdx +54 -0
  117. package/core/Confirmation/confirmation.mdx +19 -0
  118. package/core/DateInput/DateInput.stories.d.ts +1 -0
  119. package/core/DateInput/DateInput.stories.js +14 -0
  120. package/core/DateInput/__stories__/Default.js +3 -1
  121. package/core/DateInput/__stories__/MultipleQuestions.d.ts +3 -0
  122. package/core/DateInput/__stories__/MultipleQuestions.js +41 -0
  123. package/core/DateInput/index.mdx +34 -0
  124. package/core/Details/index.mdx +9 -25
  125. package/core/ErrorMessage/__stories__/Default.js +1 -1
  126. package/core/ErrorMessage/index.mdx +21 -0
  127. package/core/ErrorSummary/__stories__/LinkedToCheckbox.js +1 -1
  128. package/core/ErrorSummary/index.mdx +21 -38
  129. package/core/FileUpload/__stories__/Default.d.ts +1 -0
  130. package/core/FileUpload/__stories__/Default.js +4 -2
  131. package/core/FileUpload/index.mdx +22 -0
  132. package/core/Link/__stories__/DarkBackground.js +4 -2
  133. package/core/Link/__stories__/DarkBackgroundNoUnderline.js +4 -2
  134. package/core/Link/__stories__/Default.js +3 -1
  135. package/core/Link/__stories__/NoUnderline.js +3 -1
  136. package/core/Link/link.mdx +34 -0
  137. package/core/List/index.mdx +22 -3
  138. package/core/Masthead/masthead.mdx +14 -0
  139. package/core/NavList/NavList.d.ts +1 -14
  140. package/core/NavList/NavList.js +14 -71
  141. package/core/NavList/NavList.stories.d.ts +8 -0
  142. package/core/NavList/NavList.stories.js +44 -0
  143. package/core/NavList/NavListBase.d.ts +4 -0
  144. package/core/NavList/NavListBase.js +76 -0
  145. package/core/NavList/NavListItem.d.ts +1 -0
  146. package/core/NavList/NavListItem.js +3 -1
  147. package/core/NavList/NavListItemBase.d.ts +1 -0
  148. package/core/NavList/NavListItemBase.js +7 -3
  149. package/core/NavList/NavListSubMenu.d.ts +1 -1
  150. package/core/NavList/NavListSubMenu.js +2 -2
  151. package/core/NavList/__stories__/Default.d.ts +3 -0
  152. package/core/NavList/__stories__/Default.js +69 -0
  153. package/core/NavList/__stories__/NavHorizontalLayout.d.ts +3 -0
  154. package/core/NavList/__stories__/NavHorizontalLayout.js +67 -0
  155. package/core/NavList/index.mdx +22 -1
  156. package/core/NavList/types.d.ts +14 -0
  157. package/core/NavList/types.js +5 -0
  158. package/core/NotificationBanner/index.mdx +13 -60
  159. package/core/PhaseBanner/PhaseBanner.stories.d.ts +1 -0
  160. package/core/PhaseBanner/PhaseBanner.stories.js +14 -0
  161. package/core/PhaseBanner/__stories__/Underlined.d.ts +3 -0
  162. package/{admin/CopyToClipboardMessage/index.js → core/PhaseBanner/__stories__/Underlined.js} +21 -17
  163. package/core/PhaseBanner/index.mdx +24 -0
  164. package/core/Radios/__stories__/ConditionalReveal.js +5 -1
  165. package/core/Radios/__stories__/Default.js +1 -3
  166. package/core/Radios/__stories__/Inline.js +5 -1
  167. package/core/Radios/__stories__/MultipleQuestions.js +7 -3
  168. package/core/Radios/__stories__/WithErrorMessage.js +7 -1
  169. package/core/Radios/__stories__/WithHints.js +17 -7
  170. package/core/Radios/index.mdx +56 -0
  171. package/core/Select/Select.stories.d.ts +1 -0
  172. package/core/Select/Select.stories.js +14 -0
  173. package/core/Select/__stories__/Default.js +2 -2
  174. package/core/Select/__stories__/DisabledInput.js +3 -1
  175. package/core/Select/__stories__/WithHint.d.ts +3 -0
  176. package/core/Select/__stories__/WithHint.js +45 -0
  177. package/core/Select/index.mdx +42 -0
  178. package/core/SummaryList/SummaryList.stories.d.ts +2 -2
  179. package/core/SummaryList/SummaryList.stories.js +8 -8
  180. package/core/SummaryList/__stories__/Default.js +1 -1
  181. package/core/SummaryList/__stories__/WithActions.d.ts +3 -0
  182. package/core/SummaryList/__stories__/{SummaryListWithActions.js → WithActions.js} +10 -12
  183. package/core/SummaryList/__stories__/WithoutBorders.d.ts +3 -0
  184. package/core/SummaryList/__stories__/{SummaryListWithoutBorders.js → WithoutBorders.js} +5 -5
  185. package/core/SummaryList/index.mdx +17 -65
  186. package/core/Table/Table.stories.d.ts +1 -0
  187. package/core/Table/Table.stories.js +14 -0
  188. package/core/Table/TableFloatingScroll.d.ts +3 -0
  189. package/core/Table/TableFloatingScroll.js +105 -0
  190. package/core/Table/__stories__/DarkVariant.js +1 -1
  191. package/core/Table/__stories__/Default.js +1 -1
  192. package/core/Table/__stories__/NoData.js +3 -1
  193. package/core/Table/__stories__/TableCaptions.d.ts +3 -0
  194. package/core/Table/__stories__/TableCaptions.js +30 -0
  195. package/core/Table/__stories__/WithLoader.js +16 -12
  196. package/core/Table/index.d.ts +1 -0
  197. package/core/Table/index.js +13 -0
  198. package/core/Table/index.mdx +59 -0
  199. package/core/Tabs/__stories__/Default.d.ts +1 -0
  200. package/core/Tabs/__stories__/Default.js +6 -2
  201. package/core/Tabs/index.mdx +10 -2
  202. package/core/TextArea/index.mdx +50 -0
  203. package/core/TextInput/index.mdx +59 -0
  204. package/core/VisuallyHidden/__stories__/Default.js +14 -2
  205. package/core/VisuallyHidden/index.mdx +17 -0
  206. package/core/WarningText/index.mdx +10 -35
  207. package/es/admin/AutoComplete/AccesibleAutoComplete/index.js +87 -0
  208. package/es/admin/AutoComplete/AutoComplete.stories.js +13 -0
  209. package/es/admin/AutoComplete/Status/index.js +153 -0
  210. package/es/admin/AutoComplete/__stories__/Default.js +19 -0
  211. package/es/admin/AutoComplete/__stories__/WithAutoSelect.js +20 -0
  212. package/es/admin/AutoComplete/__stories__/WithDefaultValue.js +18 -0
  213. package/es/admin/AutoComplete/__stories__/WithInLine.js +18 -0
  214. package/es/admin/AutoComplete/__stories__/WithMinLength.js +19 -0
  215. package/es/admin/AutoComplete/__stories__/WithPlaceHolder.js +18 -0
  216. package/es/admin/AutoComplete/__stories__/WithShowAllValues.js +18 -0
  217. package/es/admin/AutoComplete/index.js +676 -0
  218. package/es/admin/AutoComplete/index.mdx +46 -0
  219. package/es/admin/AutoComplete/utils.js +6 -0
  220. package/es/admin/CopyToClipboard/CopyToClipboard.stories.js +8 -0
  221. package/es/admin/CopyToClipboard/__stories__/Banner.js +16 -0
  222. package/es/admin/CopyToClipboard/__stories__/Default.js +18 -0
  223. package/{esm/app/CopyToClipboard/__stories__/Default.js → es/admin/CopyToClipboard/__stories__/MultipleCopies.js} +10 -8
  224. package/es/admin/CopyToClipboard/index.js +3 -2
  225. package/es/admin/CopyToClipboard/index.mdx +22 -0
  226. package/es/admin/Drawer/__stories__/Default.js +1 -1
  227. package/es/admin/Drawer/index.mdx +12 -0
  228. package/es/admin/Dropdown/Dropdown.stories.js +9 -0
  229. package/es/admin/Dropdown/__stories__/AlignRight.js +56 -0
  230. package/es/admin/Dropdown/__stories__/Default.js +48 -0
  231. package/es/admin/Dropdown/__stories__/PlacementTop.js +56 -0
  232. package/es/admin/Dropdown/index.js +28 -1
  233. package/es/admin/Dropdown/index.mdx +29 -0
  234. package/es/admin/FilterSection/index.js +1 -0
  235. package/es/admin/Modal/Modal.stories.js +7 -0
  236. package/es/admin/Modal/__stories__/AlertDialog.js +58 -0
  237. package/es/admin/Modal/__stories__/Default.js +56 -0
  238. package/es/admin/Modal/index.mdx +26 -0
  239. package/es/admin/Pagination/__stories__/Default.js +56 -16
  240. package/es/admin/Pagination/index.mdx +12 -0
  241. package/es/admin/index.js +3 -2
  242. package/es/api/fetchAPI.js +6 -3
  243. package/es/api/index.spec.js +19 -17
  244. package/es/api/useResource.js +6 -3
  245. package/es/api/useResourceAction.js +6 -3
  246. package/es/api/useResourceQuery.js +6 -3
  247. package/es/api/utils.js +8 -5
  248. package/es/app/Confirmation/Confirmation.mdx +9 -0
  249. package/es/app/Footer/Footer.mdx +27 -0
  250. package/es/app/Header/index.mdx +18 -0
  251. package/es/app/I18nText.js +7 -6
  252. package/es/app/NotFound/index.mdx +12 -0
  253. package/es/app/PhaseBannerHeader/index.mdx +12 -0
  254. package/es/core/Accordion/__stories__/Default.js +17 -1
  255. package/es/core/Accordion/__stories__/WithHints.js +17 -1
  256. package/es/core/Accordion/index.mdx +16 -84
  257. package/es/core/BackLink/index.mdx +16 -0
  258. package/es/core/Blockquote/index.mdx +17 -2
  259. package/es/core/Breadcrumbs/__stories__/Default.js +13 -1
  260. package/es/core/Breadcrumbs/breadcrumbs.mdx +22 -0
  261. package/es/core/Button/Button.stories.js +7 -1
  262. package/es/core/Button/__stories__/Back.js +13 -0
  263. package/es/core/Button/__stories__/ButtonLinkButton.js +17 -0
  264. package/es/core/Button/__stories__/CallToActionButton.js +17 -0
  265. package/es/core/Button/__stories__/Disabled.js +14 -0
  266. package/es/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
  267. package/es/core/Button/__stories__/Primary.js +3 -1
  268. package/es/core/Button/__stories__/Secondary.js +3 -2
  269. package/es/core/Button/__stories__/Warning.js +2 -1
  270. package/es/core/Button/__stories__/WithVariantLink.js +16 -0
  271. package/es/core/Button/index.mdx +97 -0
  272. package/es/core/Card/Card.stories.js +2 -1
  273. package/es/core/Card/__stories__/WithClickableLink.js +2 -3
  274. package/es/core/Card/__stories__/WithGroupButton.js +11 -0
  275. package/es/core/Card/card.mdx +78 -0
  276. package/es/core/Checkboxes/Checkbox.stories.js +1 -0
  277. package/es/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
  278. package/es/core/Checkboxes/__stories__/Default.js +5 -1
  279. package/es/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
  280. package/es/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
  281. package/es/core/Checkboxes/__stories__/NoneAnswerWithError.js +34 -0
  282. package/es/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
  283. package/es/core/Checkboxes/__stories__/WithHint.js +5 -1
  284. package/es/core/Checkboxes/checkboxes.mdx +54 -0
  285. package/es/core/Confirmation/confirmation.mdx +19 -0
  286. package/es/core/DateInput/DateInput.stories.js +1 -0
  287. package/es/core/DateInput/__stories__/Default.js +3 -1
  288. package/es/core/DateInput/__stories__/MultipleQuestions.js +20 -0
  289. package/es/core/DateInput/index.mdx +34 -0
  290. package/es/core/Details/index.mdx +9 -25
  291. package/es/core/ErrorMessage/__stories__/Default.js +1 -1
  292. package/es/core/ErrorMessage/index.mdx +21 -0
  293. package/es/core/ErrorSummary/__stories__/LinkedToCheckbox.js +1 -1
  294. package/es/core/ErrorSummary/index.mdx +21 -38
  295. package/es/core/FileUpload/__stories__/Default.js +2 -1
  296. package/es/core/FileUpload/index.mdx +22 -0
  297. package/es/core/Link/__stories__/DarkBackground.js +7 -5
  298. package/es/core/Link/__stories__/DarkBackgroundNoUnderline.js +7 -5
  299. package/es/core/Link/__stories__/Default.js +5 -3
  300. package/es/core/Link/__stories__/NoUnderline.js +5 -3
  301. package/es/core/Link/link.mdx +34 -0
  302. package/es/core/List/index.mdx +22 -3
  303. package/es/core/Masthead/masthead.mdx +14 -0
  304. package/es/core/NavList/NavList.js +11 -64
  305. package/es/core/NavList/NavList.stories.js +7 -0
  306. package/es/core/NavList/NavListBase.js +60 -0
  307. package/es/core/NavList/NavListItem.js +3 -1
  308. package/es/core/NavList/NavListItemBase.js +7 -3
  309. package/es/core/NavList/NavListSubMenu.js +1 -1
  310. package/es/core/NavList/__stories__/Default.js +48 -0
  311. package/es/core/NavList/__stories__/NavHorizontalLayout.js +46 -0
  312. package/es/core/NavList/index.mdx +22 -1
  313. package/es/core/NavList/types.js +1 -0
  314. package/es/core/NotificationBanner/index.mdx +13 -60
  315. package/es/core/PhaseBanner/PhaseBanner.stories.js +2 -1
  316. package/es/core/PhaseBanner/__stories__/Underlined.js +14 -0
  317. package/es/core/PhaseBanner/index.mdx +24 -0
  318. package/es/core/Radios/__stories__/ConditionalReveal.js +5 -1
  319. package/es/core/Radios/__stories__/Default.js +1 -2
  320. package/es/core/Radios/__stories__/Inline.js +5 -1
  321. package/es/core/Radios/__stories__/MultipleQuestions.js +7 -3
  322. package/es/core/Radios/__stories__/WithErrorMessage.js +7 -1
  323. package/es/core/Radios/__stories__/WithHints.js +17 -7
  324. package/es/core/Radios/index.mdx +56 -0
  325. package/es/core/Select/Select.stories.js +2 -1
  326. package/es/core/Select/__stories__/Default.js +5 -4
  327. package/es/core/Select/__stories__/DisabledInput.js +5 -3
  328. package/es/core/Select/__stories__/WithHint.js +23 -0
  329. package/es/core/Select/index.mdx +42 -0
  330. package/es/core/SummaryList/SummaryList.stories.js +2 -2
  331. package/es/core/SummaryList/__stories__/Default.js +1 -1
  332. package/es/core/SummaryList/__stories__/WithActions.js +20 -0
  333. package/es/core/SummaryList/__stories__/WithoutBorders.js +11 -0
  334. package/es/core/SummaryList/index.mdx +17 -65
  335. package/es/core/Table/Table.stories.js +1 -0
  336. package/es/core/Table/TableFloatingScroll.js +85 -0
  337. package/es/core/Table/__stories__/DarkVariant.js +1 -1
  338. package/es/core/Table/__stories__/Default.js +1 -1
  339. package/es/core/Table/__stories__/NoData.js +3 -1
  340. package/es/core/Table/__stories__/TableCaptions.js +17 -0
  341. package/es/core/Table/__stories__/WithLoader.js +12 -10
  342. package/es/core/Table/index.js +2 -1
  343. package/es/core/Table/index.mdx +59 -0
  344. package/es/core/Tabs/__stories__/Default.js +3 -2
  345. package/es/core/Tabs/index.mdx +10 -2
  346. package/es/core/TextArea/index.mdx +50 -0
  347. package/es/core/TextInput/index.mdx +59 -0
  348. package/es/core/VisuallyHidden/__stories__/Default.js +9 -5
  349. package/es/core/VisuallyHidden/index.mdx +17 -0
  350. package/es/core/WarningText/index.mdx +10 -35
  351. package/es/govgr/Footer/index.mdx +4 -4
  352. package/es/introduction.md +4 -1
  353. package/es/layouts/Basic/Content/index.mdx +0 -12
  354. package/es/layouts/Basic/Main/index.mdx +0 -10
  355. package/es/layouts/Basic/Masthead/index.mdx +0 -12
  356. package/es/layouts/Basic/Side/index.mdx +0 -12
  357. package/es/layouts/Basic/Top/index.mdx +0 -12
  358. package/es/layouts/Basic/index.mdx +1 -15
  359. package/es/layouts/Grid/Grid.stories.js +2 -1
  360. package/es/layouts/Grid/__stories__/Default.js +26 -6
  361. package/es/layouts/Grid/__stories__/Inline.js +75 -0
  362. package/es/layouts/Grid/index.js +1 -0
  363. package/es/layouts/index.js +2 -0
  364. package/es/registry.js +66 -30
  365. package/es/test-utils/delay.js +6 -3
  366. package/es/typography/Caption/index.mdx +16 -0
  367. package/es/typography/Hint/index.mdx +16 -0
  368. package/es/typography/NormalText/index.mdx +26 -0
  369. package/es/typography/Paragraph/index.mdx +30 -0
  370. package/es/typography/Title/index.mdx +12 -0
  371. package/esm/admin/AutoComplete/AccesibleAutoComplete/index.js +87 -0
  372. package/esm/admin/AutoComplete/AutoComplete.stories.js +13 -0
  373. package/esm/admin/AutoComplete/Status/index.js +153 -0
  374. package/esm/admin/AutoComplete/__stories__/Default.js +19 -0
  375. package/esm/admin/AutoComplete/__stories__/WithAutoSelect.js +20 -0
  376. package/esm/admin/AutoComplete/__stories__/WithDefaultValue.js +18 -0
  377. package/esm/admin/AutoComplete/__stories__/WithInLine.js +18 -0
  378. package/esm/admin/AutoComplete/__stories__/WithMinLength.js +19 -0
  379. package/esm/admin/AutoComplete/__stories__/WithPlaceHolder.js +18 -0
  380. package/esm/admin/AutoComplete/__stories__/WithShowAllValues.js +18 -0
  381. package/esm/admin/AutoComplete/index.js +676 -0
  382. package/esm/admin/AutoComplete/index.mdx +46 -0
  383. package/esm/admin/AutoComplete/utils.js +6 -0
  384. package/esm/admin/CopyToClipboard/CopyToClipboard.stories.js +8 -0
  385. package/esm/admin/CopyToClipboard/__stories__/Banner.js +16 -0
  386. package/esm/admin/CopyToClipboard/__stories__/Default.js +18 -0
  387. package/{es/app/CopyToClipboard/__stories__/Default.js → esm/admin/CopyToClipboard/__stories__/MultipleCopies.js} +10 -8
  388. package/esm/admin/CopyToClipboard/index.js +3 -2
  389. package/esm/admin/CopyToClipboard/index.mdx +22 -0
  390. package/esm/admin/Drawer/__stories__/Default.js +1 -1
  391. package/esm/admin/Drawer/index.mdx +12 -0
  392. package/esm/admin/Dropdown/Dropdown.stories.js +9 -0
  393. package/esm/admin/Dropdown/__stories__/AlignRight.js +56 -0
  394. package/esm/admin/Dropdown/__stories__/Default.js +48 -0
  395. package/esm/admin/Dropdown/__stories__/PlacementTop.js +56 -0
  396. package/esm/admin/Dropdown/index.js +28 -1
  397. package/esm/admin/Dropdown/index.mdx +29 -0
  398. package/esm/admin/FilterSection/index.js +1 -0
  399. package/esm/admin/Modal/Modal.stories.js +7 -0
  400. package/esm/admin/Modal/__stories__/AlertDialog.js +58 -0
  401. package/esm/admin/Modal/__stories__/Default.js +56 -0
  402. package/esm/admin/Modal/index.mdx +26 -0
  403. package/esm/admin/Pagination/__stories__/Default.js +56 -16
  404. package/esm/admin/Pagination/index.mdx +12 -0
  405. package/esm/admin/index.js +3 -2
  406. package/esm/api/fetchAPI.js +6 -3
  407. package/esm/api/index.spec.js +19 -17
  408. package/esm/api/useResource.js +6 -3
  409. package/esm/api/useResourceAction.js +6 -3
  410. package/esm/api/useResourceQuery.js +6 -3
  411. package/esm/api/utils.js +8 -5
  412. package/esm/app/Confirmation/Confirmation.mdx +9 -0
  413. package/esm/app/Footer/Footer.mdx +27 -0
  414. package/esm/app/Header/index.mdx +18 -0
  415. package/esm/app/I18nText.js +7 -6
  416. package/esm/app/NotFound/index.mdx +12 -0
  417. package/esm/app/PhaseBannerHeader/index.mdx +12 -0
  418. package/esm/core/Accordion/__stories__/Default.js +17 -1
  419. package/esm/core/Accordion/__stories__/WithHints.js +17 -1
  420. package/esm/core/Accordion/index.mdx +16 -84
  421. package/esm/core/BackLink/index.mdx +16 -0
  422. package/esm/core/Blockquote/index.mdx +17 -2
  423. package/esm/core/Breadcrumbs/__stories__/Default.js +13 -1
  424. package/esm/core/Breadcrumbs/breadcrumbs.mdx +22 -0
  425. package/esm/core/Button/Button.stories.js +7 -1
  426. package/esm/core/Button/__stories__/Back.js +13 -0
  427. package/esm/core/Button/__stories__/ButtonLinkButton.js +17 -0
  428. package/esm/core/Button/__stories__/CallToActionButton.js +17 -0
  429. package/esm/core/Button/__stories__/Disabled.js +14 -0
  430. package/esm/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
  431. package/esm/core/Button/__stories__/Primary.js +3 -1
  432. package/esm/core/Button/__stories__/Secondary.js +3 -2
  433. package/esm/core/Button/__stories__/Warning.js +2 -1
  434. package/esm/core/Button/__stories__/WithVariantLink.js +16 -0
  435. package/esm/core/Button/index.mdx +97 -0
  436. package/esm/core/Card/Card.stories.js +2 -1
  437. package/esm/core/Card/__stories__/WithClickableLink.js +2 -3
  438. package/esm/core/Card/__stories__/WithGroupButton.js +11 -0
  439. package/esm/core/Card/card.mdx +78 -0
  440. package/esm/core/Checkboxes/Checkbox.stories.js +1 -0
  441. package/esm/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
  442. package/esm/core/Checkboxes/__stories__/Default.js +5 -1
  443. package/esm/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
  444. package/esm/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
  445. package/esm/core/Checkboxes/__stories__/NoneAnswerWithError.js +34 -0
  446. package/esm/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
  447. package/esm/core/Checkboxes/__stories__/WithHint.js +5 -1
  448. package/esm/core/Checkboxes/checkboxes.mdx +54 -0
  449. package/esm/core/Confirmation/confirmation.mdx +19 -0
  450. package/esm/core/DateInput/DateInput.stories.js +1 -0
  451. package/esm/core/DateInput/__stories__/Default.js +3 -1
  452. package/esm/core/DateInput/__stories__/MultipleQuestions.js +20 -0
  453. package/esm/core/DateInput/index.mdx +34 -0
  454. package/esm/core/Details/index.mdx +9 -25
  455. package/esm/core/ErrorMessage/__stories__/Default.js +1 -1
  456. package/esm/core/ErrorMessage/index.mdx +21 -0
  457. package/esm/core/ErrorSummary/__stories__/LinkedToCheckbox.js +1 -1
  458. package/esm/core/ErrorSummary/index.mdx +21 -38
  459. package/esm/core/FileUpload/__stories__/Default.js +2 -1
  460. package/esm/core/FileUpload/index.mdx +22 -0
  461. package/esm/core/Link/__stories__/DarkBackground.js +7 -5
  462. package/esm/core/Link/__stories__/DarkBackgroundNoUnderline.js +7 -5
  463. package/esm/core/Link/__stories__/Default.js +5 -3
  464. package/esm/core/Link/__stories__/NoUnderline.js +5 -3
  465. package/esm/core/Link/link.mdx +34 -0
  466. package/esm/core/List/index.mdx +22 -3
  467. package/esm/core/Masthead/masthead.mdx +14 -0
  468. package/esm/core/NavList/NavList.js +11 -64
  469. package/esm/core/NavList/NavList.stories.js +7 -0
  470. package/esm/core/NavList/NavListBase.js +60 -0
  471. package/esm/core/NavList/NavListItem.js +3 -1
  472. package/esm/core/NavList/NavListItemBase.js +7 -3
  473. package/esm/core/NavList/NavListSubMenu.js +1 -1
  474. package/esm/core/NavList/__stories__/Default.js +48 -0
  475. package/esm/core/NavList/__stories__/NavHorizontalLayout.js +46 -0
  476. package/esm/core/NavList/index.mdx +22 -1
  477. package/esm/core/NavList/types.js +1 -0
  478. package/esm/core/NotificationBanner/index.mdx +13 -60
  479. package/esm/core/PhaseBanner/PhaseBanner.stories.js +2 -1
  480. package/esm/core/PhaseBanner/__stories__/Underlined.js +14 -0
  481. package/esm/core/PhaseBanner/index.mdx +24 -0
  482. package/esm/core/Radios/__stories__/ConditionalReveal.js +5 -1
  483. package/esm/core/Radios/__stories__/Default.js +1 -2
  484. package/esm/core/Radios/__stories__/Inline.js +5 -1
  485. package/esm/core/Radios/__stories__/MultipleQuestions.js +7 -3
  486. package/esm/core/Radios/__stories__/WithErrorMessage.js +7 -1
  487. package/esm/core/Radios/__stories__/WithHints.js +17 -7
  488. package/esm/core/Radios/index.mdx +56 -0
  489. package/esm/core/Select/Select.stories.js +2 -1
  490. package/esm/core/Select/__stories__/Default.js +5 -4
  491. package/esm/core/Select/__stories__/DisabledInput.js +5 -3
  492. package/esm/core/Select/__stories__/WithHint.js +23 -0
  493. package/esm/core/Select/index.mdx +42 -0
  494. package/esm/core/SummaryList/SummaryList.stories.js +2 -2
  495. package/esm/core/SummaryList/__stories__/Default.js +1 -1
  496. package/esm/core/SummaryList/__stories__/WithActions.js +20 -0
  497. package/esm/core/SummaryList/__stories__/WithoutBorders.js +11 -0
  498. package/esm/core/SummaryList/index.mdx +17 -65
  499. package/esm/core/Table/Table.stories.js +1 -0
  500. package/esm/core/Table/TableFloatingScroll.js +85 -0
  501. package/esm/core/Table/__stories__/DarkVariant.js +1 -1
  502. package/esm/core/Table/__stories__/Default.js +1 -1
  503. package/esm/core/Table/__stories__/NoData.js +3 -1
  504. package/esm/core/Table/__stories__/TableCaptions.js +17 -0
  505. package/esm/core/Table/__stories__/WithLoader.js +12 -10
  506. package/esm/core/Table/index.js +2 -1
  507. package/esm/core/Table/index.mdx +59 -0
  508. package/esm/core/Tabs/__stories__/Default.js +3 -2
  509. package/esm/core/Tabs/index.mdx +10 -2
  510. package/esm/core/TextArea/index.mdx +50 -0
  511. package/esm/core/TextInput/index.mdx +59 -0
  512. package/esm/core/VisuallyHidden/__stories__/Default.js +9 -5
  513. package/esm/core/VisuallyHidden/index.mdx +17 -0
  514. package/esm/core/WarningText/index.mdx +10 -35
  515. package/esm/govgr/Footer/index.mdx +4 -4
  516. package/esm/index.js +1 -1
  517. package/esm/introduction.md +4 -1
  518. package/esm/layouts/Basic/Content/index.mdx +0 -12
  519. package/esm/layouts/Basic/Main/index.mdx +0 -10
  520. package/esm/layouts/Basic/Masthead/index.mdx +0 -12
  521. package/esm/layouts/Basic/Side/index.mdx +0 -12
  522. package/esm/layouts/Basic/Top/index.mdx +0 -12
  523. package/esm/layouts/Basic/index.mdx +1 -15
  524. package/esm/layouts/Grid/Grid.stories.js +2 -1
  525. package/esm/layouts/Grid/__stories__/Default.js +26 -6
  526. package/esm/layouts/Grid/__stories__/Inline.js +75 -0
  527. package/esm/layouts/Grid/index.js +1 -0
  528. package/esm/layouts/index.js +2 -0
  529. package/esm/registry.js +66 -30
  530. package/esm/test-utils/delay.js +6 -3
  531. package/esm/typography/Caption/index.mdx +16 -0
  532. package/esm/typography/Hint/index.mdx +16 -0
  533. package/esm/typography/NormalText/index.mdx +26 -0
  534. package/esm/typography/Paragraph/index.mdx +30 -0
  535. package/esm/typography/Title/index.mdx +12 -0
  536. package/govgr/Footer/index.mdx +4 -4
  537. package/introduction.md +4 -1
  538. package/layouts/Basic/Content/index.mdx +0 -12
  539. package/layouts/Basic/Main/index.mdx +0 -10
  540. package/layouts/Basic/Masthead/index.mdx +0 -12
  541. package/layouts/Basic/Side/index.mdx +0 -12
  542. package/layouts/Basic/Top/index.mdx +0 -12
  543. package/layouts/Basic/index.mdx +1 -15
  544. package/layouts/Grid/Grid.stories.d.ts +1 -0
  545. package/layouts/Grid/Grid.stories.js +14 -0
  546. package/layouts/Grid/__stories__/Default.js +26 -6
  547. package/layouts/Grid/__stories__/Inline.d.ts +3 -0
  548. package/layouts/Grid/__stories__/Inline.js +88 -0
  549. package/layouts/Grid/index.d.ts +1 -0
  550. package/layouts/Grid/index.js +6 -0
  551. package/layouts/index.d.ts +2 -0
  552. package/layouts/index.js +22 -1
  553. package/package.json +3 -3
  554. package/registry.d.ts +33 -15
  555. package/registry.js +99 -45
  556. package/test-utils/delay.js +5 -3
  557. package/typography/Caption/index.mdx +16 -0
  558. package/typography/Hint/index.mdx +16 -0
  559. package/typography/NormalText/index.mdx +26 -0
  560. package/typography/Paragraph/index.mdx +30 -0
  561. package/typography/Title/index.mdx +12 -0
  562. package/admin/CopyToClipboardMessage/index.d.ts +0 -3
  563. package/app/CopyToClipboard/CopyToClipboard.stories.d.ts +0 -7
  564. package/app/CopyToClipboard/CopyToClipboard.stories.js +0 -30
  565. package/app/CopyToClipboard/index.d.ts +0 -9
  566. package/app/CopyToClipboard/index.js +0 -69
  567. package/app/NotFound/NotFound.mdx +0 -5
  568. package/app/QrCodeScanner/index.mdx +0 -7
  569. package/core/Button/Button.mdx +0 -55
  570. package/core/SummaryList/__stories__/SummaryListWithActions.d.ts +0 -3
  571. package/core/SummaryList/__stories__/SummaryListWithoutBorders.d.ts +0 -3
  572. package/es/admin/CopyToClipboardMessage/index.js +0 -3
  573. package/es/app/CopyToClipboard/CopyToClipboard.stories.js +0 -6
  574. package/es/app/CopyToClipboard/index.js +0 -45
  575. package/es/app/NotFound/NotFound.mdx +0 -5
  576. package/es/app/QrCodeScanner/index.mdx +0 -7
  577. package/es/core/Button/Button.mdx +0 -55
  578. package/es/core/SummaryList/__stories__/SummaryListWithActions.js +0 -21
  579. package/es/core/SummaryList/__stories__/SummaryListWithoutBorders.js +0 -11
  580. package/esm/admin/CopyToClipboardMessage/index.js +0 -3
  581. package/esm/app/CopyToClipboard/CopyToClipboard.stories.js +0 -6
  582. package/esm/app/CopyToClipboard/index.js +0 -45
  583. package/esm/app/NotFound/NotFound.mdx +0 -5
  584. package/esm/app/QrCodeScanner/index.mdx +0 -7
  585. package/esm/core/Button/Button.mdx +0 -55
  586. package/esm/core/SummaryList/__stories__/SummaryListWithActions.js +0 -21
  587. package/esm/core/SummaryList/__stories__/SummaryListWithoutBorders.js +0 -11
@@ -0,0 +1,676 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+
9
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
+
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+
13
+ import React from 'react';
14
+ import AutoCompleteInput from '@digigov/react-extensions/admin/AutoCompleteInput';
15
+ import AutoCompleteInputTypeahead from '@digigov/react-extensions/admin/AutoCompleteInputTypeahead';
16
+ import AutoCompleteNoResult from '@digigov/react-extensions/admin/AutoCompleteNoResult';
17
+ import AutoCompleteResultList from '@digigov/react-extensions/admin/AutoCompleteResultList';
18
+ import AutoCompleteResultListItem from '@digigov/react-extensions/admin/AutoCompleteResultListItem';
19
+ import AutoCompleteWrapper from '@digigov/react-extensions/admin/AutoCompleteWrapper';
20
+ import AutoCompleteAssistiveHint from '@digigov/react-extensions/admin/AutoCompleteAssistiveHint';
21
+ import { Component } from 'react';
22
+ import Status from '@digigov/ui/admin/AutoComplete/Status';
23
+ import DropdownArrowDown from '@digigov/react-extensions/admin/DropdownArrowDown';
24
+ /* const IS_PREACT = process.env.COMPONENT_LIBRARY === 'PREACT'; */
25
+
26
+ /* const IS_REACT = process.env.COMPONENT_LIBRARY === 'REACT'; */
27
+
28
+ var keyCodes = {
29
+ 13: 'enter',
30
+ 27: 'escape',
31
+ 32: 'space',
32
+ 38: 'up',
33
+ 40: 'down'
34
+ };
35
+
36
+ function isIosDevice() {
37
+ return typeof navigator !== 'undefined' && !!(navigator.userAgent.match(/(iPod|iPhone|iPad)/g) && navigator.userAgent.match(/AppleWebKit/g));
38
+ }
39
+
40
+ function isPrintableKeyCode(keyCode) {
41
+ return keyCode > 47 && keyCode < 58 || // number keys
42
+ keyCode === 32 || keyCode === 8 || // spacebar or backspace
43
+ keyCode > 64 && keyCode < 91 || // letter keys
44
+ keyCode > 95 && keyCode < 112 || // numpad keys
45
+ keyCode > 185 && keyCode < 193 || // ;=,-./` (in order)
46
+ keyCode > 218 && keyCode < 223 // [\]' (in order)
47
+ ;
48
+ }
49
+
50
+ var AutoComplete = /*#__PURE__*/function (_Component) {
51
+ _inherits(AutoComplete, _Component);
52
+
53
+ var _super = _createSuper(AutoComplete);
54
+
55
+ function AutoComplete(props) {
56
+ var _this;
57
+
58
+ _classCallCheck(this, AutoComplete);
59
+
60
+ _this = _super.call(this, props);
61
+ _this.elementReferences = {};
62
+ _this.$pollInput = void 0;
63
+ _this.state = {
64
+ focused: null,
65
+ hovered: null,
66
+ menuOpen: false,
67
+ options: props.defaultValue ? [props.defaultValue] : [],
68
+ query: props.defaultValue,
69
+ validChoiceMade: false,
70
+ selected: null,
71
+ ariaHint: true
72
+ };
73
+ _this.handleComponentBlur = _this.handleComponentBlur.bind(_assertThisInitialized(_this));
74
+ _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
75
+ _this.handleUpArrow = _this.handleUpArrow.bind(_assertThisInitialized(_this));
76
+ _this.handleDownArrow = _this.handleDownArrow.bind(_assertThisInitialized(_this));
77
+ _this.handleEnter = _this.handleEnter.bind(_assertThisInitialized(_this));
78
+ _this.handlePrintableKey = _this.handlePrintableKey.bind(_assertThisInitialized(_this));
79
+ _this.handleListMouseLeave = _this.handleListMouseLeave.bind(_assertThisInitialized(_this));
80
+ _this.handleOptionBlur = _this.handleOptionBlur.bind(_assertThisInitialized(_this));
81
+ _this.handleOptionClick = _this.handleOptionClick.bind(_assertThisInitialized(_this));
82
+ _this.handleOptionFocus = _this.handleOptionFocus.bind(_assertThisInitialized(_this));
83
+ _this.handleOptionMouseDown = _this.handleOptionMouseDown.bind(_assertThisInitialized(_this));
84
+ _this.handleOptionMouseEnter = _this.handleOptionMouseEnter.bind(_assertThisInitialized(_this));
85
+ _this.handleInputBlur = _this.handleInputBlur.bind(_assertThisInitialized(_this));
86
+ _this.handleInputChange = _this.handleInputChange.bind(_assertThisInitialized(_this));
87
+ _this.handleInputFocus = _this.handleInputFocus.bind(_assertThisInitialized(_this));
88
+ _this.pollInputElement = _this.pollInputElement.bind(_assertThisInitialized(_this));
89
+ _this.getDirectInputChanges = _this.getDirectInputChanges.bind(_assertThisInitialized(_this));
90
+ return _this;
91
+ }
92
+
93
+ _createClass(AutoComplete, [{
94
+ key: "isQueryAnOption",
95
+ value: function isQueryAnOption(query, options) {
96
+ var _this2 = this;
97
+
98
+ return options.map(function (entry) {
99
+ return _this2.templateInputValue(entry).toLowerCase();
100
+ }).indexOf(query.toLowerCase()) !== -1;
101
+ }
102
+ }, {
103
+ key: "componentDidMount",
104
+ value: function componentDidMount() {
105
+ this.pollInputElement();
106
+ }
107
+ }, {
108
+ key: "componentWillUnmount",
109
+ value: function componentWillUnmount() {
110
+ clearTimeout(this.$pollInput);
111
+ } // Applications like Dragon NaturallySpeaking will modify the
112
+ // `input` field by directly changing its `.value`. These events
113
+ // don't trigger our JavaScript event listeners, so we need to poll
114
+ // to handle when and if they occur.
115
+
116
+ }, {
117
+ key: "pollInputElement",
118
+ value: function pollInputElement() {
119
+ var _this3 = this;
120
+
121
+ this.getDirectInputChanges();
122
+ this.$pollInput = setTimeout(function () {
123
+ _this3.pollInputElement();
124
+ }, 100);
125
+ }
126
+ }, {
127
+ key: "getDirectInputChanges",
128
+ value: function getDirectInputChanges() {
129
+ var inputReference = this.elementReferences[-1];
130
+ var queryHasChanged = inputReference && inputReference.value !== this.state.query;
131
+
132
+ if (queryHasChanged) {
133
+ this.handleInputChange({
134
+ target: {
135
+ value: inputReference.value
136
+ }
137
+ });
138
+ }
139
+ }
140
+ }, {
141
+ key: "componentDidUpdate",
142
+ value: function componentDidUpdate(prevState) {
143
+ var focused = this.state.focused;
144
+ var componentLostFocus = focused === null;
145
+ var focusedChanged = prevState.focused !== focused;
146
+ var focusDifferentElement = focusedChanged && !componentLostFocus;
147
+
148
+ if (focusDifferentElement) {
149
+ this.elementReferences[focused].focus();
150
+ }
151
+
152
+ var focusedInput = focused === -1;
153
+ var componentGainedFocus = focusedChanged && prevState.focused === null;
154
+ var selectAllText = focusedInput && componentGainedFocus;
155
+
156
+ if (selectAllText) {
157
+ var inputElement = this.elementReferences[focused];
158
+ inputElement.setSelectionRange(0, inputElement.value.length);
159
+ }
160
+ }
161
+ }, {
162
+ key: "hasAutoselect",
163
+ value: function hasAutoselect() {
164
+ return isIosDevice() ? false : this.props.autoselect;
165
+ } // This template is used when converting from a state.options object into a state.query.
166
+
167
+ }, {
168
+ key: "templateInputValue",
169
+ value: function templateInputValue(value) {
170
+ var inputValueTemplate = this.props.templates && this.props.templates.inputValue;
171
+ return inputValueTemplate ? inputValueTemplate(value) : value;
172
+ } // This template is used when displaying results / suggestions.
173
+
174
+ }, {
175
+ key: "templateSuggestion",
176
+ value: function templateSuggestion(value) {
177
+ var suggestionTemplate = this.props.templates && this.props.templates.suggestion;
178
+ return suggestionTemplate ? suggestionTemplate(value) : value;
179
+ }
180
+ }, {
181
+ key: "handleComponentBlur",
182
+ value: function handleComponentBlur(newState) {
183
+ var _this$state = this.state,
184
+ options = _this$state.options,
185
+ query = _this$state.query,
186
+ selected = _this$state.selected;
187
+ var newQuery;
188
+
189
+ if (this.props.confirmOnBlur) {
190
+ var _this$props$onConfirm, _this$props;
191
+
192
+ newQuery = newState.query || query;
193
+ (_this$props$onConfirm = (_this$props = this.props).onConfirm) === null || _this$props$onConfirm === void 0 ? void 0 : _this$props$onConfirm.call(_this$props, options[selected]);
194
+ } else {
195
+ newQuery = query;
196
+ }
197
+
198
+ this.setState({
199
+ focused: null,
200
+ menuOpen: newState.menuOpen || false,
201
+ query: newQuery,
202
+ selected: null,
203
+ validChoiceMade: this.isQueryAnOption(newQuery, options)
204
+ });
205
+ }
206
+ }, {
207
+ key: "handleListMouseLeave",
208
+ value: function handleListMouseLeave() {
209
+ this.setState({
210
+ hovered: null
211
+ });
212
+ }
213
+ }, {
214
+ key: "handleOptionBlur",
215
+ value: function handleOptionBlur(event, index) {
216
+ var _this$state2 = this.state,
217
+ focused = _this$state2.focused,
218
+ menuOpen = _this$state2.menuOpen,
219
+ options = _this$state2.options,
220
+ selected = _this$state2.selected;
221
+ var focusingOutsideComponent = event.relatedTarget === null;
222
+ var focusingInput = event.relatedTarget === this.elementReferences[-1];
223
+ var focusingAnotherOption = focused !== index && focused !== -1;
224
+ var blurComponent = !focusingAnotherOption && focusingOutsideComponent || !(focusingAnotherOption || focusingInput);
225
+
226
+ if (blurComponent) {
227
+ var keepMenuOpen = menuOpen && isIosDevice();
228
+ this.handleComponentBlur({
229
+ menuOpen: keepMenuOpen,
230
+ query: this.templateInputValue(options[selected])
231
+ });
232
+ }
233
+ }
234
+ }, {
235
+ key: "handleInputBlur",
236
+ value: function handleInputBlur() {
237
+ var _this$state3 = this.state,
238
+ focused = _this$state3.focused,
239
+ menuOpen = _this$state3.menuOpen,
240
+ options = _this$state3.options,
241
+ query = _this$state3.query,
242
+ selected = _this$state3.selected;
243
+ var focusingAnOption = focused !== -1;
244
+
245
+ if (!focusingAnOption) {
246
+ var keepMenuOpen = menuOpen && isIosDevice();
247
+ var newQuery = isIosDevice() ? query : this.templateInputValue(options[selected]);
248
+ this.handleComponentBlur({
249
+ menuOpen: keepMenuOpen,
250
+ query: newQuery
251
+ });
252
+ }
253
+ }
254
+ }, {
255
+ key: "handleInputChange",
256
+ value: function handleInputChange(event) {
257
+ var _this4 = this;
258
+
259
+ var _this$props2 = this.props,
260
+ minLength = _this$props2.minLength,
261
+ source = _this$props2.source,
262
+ showAllValues = _this$props2.showAllValues;
263
+ var autoselect = this.hasAutoselect();
264
+ var query = event.target.value;
265
+ var queryEmpty = query.length === 0;
266
+ var queryChanged = this.state.query.length !== query.length;
267
+ var queryLongEnough = query.length >= minLength;
268
+ this.setState({
269
+ query: query,
270
+ ariaHint: queryEmpty
271
+ });
272
+ var searchForOptions = showAllValues || !queryEmpty && queryChanged && queryLongEnough;
273
+
274
+ if (searchForOptions) {
275
+ source(query, function (options) {
276
+ var optionsAvailable = options.length > 0;
277
+
278
+ _this4.setState({
279
+ menuOpen: optionsAvailable,
280
+ options: options,
281
+ selected: autoselect && optionsAvailable ? 0 : -1,
282
+ validChoiceMade: false
283
+ });
284
+ });
285
+ } else if (queryEmpty || !queryLongEnough) {
286
+ this.setState({
287
+ menuOpen: false,
288
+ options: []
289
+ });
290
+ }
291
+ }
292
+ }, {
293
+ key: "handleInputClick",
294
+ value: function handleInputClick(event) {
295
+ this.handleInputChange(event);
296
+ }
297
+ }, {
298
+ key: "handleInputFocus",
299
+ value: function handleInputFocus() {
300
+ var _this$state4 = this.state,
301
+ query = _this$state4.query,
302
+ validChoiceMade = _this$state4.validChoiceMade,
303
+ options = _this$state4.options;
304
+ var minLength = this.props.minLength;
305
+ var shouldReopenMenu = !validChoiceMade && query.length >= minLength && options.length > 0;
306
+
307
+ if (shouldReopenMenu) {
308
+ this.setState(function (_ref) {
309
+ var menuOpen = _ref.menuOpen;
310
+ return {
311
+ focused: -1,
312
+ menuOpen: shouldReopenMenu || menuOpen,
313
+ selected: -1
314
+ };
315
+ });
316
+ } else {
317
+ this.setState({
318
+ focused: -1
319
+ });
320
+ }
321
+ }
322
+ }, {
323
+ key: "handleOptionFocus",
324
+ value: function handleOptionFocus(index) {
325
+ this.setState({
326
+ focused: index,
327
+ hovered: null,
328
+ selected: index
329
+ });
330
+ }
331
+ }, {
332
+ key: "handleOptionMouseEnter",
333
+ value: function handleOptionMouseEnter(index) {
334
+ // iOS Safari prevents click event if mouseenter adds hover background colour
335
+ // See: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW4
336
+ if (!isIosDevice()) {
337
+ this.setState({
338
+ hovered: index
339
+ });
340
+ }
341
+ }
342
+ }, {
343
+ key: "handleOptionClick",
344
+ value: function handleOptionClick(index) {
345
+ var _this$props$onConfirm2, _this$props3;
346
+
347
+ var selectedOption = this.state.options[index];
348
+ var newQuery = this.templateInputValue(selectedOption);
349
+ (_this$props$onConfirm2 = (_this$props3 = this.props).onConfirm) === null || _this$props$onConfirm2 === void 0 ? void 0 : _this$props$onConfirm2.call(_this$props3, selectedOption);
350
+ this.setState({
351
+ focused: -1,
352
+ hovered: null,
353
+ menuOpen: false,
354
+ query: newQuery,
355
+ selected: -1,
356
+ validChoiceMade: true
357
+ });
358
+ this.forceUpdate();
359
+ }
360
+ }, {
361
+ key: "handleOptionMouseDown",
362
+ value: function handleOptionMouseDown(event) {
363
+ // Safari triggers focusOut before click, but if you
364
+ // preventDefault on mouseDown, you can stop that from happening.
365
+ // If this is removed, clicking on an option in Safari will trigger
366
+ // `handleOptionBlur`, which closes the menu, and the click will
367
+ // trigger on the element underneath instead.
368
+ // See: http://stackoverflow.com/questions/7621711/how-to-prevent-blur-running-when-clicking-a-link-in-jquery
369
+ event.preventDefault();
370
+ }
371
+ }, {
372
+ key: "handleUpArrow",
373
+ value: function handleUpArrow(event) {
374
+ event.preventDefault();
375
+ var _this$state5 = this.state,
376
+ menuOpen = _this$state5.menuOpen,
377
+ selected = _this$state5.selected;
378
+ var isNotAtTop = selected !== -1;
379
+ var allowMoveUp = isNotAtTop && menuOpen;
380
+
381
+ if (allowMoveUp) {
382
+ this.handleOptionFocus(selected - 1);
383
+ }
384
+ }
385
+ }, {
386
+ key: "handleDownArrow",
387
+ value: function handleDownArrow(event) {
388
+ var _this5 = this;
389
+
390
+ event.preventDefault(); // if not open, open
391
+
392
+ if (this.props.showAllValues && this.state.menuOpen === false) {
393
+ event.preventDefault();
394
+ this.props.source('', function (options) {
395
+ _this5.setState({
396
+ menuOpen: true,
397
+ options: options,
398
+ selected: 0,
399
+ focused: 0,
400
+ hovered: null
401
+ });
402
+ });
403
+ } else if (this.state.menuOpen === true) {
404
+ var _this$state6 = this.state,
405
+ menuOpen = _this$state6.menuOpen,
406
+ _options = _this$state6.options,
407
+ selected = _this$state6.selected;
408
+ var isNotAtBottom = selected !== _options.length - 1;
409
+ var allowMoveDown = isNotAtBottom && menuOpen;
410
+
411
+ if (allowMoveDown) {
412
+ this.handleOptionFocus(selected + 1);
413
+ }
414
+ }
415
+ }
416
+ }, {
417
+ key: "handleSpace",
418
+ value: function handleSpace(event) {
419
+ var _this6 = this;
420
+
421
+ // if not open, open
422
+ if (this.props.showAllValues && this.state.menuOpen === false && this.state.query === '') {
423
+ event.preventDefault();
424
+ this.props.source('', function (options) {
425
+ _this6.setState({
426
+ menuOpen: true,
427
+ options: options
428
+ });
429
+ });
430
+ }
431
+
432
+ var focusIsOnOption = this.state.focused !== -1;
433
+
434
+ if (focusIsOnOption) {
435
+ event.preventDefault();
436
+ this.handleOptionClick(this.state.focused);
437
+ }
438
+ }
439
+ }, {
440
+ key: "handleEnter",
441
+ value: function handleEnter(event) {
442
+ if (this.state.menuOpen) {
443
+ event.preventDefault();
444
+ var hasSelectedOption = this.state.selected >= 0;
445
+
446
+ if (hasSelectedOption) {
447
+ this.handleOptionClick(this.state.selected);
448
+ }
449
+ }
450
+ }
451
+ }, {
452
+ key: "handlePrintableKey",
453
+ value: function handlePrintableKey(event) {
454
+ var inputElement = this.elementReferences[-1];
455
+ var eventIsOnInput = event.target === inputElement;
456
+
457
+ if (!eventIsOnInput) {
458
+ // FIXME: This would be better if it was in componentDidUpdate,
459
+ // but using setState to trigger that seems to not work correctly
460
+ // in preact@8.1.0.
461
+ inputElement.focus();
462
+ }
463
+ }
464
+ }, {
465
+ key: "handleKeyDown",
466
+ value: function handleKeyDown(event) {
467
+ switch (keyCodes[event.keyCode]) {
468
+ case 'up':
469
+ this.handleUpArrow(event);
470
+ break;
471
+
472
+ case 'down':
473
+ this.handleDownArrow(event);
474
+ break;
475
+
476
+ case 'space':
477
+ this.handleSpace(event);
478
+ break;
479
+
480
+ case 'enter':
481
+ this.handleEnter(event);
482
+ break;
483
+
484
+ case 'escape':
485
+ this.handleComponentBlur({
486
+ query: this.state.query
487
+ });
488
+ break;
489
+
490
+ default:
491
+ if (isPrintableKeyCode(event.keyCode)) {
492
+ this.handlePrintableKey(event);
493
+ }
494
+
495
+ break;
496
+ }
497
+ }
498
+ }, {
499
+ key: "render",
500
+ value: function render() {
501
+ var _this7 = this;
502
+
503
+ var _this$props4 = this.props,
504
+ id = _this$props4.id,
505
+ cellWidth = _this$props4.cellWidth,
506
+ displayMenu = _this$props4.displayMenu,
507
+ minLength = _this$props4.minLength,
508
+ name = _this$props4.name,
509
+ placeholder = _this$props4.placeholder,
510
+ required = _this$props4.required,
511
+ showAllValues = _this$props4.showAllValues,
512
+ tNoResults = _this$props4.tNoResults,
513
+ tStatusQueryTooShort = _this$props4.tStatusQueryTooShort,
514
+ tStatusNoResults = _this$props4.tStatusNoResults,
515
+ tStatusSelectedOption = _this$props4.tStatusSelectedOption,
516
+ tStatusResults = _this$props4.tStatusResults,
517
+ tAssistiveHint = _this$props4.tAssistiveHint,
518
+ dropdownArrowFactory = _this$props4.dropdownArrow;
519
+ var _this$state7 = this.state,
520
+ focused = _this$state7.focused,
521
+ hovered = _this$state7.hovered,
522
+ menuOpen = _this$state7.menuOpen,
523
+ options = _this$state7.options,
524
+ query = _this$state7.query,
525
+ selected = _this$state7.selected,
526
+ ariaHint = _this$state7.ariaHint,
527
+ validChoiceMade = _this$state7.validChoiceMade;
528
+ var autoselect = this.hasAutoselect();
529
+ var inputFocused = focused === -1;
530
+ var noOptionsAvailable = options.length === 0;
531
+ var queryNotEmpty = query.length !== 0;
532
+ var queryLongEnough = query.length >= minLength;
533
+ var showNoOptionsFound = this.props.showNoOptionsFound && inputFocused && noOptionsAvailable && queryNotEmpty && queryLongEnough;
534
+ var componentIsFocused = focused !== null;
535
+ var dropdownArrowClassName = "govgr-autocomplete__dropdown-arrow-down";
536
+ var optionFocused = focused !== -1 && focused !== null;
537
+ var menuIsVisible = menuOpen || showNoOptionsFound;
538
+ var selectedOptionText = this.templateInputValue(options[selected]);
539
+ var optionBeginsWithQuery = selectedOptionText && selectedOptionText.toLowerCase().indexOf(query.toLowerCase()) === 0;
540
+ var hintValue = optionBeginsWithQuery && autoselect ? query + selectedOptionText.substr(query.length) : '';
541
+ var assistiveHintID = id + '__assistiveHint';
542
+ var ariaDescribedProp = ariaHint ? {
543
+ 'aria-describedby': assistiveHintID
544
+ } : null;
545
+ var dropdownArrow; // we only need a dropdown arrow if showAllValues is set to a truthy value
546
+
547
+ if (showAllValues) {
548
+ dropdownArrow = dropdownArrowFactory({
549
+ className: dropdownArrowClassName
550
+ }); // if the factory returns a string we'll render this as HTML (usage w/o (P)React)
551
+
552
+ if (typeof dropdownArrow === 'string') {
553
+ dropdownArrow = /*#__PURE__*/React.createElement("div", {
554
+ className: "autocomplete__dropdown-arrow-down-wrapper",
555
+ dangerouslySetInnerHTML: {
556
+ __html: dropdownArrow
557
+ }
558
+ });
559
+ }
560
+ }
561
+
562
+ return /*#__PURE__*/React.createElement(AutoCompleteWrapper, {
563
+ onKeyDown: this.handleKeyDown,
564
+ cellWidth: cellWidth
565
+ }, /*#__PURE__*/React.createElement(Status, {
566
+ id: id,
567
+ length: options.length,
568
+ queryLength: query.length,
569
+ minQueryLength: minLength,
570
+ selectedOption: this.templateInputValue(options[selected]),
571
+ selectedOptionIndex: selected,
572
+ validChoiceMade: validChoiceMade,
573
+ isInFocus: this.state.focused !== null,
574
+ tQueryTooShort: tStatusQueryTooShort,
575
+ tNoResults: tStatusNoResults,
576
+ tSelectedOption: tStatusSelectedOption,
577
+ tResults: tStatusResults
578
+ }), hintValue && /*#__PURE__*/React.createElement(AutoCompleteInputTypeahead, {
579
+ value: hintValue
580
+ }), /*#__PURE__*/React.createElement(AutoCompleteInput, _extends({
581
+ "aria-expanded": menuOpen ? 'true' : 'false',
582
+ "aria-activedescendant": optionFocused ? "".concat(id, "__option--").concat(focused) : '',
583
+ "aria-owns": "".concat(id, "__listbox"),
584
+ "aria-autocomplete": this.hasAutoselect() ? 'both' : 'list'
585
+ }, ariaDescribedProp, {
586
+ autoComplete: "off",
587
+ isFocused: componentIsFocused,
588
+ showAllValues: this.props.showAllValues,
589
+ id: id,
590
+ onClick: function onClick(event) {
591
+ return _this7.handleInputClick(event);
592
+ },
593
+ onBlur: this.handleInputBlur,
594
+ onChange: this.handleInputChange,
595
+ onFocus: this.handleInputFocus,
596
+ name: name,
597
+ placeholder: placeholder,
598
+ ref: function ref(inputElement) {
599
+ _this7.elementReferences[-1] = inputElement;
600
+ },
601
+ role: "combobox",
602
+ required: required,
603
+ value: query
604
+ })), dropdownArrow, /*#__PURE__*/React.createElement(AutoCompleteResultList, {
605
+ displayMenu: displayMenu,
606
+ isVisible: menuIsVisible,
607
+ onMouseLeave: function onMouseLeave() {
608
+ return _this7.handleListMouseLeave();
609
+ },
610
+ id: "".concat(id, "__listbox"),
611
+ role: "listbox"
612
+ }, options.map(function (option, index) {
613
+ var showFocused = focused === -1 ? selected === index : focused === index;
614
+ var iosPosinsetHtml = isIosDevice() ? "<span id=".concat(id, "__option-suffix--").concat(index, " style=\"border:0;clip:rect(0 0 0 0);height:1px;") + 'marginBottom:-1px;marginRight:-1px;overflow:hidden;padding:0;position:absolute;' + 'whiteSpace:nowrap;width:1px">' + " ".concat(index + 1, " of ").concat(options.length, "</span>") : '';
615
+ return /*#__PURE__*/React.createElement(AutoCompleteResultListItem, {
616
+ isFocused: showFocused,
617
+ isHovered: hovered,
618
+ index: index,
619
+ "aria-selected": focused === index ? 'true' : 'false',
620
+ dangerouslySetInnerHTML: {
621
+ __html: _this7.templateSuggestion(option) + iosPosinsetHtml
622
+ },
623
+ id: "".concat(id, "__option--").concat(index),
624
+ key: index,
625
+ onBlur: function onBlur(event) {
626
+ return _this7.handleOptionBlur(event, index);
627
+ },
628
+ onClick: function onClick() {
629
+ return _this7.handleOptionClick(index);
630
+ },
631
+ onMouseDown: _this7.handleOptionMouseDown,
632
+ onMouseEnter: function onMouseEnter() {
633
+ return _this7.handleOptionMouseEnter(index);
634
+ },
635
+ ref: function ref(optionEl) {
636
+ _this7.elementReferences[index] = optionEl;
637
+ },
638
+ role: "option",
639
+ tabIndex: -1,
640
+ "aria-posinset": index + 1,
641
+ "aria-setsize": options.length
642
+ });
643
+ }), showNoOptionsFound && /*#__PURE__*/React.createElement(AutoCompleteNoResult, null, tNoResults === null || tNoResults === void 0 ? void 0 : tNoResults())), /*#__PURE__*/React.createElement(AutoCompleteAssistiveHint, {
644
+ id: assistiveHintID
645
+ }, tAssistiveHint === null || tAssistiveHint === void 0 ? void 0 : tAssistiveHint()));
646
+ }
647
+ }]);
648
+
649
+ return AutoComplete;
650
+ }(Component);
651
+
652
+ AutoComplete.defaultProps = {
653
+ cellWidth: 'one-third',
654
+ autoselect: false,
655
+ defaultValue: '',
656
+ displayMenu: 'overlay',
657
+ minLength: 0,
658
+ name: 'govgr-input-autocomplete',
659
+ placeholder: '',
660
+ onConfirm: function onConfirm() {
661
+ return;
662
+ },
663
+ confirmOnBlur: false,
664
+ showNoOptionsFound: true,
665
+ showAllValues: false,
666
+ required: false,
667
+ tNoResults: function tNoResults() {
668
+ return 'No results found';
669
+ },
670
+ tAssistiveHint: function tAssistiveHint() {
671
+ return 'When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.';
672
+ },
673
+ dropdownArrow: DropdownArrowDown
674
+ };
675
+ export { AutoComplete as default };
676
+ export { AutoCompleteInput, AutoCompleteInputTypeahead, AutoCompleteNoResult, AutoCompleteResultList, AutoCompleteResultListItem, AutoCompleteWrapper, AutoCompleteAssistiveHint };