design-react-kit 3.3.1 → 4.0.1

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 (352) hide show
  1. package/README.EN.md +35 -17
  2. package/README.md +34 -18
  3. package/package.json +152 -120
  4. package/src/Accordion/Accordion.tsx +30 -0
  5. package/src/Accordion/AccordionBody.tsx +127 -0
  6. package/src/Accordion/AccordionHeader.tsx +42 -0
  7. package/src/Alert/Alert.tsx +39 -0
  8. package/src/Avatar/AvatarContainer.tsx +22 -0
  9. package/src/Avatar/AvatarExtraText.tsx +19 -0
  10. package/src/Avatar/AvatarGroupContainer.tsx +23 -0
  11. package/src/Avatar/AvatarIcon.tsx +57 -0
  12. package/src/Avatar/AvatarPresence.tsx +24 -0
  13. package/src/Avatar/AvatarStatus.tsx +24 -0
  14. package/src/Avatar/AvatarWrapper.tsx +24 -0
  15. package/src/Badge/Badge.tsx +40 -0
  16. package/src/BottomNav/BottomNav.tsx +20 -0
  17. package/src/BottomNav/BottomNavItem.tsx +75 -0
  18. package/src/Breadcrumb/Breadcrumb.tsx +40 -0
  19. package/src/Button/Button.tsx +55 -0
  20. package/src/Callout/Callout.tsx +35 -0
  21. package/src/Callout/CalloutText.tsx +29 -0
  22. package/src/Callout/CalloutTitle.tsx +24 -0
  23. package/src/Card/Card.tsx +49 -0
  24. package/src/Card/CardBody.tsx +21 -0
  25. package/src/Card/CardCategory.tsx +48 -0
  26. package/src/Card/CardFooterCTA.tsx +19 -0
  27. package/src/Card/CardReadMore.tsx +35 -0
  28. package/src/Card/CardSignature.tsx +19 -0
  29. package/src/Card/CardTag.tsx +19 -0
  30. package/src/Card/CardTagsHeader.tsx +28 -0
  31. package/src/Card/CardText.tsx +19 -0
  32. package/src/Card/CardTitle.tsx +17 -0
  33. package/src/Chips/Chip.tsx +37 -0
  34. package/src/Chips/ChipLabel.tsx +19 -0
  35. package/src/Collapse/Collapse.tsx +100 -0
  36. package/src/CookieBar/CookieBar.tsx +19 -0
  37. package/src/CookieBar/CookieBarButton.tsx +27 -0
  38. package/src/CookieBar/CookieBarButtons.tsx +19 -0
  39. package/src/Dimmer/Dimmer.tsx +51 -0
  40. package/src/Dimmer/DimmerButtons.tsx +35 -0
  41. package/src/FontLoader/FontLoader.tsx +32 -0
  42. package/src/Forward/Forward.tsx +40 -0
  43. package/src/Grid/GridItem.tsx +23 -0
  44. package/src/Grid/GridItemText.tsx +20 -0
  45. package/src/Grid/GridItemTextWrapper.tsx +21 -0
  46. package/src/Grid/GridList.tsx +20 -0
  47. package/src/Grid/GridRow.tsx +20 -0
  48. package/src/Grid/index.ts +11 -0
  49. package/src/{components/Header/Header.js → Header/Header.tsx} +19 -24
  50. package/src/Header/HeaderBrand.tsx +90 -0
  51. package/src/Header/HeaderContent.tsx +42 -0
  52. package/src/Header/HeaderContext.tsx +9 -0
  53. package/src/Header/HeaderLinkZone.tsx +19 -0
  54. package/src/Header/HeaderRightZone.tsx +26 -0
  55. package/src/Header/HeaderSearch.tsx +33 -0
  56. package/src/Header/HeaderSocialsZone.tsx +26 -0
  57. package/src/Header/HeaderToggler.tsx +46 -0
  58. package/src/{components/Header/Headers.js → Header/Headers.tsx} +17 -22
  59. package/src/Hero/Hero.tsx +34 -0
  60. package/src/Hero/HeroBackground.tsx +25 -0
  61. package/src/Hero/HeroBody.tsx +21 -0
  62. package/src/Hero/HeroButton.tsx +19 -0
  63. package/src/Hero/HeroCategory.tsx +15 -0
  64. package/src/Hero/HeroTitle.tsx +16 -0
  65. package/src/Hero/index.ts +13 -0
  66. package/src/Icon/EmptyIcon.tsx +7 -0
  67. package/src/Icon/Icon.tsx +116 -0
  68. package/src/Icon/assets/ItArrowDown.tsx +9 -0
  69. package/src/Icon/assets/ItArrowDownCircle.tsx +9 -0
  70. package/src/Icon/assets/ItArrowDownTriangle.tsx +9 -0
  71. package/src/Icon/assets/ItArrowLeft.tsx +9 -0
  72. package/src/Icon/assets/ItArrowLeftCircle.tsx +9 -0
  73. package/src/Icon/assets/ItArrowLeftTriangle.tsx +9 -0
  74. package/src/Icon/assets/ItArrowRight.tsx +9 -0
  75. package/src/Icon/assets/ItArrowRightCircle.tsx +9 -0
  76. package/src/Icon/assets/ItArrowRightTriangle.tsx +9 -0
  77. package/src/Icon/assets/ItArrowUp.tsx +9 -0
  78. package/src/Icon/assets/ItArrowUpCircle.tsx +9 -0
  79. package/src/Icon/assets/ItArrowUpTriangle.tsx +9 -0
  80. package/src/Icon/assets/ItBan.tsx +9 -0
  81. package/src/Icon/assets/ItBehance.tsx +9 -0
  82. package/src/Icon/assets/ItBookmark.tsx +9 -0
  83. package/src/Icon/assets/ItBox.tsx +12 -0
  84. package/src/Icon/assets/ItBurger.tsx +9 -0
  85. package/src/Icon/assets/ItCalendar.tsx +9 -0
  86. package/src/Icon/assets/ItCamera.tsx +9 -0
  87. package/src/Icon/assets/ItCard.tsx +9 -0
  88. package/src/Icon/assets/ItChartLine.tsx +12 -0
  89. package/src/Icon/assets/ItCheck.tsx +9 -0
  90. package/src/Icon/assets/ItCheckCircle.tsx +9 -0
  91. package/src/Icon/assets/ItChevronLeft.tsx +8 -0
  92. package/src/Icon/assets/ItChevronRight.tsx +8 -0
  93. package/src/Icon/assets/ItClip.tsx +9 -0
  94. package/src/Icon/assets/ItClock.tsx +9 -0
  95. package/src/Icon/assets/ItClose.tsx +9 -0
  96. package/src/Icon/assets/ItCloseBig.tsx +9 -0
  97. package/src/Icon/assets/ItCloseCircle.tsx +9 -0
  98. package/src/Icon/assets/ItCodeCircle.tsx +9 -0
  99. package/src/Icon/assets/ItCollapse.tsx +8 -0
  100. package/src/Icon/assets/ItComment.tsx +9 -0
  101. package/src/Icon/assets/ItCopy.tsx +9 -0
  102. package/src/Icon/assets/ItDelete.tsx +12 -0
  103. package/src/Icon/assets/ItDesignersItalia.tsx +9 -0
  104. package/src/Icon/assets/ItDownload.tsx +9 -0
  105. package/src/Icon/assets/ItError.tsx +9 -0
  106. package/src/Icon/assets/ItExchangeCircle.tsx +9 -0
  107. package/src/Icon/assets/ItExpand.tsx +8 -0
  108. package/src/Icon/assets/ItExternalLink.tsx +9 -0
  109. package/src/Icon/assets/ItFacebook.tsx +9 -0
  110. package/src/Icon/assets/ItFacebookSquare.tsx +9 -0
  111. package/src/Icon/assets/ItFile.tsx +9 -0
  112. package/src/Icon/assets/ItFiles.tsx +9 -0
  113. package/src/Icon/assets/ItFlag.tsx +9 -0
  114. package/src/Icon/assets/ItFlickr.tsx +10 -0
  115. package/src/Icon/assets/ItFlickrSquare.tsx +9 -0
  116. package/src/Icon/assets/ItFolder.tsx +9 -0
  117. package/src/Icon/assets/ItFullscreen.tsx +11 -0
  118. package/src/Icon/assets/ItFunnel.tsx +9 -0
  119. package/src/Icon/assets/ItGithub.tsx +9 -0
  120. package/src/Icon/assets/ItHearing.tsx +9 -0
  121. package/src/Icon/assets/ItHelp.tsx +9 -0
  122. package/src/Icon/assets/ItHelpCircle.tsx +9 -0
  123. package/src/Icon/assets/ItHorn.tsx +9 -0
  124. package/src/Icon/assets/ItInbox.tsx +12 -0
  125. package/src/Icon/assets/ItInfoCircle.tsx +9 -0
  126. package/src/Icon/assets/ItInstagram.tsx +9 -0
  127. package/src/Icon/assets/ItKey.tsx +9 -0
  128. package/src/Icon/assets/ItLessCircle.tsx +12 -0
  129. package/src/Icon/assets/ItLink.tsx +9 -0
  130. package/src/Icon/assets/ItLinkedin.tsx +9 -0
  131. package/src/Icon/assets/ItLinkedinSquare.tsx +9 -0
  132. package/src/Icon/assets/ItList.tsx +9 -0
  133. package/src/Icon/assets/ItLock.tsx +12 -0
  134. package/src/Icon/assets/ItLocked.tsx +9 -0
  135. package/src/Icon/assets/ItMail.tsx +9 -0
  136. package/src/Icon/assets/ItMapMarker.tsx +9 -0
  137. package/src/Icon/assets/ItMapMarkerCircle.tsx +12 -0
  138. package/src/Icon/assets/ItMapMarkerMinus.tsx +9 -0
  139. package/src/Icon/assets/ItMapMarkerPlus.tsx +12 -0
  140. package/src/Icon/assets/ItMaximize.tsx +11 -0
  141. package/src/Icon/assets/ItMaximizeAlt.tsx +11 -0
  142. package/src/Icon/assets/ItMedium.tsx +9 -0
  143. package/src/Icon/assets/ItMediumSquare.tsx +9 -0
  144. package/src/Icon/assets/ItMinimize.tsx +11 -0
  145. package/src/Icon/assets/ItMinus.tsx +9 -0
  146. package/src/Icon/assets/ItMinusCircle.tsx +9 -0
  147. package/src/Icon/assets/ItMoreActions.tsx +9 -0
  148. package/src/Icon/assets/ItMoreItems.tsx +9 -0
  149. package/src/Icon/assets/ItNote.tsx +9 -0
  150. package/src/Icon/assets/ItOpenSource.tsx +9 -0
  151. package/src/Icon/assets/ItPa.tsx +9 -0
  152. package/src/Icon/assets/ItPasswordInvisible.tsx +9 -0
  153. package/src/Icon/assets/ItPasswordVisible.tsx +9 -0
  154. package/src/Icon/assets/ItPencil.tsx +9 -0
  155. package/src/Icon/assets/ItPiattaforme.tsx +10 -0
  156. package/src/Icon/assets/ItPin.tsx +9 -0
  157. package/src/Icon/assets/ItPlug.tsx +9 -0
  158. package/src/Icon/assets/ItPlus.tsx +9 -0
  159. package/src/Icon/assets/ItPlusCircle.tsx +9 -0
  160. package/src/Icon/assets/ItPresentation.tsx +9 -0
  161. package/src/Icon/assets/ItPrint.tsx +9 -0
  162. package/src/Icon/assets/ItRefresh.tsx +9 -0
  163. package/src/Icon/assets/ItRestore.tsx +9 -0
  164. package/src/Icon/assets/ItRss.tsx +11 -0
  165. package/src/Icon/assets/ItRssSquare.tsx +9 -0
  166. package/src/Icon/assets/ItSearch.tsx +9 -0
  167. package/src/Icon/assets/ItSettings.tsx +9 -0
  168. package/src/Icon/assets/ItShare.tsx +9 -0
  169. package/src/Icon/assets/ItSoftware.tsx +10 -0
  170. package/src/Icon/assets/ItStarFull.tsx +9 -0
  171. package/src/Icon/assets/ItStarOutline.tsx +9 -0
  172. package/src/Icon/assets/ItTeamDigitale.tsx +8 -0
  173. package/src/Icon/assets/ItTelegram.tsx +11 -0
  174. package/src/Icon/assets/ItTelephone.tsx +9 -0
  175. package/src/Icon/assets/ItTool.tsx +9 -0
  176. package/src/Icon/assets/ItTwitter.tsx +9 -0
  177. package/src/Icon/assets/ItTwitterSquare.tsx +9 -0
  178. package/src/Icon/assets/ItUnlocked.tsx +9 -0
  179. package/src/Icon/assets/ItUpload.tsx +9 -0
  180. package/src/Icon/assets/ItUser.tsx +9 -0
  181. package/src/Icon/assets/ItVideo.tsx +9 -0
  182. package/src/Icon/assets/ItWarning.tsx +9 -0
  183. package/src/Icon/assets/ItWarningCircle.tsx +9 -0
  184. package/src/Icon/assets/ItWhatsapp.tsx +9 -0
  185. package/src/Icon/assets/ItWhatsappSquare.tsx +10 -0
  186. package/src/Icon/assets/ItWifi.tsx +12 -0
  187. package/src/Icon/assets/ItYoutube.tsx +9 -0
  188. package/src/Icon/assets/ItZoomIn.tsx +9 -0
  189. package/src/Icon/assets/ItZoomOut.tsx +9 -0
  190. package/src/Icon/assets/index.tsx +504 -0
  191. package/src/Input/Input.tsx +342 -0
  192. package/src/Input/InputContainer.tsx +34 -0
  193. package/src/Input/TextArea.tsx +184 -0
  194. package/src/Input/TimeInput.tsx +303 -0
  195. package/src/Input/utils.tsx +166 -0
  196. package/src/LinkList/LinkList.tsx +65 -0
  197. package/src/LinkList/LinkListItem.tsx +98 -0
  198. package/src/Megamenu/Megamenu.tsx +37 -0
  199. package/src/Megamenu/MegamenuFooter.tsx +20 -0
  200. package/src/Megamenu/MegamenuHighlightColumn.tsx +33 -0
  201. package/src/Megamenu/MegamenuItem.tsx +27 -0
  202. package/src/Modal/Modal.tsx +79 -0
  203. package/src/Modal/ModalBody.tsx +11 -0
  204. package/src/Modal/ModalFooter.tsx +11 -0
  205. package/src/Modal/ModalHeader.tsx +70 -0
  206. package/src/Nav/Nav.tsx +56 -0
  207. package/src/Notification/Notification.tsx +60 -0
  208. package/src/Notification/NotificationContent.tsx +135 -0
  209. package/src/Notification/NotificationManager.tsx +65 -0
  210. package/src/Notification/core.tsx +46 -0
  211. package/src/Notification/index.ts +9 -0
  212. package/src/Notification/types.ts +12 -0
  213. package/src/Notification/usePosition.tsx +11 -0
  214. package/src/Pager/Pager.tsx +48 -0
  215. package/src/PasswordInput/PasswordInput.tsx +43 -0
  216. package/src/Progress/Progress.tsx +94 -0
  217. package/src/Rating/Rating.tsx +130 -0
  218. package/src/ResponsiveImage/ResponsiveImage.tsx +25 -0
  219. package/src/Section/Section.tsx +86 -0
  220. package/src/Select/Select.tsx +97 -0
  221. package/src/Select/shared.tsx +45 -0
  222. package/src/Sidebar/Sidebar.tsx +46 -0
  223. package/src/Skiplink/Skiplink.tsx +20 -0
  224. package/src/Skiplink/SkiplinkItem.tsx +29 -0
  225. package/src/Spinner/Spinner.tsx +55 -0
  226. package/src/Stepper/StepperContainer.tsx +30 -0
  227. package/src/Stepper/StepperContent.tsx +51 -0
  228. package/src/Stepper/StepperDots.tsx +21 -0
  229. package/src/Stepper/StepperHeader.tsx +19 -0
  230. package/src/Stepper/StepperHeaderElement.tsx +77 -0
  231. package/src/Stepper/StepperNav.tsx +19 -0
  232. package/src/ThumbNav/ThumbNav.tsx +37 -0
  233. package/src/ThumbNav/ThumbNavItem.tsx +35 -0
  234. package/src/Timeline/TimelinePin.tsx +67 -0
  235. package/src/Timeline/TimelineWrapper.tsx +19 -0
  236. package/src/Toggle/Toggle.tsx +29 -0
  237. package/src/Toolbar/Toolbar.tsx +28 -0
  238. package/src/Toolbar/ToolbarDividerItem.tsx +5 -0
  239. package/src/Toolbar/ToolbarItem.tsx +95 -0
  240. package/src/assets.d.ts +4 -0
  241. package/src/index.tsx +350 -0
  242. package/src/utils.tsx +26 -0
  243. package/.editorconfig +0 -18
  244. package/.eslintrc +0 -65
  245. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
  246. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  247. package/.github/PULL_REQUEST_TEMPLATE.md +0 -24
  248. package/AUTHORS +0 -3
  249. package/CODE_OF_CONDUCT.EN.md +0 -77
  250. package/CODE_OF_CONDUCT.md +0 -69
  251. package/dist/design-react-kit.cjs.js +0 -3698
  252. package/dist/design-react-kit.cjs.js.map +0 -1
  253. package/dist/design-react-kit.d.ts +0 -1704
  254. package/dist/design-react-kit.es.js +0 -3188
  255. package/dist/design-react-kit.es.js.map +0 -1
  256. package/dist/design-react-kit.full.js +0 -17596
  257. package/dist/design-react-kit.full.js.map +0 -1
  258. package/dist/design-react-kit.full.min.js +0 -2
  259. package/dist/design-react-kit.full.min.js.map +0 -1
  260. package/dist/design-react-kit.js +0 -13394
  261. package/dist/design-react-kit.js.map +0 -1
  262. package/dist/design-react-kit.min.js +0 -2
  263. package/dist/design-react-kit.min.js.map +0 -1
  264. package/src/Storyshots.test.js +0 -9
  265. package/src/components/Accordion/Accordion.js +0 -22
  266. package/src/components/Accordion/AccordionBody.js +0 -118
  267. package/src/components/Accordion/AccordionHeader.js +0 -37
  268. package/src/components/Autocomplete/Autocomplete.js +0 -255
  269. package/src/components/Avatar/AvatarContainer.js +0 -24
  270. package/src/components/Avatar/AvatarExtraText.js +0 -22
  271. package/src/components/Avatar/AvatarGroupContainer.js +0 -23
  272. package/src/components/Avatar/AvatarIcon.js +0 -32
  273. package/src/components/Avatar/AvatarPresence.js +0 -25
  274. package/src/components/Avatar/AvatarStatus.js +0 -25
  275. package/src/components/Avatar/AvatarWrapper.js +0 -25
  276. package/src/components/Badge/Badge.js +0 -28
  277. package/src/components/BottomNav/BottomNav.js +0 -27
  278. package/src/components/BottomNav/BottomNavItem.js +0 -69
  279. package/src/components/Button/Button.js +0 -26
  280. package/src/components/Callout/Callout.js +0 -33
  281. package/src/components/Callout/CalloutText.js +0 -37
  282. package/src/components/Callout/CalloutTitle.js +0 -27
  283. package/src/components/Card/Card.js +0 -50
  284. package/src/components/Card/CardCategory.js +0 -43
  285. package/src/components/Card/CardFooterCTA.js +0 -17
  286. package/src/components/Card/CardReadMore.js +0 -45
  287. package/src/components/Card/CardSignature.js +0 -17
  288. package/src/components/Card/CardTag.js +0 -23
  289. package/src/components/Card/CardTagsHeader.js +0 -21
  290. package/src/components/Chips/Chip.js +0 -50
  291. package/src/components/Chips/ChipLabel.js +0 -25
  292. package/src/components/Collapse/Collapse.js +0 -66
  293. package/src/components/CookieBar/CookieBar.js +0 -22
  294. package/src/components/CookieBar/CookieBarButton.js +0 -25
  295. package/src/components/CookieBar/CookieBarButtons.js +0 -23
  296. package/src/components/Dimmer/Dimmer.js +0 -38
  297. package/src/components/Dimmer/DimmerButtons.js +0 -35
  298. package/src/components/FontLoader/FontLoader.js +0 -22
  299. package/src/components/FormGroup/FormGroup.js +0 -137
  300. package/src/components/Forward/Forward.js +0 -32
  301. package/src/components/Header/HeaderBrand.js +0 -86
  302. package/src/components/Header/HeaderContent.js +0 -49
  303. package/src/components/Header/HeaderContext.js +0 -14
  304. package/src/components/Header/HeaderLinkZone.js +0 -24
  305. package/src/components/Header/HeaderRightZone.js +0 -33
  306. package/src/components/Header/HeaderSearch.js +0 -36
  307. package/src/components/Header/HeaderSocialsZone.js +0 -30
  308. package/src/components/Header/HeaderToggler.js +0 -50
  309. package/src/components/Hero/Hero.js +0 -10
  310. package/src/components/Icon/Icon.js +0 -42
  311. package/src/components/Input/Input.js +0 -261
  312. package/src/components/Input/InputContainer.js +0 -39
  313. package/src/components/Input/utils.js +0 -126
  314. package/src/components/LinkList/LinkList.js +0 -65
  315. package/src/components/LinkList/LinkListItem.js +0 -88
  316. package/src/components/Nav/Nav.js +0 -37
  317. package/src/components/Notification/Notification.js +0 -78
  318. package/src/components/Offcanvas/Offcanvas.js +0 -101
  319. package/src/components/Pager/Pager.js +0 -32
  320. package/src/components/PagerList/PagerList.js +0 -28
  321. package/src/components/PasswordInput/PasswordInput.js +0 -41
  322. package/src/components/PasswordMeter/PasswordMeter.js +0 -80
  323. package/src/components/Progress/Progress.js +0 -88
  324. package/src/components/Rating/Rating.js +0 -130
  325. package/src/components/Section/Section.js +0 -49
  326. package/src/components/Separator/Separator.js +0 -34
  327. package/src/components/Sidebar/Sidebar.js +0 -53
  328. package/src/components/Skiplink/Skiplink.js +0 -25
  329. package/src/components/Skiplink/SkiplinkItem.js +0 -25
  330. package/src/components/Spinner/Spinner.js +0 -65
  331. package/src/components/Stepper/StepperContainer.js +0 -33
  332. package/src/components/Stepper/StepperContent.js +0 -54
  333. package/src/components/Stepper/StepperDots.js +0 -27
  334. package/src/components/Stepper/StepperHeader.js +0 -27
  335. package/src/components/Stepper/StepperHeaderElement.js +0 -45
  336. package/src/components/Stepper/StepperNav.js +0 -27
  337. package/src/components/Table/Table.js +0 -68
  338. package/src/components/Timeline/TimelinePin.js +0 -59
  339. package/src/components/Timeline/TimelineWrapper.js +0 -21
  340. package/src/components/Toggle/Toggle.js +0 -27
  341. package/src/components/utils.js +0 -1
  342. package/src/index.js +0 -144
  343. package/static/favicons/android-chrome-192x192.png +0 -0
  344. package/static/favicons/android-chrome-512x512.png +0 -0
  345. package/static/favicons/apple-touch-icon.png +0 -0
  346. package/static/favicons/browserconfig.xml +0 -9
  347. package/static/favicons/favicon-16x16.png +0 -0
  348. package/static/favicons/favicon-32x32.png +0 -0
  349. package/static/favicons/favicon.ico +0 -0
  350. package/static/favicons/manifest.webmanifest +0 -21
  351. package/static/favicons/mstile-150x150.png +0 -0
  352. package/static/favicons/safari-pinned-tab.svg +0 -23
package/README.EN.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Design React Kit
2
2
 
3
+ ![CircleCI](https://img.shields.io/circleci/build/github/italia/design-react-kit)
3
4
  [![Join channel #design-devel](https://img.shields.io/badge/Slack%20channel-%23design--devel-blue.svg)](https://developersitalia.slack.com/messages/C7VPAUVB3/)
4
5
  [![Get an invitation for Slack](https://slack.developers.italia.it/badge.svg)](https://slack.developers.italia.it/)
5
6
 
@@ -11,7 +12,7 @@
11
12
 
12
13
  Components are showcased with [Storybook](https://storybook.js.org/).
13
14
 
14
- Public version of Storybook (built from `master` branch) is available here: https://italia.github.io/design-react-kit.
15
+ Public version of Storybook is available [here](https://italia.github.io/design-react-kit) for the latest stable release, while [here](https://design-react-kit.vercel.app/) for the current development version built from `master` branch.
15
16
 
16
17
  ## Table of contents
17
18
 
@@ -88,9 +89,9 @@ const WebFont = require('webfontloader')
88
89
  WebFont.load({
89
90
  custom: {
90
91
  families: [
91
- 'Titillium Web:300,400,600,700:latin-ext',
92
- 'Lora:400,700:latin-ext',
93
- 'Roboto Mono:400,700:latin-ext'
92
+ 'Titillium Web:300,400,600,700:latin-ext',
93
+ 'Lora:400,700:latin-ext',
94
+ 'Roboto Mono:400,700:latin-ext'
94
95
  ]
95
96
  }
96
97
  })
@@ -126,27 +127,48 @@ Storybook has been enriched with some `addons` that make it more talented. Check
126
127
  ## How to create new components
127
128
 
128
129
  This section explains how to create new components in the repository.
129
- All components reside in the `components` directory: each component is a folder with all that is needed to make it work. *Storybook* stories are instead under `stories`.
130
+ All components reside in the `src` directory: each component is a folder with all that is needed to make it work.
131
+ *Storybook* stories are instead under `stories`.
132
+ Unit tests are under the `test` folder.
130
133
 
131
- i.e. the `Button` component is shown below the `src/components/Button` path and its structure is as follows:
134
+ i.e. the `Button` component is shown below the `src/Button` path and its structure is as follows:
132
135
 
133
136
  ```
134
137
  src
135
- └── components
136
- └── Button
137
- ├── Button.js
138
+ └── Button
139
+ ├── Button.tsx
138
140
  stories
139
141
  └── Button
140
- ├── Button.stories.js
142
+ ├── Button.stories.mdx
143
+ ├── Button.stories.tsx
144
+ test
145
+ ├── Button.test.tsx
141
146
  ```
142
147
 
143
148
  Some basic rules for structuring the components:
144
149
 
145
- * JS file component files use JSX syntax.
146
- * The `.stories.js` files only restore the relative component only.
150
+ * TSX file component files use JSX syntax.
151
+ * The `.stories.tsx` files only contains examples relative to component.
152
+ * The `.stories.mdx` files only contains documentation relative to component.
153
+ * The `.test.tsx` files only contains tests relative to component.
147
154
 
148
155
  Once you have created a new component, with its history, starting *Storybook* will be able to check that everything works as it should.
149
156
 
157
+ ### How to contribute
158
+
159
+ To submit new content (feature or bug fixes) is required to fork the repository, starting from `master` create a new branch for the new feature: once completed the development (with tests when possible), create a PR to the original repository.
160
+
161
+ #### Snapshot tests
162
+
163
+ The testing system has been provided with a snapshot check on existing stories: this means that each story content is copied into a special file used as reference to check changes in the future. This might fail some test checks on the PR in case of new or changed stories.
164
+ In such case it is possible to update the snapshot file with the following command:
165
+
166
+ ```
167
+ yarn test -u
168
+ ```
169
+
170
+ At this point create a new commit and update the PR. Make sure to check the new snapshot content whether it is in line with the changes made before pushing.
171
+
150
172
  ## Publishing
151
173
 
152
174
  A command is available to reach a static version of the Storybook catalog as it can be deployed without using a webserver.
@@ -185,8 +207,4 @@ The same list is also available in the `package.json` file. Unfortunately, it's
185
207
 
186
208
  ## TypeScript typing definitions
187
209
 
188
- To generate Typescript typing definitions file:
189
-
190
- ```sh
191
- $ yarn typescript:dts
192
- ```
210
+ The library has been rewritten in Typescript and types are exported in the bundle.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![CircleCI](https://img.shields.io/circleci/project/github/RedSparr0w/node-csgo-parser.svg)](https://circleci.com/gh/italia/design-react-kit)
1
+ ![CircleCI](https://img.shields.io/circleci/build/github/italia/design-react-kit)
2
2
  [![Partecipa sul canale #design-devel](https://img.shields.io/badge/Slack%20channel-%23design--devel-blue.svg)](https://developersitalia.slack.com/messages/C7VPAUVB3/)
3
3
  [![Ricevi un invito a Slack](https://slack.developers.italia.it/badge.svg)](https://slack.developers.italia.it/)
4
4
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  Per navigare la libreria e visualizzare i componenti, è stato utilizzato [Storybook](https://storybook.js.org/).
12
12
 
13
- La versione pubblica dello Storybook (relativa al branch `master`) è disponibile [qui](https://italia.github.io/design-react-kit).
13
+ La versione pubblica dello Storybook è disponibile [qui](https://italia.github.io/design-react-kit) per l'ultima release stabile pubblicata, mentre [qui](https://design-react-kit.vercel.app/) per la versione di sviluppo relativa al branch `master`.
14
14
 
15
15
  ## Indice
16
16
 
@@ -87,9 +87,9 @@ const WebFont = require('webfontloader')
87
87
  WebFont.load({
88
88
  custom: {
89
89
  families: [
90
- 'Titillium Web:300,400,600,700:latin-ext',
91
- 'Lora:400,700:latin-ext',
92
- 'Roboto Mono:400,700:latin-ext'
90
+ 'Titillium Web:300,400,600,700:latin-ext',
91
+ 'Lora:400,700:latin-ext',
92
+ 'Roboto Mono:400,700:latin-ext'
93
93
  ]
94
94
  }
95
95
  })
@@ -123,27 +123,47 @@ Storybook è stato arricchito con alcuni `addons` che lo rendono più parlante.
123
123
  ## Come creare nuovi componenti
124
124
 
125
125
  Questa sezione guiderà alla creazione di nuovi componenti nel repository.
126
- Tutti i componenti risiedono nella folder `components`: ogni componente possiede una sua folder con tutto ciò che è necessario per farlo funzionare.
126
+ Tutti i componenti risiedono nella cartella `src`: ogni componente possiede una sua cartella con tutto ciò che è necessario per farlo funzionare.
127
127
  Le storie `Storybook` invece sono sotto `stories`.
128
- Il componente `Button` ad esempio è presente sotto il path `src/components/Button` e la sua struttura è la seguente:
128
+ I test unitari risiedono nella cartella `test`.
129
+ Il componente `Button` ad esempio è presente sotto il percorso `src/Button` e la sua struttura è la seguente:
129
130
 
130
131
  ```
131
132
  src
132
- └── components
133
- └── Button
134
- ├── Button.js
133
+ └── Button
134
+ ├── Button.tsx
135
135
  stories
136
136
  └── Button
137
- ├── Button.stories.js
137
+ ├── Button.stories.mdx
138
+ ├── Button.stories.tsx
139
+ test
140
+ ├── Button.test.tsx
138
141
  ```
139
142
 
140
143
  Alcune regole di base per strutturare i componenti:
141
144
 
142
- * I file JS file del componente utilizza la sintassi JSX.
143
- * I file `.stories.js` dovrebbero contenere solo quanto relativo al componente stesso.
145
+ * I file TSX file del componente utilizza la sintassi JSX.
146
+ * I file `.stories.tsx` dovrebbero contenere solo quanto relativo al componente stesso.
147
+ * I file `.stories.mdx` dovrebbero contenere solo documentazione relativa al componente stesso
148
+ * I file `.test.tsx` dovrebbero contenere solo test relativi al componente stesso.
144
149
 
145
150
  Una volta creato un nuovo componente, con la sua story, avviando Storybook sarà possibile controllare che tutto funzioni come dovrebbe.
146
151
 
152
+ ### Come contribuire
153
+
154
+ Per inviare nuovi contenuti o bug fix è necessario fare un fork del repository, quindi partire dal branch `master` per un nuovo branch contenente la funzionalità: una volta completa la funzionalità (con relativi test ove possibile), sarà necessario fare una PR sul repository principale.
155
+
156
+ #### Snapshot tests
157
+
158
+ Il sistema di testing prevede un controllo delle storie presenti, mediante una tecnica chiamata "snapshot" testing: il contenuto della storia Storybook verrà copiato in un file speciale e preservato per notificare eventuali cambiamenti in futuro. Questo fa si che l'aggiunta di nuove storie potrebbe risultare in un fallimento del task "test" in una PR.
159
+ Qualora fosse stata aggiunta una nuova storia o modificata una già presente, sarà necessario aggiornare il file di snapshot come segue:
160
+
161
+ ```
162
+ yarn test -u
163
+ ```
164
+
165
+ A questo punto creare un nuovo commit ed aggiornare la PR con il file di snapshot aggiornato. Controllare che le modifiche apportate siano corrette prima di aggiornare la PR.
166
+
147
167
  ## Publishing
148
168
 
149
169
  E' disponibile un comando per generare una versione statica del catalogo Storybook così che possa essere deployato senza utilizzo di un webserver.
@@ -181,8 +201,4 @@ La lista è anche disponibile nel `package.json`. Purtroppo, non è ancora possi
181
201
 
182
202
  ## TypeScript typings
183
203
 
184
- Per generare il file delle definizioni per i _typing_ Typescript, è sufficiente lanciare il comando dedicato:
185
-
186
- ```sh
187
- $ yarn typescript:dts
188
- ```
204
+ La libreria è stata portata a Typescript ed i tipi sono esportati con essa.
package/package.json CHANGED
@@ -1,125 +1,157 @@
1
1
  {
2
- "name": "design-react-kit",
3
- "version": "3.3.1",
4
- "description": "Componenti React per Bootstrap 4",
5
- "author": "Presidenza del Consiglio dei Ministri",
6
- "homepage": "https://github.com/italia/design-react-kit#README",
7
- "license": "BSD-3-Clause",
8
- "sideEffects": false,
9
- "main": "dist/design-react-kit.js",
10
- "module": "dist/design-react-kit.es.js",
11
- "typings": "dist/design-react-kit.d.ts",
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/italia/design-react-kit.git"
2
+ "name": "design-react-kit",
3
+ "description": "Componenti React per Bootstrap 4",
4
+ "keywords": [
5
+ "react",
6
+ "bootstrap",
7
+ "bootstrap-italia"
8
+ ],
9
+ "author": "Presidenza del Consiglio dei Ministri",
10
+ "contributors": [
11
+ "Gianluca Esposito",
12
+ "Matteo Manchi",
13
+ "Paolo Mariotti",
14
+ "Marco Liberati",
15
+ "Francesco Zaia",
16
+ "Sanyam Dogra",
17
+ "Silvio Relli"
18
+ ],
19
+ "bugs": {
20
+ "url": "https://github.com/italia/design-react-kit/issues"
21
+ },
22
+ "version": "4.0.1",
23
+ "license": "BSD-3",
24
+ "module": "dist/esm/index.js",
25
+ "main": "./src/index.tsx",
26
+ "typings": "dist/types/index.d.ts",
27
+ "exports": {
28
+ "require": "./dist/index.js",
29
+ "import": "./dist/esm/index.js",
30
+ "default": "./dist/esm/index.js"
31
+ },
32
+ "sideEffects": false,
33
+ "files": [
34
+ "dist",
35
+ "src"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/italia/design-react-kit.git"
40
+ },
41
+ "engines": {
42
+ "node": ">=10"
43
+ },
44
+ "scripts": {
45
+ "start": "npm run storybook:serve",
46
+ "svg:import": "svgr -d src/Icon/assets node_modules/bootstrap-italia/src/svg && echo \"\" >> src/Icon/assets/index.tsx && npx eslint src/Icon/assets/index.tsx --fix",
47
+ "prebuild": "npm run svg:import",
48
+ "build": "tsdx build --format cjs,esm",
49
+ "test": "tsdx test --passWithNoTests --coverage",
50
+ "test:ci": "tsdx test --passWithNoTests --coverage --runInBand --ci",
51
+ "lint": "npx eslint src stories test --ext js,ts,tsx,jsx,mdx",
52
+ "prepare": "tsdx build --format cjs,esm && husky install",
53
+ "size": "size-limit",
54
+ "analyze": "size-limit --why",
55
+ "prestorybook": "npm run svg:import",
56
+ "storybook:serve": "start-storybook -p 9001 -c .storybook -s ./static",
57
+ "storybook:build": "npm run storybook:build:base --docs",
58
+ "storybook:build:base": "build-storybook -c .storybook -s ./static",
59
+ "storybook:deploy": "npx gh-pages -d storybook-static -m 'Update GitHub Pages [ci skip]'"
60
+ },
61
+ "peerDependencies": {
62
+ "react": ">=16.8.0",
63
+ "bootstrap-italia": "1.4.3"
64
+ },
65
+ "size-limit": [
66
+ {
67
+ "path": "dist/cjs/index.js",
68
+ "limit": "200 KB"
15
69
  },
16
- "contributors": [
17
- "Gianluca Esposito",
18
- "Matteo Manchi",
19
- "Paolo Mariotti",
20
- "Marco Liberati",
21
- "Francesco Zaia",
22
- "Sanyam Dogra",
23
- "Silvio Relli"
24
- ],
25
- "bugs": {
26
- "url": "https://github.com/italia/design-react-kit/issues"
70
+ {
71
+ "path": "dist/esm/index.js",
72
+ "limit": "200 KB"
73
+ }
74
+ ],
75
+ "devDependencies": {
76
+ "@babel/core": "^7.13.15",
77
+ "@rollup/plugin-url": "^6.0.0",
78
+ "@size-limit/preset-small-lib": "^4.10.2",
79
+ "@skypack/package-check": "^0.2.2",
80
+ "@storybook/addon-a11y": "^6.3.9",
81
+ "@storybook/addon-essentials": "^6.3.9",
82
+ "@storybook/addon-links": "^6.3.9",
83
+ "@storybook/addon-postcss": "^2.0.0",
84
+ "@storybook/addon-storyshots": "^6.3.9",
85
+ "@storybook/addons": "^6.3.9",
86
+ "@storybook/react": "^6.3.9",
87
+ "@svgr/cli": "^5.5.0",
88
+ "@svgr/rollup": "^5.5.0",
89
+ "@svgr/webpack": "^5.5.0",
90
+ "@testing-library/jest-dom": "^5.12.0",
91
+ "@testing-library/react": "^11.2.6",
92
+ "@types/is-number": "^7.0.1",
93
+ "@types/react": "^17.0.3",
94
+ "@types/react-dom": "^17.0.3",
95
+ "@types/react-select": "^4.0.15",
96
+ "@types/react-transition-group": "^4.4.1",
97
+ "autoprefixer": "^9.8.6",
98
+ "babel-loader": "^8.2.2",
99
+ "bootstrap-italia": "^1.4.3",
100
+ "circular-dependency-plugin": "^5.2.2",
101
+ "eslint-plugin-mdx": "^1.13.0",
102
+ "eslint-plugin-prettier": "^3.4.0",
103
+ "husky": "^7.0.4",
104
+ "identity-obj-proxy": "^3.0.0",
105
+ "jest-transform-stub": "^2.0.0",
106
+ "postcss-flexbugs-fixes": "^4.2.1",
107
+ "react": "^17.0.2",
108
+ "react-dom": "^17.0.2",
109
+ "react-is": "^17.0.2",
110
+ "size-limit": "^4.10.2",
111
+ "ts-jest": "^25.3.1",
112
+ "tsdx": "^0.14.1",
113
+ "tslib": "^2.2.0",
114
+ "typeface-lora": "^1.1.13",
115
+ "typeface-roboto-mono": "^1.1.13",
116
+ "typescript": "^4.2.4"
117
+ },
118
+ "dependencies": {
119
+ "classnames": "^2.3.1",
120
+ "is-number": "^7.0.0",
121
+ "react-select": "^4.3.0",
122
+ "react-stickup": "^1.12.0",
123
+ "react-toastify": "^7.0.4",
124
+ "react-transition-group": "^4.4.1",
125
+ "react-use-navscroll": "0.2.0",
126
+ "reactstrap": "^8.9.0",
127
+ "webfontloader": "^1.6.28"
128
+ },
129
+ "browserslist": [
130
+ "defaults",
131
+ "ie 11",
132
+ "not ie_mob 11",
133
+ "not op_mini all",
134
+ "edge >= 13",
135
+ "safari 11"
136
+ ],
137
+ "jest": {
138
+ "transform": {
139
+ ".(ts|tsx)$": "ts-jest",
140
+ ".(js|jsx)$": "./jest-transformer.js",
141
+ "^.+\\.mdx$": "@storybook/addon-docs/jest-transform-mdx"
27
142
  },
28
- "devDependencies": {
29
- "@babel/core": "^7.6.4",
30
- "@babel/plugin-proposal-class-properties": "^7.5.5",
31
- "@babel/plugin-proposal-export-default-from": "^7.5.2",
32
- "@babel/plugin-proposal-export-namespace-from": "^7.5.2",
33
- "@babel/plugin-proposal-object-rest-spread": "^7.6.2",
34
- "@babel/preset-env": "^7.6.3",
35
- "@babel/preset-react": "^7.6.3",
36
- "@sambego/storybook-state": "^1.3.3",
37
- "@storybook/addon-a11y": "^5.3.21",
38
- "@storybook/addon-actions": "^5.3.21",
39
- "@storybook/addon-console": "^1.2.0",
40
- "@storybook/addon-info": "^5.3.21",
41
- "@storybook/addon-knobs": "^5.3.21",
42
- "@storybook/addon-links": "^5.3.21",
43
- "@storybook/addon-notes": "^5.3.21",
44
- "@storybook/addon-storyshots": "^5.3.21",
45
- "@storybook/addon-storysource": "^5.3.21",
46
- "@storybook/addon-viewport": "^5.3.19",
47
- "@storybook/addons": "^5.3.21",
48
- "@storybook/react": "^5.3.21",
49
- "@typescript-eslint/eslint-plugin": "^2.3.3",
50
- "@typescript-eslint/parser": "^2.3.3",
51
- "babel-eslint": "^10.0.3",
52
- "babel-loader": "^8.0.6",
53
- "bootstrap-italia": "1.4.1",
54
- "classnames": "^2.2.6",
55
- "eslint": "^6.8.0",
56
- "eslint-config-prettier": "^6.3.0",
57
- "eslint-config-standard": "^14.1.0",
58
- "eslint-plugin-babel": "^5.3.0",
59
- "eslint-plugin-import": "^2.18.2",
60
- "eslint-plugin-jsx-a11y": "^6.2.3",
61
- "eslint-plugin-node": "^10.0.0",
62
- "eslint-plugin-prettier": "^3.1.1",
63
- "eslint-plugin-promise": "^4.2.1",
64
- "eslint-plugin-react": "^7.15.1",
65
- "eslint-plugin-standard": "^4.0.1",
66
- "glob": "^7.1.4",
67
- "husky": "^3.0.9",
68
- "react-scripts": "^3.1.2",
69
- "react-test-renderer": "^16.10.1",
70
- "react-to-typescript-definitions": "^2.0.0",
71
- "rollup": "^1.26.0",
72
- "rollup-plugin-babel": "^4.3.3",
73
- "rollup-plugin-babel-minify": "^9.1.0",
74
- "rollup-plugin-commonjs": "^10.1.0",
75
- "rollup-plugin-node-resolve": "^5.2.0",
76
- "rollup-plugin-replace": "^2.2.0",
77
- "rollup-plugin-svg": "^2.0.0",
78
- "run-script-os": "^1.0.7",
79
- "typeface-lora": "^0.0.72",
80
- "typeface-roboto-mono": "^0.0.75",
81
- "typeface-titillium-web": "^0.0.72"
143
+ "moduleNameMapper": {
144
+ "^.+.(svg|png|jpg)$": "jest-transform-stub",
145
+ "^.+\\.css$": "identity-obj-proxy"
82
146
  },
83
- "peerDependencies": {
84
- "react": "^16.8.3",
85
- "react-dom": "^16.8.3"
86
- },
87
- "scripts": {
88
- "install-dependencies": "yarn install --peers",
89
- "prebuild": "yarn install-dependencies",
90
- "build": "rollup -c scripts/rollup.config.js",
91
- "prestorybook": "yarn install-dependencies",
92
- "storybook:build": "build-storybook -c .storybook -s ./static",
93
- "storybook:serve": "start-storybook -p 9001 -c .storybook -s ./static",
94
- "storybook:deploy": "npx gh-pages -d storybook-static -m 'Update GitHub Pages [ci skip]'",
95
- "lint": "eslint src/ stories/",
96
- "lint:fix": "eslint --fix src/",
97
- "test": "export SKIP_PREFLIGHT_CHECK=true && react-scripts test --env=jsdom",
98
- "test:ci": "CI=true react-scripts test --env=jsdom",
99
- "start": "yarn run storybook:serve",
100
- "typescript:dts": "node scripts/dts.js"
101
- },
102
- "husky": {
103
- "hooks": {
104
- "pre-push": "yarn run lint"
105
- }
106
- },
107
- "dependencies": {
108
- "prop-types": "^15.7.2",
109
- "react-scrollspy": "^3.3.5",
110
- "react-select": "^3.0.8",
111
- "react-stickup": "^1.11.0",
112
- "react-toastify": "^5.5.0",
113
- "react-transition-group": "^2.3.1",
114
- "reactstrap": "^8.0.0",
115
- "webfontloader": "^1.6.28"
116
- },
117
- "browserslist": [
118
- "defaults",
119
- "ie 11",
120
- "not ie_mob 11",
121
- "not op_mini all",
122
- "edge >= 13",
123
- "safari 11"
147
+ "moduleFileExtensions": [
148
+ "ts",
149
+ "tsx",
150
+ "js",
151
+ "jsx",
152
+ "json",
153
+ "node",
154
+ "mdx"
124
155
  ]
125
- }
156
+ }
157
+ }
@@ -0,0 +1,30 @@
1
+ import React, { ElementType, FC } from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ export interface AccordionProps {
5
+ /** Utilizzarlo in caso di utilizzo di componenti personalizzati */
6
+ tag?: ElementType;
7
+ /** Classi aggiuntive da usare per il componente Badge */
8
+ className?: string;
9
+ /** Utilizzare questo attributo per ottenere header con sfondo di colore primario quando questi è attivo o all’hover. */
10
+ background?: 'active' | 'hover';
11
+ /** Utilizzare questo attributo per mostrare, mediante un'icona a sinistra, lo stato di apertura */
12
+ iconLeft?: boolean;
13
+ }
14
+
15
+ export const Accordion: FC<AccordionProps> = ({
16
+ tag = 'div',
17
+ className,
18
+ background,
19
+ iconLeft = false,
20
+ ...attributes
21
+ }) => {
22
+ const Tag = tag;
23
+ const classes = classNames('collapse-div', className, {
24
+ 'collapse-background-active': background === 'active',
25
+ 'collapse-background-hover': background === 'hover',
26
+ 'collapse-left-icon': iconLeft
27
+ });
28
+
29
+ return <Tag {...attributes} className={classes} />;
30
+ };
@@ -0,0 +1,127 @@
1
+ import React, { Component, ElementType } from 'react';
2
+ import classNames from 'classnames';
3
+ import { Transition } from 'react-transition-group';
4
+
5
+ import { Util } from 'reactstrap';
6
+ import type { TransitionProps } from 'react-transition-group/Transition';
7
+
8
+ const {
9
+ // @ts-ignore
10
+ TransitionTimeouts,
11
+ // @ts-ignore
12
+ TransitionPropTypeKeys,
13
+ // @ts-ignore
14
+ TransitionStatuses,
15
+ // @ts-ignore
16
+ pick,
17
+ // @ts-ignore
18
+ omit
19
+ } = Util;
20
+
21
+ export type AccordionBodyProps = Partial<TransitionProps> & {
22
+ tag?: ElementType;
23
+ className?: string;
24
+ active?: boolean;
25
+ onToggle?: () => void;
26
+ };
27
+
28
+ const transitionStatusToClassHash = {
29
+ [TransitionStatuses.ENTERING]: 'collapsing',
30
+ [TransitionStatuses.ENTERED]: 'collapse show',
31
+ [TransitionStatuses.EXITING]: 'collapsing',
32
+ [TransitionStatuses.EXITED]: 'collapse'
33
+ };
34
+
35
+ type TransitionStates = keyof typeof transitionStatusToClassHash;
36
+
37
+ function getTransitionClass(status: TransitionStates) {
38
+ return transitionStatusToClassHash[status] || 'collapse';
39
+ }
40
+
41
+ function getHeight(node: HTMLElement) {
42
+ return node.scrollHeight;
43
+ }
44
+
45
+ export class AccordionBody extends Component<
46
+ AccordionBodyProps,
47
+ { height: null | number }
48
+ > {
49
+ state = {
50
+ height: null
51
+ };
52
+
53
+ onEntering = (node: HTMLElement, isAppearing: boolean) => {
54
+ this.setState({ height: getHeight(node) });
55
+ this.props.onEntering?.(node, isAppearing);
56
+ };
57
+
58
+ onEntered = (node: HTMLElement, isAppearing: boolean) => {
59
+ this.setState({ height: null });
60
+ this.props.onEntered?.(node, isAppearing);
61
+ };
62
+
63
+ onExit = (node: HTMLElement) => {
64
+ this.setState({ height: getHeight(node) });
65
+ this.props.onExit?.(node);
66
+ };
67
+
68
+ onExiting = (node: HTMLElement) => {
69
+ // getting this variable triggers a reflow
70
+ // @ts-expect-error
71
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
+ const _unused = node.offsetHeight;
73
+ this.setState({ height: 0 });
74
+ this.props.onExiting?.(node);
75
+ };
76
+
77
+ onExited = (node: HTMLElement) => {
78
+ this.setState({ height: null });
79
+ this.props.onExited?.(node);
80
+ };
81
+
82
+ render() {
83
+ const {
84
+ className,
85
+ tag = 'div',
86
+ active = false,
87
+ children,
88
+ timeout = TransitionTimeouts.Collapse,
89
+ ...attributes
90
+ } = this.props;
91
+ const Tag = tag;
92
+ const { height } = this.state;
93
+
94
+ const transitionProps = pick(attributes, TransitionPropTypeKeys);
95
+ const childProps = omit(attributes, TransitionPropTypeKeys);
96
+
97
+ return (
98
+ <Transition
99
+ {...transitionProps}
100
+ timeout={timeout}
101
+ in={active}
102
+ onEntering={this.onEntering}
103
+ onEntered={this.onEntered}
104
+ onExit={this.onExit}
105
+ onExiting={this.onExiting}
106
+ onExited={this.onExited}
107
+ >
108
+ {(status: TransitionStates) => {
109
+ const transitionClass = getTransitionClass(status);
110
+ const classes = classNames(className, transitionClass);
111
+
112
+ const style = height == null ? null : { height };
113
+
114
+ return (
115
+ <Tag
116
+ className={classes}
117
+ style={{ ...childProps.style, ...style }}
118
+ {...childProps}
119
+ >
120
+ <div className='collapse-body'>{children}</div>
121
+ </Tag>
122
+ );
123
+ }}
124
+ </Transition>
125
+ );
126
+ }
127
+ }
@@ -0,0 +1,42 @@
1
+ import React, { FC, ReactNode, ElementType } from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ export interface AccordionHeaderProps {
5
+ /** Utilizzarlo in caso di utilizzo di componenti personalizzati */
6
+ tag?: ElementType;
7
+ /** Classi aggiuntive da usare per il componente AccordionHeader */
8
+ className?: string;
9
+ /** Utilizzare questo attributo per indicare se l'elemento è attivo o no */
10
+ active?: boolean;
11
+ /** Questa funzione verrà chiamata quando avviene un click sul componente AccordionHeader */
12
+ onToggle?: () => void;
13
+ /** Contenuto aggiuntivo all'interno del bottone dell'AccordionHeader */
14
+ append?: ReactNode;
15
+ }
16
+
17
+ export const AccordionHeader: FC<AccordionHeaderProps> = ({
18
+ className,
19
+ tag = 'button',
20
+ active = false,
21
+ append,
22
+ onToggle,
23
+ ...attributes
24
+ }) => {
25
+ const Tag = tag;
26
+ const toggleClasses = classNames(className, {
27
+ collapsed: active
28
+ });
29
+
30
+ return (
31
+ <div className='collapse-header'>
32
+ <Tag
33
+ data-toggle='collapse'
34
+ aria-expanded={active ? 'true' : 'false'}
35
+ className={toggleClasses}
36
+ onClick={onToggle}
37
+ {...attributes}
38
+ />
39
+ {append}
40
+ </div>
41
+ );
42
+ };