@evolve.ui/core-components 1.0.1 → 1.1.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 (509) hide show
  1. package/evolve-ui.entries.json +556 -0
  2. package/fileUpload/testUtils/mockFilesAndImages.d.cts +3 -3
  3. package/fileUpload/testUtils/mockFilesAndImages.d.cts.map +1 -1
  4. package/fileUpload/testUtils/mockFilesAndImages.d.mts +3 -3
  5. package/fileUpload/testUtils/mockFilesAndImages.d.mts.map +1 -1
  6. package/fileUpload/testUtils/testUtils.d.cts +1 -1
  7. package/fileUpload/testUtils/testUtils.d.cts.map +1 -1
  8. package/fileUpload/testUtils/testUtils.d.mts +1 -1
  9. package/fileUpload/testUtils/testUtils.d.mts.map +1 -1
  10. package/package.json +2 -2
  11. package/src/Accordion/Accordion.tsx +233 -0
  12. package/src/AddressDisplay/AddressDisplay.tsx +43 -0
  13. package/src/AddressDisplay/components/addressComponents.tsx +111 -0
  14. package/src/AddressDisplay/components/addressField.tsx +25 -0
  15. package/src/AddressDisplay/components/addressSection.tsx +8 -0
  16. package/src/AddressDisplay/components/getCountryValue.tsx +31 -0
  17. package/src/AddressDisplay/types.ts +26 -0
  18. package/src/AutomatedCarousel/AutomatedCarousel.tsx +163 -0
  19. package/src/AutomatedCarousel/automatedCarousel.types.ts +7 -0
  20. package/src/AutomatedCarousel/components/CarouselProgressBar/CarouselProgressBar.tsx +139 -0
  21. package/src/AutomatedCarousel/components/CarouselProgressBar/components/CarouselProgressBarUnit/CarouselProgressBarUnit.tsx +165 -0
  22. package/src/Badge/Badge.tsx +104 -0
  23. package/src/Badge/Badge.types.ts +58 -0
  24. package/src/Badge/ItemBadge.tsx +97 -0
  25. package/src/Badge/LiveStatusBadge.tsx +93 -0
  26. package/src/BannerNotification/BannerNotification.tsx +157 -0
  27. package/src/BannerNotification/components/BannerNotificationSkeleton.tsx +39 -0
  28. package/src/BannerNotification/components/CalloutIcon/BannerIcon.tsx +48 -0
  29. package/src/BannerNotification/utils/getRandomTooltipId.ts +3 -0
  30. package/src/BottomSheet/BottomSheet.tsx +476 -0
  31. package/src/BottomSheet/components/BottomSheetBackdrop/BottomSheetBackdrop.tsx +47 -0
  32. package/src/BottomSheet/components/BottomSheetContentArea/BottomSheetContentArea.tsx +92 -0
  33. package/src/BottomSheet/components/BottomSheetOverlay/BottomSheetOverlayTranslate3d.tsx +196 -0
  34. package/src/BottomSheet/components/SheetDescription/SheetDescription.tsx +22 -0
  35. package/src/BottomSheet/components/SheetTitle/SheetTitle.tsx +21 -0
  36. package/src/BottomSheet/components/index.tsx +5 -0
  37. package/src/BottomSheet/hooks/index.tsx +13 -0
  38. package/src/BottomSheet/hooks/useAriaHider.tsx +91 -0
  39. package/src/BottomSheet/hooks/useBottomSheetServices.tsx +224 -0
  40. package/src/BottomSheet/hooks/useDragHandler.tsx +282 -0
  41. package/src/BottomSheet/hooks/useFocusTrap.tsx +113 -0
  42. package/src/BottomSheet/hooks/useLayoutEffect.tsx +4 -0
  43. package/src/BottomSheet/hooks/useOptimizedResizeObserver.tsx +94 -0
  44. package/src/BottomSheet/hooks/useOptimizedScrollState.tsx +87 -0
  45. package/src/BottomSheet/hooks/useReady.tsx +34 -0
  46. package/src/BottomSheet/hooks/useReducedMotion.tsx +22 -0
  47. package/src/BottomSheet/hooks/useScrollLock.tsx +143 -0
  48. package/src/BottomSheet/hooks/useSnapPoints.tsx +355 -0
  49. package/src/BottomSheet/hooks/useSpring.tsx +47 -0
  50. package/src/BottomSheet/hooks/useSpringInterpolationsTranslate3d.tsx +101 -0
  51. package/src/BottomSheet/index.tsx +237 -0
  52. package/src/BottomSheet/state/atoms.ts +147 -0
  53. package/src/BottomSheet/state/useBottomSheetStateMachine.ts +246 -0
  54. package/src/BottomSheet/types.ts +172 -0
  55. package/src/BottomSheet/utils.ts +65 -0
  56. package/src/Breadcrumbs/Breadcrumbs.tsx +126 -0
  57. package/src/Button/Button.tsx +164 -0
  58. package/src/Button/Button.types.ts +80 -0
  59. package/src/Button/buttonColorClasses.ts +53 -0
  60. package/src/Callout/Callout.tsx +136 -0
  61. package/src/Callout/Callout.types.ts +29 -0
  62. package/src/Callout/components/CalloutIcon/CalloutIcon.tsx +56 -0
  63. package/src/Card/CardGrid.tsx +263 -0
  64. package/src/Card/SingleCard.tsx +22 -0
  65. package/src/Card/cardFactory.tsx +176 -0
  66. package/src/Card/components/createBadge.tsx +34 -0
  67. package/src/Card/components/createFavoriteButton.tsx +40 -0
  68. package/src/Card/components/createImage.tsx +64 -0
  69. package/src/Card/components/createInfo.tsx +84 -0
  70. package/src/Card/components/createName.tsx +63 -0
  71. package/src/Card/components/createPriceStatus.tsx +100 -0
  72. package/src/Card/components/types.ts +4 -0
  73. package/src/Card/hooks/useCardVisibilityTracking.ts +82 -0
  74. package/src/Card/sharedProps.ts +12 -0
  75. package/src/Card/types.ts +62 -0
  76. package/src/Carousel/Carousel.tsx +513 -0
  77. package/src/Carousel/Carousel.types.ts +43 -0
  78. package/src/Carousel/Carousel.utils.ts +63 -0
  79. package/src/Carousel/components/DotButton/DotButton.tsx +42 -0
  80. package/src/Carousel/components/NavigationButtons/NavigationButtons.tsx +77 -0
  81. package/src/Carousel/components/TitleSection/TitleSection.tsx +61 -0
  82. package/src/Carousel/components/TitleSection/components/SubHeaderLeft/SubHeaderLeft.tsx +53 -0
  83. package/src/Carousel/components/TitleSection/components/Title/Title.tsx +46 -0
  84. package/src/Carousel/index.ts +2 -0
  85. package/src/Carousel/testUtils.ts +10 -0
  86. package/src/Chips/Chip.tsx +153 -0
  87. package/src/Chips/ChipGroup.tsx +173 -0
  88. package/src/Chips/SuggestionChip.tsx +15 -0
  89. package/src/Chips/chipTypes.ts +113 -0
  90. package/src/Chips/index.ts +4 -0
  91. package/src/ChoiceListItem/Checkbox.tsx +69 -0
  92. package/src/ChoiceListItem/Radio.tsx +61 -0
  93. package/src/ChoiceListItem/choiceListItem.tsx +99 -0
  94. package/src/ChoiceListItem/common.tsx +148 -0
  95. package/src/ChoiceListItem/index.ts +3 -0
  96. package/src/Collapsible/Collapsible.tsx +58 -0
  97. package/src/Confetti/Confetti.tsx +270 -0
  98. package/src/Confetti/index.ts +2 -0
  99. package/src/ContentPager/ContentPager.tsx +189 -0
  100. package/src/ContentPager/components/Page.tsx +24 -0
  101. package/src/CookieConsent/components/CookieCategoryRow/CookieCategoryRow.tsx +30 -0
  102. package/src/CookieConsent/components/CookieConsent/CookieConsent.tsx +74 -0
  103. package/src/CookieConsent/components/CookieConsentBanner/CookieConsentBanner.tsx +51 -0
  104. package/src/CookieConsent/components/CookieConsentModal/CookieConsentModal.tsx +64 -0
  105. package/src/CookieConsent/hooks/useCookieConsent.ts +170 -0
  106. package/src/CookieConsent/hooks/useCookieConsentState.ts +142 -0
  107. package/src/CookieConsent/index.ts +16 -0
  108. package/src/CookieConsent/types/cookieConsent.types.ts +79 -0
  109. package/src/CookieConsent/types/index.ts +7 -0
  110. package/src/Countdown/Countdown.tsx +161 -0
  111. package/src/Countdown/Countdown.types.ts +4 -0
  112. package/src/Countdown/hooks/useGetCountdown.ts +103 -0
  113. package/src/DateTimeInput/dateInput/DateInput.tsx +199 -0
  114. package/src/DateTimeInput/datePicker/DatePicker.tsx +138 -0
  115. package/src/DateTimeInput/datePicker/components/calendar/Calendar.tsx +72 -0
  116. package/src/DateTimeInput/datePicker/index.ts +2 -0
  117. package/src/DateTimeInput/timeInput/TimeInput.tsx +128 -0
  118. package/src/DateTimeInput/timePicker/TimePicker.tsx +118 -0
  119. package/src/DateTimeInput/timePicker/components/TimePopover/AmPmSwitch.tsx +103 -0
  120. package/src/DateTimeInput/timePicker/components/TimePopover/TimeFieldInput.tsx +26 -0
  121. package/src/DateTimeInput/timePicker/components/TimePopover/TimePopover.tsx +84 -0
  122. package/src/DateTimeInput/timePicker/components/TimePopover/TimePopover.utils.ts +67 -0
  123. package/src/DateTimeInput/timePicker/components/TimePopover/TimePopoverActions.tsx +26 -0
  124. package/src/DateTimeInput/timePicker/index.ts +2 -0
  125. package/src/DateTimeInput/utils/getDisplayDate.ts +15 -0
  126. package/src/DateTimeInput/utils/getDisplayTime.ts +15 -0
  127. package/src/DateTimeInput/utils/index.ts +2 -0
  128. package/src/DateTimeInput/utils/parseTimeValue.ts +54 -0
  129. package/src/Drawer/Drawer.tsx +446 -0
  130. package/src/Drawer/atoms.ts +4 -0
  131. package/src/Drawer/components/DialogActions/DialogActions.tsx +33 -0
  132. package/src/Drawer/components/DialogContent/DialogContent.tsx +80 -0
  133. package/src/Drawer/components/DialogHeader/DialogHeader.tsx +68 -0
  134. package/src/EducationalPopover/EducationalPopover.tsx +174 -0
  135. package/src/FavoriteButton/FavoriteButton.tsx +64 -0
  136. package/src/FavoriteButton/components/IconOnlyFavoriteButton/IconOnlyFavoriteButton.tsx +80 -0
  137. package/src/FavoriteButton/components/LabeledAnimatedFavoriteButton/LabeledAnimatedFavoriteButton.tsx +179 -0
  138. package/src/FavoriteButton/components/LabeledFavoriteButton/LabeledFavoriteButton.tsx +71 -0
  139. package/src/FavoriteButton/components/SmallHeartStraightIcon/SmallHeartStraightIcon.tsx +14 -0
  140. package/src/FavoriteButton/hooks/useFavoriteButtonState.ts +30 -0
  141. package/src/FavoriteButton/index.ts +2 -0
  142. package/src/FavoriteButton/types/favoriteButton.ts +87 -0
  143. package/src/FeatureFlags/devTools/FeatureFlagDevToolsUI.tsx +226 -0
  144. package/src/FeatureFlags/devTools/getFeatureFlagCookieOverrides.ts +30 -0
  145. package/src/FeatureFlags/devTools/utils/cookies.ts +169 -0
  146. package/src/FeatureFlags/hooks/index.ts +2 -0
  147. package/src/FeatureFlags/hooks/useFeatureFlag.tsx +19 -0
  148. package/src/FeatureFlags/hooks/useFeatureFlags.tsx +15 -0
  149. package/src/FileUpload/components/FileCard/FileCard.tsx +50 -0
  150. package/src/FileUpload/components/FileDropzone/FileDropzone.tsx +221 -0
  151. package/src/FileUpload/components/FileDropzone/components/DropzoneContent/DropzoneContent.tsx +28 -0
  152. package/src/FileUpload/components/FileDropzone/components/DropzoneContent/DropzoneText.tsx +81 -0
  153. package/src/FileUpload/components/FileDropzone/components/FileDropzoneDebugger/FileDropzoneDebugger.tsx +40 -0
  154. package/src/FileUpload/components/FileDropzone/components/FileDropzoneDebugger/FileRejectionsDisplay.tsx +110 -0
  155. package/src/FileUpload/components/FileDropzoneOverlay/FileDropzoneOverlay.tsx +183 -0
  156. package/src/FileUpload/components/FileDropzoneOverlay/components/OverlayDropzoneContent.tsx +146 -0
  157. package/src/FileUpload/components/FileDropzoneOverlay/components/OverlayDropzoneDragText.tsx +42 -0
  158. package/src/FileUpload/components/FileDropzoneOverlay/styles.ts +79 -0
  159. package/src/FileUpload/components/FilePreviewList/FilePreviewList.tsx +251 -0
  160. package/src/FileUpload/components/FilePreviewList/virtualizerComponents/FilePreviewVirtualizedList/FilePreviewVirtualizedList.tsx +88 -0
  161. package/src/FileUpload/components/FileUpload/FileUpload.tsx +63 -0
  162. package/src/FileUpload/components/FileUploadCanvas/FileUploadCanvas.tsx +125 -0
  163. package/src/FileUpload/components/GridFileCard/GridFileCard.tsx +364 -0
  164. package/src/FileUpload/components/GridFileCard/utils/sortable.ts +48 -0
  165. package/src/FileUpload/components/ListFileCard/ListFileCard.tsx +259 -0
  166. package/src/FileUpload/components/types.ts +78 -0
  167. package/src/FileUpload/hooks/filePreview/useImageFilePreviewUrl.ts +62 -0
  168. package/src/FileUpload/hooks/index.ts +11 -0
  169. package/src/FileUpload/hooks/upload/useHandleDragEnter/useHandleDragEnter.ts +154 -0
  170. package/src/FileUpload/hooks/upload/useHandleDrop/createFileRejectionHelpers.ts +273 -0
  171. package/src/FileUpload/hooks/upload/useHandleDrop/useHandleDrop.ts +153 -0
  172. package/src/FileUpload/hooks/upload/useUploadAvailability/useUploadAvailability.ts +44 -0
  173. package/src/FileUpload/hooks/validation/createDropzoneValidator.ts +41 -0
  174. package/src/FileUpload/hooks/validation/useFileValidation.ts +25 -0
  175. package/src/FileUpload/hooks/validation/useFileValidationLogic.ts +107 -0
  176. package/src/FileUpload/hooks/validation/useValidationMessages.ts +92 -0
  177. package/src/FileUpload/hooks/validation/useValidationState.ts +171 -0
  178. package/src/FileUpload/index.ts +57 -0
  179. package/src/FileUpload/providers/FileUploadProvider.tsx +219 -0
  180. package/src/FileUpload/providers/UploadValidationProvider.tsx +159 -0
  181. package/src/FileUpload/testUtils/mockFilesAndImages.ts +64 -0
  182. package/src/FileUpload/testUtils/testUtils.ts +111 -0
  183. package/src/FileUpload/types/commonTypes.ts +267 -0
  184. package/src/FileUpload/types/index.ts +31 -0
  185. package/src/FileUpload/types/sharedTypes.ts +159 -0
  186. package/src/FileUpload/utils/constants.ts +79 -0
  187. package/src/FileUpload/utils/createMessageContext.ts +180 -0
  188. package/src/FileUpload/utils/getFileExtensionsFromAcceptedTypes.ts +73 -0
  189. package/src/FileUpload/utils/getFilePluralizationText.ts +68 -0
  190. package/src/FileUpload/utils/getMimeTypes.ts +26 -0
  191. package/src/FileUpload/utils/messageUtils.ts +41 -0
  192. package/src/FileUpload/utils/styles.ts +68 -0
  193. package/src/FormLabel/FormLabel.tsx +212 -0
  194. package/src/IconButton/IconButton.tsx +154 -0
  195. package/src/Icons/CreditCardIcon/CreditCardIcon.tsx +73 -0
  196. package/src/Icons/CreditCardIcon/cardIcons.tsx +270 -0
  197. package/src/Icons/IconBase.tsx +133 -0
  198. package/src/Icons/anyIcon.ts +3 -0
  199. package/src/Icons/generatedIcons/Archive.tsx +48 -0
  200. package/src/Icons/generatedIcons/ArrowClockwise.tsx +48 -0
  201. package/src/Icons/generatedIcons/ArrowDown.tsx +48 -0
  202. package/src/Icons/generatedIcons/ArrowLeft.tsx +48 -0
  203. package/src/Icons/generatedIcons/ArrowRight.tsx +48 -0
  204. package/src/Icons/generatedIcons/ArrowSquareOut.tsx +51 -0
  205. package/src/Icons/generatedIcons/ArrowSquareRight.tsx +51 -0
  206. package/src/Icons/generatedIcons/ArrowUp.tsx +48 -0
  207. package/src/Icons/generatedIcons/ArrowsCounterClockwise.tsx +48 -0
  208. package/src/Icons/generatedIcons/ArrowsLeftRight.tsx +48 -0
  209. package/src/Icons/generatedIcons/ArrowsOutCardinal.tsx +48 -0
  210. package/src/Icons/generatedIcons/Bank.tsx +48 -0
  211. package/src/Icons/generatedIcons/Bell.tsx +51 -0
  212. package/src/Icons/generatedIcons/BookBookmark.tsx +51 -0
  213. package/src/Icons/generatedIcons/BookmarksSimple.tsx +51 -0
  214. package/src/Icons/generatedIcons/Broadcast.tsx +48 -0
  215. package/src/Icons/generatedIcons/CalendarBlank.tsx +48 -0
  216. package/src/Icons/generatedIcons/CalendarStar.tsx +51 -0
  217. package/src/Icons/generatedIcons/Camera.tsx +51 -0
  218. package/src/Icons/generatedIcons/CaretDown.tsx +48 -0
  219. package/src/Icons/generatedIcons/CaretLeft.tsx +48 -0
  220. package/src/Icons/generatedIcons/CaretRight.tsx +48 -0
  221. package/src/Icons/generatedIcons/CaretUp.tsx +48 -0
  222. package/src/Icons/generatedIcons/Certificate.tsx +51 -0
  223. package/src/Icons/generatedIcons/ChartBar.tsx +48 -0
  224. package/src/Icons/generatedIcons/Check.tsx +51 -0
  225. package/src/Icons/generatedIcons/CheckCircle.tsx +48 -0
  226. package/src/Icons/generatedIcons/CirclesFour.tsx +51 -0
  227. package/src/Icons/generatedIcons/Clock.tsx +48 -0
  228. package/src/Icons/generatedIcons/ClockCountdown.tsx +48 -0
  229. package/src/Icons/generatedIcons/Close.tsx +51 -0
  230. package/src/Icons/generatedIcons/CloudArrowUp.tsx +51 -0
  231. package/src/Icons/generatedIcons/CloudWarning.tsx +51 -0
  232. package/src/Icons/generatedIcons/Code.tsx +48 -0
  233. package/src/Icons/generatedIcons/Compass.tsx +51 -0
  234. package/src/Icons/generatedIcons/Confetti.tsx +51 -0
  235. package/src/Icons/generatedIcons/Copy.tsx +48 -0
  236. package/src/Icons/generatedIcons/CornersOut.tsx +48 -0
  237. package/src/Icons/generatedIcons/CreditCard.tsx +48 -0
  238. package/src/Icons/generatedIcons/Crown.tsx +51 -0
  239. package/src/Icons/generatedIcons/CrownSimple.tsx +51 -0
  240. package/src/Icons/generatedIcons/CurrencyCircleDollar.tsx +48 -0
  241. package/src/Icons/generatedIcons/CurrencyDollarSimple.tsx +51 -0
  242. package/src/Icons/generatedIcons/Desktop.tsx +51 -0
  243. package/src/Icons/generatedIcons/Detective.tsx +51 -0
  244. package/src/Icons/generatedIcons/DotOutline.tsx +46 -0
  245. package/src/Icons/generatedIcons/DotsSixVertical.tsx +51 -0
  246. package/src/Icons/generatedIcons/DotsThreeOutline.tsx +51 -0
  247. package/src/Icons/generatedIcons/DotsThreeOutlineVertical.tsx +51 -0
  248. package/src/Icons/generatedIcons/DownloadSimple.tsx +51 -0
  249. package/src/Icons/generatedIcons/EnvelopeSimple.tsx +48 -0
  250. package/src/Icons/generatedIcons/Eraser.tsx +51 -0
  251. package/src/Icons/generatedIcons/Eye.tsx +51 -0
  252. package/src/Icons/generatedIcons/EyeSlash.tsx +51 -0
  253. package/src/Icons/generatedIcons/FacebookLogo.tsx +48 -0
  254. package/src/Icons/generatedIcons/FileArchive.tsx +48 -0
  255. package/src/Icons/generatedIcons/FileArrowDown.tsx +48 -0
  256. package/src/Icons/generatedIcons/FileCsv.tsx +48 -0
  257. package/src/Icons/generatedIcons/FilePdf.tsx +48 -0
  258. package/src/Icons/generatedIcons/FileText.tsx +48 -0
  259. package/src/Icons/generatedIcons/Files.tsx +51 -0
  260. package/src/Icons/generatedIcons/Fire.tsx +51 -0
  261. package/src/Icons/generatedIcons/Flag.tsx +51 -0
  262. package/src/Icons/generatedIcons/FlagBannerFold.tsx +48 -0
  263. package/src/Icons/generatedIcons/FloppyDisk.tsx +51 -0
  264. package/src/Icons/generatedIcons/Gauge.tsx +51 -0
  265. package/src/Icons/generatedIcons/Gavel.tsx +51 -0
  266. package/src/Icons/generatedIcons/Gear.tsx +51 -0
  267. package/src/Icons/generatedIcons/GlobeHemisphereWest.tsx +51 -0
  268. package/src/Icons/generatedIcons/GoogleLogo.tsx +48 -0
  269. package/src/Icons/generatedIcons/GridNine.tsx +51 -0
  270. package/src/Icons/generatedIcons/HandCoins.tsx +51 -0
  271. package/src/Icons/generatedIcons/HandbagSimple.tsx +51 -0
  272. package/src/Icons/generatedIcons/Headset.tsx +51 -0
  273. package/src/Icons/generatedIcons/HeartStraight.tsx +51 -0
  274. package/src/Icons/generatedIcons/HourglassLow.tsx +48 -0
  275. package/src/Icons/generatedIcons/House.tsx +51 -0
  276. package/src/Icons/generatedIcons/Image.tsx +51 -0
  277. package/src/Icons/generatedIcons/ImageSquare.tsx +51 -0
  278. package/src/Icons/generatedIcons/ImagesSquare.tsx +51 -0
  279. package/src/Icons/generatedIcons/Info.tsx +48 -0
  280. package/src/Icons/generatedIcons/InstagramLogo.tsx +51 -0
  281. package/src/Icons/generatedIcons/Lightning.tsx +48 -0
  282. package/src/Icons/generatedIcons/Link.tsx +51 -0
  283. package/src/Icons/generatedIcons/LinkedinLogo.tsx +51 -0
  284. package/src/Icons/generatedIcons/List.tsx +48 -0
  285. package/src/Icons/generatedIcons/Lock.tsx +51 -0
  286. package/src/Icons/generatedIcons/LockOpen.tsx +51 -0
  287. package/src/Icons/generatedIcons/MagnifyingGlass.tsx +48 -0
  288. package/src/Icons/generatedIcons/MapPin.tsx +51 -0
  289. package/src/Icons/generatedIcons/MapPinSimpleArea.tsx +48 -0
  290. package/src/Icons/generatedIcons/Medal.tsx +48 -0
  291. package/src/Icons/generatedIcons/Megaphone.tsx +48 -0
  292. package/src/Icons/generatedIcons/Minus.tsx +45 -0
  293. package/src/Icons/generatedIcons/Money.tsx +51 -0
  294. package/src/Icons/generatedIcons/Notches.tsx +48 -0
  295. package/src/Icons/generatedIcons/NotePencil.tsx +48 -0
  296. package/src/Icons/generatedIcons/Package.tsx +51 -0
  297. package/src/Icons/generatedIcons/PaintBrush.tsx +51 -0
  298. package/src/Icons/generatedIcons/PaperPlaneTilt.tsx +51 -0
  299. package/src/Icons/generatedIcons/Paperclip.tsx +51 -0
  300. package/src/Icons/generatedIcons/Pause.tsx +51 -0
  301. package/src/Icons/generatedIcons/PencilLine.tsx +51 -0
  302. package/src/Icons/generatedIcons/PencilRuler.tsx +51 -0
  303. package/src/Icons/generatedIcons/PencilSimple.tsx +51 -0
  304. package/src/Icons/generatedIcons/Phone.tsx +51 -0
  305. package/src/Icons/generatedIcons/PinterestLogo.tsx +51 -0
  306. package/src/Icons/generatedIcons/Play.tsx +51 -0
  307. package/src/Icons/generatedIcons/Plus.tsx +51 -0
  308. package/src/Icons/generatedIcons/PlusCircle.tsx +48 -0
  309. package/src/Icons/generatedIcons/Printer.tsx +51 -0
  310. package/src/Icons/generatedIcons/Question.tsx +48 -0
  311. package/src/Icons/generatedIcons/Receipt.tsx +51 -0
  312. package/src/Icons/generatedIcons/Rows.tsx +51 -0
  313. package/src/Icons/generatedIcons/SealCheck.tsx +51 -0
  314. package/src/Icons/generatedIcons/SelectionSlash.tsx +48 -0
  315. package/src/Icons/generatedIcons/ShareNetwork.tsx +51 -0
  316. package/src/Icons/generatedIcons/ShieldCheck.tsx +51 -0
  317. package/src/Icons/generatedIcons/ShieldStar.tsx +51 -0
  318. package/src/Icons/generatedIcons/ShoppingCart.tsx +48 -0
  319. package/src/Icons/generatedIcons/ShuffleAngular.tsx +48 -0
  320. package/src/Icons/generatedIcons/SidebarSimple.tsx +48 -0
  321. package/src/Icons/generatedIcons/SlidersHorizontal.tsx +51 -0
  322. package/src/Icons/generatedIcons/Smiley.tsx +48 -0
  323. package/src/Icons/generatedIcons/Sparkle.tsx +51 -0
  324. package/src/Icons/generatedIcons/SpinnerGap.tsx +48 -0
  325. package/src/Icons/generatedIcons/StackPlus.tsx +48 -0
  326. package/src/Icons/generatedIcons/Star.tsx +51 -0
  327. package/src/Icons/generatedIcons/Storefront.tsx +51 -0
  328. package/src/Icons/generatedIcons/Swap.tsx +51 -0
  329. package/src/Icons/generatedIcons/Tag.tsx +51 -0
  330. package/src/Icons/generatedIcons/ThumbsDown.tsx +48 -0
  331. package/src/Icons/generatedIcons/ThumbsUp.tsx +48 -0
  332. package/src/Icons/generatedIcons/Toolbox.tsx +48 -0
  333. package/src/Icons/generatedIcons/Trash.tsx +48 -0
  334. package/src/Icons/generatedIcons/TrendUp.tsx +48 -0
  335. package/src/Icons/generatedIcons/Trophy.tsx +51 -0
  336. package/src/Icons/generatedIcons/Truck.tsx +51 -0
  337. package/src/Icons/generatedIcons/UploadSimple.tsx +51 -0
  338. package/src/Icons/generatedIcons/User.tsx +48 -0
  339. package/src/Icons/generatedIcons/Users.tsx +48 -0
  340. package/src/Icons/generatedIcons/UsersThree.tsx +51 -0
  341. package/src/Icons/generatedIcons/VideoCamera.tsx +51 -0
  342. package/src/Icons/generatedIcons/Warning.tsx +51 -0
  343. package/src/Icons/generatedIcons/WarningCircle.tsx +48 -0
  344. package/src/Icons/generatedIcons/WifiHigh.tsx +51 -0
  345. package/src/Icons/generatedIcons/XCircle.tsx +48 -0
  346. package/src/Icons/generatedIcons/XLogo.tsx +48 -0
  347. package/src/Icons/generatedIcons/YoutubeLogo.tsx +51 -0
  348. package/src/Icons/importedIcons.ts +152 -0
  349. package/src/Icons/index.ts +149 -0
  350. package/src/Icons/socialIcons/appleSocialIcon.tsx +50 -0
  351. package/src/Icons/socialIcons/facebookSocialIcon.tsx +41 -0
  352. package/src/Icons/socialIcons/googleSocialIcon.tsx +134 -0
  353. package/src/ImageCluster/ImageCluster.tsx +125 -0
  354. package/src/ImageSlider/ImageSlider.tsx +582 -0
  355. package/src/ImageSlider/ImageSlider.types.ts +90 -0
  356. package/src/ImageSlider/components/IndexIndicator/IndexIndicator.tsx +21 -0
  357. package/src/ImageSlider/components/NavigationButtons/NavigationButtons.tsx +113 -0
  358. package/src/ImageSlider/components/ResponsiveImage/ResponsiveImage.tsx +114 -0
  359. package/src/ImageSlider/components/ResponsiveImage/index.ts +1 -0
  360. package/src/ImageSlider/components/Thumbnails/Thumbnails.tsx +184 -0
  361. package/src/ImageSlider/constants.ts +59 -0
  362. package/src/ImageSlider/hooks/index.ts +3 -0
  363. package/src/ImageSlider/hooks/useImageSlider.ts +57 -0
  364. package/src/ImageSlider/hooks/useImageSliderNavigation.ts +133 -0
  365. package/src/ImageSlider/hooks/useImageSliderScrollHandler.ts +171 -0
  366. package/src/ImageSlider/index.ts +3 -0
  367. package/src/ImageSlider/utils/imageOptimization.ts +97 -0
  368. package/src/ImageSlider/utils/index.ts +1 -0
  369. package/src/InlineNotification/InlineNotification.tsx +95 -0
  370. package/src/JumpMenu/JumpMenu.tsx +395 -0
  371. package/src/JumpMenu/components/JumpMenuItem/JumpMenuItem.tsx +62 -0
  372. package/src/JumpMenu/hooks/useContainerTracking.ts +171 -0
  373. package/src/JumpMenu/hooks/useIntersectionObserver.ts +77 -0
  374. package/src/JumpMenu/hooks/useKeyboardNavigation.ts +102 -0
  375. package/src/JumpMenu/hooks/useResizeObserver.ts +53 -0
  376. package/src/JumpMenu/hooks/useSectionObserver.ts +102 -0
  377. package/src/JumpMenu/index.ts +2 -0
  378. package/src/JumpMenu/types/index.ts +19 -0
  379. package/src/Loading/Loading.tsx +39 -0
  380. package/src/Loading/components/LoadingDot/LoadingDot.tsx +16 -0
  381. package/src/LoadingSpinner/LoadingSpinner.tsx +20 -0
  382. package/src/Menu/Menu.tsx +372 -0
  383. package/src/Menu/components/MenuDivider/MenuDivider.tsx +5 -0
  384. package/src/Menu/components/MenuItem/MenuItem.tsx +298 -0
  385. package/src/Menu/context/menuContext.tsx +20 -0
  386. package/src/Menu/hooks/useMenu.tsx +18 -0
  387. package/src/Menu/index.ts +3 -0
  388. package/src/Modal/ComposableModal.tsx +313 -0
  389. package/src/Modal/Modal.tsx +231 -0
  390. package/src/Modal/components/BackButton/BackButton.tsx +43 -0
  391. package/src/Modal/components/Backdrop/Backdrop.tsx +62 -0
  392. package/src/Modal/components/CloseButton/CloseButton.tsx +55 -0
  393. package/src/Modal/components/ModalActions/ModalActions.tsx +135 -0
  394. package/src/Modal/components/ModalContent/ModalContent.tsx +163 -0
  395. package/src/Modal/components/ModalHeader/ModalHeader.tsx +84 -0
  396. package/src/Modal/components/ModalHeader/hooks/useHeaderAnimation.tsx +49 -0
  397. package/src/Modal/components/ModalProgressSteps/ModalProgressSteps.tsx +26 -0
  398. package/src/Modal/components/ModalSubTitle/ModalSubTitle.tsx +29 -0
  399. package/src/Modal/components/ModalTitle/ModalTitle.tsx +22 -0
  400. package/src/Modal/components/PreventModalScroll/PreventModalScroll.tsx +106 -0
  401. package/src/Modal/components/index.ts +12 -0
  402. package/src/Modal/context.ts +33 -0
  403. package/src/Modal/hooks/useCloseModal.ts +133 -0
  404. package/src/NotificationBadge/NotificationBadge.tsx +34 -0
  405. package/src/Pagination/AdvancedPagination.tsx +48 -0
  406. package/src/Pagination/Pagination.tsx +216 -0
  407. package/src/Pagination/components/AdvancedPaginator/AdvancedPaginator.tsx +52 -0
  408. package/src/Pagination/components/AdvancedPaginator/components/PageSelect/PageSelect.tsx +43 -0
  409. package/src/Pagination/components/ItemCountDisplay/ItemCountDisplay.tsx +32 -0
  410. package/src/Pagination/components/ItemCountSelect/ItemCountSelect.tsx +33 -0
  411. package/src/Pagination/index.tsx +3 -0
  412. package/src/Pagination/paginationProvider.tsx +234 -0
  413. package/src/Pagination/utils.tsx +36 -0
  414. package/src/PhoneInput/PhoneInput.tsx +509 -0
  415. package/src/PhoneInput/useDropdownLogic.tsx +163 -0
  416. package/src/ProgressCircle/ProgressCircle.tsx +246 -0
  417. package/src/ProgressCircle/hooks/useProgressStatusTransitions.ts +49 -0
  418. package/src/ProgressCircle/utils/progressCircle.constants.ts +27 -0
  419. package/src/ProgressSteps/ProgressSteps.tsx +160 -0
  420. package/src/SaveConfetti/SaveConfetti.tsx +277 -0
  421. package/src/SaveConfetti/index.ts +2 -0
  422. package/src/SearchInput/SearchInput.tsx +236 -0
  423. package/src/SegmentedControl/SegmentedControl.tsx +111 -0
  424. package/src/SegmentedControl/SegmentedControlGroup.tsx +94 -0
  425. package/src/SegmentedControl/index.ts +4 -0
  426. package/src/Select/Select.tsx +154 -0
  427. package/src/Select/SelectAsync.tsx +13 -0
  428. package/src/Select/SelectAsyncCreatable.tsx +14 -0
  429. package/src/Select/SelectCreatable.tsx +12 -0
  430. package/src/Select/reexportedComponents.tsx +5 -0
  431. package/src/Select/selectComponents.tsx +306 -0
  432. package/src/Skeleton/Skeleton.tsx +13 -0
  433. package/src/SplitButton/SplitButton.tsx +298 -0
  434. package/src/SplitButton/SplitButtonTrigger.tsx +55 -0
  435. package/src/StarRating/StarRating.tsx +165 -0
  436. package/src/StarRating/components/StarComponent/StarComponent.tsx +44 -0
  437. package/src/Table/Table.tsx +474 -0
  438. package/src/Table/components/TableHeader/TableHeader.tsx +166 -0
  439. package/src/Table/components/TablePagination/TablePagination.tsx +18 -0
  440. package/src/Table/components/TablePagination/components/ItemCountDisplay/ItemCountDisplay.tsx +17 -0
  441. package/src/Table/components/TablePagination/components/ItemCountSelect/ItemCountSelect.tsx +31 -0
  442. package/src/Table/components/TablePagination/components/TablePaginator/TablePaginator.tsx +37 -0
  443. package/src/Table/components/TablePagination/components/TablePaginator/components/PageSelect/PageSelect.tsx +32 -0
  444. package/src/Table/components/TableRow/TableRows.tsx +147 -0
  445. package/src/Table/components/TableRow/components/TableRowCell/TableRowCell.tsx +49 -0
  446. package/src/Table/components/TableShadow/TableShadow.tsx +46 -0
  447. package/src/Table/index.ts +2 -0
  448. package/src/Table/sharedState.ts +30 -0
  449. package/src/Table/sharedStyles.ts +1 -0
  450. package/src/Table/types.ts +55 -0
  451. package/src/Tabs/Tabs.tsx +358 -0
  452. package/src/TextArea/TextArea.tsx +157 -0
  453. package/src/TextInput/TextInput.tsx +173 -0
  454. package/src/Toast/Toast.tsx +64 -0
  455. package/src/Toast/components/ToastContainer/ToastContainer.tsx +48 -0
  456. package/src/Toast/index.ts +2 -0
  457. package/src/Toast/types/role.ts +1 -0
  458. package/src/Toast/utils/getIcon.tsx +41 -0
  459. package/src/ToggleSwitch/ToggleSwitch.tsx +188 -0
  460. package/src/Tooltip/InfoIconTooltip.tsx +47 -0
  461. package/src/Tooltip/Tooltip.tsx +41 -0
  462. package/src/Typography/InlineButton/InlineButton.tsx +166 -0
  463. package/src/Typography/Links/Links.tsx +113 -0
  464. package/src/Typography/Text/Text.tsx +239 -0
  465. package/src/ViewMore/ViewMore.tsx +226 -0
  466. package/src/WebRTCPlayer/WebRTCPlayer.tsx +325 -0
  467. package/src/WebRTCPlayer/adaptor/NativeWebRTCAdaptor.ts +588 -0
  468. package/src/WebRTCPlayer/hooks/useWebRTCStream.ts +571 -0
  469. package/src/WebRTCPlayer/index.ts +22 -0
  470. package/src/WebRTCPlayer/types.ts +95 -0
  471. package/src/breakpoints/index.tsx +1 -0
  472. package/src/breakpoints/utils.tsx +50 -0
  473. package/src/declarations.d.ts +7 -0
  474. package/src/grid/gridHighlighter.tsx +83 -0
  475. package/src/grid/index.ts +3 -0
  476. package/src/grid/pageGrid.tsx +37 -0
  477. package/src/grid/useSubGridCSS.tsx +214 -0
  478. package/src/hooks/useHorizontalScrollFade.ts +44 -0
  479. package/src/hooks/usePrevious.ts +14 -0
  480. package/src/index.ts +351 -0
  481. package/src/intl/index.ts +4 -0
  482. package/src/intl/utils.ts +67 -0
  483. package/src/mixins/horizontalScrollFadeMixin.ts +56 -0
  484. package/src/mixins/index.ts +18 -0
  485. package/src/mixins/propMixins.ts +389 -0
  486. package/src/providers/createContextProvider.ts +22 -0
  487. package/src/providers/designSystemProvider.tsx +218 -0
  488. package/src/providers/errorBoundaryProvider.tsx +179 -0
  489. package/src/providers/featureFlagProvider.tsx +18 -0
  490. package/src/providers/gridSizeProvider.tsx +23 -0
  491. package/src/providers/index.ts +12 -0
  492. package/src/providers/linkProvider.tsx +32 -0
  493. package/src/providers/normalize.tsx +93 -0
  494. package/src/providers/targets/DatePickerTarget.tsx +10 -0
  495. package/src/providers/targets/ModalTarget.tsx +14 -0
  496. package/src/providers/targets/TimePickerTarget.tsx +10 -0
  497. package/src/providers/themeContext.tsx +24 -0
  498. package/src/providers/windowSizeProvider.tsx +125 -0
  499. package/src/spacing/index.ts +1 -0
  500. package/src/spacing/spacing.ts +11 -0
  501. package/src/utils/countriesWithISOCodes.ts +1419 -0
  502. package/src/utils/dateTimeFormat.ts +257 -0
  503. package/src/utils/effectEventListener.ts +11 -0
  504. package/src/utils/formatFileSize.ts +18 -0
  505. package/src/utils/isClientSide.ts +1 -0
  506. package/src/utils/keepTransition.ts +15 -0
  507. package/src/utils/nodeEnv.ts +9 -0
  508. package/src/utils/smoothScrollTo.ts +47 -0
  509. package/src/utils/utilityTypes.ts +13 -0
@@ -0,0 +1,92 @@
1
+ import { useCallback } from 'react';
2
+
3
+ import { formatFileSize } from '../../../utils/formatFileSize';
4
+ import { CommonFileTypes, ValidationMessageParams } from '../../types/commonTypes';
5
+ import { DRAG_MESSAGES, DROP_MESSAGES } from '../../utils/constants';
6
+ import { createMessageContext } from '../../utils/createMessageContext';
7
+ import { resolveContextAwareMessage } from '../../utils/messageUtils';
8
+
9
+ const getMessageSet = (
10
+ messages: typeof DRAG_MESSAGES | typeof DROP_MESSAGES,
11
+ isSingleFileUpload: boolean,
12
+ strictValidation?: boolean
13
+ ) => {
14
+ // Determine which message set to use
15
+ if (isSingleFileUpload) {
16
+ return messages.singleFileUpload;
17
+ }
18
+
19
+ if (strictValidation) {
20
+ return messages.strictUpload;
21
+ }
22
+
23
+ return messages.partialUpload;
24
+ };
25
+
26
+ type UseValidationMessagesProps = {
27
+ /** Optional array of accepted file types */
28
+ accept?: CommonFileTypes | string[];
29
+ /** Maximum allowed file size in bytes (Unrestricted by default) */
30
+ maxFiles?: number;
31
+ /** Maximum number of files (1 for single file, undefined for unlimited) */
32
+ maxSize?: number;
33
+ /** Whether to use strict validation */
34
+ strictValidation?: boolean;
35
+ };
36
+
37
+ /**
38
+ * Hook that manages validation message generation for file uploads
39
+ * @param props Configuration object
40
+ * @param props.accept - Optional array of accepted file types or CommonFileTypes
41
+ * @param props.maxFiles - Optional maximum number of files allowed
42
+ * @param props.maxSize - Optional maximum file size in bytes
43
+ * @param props.strictValidation - Optional flag for strict validation mode
44
+ * @returns Object containing:
45
+ * - formattedMaxSize: Human-readable maximum file size (e.g., "5 MB")
46
+ * - getValidationMessage: Function to get validation messages based on error codes and context
47
+ * @remarks
48
+ * - Handles both drag and drop validation messages
49
+ * - Supports custom error messages
50
+ * - Formats file size limits in human-readable format
51
+ * - Handles pluralization for file count messages
52
+ */
53
+ export const useValidationMessages = ({ accept, maxFiles, maxSize, strictValidation }: UseValidationMessagesProps) => {
54
+ const formattedMaxSize = maxSize ? formatFileSize(maxSize) : undefined;
55
+ const isSingleFileUpload = maxFiles === 1;
56
+
57
+ const getValidationMessage = useCallback(
58
+ ({ code, count = 1, message: customMessage, messageType = 'drop' }: ValidationMessageParams): string => {
59
+ const messages = messageType === 'drag' ? DRAG_MESSAGES : DROP_MESSAGES;
60
+
61
+ // Create the appropriate context based on message type
62
+ const messageContext = createMessageContext({
63
+ accept,
64
+ code,
65
+ count,
66
+ formattedMaxSize,
67
+ maxFiles,
68
+ maxSize,
69
+ messageType,
70
+ });
71
+
72
+ // If we have a custom message, use it
73
+ if (customMessage) {
74
+ return resolveContextAwareMessage(customMessage, messageContext);
75
+ }
76
+
77
+ // Otherwise use built-in messages
78
+ const messageSet = getMessageSet(messages, isSingleFileUpload, strictValidation);
79
+ // @ts-expect-error - we know the code exists in messageSet
80
+ const message = messageSet[code];
81
+
82
+ // Use the message or fall back to default
83
+ return resolveContextAwareMessage(message, messageContext, messages.default);
84
+ },
85
+ [formattedMaxSize, isSingleFileUpload, maxFiles, accept, strictValidation, maxSize]
86
+ );
87
+
88
+ return {
89
+ formattedMaxSize,
90
+ getValidationMessage,
91
+ };
92
+ };
@@ -0,0 +1,171 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+
3
+ import { FileError, FileErrorCode, FileRejection } from '../../types';
4
+
5
+ /**
6
+ * Hook that manages validation state for file upload operations
7
+ * @param initialError - Optional initial validation error to display
8
+ * @param getValidationMessage - Function to get validation messages
9
+ * @returns Object containing:
10
+ * - dragValidationErrors: Validation errors during drag operations
11
+ * - dropValidationErrors: Validation errors during drop operations
12
+ * - fileRejections: Rejected files
13
+ * - setDragValidation: Update drag validation state
14
+ * - setDropValidation: Update drop validation state
15
+ * - clearDragValidation: Reset drag validation state
16
+ * - clearDropValidation: Reset drop validation state
17
+ * - clearAllValidation: Reset both validation states
18
+ * @remarks
19
+ * - Maintains separate validation states for drag and drop operations
20
+ * - Provides methods to update and clear validation states
21
+ * - Supports initial error state for immediate feedback
22
+ * - Uses memoized clear functions to prevent unnecessary rerenders
23
+ * - Handles message processing internally
24
+ */
25
+ export const useValidationState = (
26
+ initialError?: FileError,
27
+ getValidationMessage?: (params: { code: FileErrorCode; count?: number; messageType: 'drag' | 'drop' }) => string
28
+ ) => {
29
+ // Single error for drag (since we show one at a time during drag)
30
+ const [dragValidationError, setDragValidationErrorState] = useState<FileError | null>(null);
31
+
32
+ // Array of errors for drop (since multiple files can have different errors)
33
+ const [dropValidationErrors, setDropValidationErrorsState] = useState<FileError[]>(
34
+ initialError ? [initialError] : []
35
+ );
36
+
37
+ const [fileRejections, setFileRejections] = useState<FileRejection[]>([]);
38
+
39
+ const clearDragValidation = useCallback(() => {
40
+ setDragValidationErrorState(null);
41
+ }, []);
42
+
43
+ const clearDropValidation = useCallback(() => {
44
+ setDropValidationErrorsState([]);
45
+ }, []);
46
+
47
+ const clearAllValidation = useCallback(() => {
48
+ clearDragValidation();
49
+ clearDropValidation();
50
+ setFileRejections([]);
51
+ }, [clearDragValidation, clearDropValidation]);
52
+
53
+ // Enhanced setters that handle message processing
54
+ const setDragValidationError = useCallback(
55
+ (errorOrCode: FileError | FileErrorCode | null, count?: number) => {
56
+ if (errorOrCode === null) {
57
+ setDragValidationErrorState(null);
58
+ return;
59
+ }
60
+
61
+ // If we're given just a code, get the message from getValidationMessage
62
+ if (typeof errorOrCode === 'string') {
63
+ if (getValidationMessage) {
64
+ const message = getValidationMessage({
65
+ code: errorOrCode,
66
+ count,
67
+ messageType: 'drag',
68
+ });
69
+ setDragValidationErrorState({
70
+ code: errorOrCode,
71
+ message,
72
+ });
73
+ } else {
74
+ // Fallback if getValidationMessage is not provided
75
+ setDragValidationErrorState({
76
+ code: errorOrCode,
77
+ message: `Error: ${errorOrCode}`,
78
+ });
79
+ }
80
+ } else {
81
+ // If we're given a complete error object, use it directly
82
+ setDragValidationErrorState(errorOrCode);
83
+ }
84
+ },
85
+ [getValidationMessage]
86
+ );
87
+
88
+ const setDropValidationErrors = useCallback(
89
+ (errorsOrCodes: Array<FileError | FileErrorCode> | FileError | FileErrorCode, count?: number) => {
90
+ // Handle single error/code case
91
+ if (!Array.isArray(errorsOrCodes)) {
92
+ const errorOrCode = errorsOrCodes;
93
+
94
+ // If we're given just a code, get the message from getValidationMessage
95
+ if (typeof errorOrCode === 'string') {
96
+ if (getValidationMessage) {
97
+ const message = getValidationMessage({
98
+ code: errorOrCode,
99
+ count,
100
+ messageType: 'drop',
101
+ });
102
+ setDropValidationErrorsState([
103
+ {
104
+ code: errorOrCode,
105
+ message,
106
+ },
107
+ ]);
108
+ } else {
109
+ // Fallback if getValidationMessage is not provided
110
+ setDropValidationErrorsState([
111
+ {
112
+ code: errorOrCode,
113
+ message: `Error: ${errorOrCode}`,
114
+ },
115
+ ]);
116
+ }
117
+ } else {
118
+ // If we're given a complete error object, use it directly
119
+ setDropValidationErrorsState([errorOrCode]);
120
+ }
121
+ return;
122
+ }
123
+
124
+ // Handle array case
125
+ const processedErrors = errorsOrCodes.map((errorOrCode) => {
126
+ // If we're given just a code, get the message from getValidationMessage
127
+ if (typeof errorOrCode === 'string') {
128
+ if (getValidationMessage) {
129
+ const message = getValidationMessage({
130
+ code: errorOrCode,
131
+ count,
132
+ messageType: 'drop',
133
+ });
134
+ return {
135
+ code: errorOrCode,
136
+ message,
137
+ };
138
+ }
139
+ // Fallback if getValidationMessage is not provided
140
+ return {
141
+ code: errorOrCode,
142
+ message: `Error: ${errorOrCode}`,
143
+ };
144
+ }
145
+ // If we're given a complete error object, use it directly
146
+ return errorOrCode;
147
+ });
148
+
149
+ setDropValidationErrorsState(processedErrors);
150
+ },
151
+ [getValidationMessage]
152
+ );
153
+
154
+ // Effect to synchronize drop errors if the initialError prop changes post-mount.
155
+ // Uses the raw state setter and only depends on initialError to avoid performance issues.
156
+ useEffect(() => {
157
+ setDropValidationErrorsState(initialError ? [initialError] : []);
158
+ }, [initialError]);
159
+
160
+ return {
161
+ clearAllValidation,
162
+ clearDragValidation,
163
+ clearDropValidation,
164
+ dragValidationError,
165
+ dropValidationErrors,
166
+ fileRejections,
167
+ setDragValidationError,
168
+ setDropValidationErrors,
169
+ setFileRejections,
170
+ };
171
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @package @evolve.ui/core-components/fileUpload
3
+ * File upload system with drag-and-drop support, previews, and validation
4
+ *
5
+ * @module
6
+ * Components:
7
+ * - FileUpload: Complete file upload solution with dropzone and preview list
8
+ * - FileDropzone: Drag-and-drop upload zone with validation feedback
9
+ * - FilePreviewList: Grid or list display of uploaded files with previews
10
+ * - FileCard: Versatile file representation that adapts between grid and list design formats
11
+ * - ListFileCard: A visual representation of a file in a list card design
12
+ * - GridFileCard: A visual representation of a file in a grid card design
13
+ *
14
+ * Providers:
15
+ * - FileUploadProvider: Manages file state and upload callbacks, with context for shared validation
16
+ * - UploadValidationProvider: Handles shared validation logic
17
+ *
18
+ * Hooks:
19
+ * - useFileValidation: File validation (optional UploadValidationProvider integration)
20
+ *
21
+ */
22
+
23
+ // Hooks
24
+ export { useFileValidation } from './hooks';
25
+
26
+ // Components
27
+ export { FileUpload } from './components/FileUpload/FileUpload';
28
+ export { FileDropzoneOverlay } from './components/FileDropzoneOverlay/FileDropzoneOverlay';
29
+ export { FileUploadCanvas } from './components/FileUploadCanvas/FileUploadCanvas';
30
+ export { FileDropzone } from './components/FileDropzone/FileDropzone';
31
+ export { FilePreviewList } from './components/FilePreviewList/FilePreviewList';
32
+ export { FileCard } from './components/FileCard/FileCard';
33
+ export { ListFileCard } from './components/ListFileCard/ListFileCard';
34
+ export { GridFileCard } from './components/GridFileCard/GridFileCard';
35
+
36
+ // Providers
37
+ export { useValidationContext, UploadValidationProvider } from './providers/UploadValidationProvider';
38
+ export { useFileUploadContext, FileUploadProvider } from './providers/FileUploadProvider';
39
+
40
+ // Contexts
41
+ export { FileUploadContext } from './providers/FileUploadProvider';
42
+ export { UploadValidationContext } from './providers/UploadValidationProvider';
43
+
44
+ // Utils
45
+ export { getFileExtensionsFromAcceptedTypes } from './utils/getFileExtensionsFromAcceptedTypes';
46
+ export { getFilePluralizationText } from './utils/getFilePluralizationText';
47
+
48
+ // Types
49
+ export type { OverlayStyleOptions } from './types/sharedTypes';
50
+ export type { ValidationError } from './types';
51
+ export type {
52
+ FileCardAction,
53
+ FileProgressCircleConfig,
54
+ FileStatusConfig,
55
+ FileStatusIcon,
56
+ FileStatusIconConfig,
57
+ } from './components/types';
@@ -0,0 +1,219 @@
1
+ import { createContext, useContext, useState } from 'react';
2
+
3
+ import { FileResource } from '../types';
4
+ import { CommonFileTypes, FileError, FileRejection, FileValidator } from '../types/commonTypes';
5
+ import { UploadValidationProvider } from './UploadValidationProvider';
6
+
7
+ /**
8
+ * Context type for the FileUploadProvider
9
+ * Contains both file state management and callback handlers for file operations.
10
+ * This context makes file upload state and operations available to all child components.
11
+ *
12
+ * @property disabled - Whether the file upload functionality is disabled
13
+ * @property files - Array of currently selected/uploaded files
14
+ * @property onDrop - Callback triggered when files are dropped, with both accepted and rejected files
15
+ * @property onDropAccepted - Callback triggered when files pass validation
16
+ * @property onDropRejected - Callback triggered when files fail validation
17
+ * @property onFileDelete - Callback triggered when a file is deleted from the preview
18
+ * @property setFiles - State setter function to update the files array
19
+ */
20
+ export type FileUploadContextType = {
21
+ disabled: boolean;
22
+ files: FileResource[];
23
+ onDrop?: (acceptedFiles: File[], rejectedFiles: FileRejection[]) => void;
24
+ onDropAccepted?: (files: File[]) => void;
25
+ onDropRejected?: (rejectedFiles: FileRejection[]) => void;
26
+ onFileDelete?: (fileResource: FileResource) => void;
27
+ setFiles: (files: FileResource[] | ((prev: FileResource[]) => FileResource[])) => void;
28
+ };
29
+
30
+ /**
31
+ * React context for file upload state and operations
32
+ * Used by the useFileUploadContext hook
33
+ */
34
+ export const FileUploadContext = createContext<FileUploadContextType | undefined>(undefined);
35
+
36
+ /**
37
+ * Configuration props for the FileUploadProvider
38
+ * These props control both file upload behavior and validation rules.
39
+ * Many of these properties are passed to the underlying ValidationProvider.
40
+ */
41
+ export type FileUploadProviderConfigProps = {
42
+ /**
43
+ * Allowed file types - either preset categories ('images', 'pdfs', 'documents')
44
+ * or an array of MIME types/extensions (e.g., ['image/jpeg', '.png'])
45
+ */
46
+ accept?: CommonFileTypes | string[];
47
+
48
+ /**
49
+ * Whether the upload is disabled
50
+ * When true, prevents any interaction with the upload components
51
+ */
52
+ disabled?: boolean;
53
+
54
+ /**
55
+ * Error object to display custom validation errors
56
+ * Overrides any validation errors with this custom error
57
+ */
58
+ error?: FileError;
59
+
60
+ /**
61
+ * Initial files to populate the uploader with
62
+ * These files will be present when the component first mounts
63
+ */
64
+ initialFiles?: FileResource[];
65
+
66
+ /**
67
+ * Maximum number of files allowed
68
+ * Set to 1 for single file upload, undefined for unlimited
69
+ */
70
+ maxFiles?: number;
71
+
72
+ /**
73
+ * Maximum allowed file size in bytes
74
+ * Example: 5 * 1024 * 1024 for 5MB
75
+ */
76
+ maxSize?: number;
77
+
78
+ /**
79
+ * Callback when files are dropped (regardless of validation result)
80
+ * Provides both accepted and rejected files for handling
81
+ */
82
+ onDrop?: (acceptedFiles: File[], rejectedFiles: FileRejection[]) => void;
83
+
84
+ /**
85
+ * Callback when files pass validation and are accepted
86
+ * Useful for immediately processing valid files
87
+ */
88
+ onDropAccepted?: (files: File[]) => void;
89
+
90
+ /**
91
+ * Callback when files fail validation
92
+ * Provides detailed rejection reasons for each file
93
+ */
94
+ onDropRejected?: (rejectedFiles: FileRejection[]) => void;
95
+
96
+ /**
97
+ * Callback when user clicks delete button on a file preview
98
+ * Used to remove files from state or external storage
99
+ */
100
+ onFileDelete?: (fileResource: FileResource) => void;
101
+
102
+ /**
103
+ * When true, if any file fails validation, all files are rejected
104
+ * When false (default), valid files are accepted even if others are rejected
105
+ */
106
+ strictValidation?: boolean;
107
+
108
+ /**
109
+ * Custom validator function for additional validation rules
110
+ * Allows you to implement validation beyond the built-in type/size checks
111
+ */
112
+ validator?: FileValidator;
113
+ };
114
+
115
+ /**
116
+ * Props for the FileUploadProvider component
117
+ * Extends the config props with React children
118
+ */
119
+ type FileUploadProviderProps = FileUploadProviderConfigProps & {
120
+ /** React children */
121
+ children: React.ReactNode;
122
+ };
123
+
124
+ /**
125
+ * Provider component for file upload functionality
126
+ *
127
+ * This provider manages both file state and validation rules:
128
+ * 1. Maintains file state (selected/uploaded files)
129
+ * 2. Provides context for drag/drop operations and file management
130
+ * 3. Wraps children with validation context for enforcing file rules
131
+ *
132
+ * While FileDropzone and FilePreviewList can function as standalone components,
133
+ * using this provider offers coordinated state management when using multiple
134
+ * file upload components together.
135
+ *
136
+ * @example
137
+ * ```tsx
138
+ * <FileUploadProvider
139
+ * accept="images"
140
+ * maxFiles={5}
141
+ * maxSize={2 * 1024 * 1024}
142
+ * onDropAccepted={(files) => console.log('Accepted:', files)}
143
+ * >
144
+ * <FileDropzone />
145
+ * <FilePreviewList />
146
+ * </FileUploadProvider>
147
+ * ```
148
+ */
149
+ export const FileUploadProvider = ({
150
+ accept,
151
+ children,
152
+ disabled = false,
153
+ error,
154
+ initialFiles = [],
155
+ maxFiles,
156
+ maxSize,
157
+ onDrop,
158
+ onDropAccepted,
159
+ onDropRejected,
160
+ onFileDelete,
161
+ strictValidation,
162
+ validator,
163
+ }: FileUploadProviderProps) => {
164
+ const [files, setFiles] = useState<FileResource[]>(initialFiles);
165
+
166
+ const value = {
167
+ accept,
168
+ disabled,
169
+ files,
170
+ onDrop,
171
+ onDropAccepted,
172
+ onDropRejected,
173
+ onFileDelete,
174
+ setFiles,
175
+ };
176
+
177
+ return (
178
+ <UploadValidationProvider
179
+ accept={accept}
180
+ error={error}
181
+ maxFiles={maxFiles}
182
+ maxSize={maxSize}
183
+ strictValidation={strictValidation}
184
+ validator={validator}
185
+ >
186
+ <FileUploadContext.Provider value={value}>{children}</FileUploadContext.Provider>
187
+ </UploadValidationProvider>
188
+ );
189
+ };
190
+
191
+ FileUploadProvider.displayName = 'FileUploadProvider';
192
+
193
+ /**
194
+ * Hook to access the file upload context
195
+ *
196
+ * Provides access to the current files array and operations for
197
+ * managing file uploads within the FileUploadProvider.
198
+ *
199
+ * @throws Error if used outside of a FileUploadProvider
200
+ * @returns The FileUploadContextType object with files array and handlers
201
+ *
202
+ * @example
203
+ * ```tsx
204
+ * const { files, setFiles, onFileDelete } = useFileUploadContext();
205
+ *
206
+ * // Remove a file
207
+ * const handleDelete = (fileToDelete) => {
208
+ * onFileDelete?.(fileToDelete);
209
+ * setFiles(files.filter(file => file.name !== fileToDelete.name));
210
+ * };
211
+ * ```
212
+ */
213
+ export const useFileUploadContext = () => {
214
+ const context = useContext<FileUploadContextType | undefined>(FileUploadContext);
215
+ if (!context) {
216
+ throw new Error('useFileUploadContext must be used within FileUploadProvider');
217
+ }
218
+ return context;
219
+ };
@@ -0,0 +1,159 @@
1
+ import { createContext, useContext, useMemo, useState } from 'react';
2
+
3
+ import { useFileValidationLogic } from '../hooks/validation/useFileValidationLogic';
4
+ import {
5
+ CommonFileTypes,
6
+ FileError,
7
+ FileRejection,
8
+ FileValidator,
9
+ ValidationMessageParams,
10
+ } from '../types/commonTypes';
11
+
12
+ /**
13
+ * Provider component that shares file validation logic and state across components
14
+ * @param props Object containing:
15
+ * - accept: Optional file type restrictions (MIME types or preset categories)
16
+ * - children: React child components
17
+ * - error: Optional custom validation error object
18
+ * - maxFiles: Optional maximum number of files allowed (1 for single file, undefined for unlimited)
19
+ * - maxSize: Optional maximum file size in bytes
20
+ * - strictValidation: Optional boolean to enable strict validation
21
+ * - validator: Optional custom validation function
22
+ * @returns Provider component with shared validation context
23
+ * @remarks
24
+ * - Components can access validation through useValidationContext hook
25
+ * - If no provider is present, components will fall back to local validation logic
26
+ * - Validation state is shared between drag and drop operations
27
+ * - Errors must be explicitly set using the provided setter methods (setDragValidationError, setDropValidationErrors)
28
+ */
29
+
30
+ export type UploadValidationContextType = {
31
+ /** Accepted file types - either preset categories or an array of MIME types */
32
+ accept?: CommonFileTypes | string[];
33
+ /** Clears all validation errors (both drag and drop errors) */
34
+ clearAllValidation: () => void;
35
+ /** Clears drag-related validation errors */
36
+ clearDragValidation: () => void;
37
+ /** Clears drop-related validation errors */
38
+ clearDropValidation: () => void;
39
+ /** Current drag validation error or null if none */
40
+ dragValidationError: FileError | null;
41
+ /** Array of drop validation errors */
42
+ dropValidationErrors: FileError[];
43
+ /** Files that failed validation with their rejection reasons */
44
+ fileRejections: FileRejection[];
45
+ /** Human-readable maximum file size (e.g., "5 MB") */
46
+ formattedMaxSize: string | undefined;
47
+ /** Generates context-aware validation messages */
48
+ getValidationMessage: (params: ValidationMessageParams) => string;
49
+ /** Maximum number of files allowed (1 for single file upload) */
50
+ maxFiles?: number;
51
+ /** Maximum file size in bytes */
52
+ maxSize?: number;
53
+ /** Sets the drag validation error */
54
+ setDragValidationError: (error: FileError | null) => void;
55
+ /** Sets the drop validation errors array */
56
+ setDropValidationErrors: (errors: FileError[]) => void;
57
+ /** Updates the file rejections array */
58
+ setFileRejections: (rejections: FileRejection[]) => void;
59
+ /** When true, all files are rejected if any fail validation */
60
+ strictValidation?: boolean;
61
+ /** Custom validation function for additional file checks */
62
+ validateCustomRules: FileValidator;
63
+ /** Validates if adding new files would exceed the maximum file count */
64
+ validateFileCount: (currentCount: number, newCount: number) => boolean;
65
+ /** Checks if a file size is within the allowed limit */
66
+ validateFileSize: (fileSize: number) => boolean;
67
+ /** Validates file type against accepted types */
68
+ validateFileType: (fileType: string, mimeTypes?: Record<string, string[]>) => boolean;
69
+ };
70
+
71
+ export const UploadValidationContext = createContext<UploadValidationContextType | undefined>(undefined);
72
+
73
+ export type UploadValidationProviderProps = {
74
+ /** Optional array of accepted file types */
75
+ accept?: CommonFileTypes | string[];
76
+ /** React children */
77
+ children: React.ReactNode;
78
+ /** Error object to display custom validation errors */
79
+ error?: FileError;
80
+ /** Maximum number of files (1 for single file, undefined for unlimited) */
81
+ maxFiles?: number;
82
+ /** Maximum allowed file size in bytes (Unrestricted by default) */
83
+ maxSize?: number;
84
+ /** Enable strict validation */
85
+ strictValidation?: boolean;
86
+ /** Custom validator function */
87
+ validator?: FileValidator;
88
+ };
89
+
90
+ export const UploadValidationProvider = ({
91
+ accept,
92
+ children,
93
+ error,
94
+ maxFiles,
95
+ maxSize,
96
+ strictValidation,
97
+ validator,
98
+ }: UploadValidationProviderProps) => {
99
+ const validation = useFileValidationLogic({
100
+ accept,
101
+ error,
102
+ maxFiles,
103
+ maxSize,
104
+ strictValidation,
105
+ validator,
106
+ });
107
+
108
+ const [fileRejections, setFileRejections] = useState<FileRejection[]>([]);
109
+
110
+ const value = useMemo(
111
+ () => ({
112
+ ...validation,
113
+ accept,
114
+ fileRejections,
115
+ maxFiles,
116
+ maxSize,
117
+ setFileRejections,
118
+ strictValidation,
119
+ }),
120
+ [validation, accept, maxFiles, maxSize, strictValidation, fileRejections]
121
+ );
122
+
123
+ return <UploadValidationContext.Provider value={value}>{children}</UploadValidationContext.Provider>;
124
+ };
125
+
126
+ UploadValidationProvider.displayName = 'UploadValidationProvider';
127
+
128
+ /**
129
+ * Hook to access the upload validation context
130
+ *
131
+ * Provides access to validation state, error handling, and validation methods
132
+ * for file upload components.
133
+ *
134
+ * @returns The UploadValidationContextType object with validation state and methods
135
+ * @throws Error if used outside of an UploadValidationProvider
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * const validation = useValidationContext();
140
+ *
141
+ * // Validate file type
142
+ * const isValidType = validation.validateFileType(file.type);
143
+ *
144
+ * // Set validation error
145
+ * if (!isValidType) {
146
+ * validation.setDragValidationError({
147
+ * code: 'invalid-file-type',
148
+ * message: 'File type not supported'
149
+ * });
150
+ * }
151
+ * ```
152
+ */
153
+ export const useValidationContext = () => {
154
+ const context = useContext<UploadValidationContextType | undefined>(UploadValidationContext);
155
+ if (!context) {
156
+ throw new Error('useValidationContext must be used within UploadValidationProvider');
157
+ }
158
+ return context;
159
+ };