@majapisoftwares/ui 4.0.2

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 (436) hide show
  1. package/base.css +359 -0
  2. package/bootstrap/AppProps.d.ts +10 -0
  3. package/bootstrap/AppProps.js +1 -0
  4. package/bootstrap/index.d.ts +1 -0
  5. package/bootstrap/index.js +1 -0
  6. package/bootstrap/modeScript.d.ts +2 -0
  7. package/bootstrap/modeScript.js +35 -0
  8. package/bootstrap/nprogress.d.ts +1 -0
  9. package/bootstrap/nprogress.js +19 -0
  10. package/bootstrap/scrolledScript.d.ts +2 -0
  11. package/bootstrap/scrolledScript.js +27 -0
  12. package/bootstrap/setupFocusManager.d.ts +1 -0
  13. package/bootstrap/setupFocusManager.js +13 -0
  14. package/bootstrap/suppressConsoleLog.d.ts +1 -0
  15. package/bootstrap/suppressConsoleLog.js +8 -0
  16. package/components/Accordion/Accordion.d.ts +19 -0
  17. package/components/Accordion/Accordion.jsx +27 -0
  18. package/components/Accordion/index.d.ts +3 -0
  19. package/components/Accordion/index.jsx +3 -0
  20. package/components/Alert/Alert.d.ts +31 -0
  21. package/components/Alert/Alert.jsx +53 -0
  22. package/components/Alert/index.d.ts +3 -0
  23. package/components/Alert/index.jsx +3 -0
  24. package/components/Aurora/Aurora.d.ts +10 -0
  25. package/components/Aurora/Aurora.jsx +189 -0
  26. package/components/Aurora/index.d.ts +3 -0
  27. package/components/Aurora/index.jsx +3 -0
  28. package/components/Autocomplete/Autocomplete.d.ts +7 -0
  29. package/components/Autocomplete/Autocomplete.jsx +23 -0
  30. package/components/Autocomplete/UnstyledAutocomplete.d.ts +36 -0
  31. package/components/Autocomplete/UnstyledAutocomplete.jsx +73 -0
  32. package/components/Autocomplete/index.d.ts +5 -0
  33. package/components/Autocomplete/index.jsx +5 -0
  34. package/components/BackgroundEffects/BottomBlurryPoint.d.ts +3 -0
  35. package/components/BackgroundEffects/BottomBlurryPoint.jsx +14 -0
  36. package/components/BackgroundEffects/TopBlurryPoint.d.ts +3 -0
  37. package/components/BackgroundEffects/TopBlurryPoint.jsx +14 -0
  38. package/components/Badge/Badge.d.ts +42 -0
  39. package/components/Badge/Badge.jsx +50 -0
  40. package/components/Badge/index.d.ts +3 -0
  41. package/components/Badge/index.jsx +3 -0
  42. package/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
  43. package/components/Breadcrumbs/Breadcrumbs.jsx +42 -0
  44. package/components/Breadcrumbs/index.d.ts +3 -0
  45. package/components/Breadcrumbs/index.jsx +3 -0
  46. package/components/Button/Button.d.ts +111 -0
  47. package/components/Button/Button.jsx +129 -0
  48. package/components/Button/UnstyledButton.d.ts +10 -0
  49. package/components/Button/UnstyledButton.jsx +13 -0
  50. package/components/Button/index.d.ts +3 -0
  51. package/components/Button/index.jsx +3 -0
  52. package/components/Carousel/Carousel.d.ts +19 -0
  53. package/components/Carousel/Carousel.jsx +55 -0
  54. package/components/Carousel/index.d.ts +3 -0
  55. package/components/Carousel/index.jsx +3 -0
  56. package/components/Checkbox/Checkbox.d.ts +14 -0
  57. package/components/Checkbox/Checkbox.jsx +45 -0
  58. package/components/Checkbox/index.d.ts +3 -0
  59. package/components/Checkbox/index.js +3 -0
  60. package/components/Code/Code.d.ts +12 -0
  61. package/components/Code/Code.jsx +25 -0
  62. package/components/Code/Json.d.ts +5 -0
  63. package/components/Code/Json.jsx +7 -0
  64. package/components/Code/index.d.ts +4 -0
  65. package/components/Code/index.jsx +4 -0
  66. package/components/ConfirmationButton/ConfirmationButton.d.ts +17 -0
  67. package/components/ConfirmationButton/ConfirmationButton.jsx +13 -0
  68. package/components/ConfirmationButton/index.d.ts +3 -0
  69. package/components/ConfirmationButton/index.jsx +3 -0
  70. package/components/ContextMenu/ContextMenu.d.ts +28 -0
  71. package/components/ContextMenu/ContextMenu.jsx +70 -0
  72. package/components/ContextMenu/index.d.ts +3 -0
  73. package/components/ContextMenu/index.jsx +3 -0
  74. package/components/CopyButton/CopyButton.d.ts +7 -0
  75. package/components/CopyButton/CopyButton.jsx +29 -0
  76. package/components/CopyButton/index.d.ts +3 -0
  77. package/components/CopyButton/index.jsx +3 -0
  78. package/components/DateInput/DateInput.d.ts +6 -0
  79. package/components/DateInput/DateInput.jsx +19 -0
  80. package/components/DateInput/DateTimeInput.d.ts +3 -0
  81. package/components/DateInput/DateTimeInput.jsx +8 -0
  82. package/components/DateInput/index.d.ts +4 -0
  83. package/components/DateInput/index.jsx +4 -0
  84. package/components/DateInput/useRefValue.d.ts +5 -0
  85. package/components/DateInput/useRefValue.js +48 -0
  86. package/components/DatePicker/DatePicker.d.ts +19 -0
  87. package/components/DatePicker/DatePicker.jsx +55 -0
  88. package/components/DatePicker/index.d.ts +3 -0
  89. package/components/DatePicker/index.jsx +3 -0
  90. package/components/DateRangePicker/DateRangePicker.d.ts +16 -0
  91. package/components/DateRangePicker/DateRangePicker.jsx +56 -0
  92. package/components/DateRangePicker/index.d.ts +3 -0
  93. package/components/DateRangePicker/index.jsx +3 -0
  94. package/components/Dialog/Dialog.d.ts +25 -0
  95. package/components/Dialog/Dialog.jsx +35 -0
  96. package/components/Dialog/Dialogs.d.ts +1 -0
  97. package/components/Dialog/Dialogs.jsx +21 -0
  98. package/components/Dialog/dialogs.state.d.ts +21 -0
  99. package/components/Dialog/dialogs.state.js +40 -0
  100. package/components/Dialog/index.d.ts +6 -0
  101. package/components/Dialog/index.jsx +7 -0
  102. package/components/Drawer/Drawer.d.ts +15 -0
  103. package/components/Drawer/Drawer.jsx +72 -0
  104. package/components/Drawer/index.d.ts +3 -0
  105. package/components/Drawer/index.jsx +3 -0
  106. package/components/DropdownMenu/DropdownMenu.d.ts +33 -0
  107. package/components/DropdownMenu/DropdownMenu.jsx +74 -0
  108. package/components/DropdownMenu/index.d.ts +3 -0
  109. package/components/DropdownMenu/index.jsx +3 -0
  110. package/components/ErrorBoundary/ErrorBoundary.d.ts +18 -0
  111. package/components/ErrorBoundary/ErrorBoundary.jsx +32 -0
  112. package/components/ErrorBoundary/index.d.ts +3 -0
  113. package/components/ErrorBoundary/index.jsx +3 -0
  114. package/components/ErrorPage/Error404Page.d.ts +1 -0
  115. package/components/ErrorPage/Error404Page.jsx +4 -0
  116. package/components/ErrorPage/Error500Page.d.ts +1 -0
  117. package/components/ErrorPage/Error500Page.jsx +4 -0
  118. package/components/ErrorPage/ErrorPage.d.ts +11 -0
  119. package/components/ErrorPage/ErrorPage.jsx +23 -0
  120. package/components/FileInput/FileInput.d.ts +47 -0
  121. package/components/FileInput/FileInput.jsx +144 -0
  122. package/components/FileInput/PreviewFile.d.ts +13 -0
  123. package/components/FileInput/PreviewFile.jsx +55 -0
  124. package/components/FileInput/index.d.ts +3 -0
  125. package/components/FileInput/index.jsx +3 -0
  126. package/components/FileSelect/FileSelect.d.ts +31 -0
  127. package/components/FileSelect/FileSelect.jsx +143 -0
  128. package/components/FileSelect/index.d.ts +3 -0
  129. package/components/FileSelect/index.jsx +3 -0
  130. package/components/Footer/Footer.d.ts +19 -0
  131. package/components/Footer/Footer.jsx +30 -0
  132. package/components/Footer/index.d.ts +3 -0
  133. package/components/Footer/index.jsx +3 -0
  134. package/components/GridPattern/GridPattern.d.ts +2 -0
  135. package/components/GridPattern/GridPattern.jsx +12 -0
  136. package/components/GridPattern/index.d.ts +3 -0
  137. package/components/GridPattern/index.jsx +3 -0
  138. package/components/Group/Group.d.ts +5 -0
  139. package/components/Group/Group.jsx +6 -0
  140. package/components/Group/index.d.ts +3 -0
  141. package/components/Group/index.jsx +3 -0
  142. package/components/Header/Header.d.ts +5 -0
  143. package/components/Header/Header.jsx +19 -0
  144. package/components/Header/index.d.ts +3 -0
  145. package/components/Header/index.jsx +3 -0
  146. package/components/ImageInput/ImageInput.d.ts +4 -0
  147. package/components/ImageInput/ImageInput.jsx +8 -0
  148. package/components/ImageInput/index.d.ts +3 -0
  149. package/components/ImageInput/index.jsx +3 -0
  150. package/components/Input/Input.d.ts +14 -0
  151. package/components/Input/Input.jsx +57 -0
  152. package/components/Input/InputIcon.d.ts +9 -0
  153. package/components/Input/InputIcon.jsx +7 -0
  154. package/components/Input/MultiSelectInput.d.ts +13 -0
  155. package/components/Input/MultiSelectInput.jsx +28 -0
  156. package/components/Input/NumericInput.d.ts +6 -0
  157. package/components/Input/NumericInput.jsx +6 -0
  158. package/components/Input/PatternInput.d.ts +6 -0
  159. package/components/Input/PatternInput.jsx +6 -0
  160. package/components/Input/UnstyledInput.d.ts +22 -0
  161. package/components/Input/UnstyledInput.jsx +28 -0
  162. package/components/Input/index.d.ts +6 -0
  163. package/components/Input/index.jsx +6 -0
  164. package/components/Input2/InputWrapper.d.ts +11 -0
  165. package/components/Input2/InputWrapper.jsx +11 -0
  166. package/components/Link/Link.d.ts +3 -0
  167. package/components/Link/Link.jsx +9 -0
  168. package/components/Link/index.d.ts +3 -0
  169. package/components/Link/index.jsx +3 -0
  170. package/components/Loading/Loading.d.ts +3 -0
  171. package/components/Loading/Loading.jsx +13 -0
  172. package/components/Loading/index.d.ts +3 -0
  173. package/components/Loading/index.jsx +3 -0
  174. package/components/Magnet/Magnet.d.ts +13 -0
  175. package/components/Magnet/Magnet.jsx +50 -0
  176. package/components/Magnet/index.d.ts +3 -0
  177. package/components/Magnet/index.jsx +3 -0
  178. package/components/Markdown/Markdown.d.ts +8 -0
  179. package/components/Markdown/Markdown.jsx +13 -0
  180. package/components/Markdown/index.d.ts +3 -0
  181. package/components/Markdown/index.jsx +3 -0
  182. package/components/Menu/Menu.d.ts +28 -0
  183. package/components/Menu/Menu.jsx +54 -0
  184. package/components/Modal/Modal.d.ts +45 -0
  185. package/components/Modal/Modal.jsx +65 -0
  186. package/components/Modal/index.d.ts +4 -0
  187. package/components/Modal/index.jsx +4 -0
  188. package/components/Modal/useModalState.d.ts +6 -0
  189. package/components/Modal/useModalState.js +16 -0
  190. package/components/ModeToggle/ModeToggle.d.ts +9 -0
  191. package/components/ModeToggle/ModeToggle.jsx +12 -0
  192. package/components/ModeToggle/index.d.ts +4 -0
  193. package/components/ModeToggle/index.jsx +5 -0
  194. package/components/ModeToggle/useModeToggle.d.ts +1 -0
  195. package/components/ModeToggle/useModeToggle.js +21 -0
  196. package/components/MultiSelect/MultiSelect.d.ts +28 -0
  197. package/components/MultiSelect/MultiSelect.jsx +130 -0
  198. package/components/MultiSelect/index.d.ts +3 -0
  199. package/components/MultiSelect/index.jsx +3 -0
  200. package/components/MultiText/MultiText.d.ts +23 -0
  201. package/components/MultiText/MultiText.jsx +119 -0
  202. package/components/MultiText/index.d.ts +3 -0
  203. package/components/MultiText/index.jsx +3 -0
  204. package/components/NavigationDrawer/NavigationDrawer.d.ts +9 -0
  205. package/components/NavigationDrawer/NavigationDrawer.jsx +29 -0
  206. package/components/NavigationDrawer/NavigationItem.d.ts +13 -0
  207. package/components/NavigationDrawer/NavigationItem.jsx +24 -0
  208. package/components/NavigationDrawer/index.d.ts +6 -0
  209. package/components/NavigationDrawer/index.jsx +6 -0
  210. package/components/NavigationDrawer/navigationDrawer.state.d.ts +9 -0
  211. package/components/NavigationDrawer/navigationDrawer.state.js +19 -0
  212. package/components/NoSsr/NoSsr.d.ts +4 -0
  213. package/components/NoSsr/NoSsr.jsx +8 -0
  214. package/components/NoSsr/index.d.ts +3 -0
  215. package/components/NoSsr/index.jsx +3 -0
  216. package/components/Noise/Noise.d.ts +11 -0
  217. package/components/Noise/Noise.jsx +69 -0
  218. package/components/Noise/index.d.ts +3 -0
  219. package/components/Noise/index.jsx +3 -0
  220. package/components/Notifications/Notifications.d.ts +3 -0
  221. package/components/Notifications/Notifications.jsx +60 -0
  222. package/components/Notifications/index.d.ts +5 -0
  223. package/components/Notifications/index.jsx +6 -0
  224. package/components/Notifications/notifications.state.d.ts +24 -0
  225. package/components/Notifications/notifications.state.js +41 -0
  226. package/components/Orb/Orb.d.ts +8 -0
  227. package/components/Orb/Orb.jsx +258 -0
  228. package/components/Orb/index.d.ts +3 -0
  229. package/components/Orb/index.jsx +3 -0
  230. package/components/Pagination/Pagination.d.ts +13 -0
  231. package/components/Pagination/Pagination.jsx +64 -0
  232. package/components/Pagination/index.d.ts +3 -0
  233. package/components/Pagination/index.jsx +3 -0
  234. package/components/Particles/Particles.d.ts +18 -0
  235. package/components/Particles/Particles.jsx +205 -0
  236. package/components/Particles/index.d.ts +3 -0
  237. package/components/Particles/index.jsx +3 -0
  238. package/components/PictureCropInput/PictureCropInput.d.ts +17 -0
  239. package/components/PictureCropInput/PictureCropInput.jsx +153 -0
  240. package/components/PictureCropInput/canvasPreview.d.ts +2 -0
  241. package/components/PictureCropInput/canvasPreview.js +37 -0
  242. package/components/PictureCropInput/index.d.ts +3 -0
  243. package/components/PictureCropInput/index.js +3 -0
  244. package/components/Popover/Popover.d.ts +13 -0
  245. package/components/Popover/Popover.jsx +22 -0
  246. package/components/Popover/index.d.ts +3 -0
  247. package/components/Popover/index.jsx +3 -0
  248. package/components/Resizable/Resizable.d.ts +12 -0
  249. package/components/Resizable/Resizable.jsx +54 -0
  250. package/components/Resizable/index.d.ts +3 -0
  251. package/components/Resizable/index.jsx +3 -0
  252. package/components/ScrollArea/ScrollArea.d.ts +9 -0
  253. package/components/ScrollArea/ScrollArea.jsx +16 -0
  254. package/components/ScrollArea/index.d.ts +3 -0
  255. package/components/ScrollArea/index.jsx +3 -0
  256. package/components/Select/Select.d.ts +24 -0
  257. package/components/Select/Select.jsx +55 -0
  258. package/components/Select/index.d.ts +3 -0
  259. package/components/Select/index.jsx +3 -0
  260. package/components/Skeleton/Skeleton.d.ts +2 -0
  261. package/components/Skeleton/Skeleton.jsx +8 -0
  262. package/components/Skeleton/index.d.ts +3 -0
  263. package/components/Skeleton/index.jsx +3 -0
  264. package/components/Slider/Slider.d.ts +10 -0
  265. package/components/Slider/Slider.jsx +21 -0
  266. package/components/Slider/index.d.ts +3 -0
  267. package/components/Slider/index.jsx +3 -0
  268. package/components/Spotlight/Spotlight.d.ts +30 -0
  269. package/components/Spotlight/Spotlight.jsx +77 -0
  270. package/components/Spotlight/index.d.ts +3 -0
  271. package/components/Spotlight/index.jsx +3 -0
  272. package/components/SpotlightCard/SpotlightCard.d.ts +7 -0
  273. package/components/SpotlightCard/SpotlightCard.jsx +35 -0
  274. package/components/SpotlightCard/index.d.ts +3 -0
  275. package/components/SpotlightCard/index.jsx +3 -0
  276. package/components/Stack/Stack.d.ts +4 -0
  277. package/components/Stack/Stack.jsx +5 -0
  278. package/components/Stack/index.d.ts +3 -0
  279. package/components/Stack/index.jsx +3 -0
  280. package/components/StarBorder/StarBorder.d.ts +11 -0
  281. package/components/StarBorder/StarBorder.jsx +19 -0
  282. package/components/StarBorder/index.d.ts +3 -0
  283. package/components/StarBorder/index.jsx +3 -0
  284. package/components/Switch/Switch.d.ts +16 -0
  285. package/components/Switch/Switch.jsx +24 -0
  286. package/components/Switch/index.d.ts +3 -0
  287. package/components/Switch/index.jsx +3 -0
  288. package/components/Table/DataTable.d.ts +57 -0
  289. package/components/Table/DataTable.jsx +155 -0
  290. package/components/Table/Table.d.ts +27 -0
  291. package/components/Table/Table.jsx +31 -0
  292. package/components/Table/TableActionButton.d.ts +6 -0
  293. package/components/Table/TableActionButton.jsx +20 -0
  294. package/components/Table/TableBody.d.ts +6 -0
  295. package/components/Table/TableBody.jsx +10 -0
  296. package/components/Table/TableCell.d.ts +9 -0
  297. package/components/Table/TableCell.jsx +18 -0
  298. package/components/Table/TableFooter.d.ts +5 -0
  299. package/components/Table/TableFooter.jsx +5 -0
  300. package/components/Table/TableFooterWithPagination.d.ts +13 -0
  301. package/components/Table/TableFooterWithPagination.jsx +57 -0
  302. package/components/Table/TableHead.d.ts +5 -0
  303. package/components/Table/TableHead.jsx +9 -0
  304. package/components/Table/TableHeadContext.d.ts +4 -0
  305. package/components/Table/TableHeadContext.jsx +3 -0
  306. package/components/Table/TableHeader.d.ts +7 -0
  307. package/components/Table/TableHeader.jsx +15 -0
  308. package/components/Table/TableRow.d.ts +8 -0
  309. package/components/Table/TableRow.jsx +9 -0
  310. package/components/Table/index.d.ts +3 -0
  311. package/components/Table/index.jsx +3 -0
  312. package/components/Tabs/Tabs.d.ts +9 -0
  313. package/components/Tabs/Tabs.jsx +13 -0
  314. package/components/Tabs/index.d.ts +3 -0
  315. package/components/Tabs/index.jsx +3 -0
  316. package/components/TabsSwitcher/Tab.d.ts +15 -0
  317. package/components/TabsSwitcher/Tab.jsx +18 -0
  318. package/components/TabsSwitcher/TabsSwitcher.d.ts +22 -0
  319. package/components/TabsSwitcher/TabsSwitcher.jsx +31 -0
  320. package/components/TabsSwitcher/index.d.ts +4 -0
  321. package/components/TabsSwitcher/index.jsx +4 -0
  322. package/components/Text/Text.d.ts +24 -0
  323. package/components/Text/Text.jsx +28 -0
  324. package/components/Text/index.d.ts +3 -0
  325. package/components/Text/index.jsx +3 -0
  326. package/components/Textarea/Textarea.d.ts +5 -0
  327. package/components/Textarea/Textarea.jsx +6 -0
  328. package/components/Textarea/index.d.ts +3 -0
  329. package/components/Textarea/index.js +3 -0
  330. package/components/Threads/Threads.d.ts +9 -0
  331. package/components/Threads/Threads.jsx +203 -0
  332. package/components/Threads/index.d.ts +3 -0
  333. package/components/Threads/index.jsx +3 -0
  334. package/components/Tooltip/Tooltip.d.ts +11 -0
  335. package/components/Tooltip/Tooltip.jsx +21 -0
  336. package/components/Tooltip/index.d.ts +3 -0
  337. package/components/Tooltip/index.jsx +3 -0
  338. package/components/VisibilityActivatedButton/VisibilityActivatedButton.d.ts +7 -0
  339. package/components/VisibilityActivatedButton/VisibilityActivatedButton.jsx +18 -0
  340. package/components/VisibilityActivatedButton/index.d.ts +3 -0
  341. package/components/VisibilityActivatedButton/index.jsx +3 -0
  342. package/form.d.ts +82 -0
  343. package/form.js +113 -0
  344. package/form2.d.ts +15 -0
  345. package/form2.jsx +29 -0
  346. package/hooks/useBeforeUnload.d.ts +1 -0
  347. package/hooks/useBeforeUnload.js +17 -0
  348. package/hooks/useDebounceEffect.d.ts +2 -0
  349. package/hooks/useDebounceEffect.js +14 -0
  350. package/hooks/useDebouncedValue.d.ts +2 -0
  351. package/hooks/useDebouncedValue.js +14 -0
  352. package/hooks/useLagRadar.d.ts +1 -0
  353. package/hooks/useLagRadar.jsx +124 -0
  354. package/hooks/useMediaQuery.d.ts +1 -0
  355. package/hooks/useMediaQuery.js +37 -0
  356. package/hooks/useMutationWindowCloseProtection.d.ts +2 -0
  357. package/hooks/useMutationWindowCloseProtection.js +13 -0
  358. package/hooks/useScroll.d.ts +3 -0
  359. package/hooks/useScroll.js +47 -0
  360. package/hooks/useTranslation.d.ts +4 -0
  361. package/hooks/useTranslation.js +11 -0
  362. package/hooks/useWhyDidYouUpdate.d.ts +3 -0
  363. package/hooks/useWhyDidYouUpdate.js +44 -0
  364. package/imgur.d.ts +1 -0
  365. package/imgur.js +13 -0
  366. package/package.json +9 -0
  367. package/styles/DayPicker.classNames.d.ts +29 -0
  368. package/styles/DayPicker.classNames.js +30 -0
  369. package/styles/DayPicker.classNames.ts +81 -0
  370. package/styles/Dropdown.classNames.d.ts +6 -0
  371. package/styles/Dropdown.classNames.js +7 -0
  372. package/styles/Dropdown.classNames.ts +38 -0
  373. package/styles/Input.css +23 -0
  374. package/styles/Modal.classNames.d.ts +2 -0
  375. package/styles/Modal.classNames.js +3 -0
  376. package/styles/Modal.classNames.ts +15 -0
  377. package/styles/MultiText.css +40 -0
  378. package/styles/Pagination.css +19 -0
  379. package/styles/Tabs.css +23 -0
  380. package/tsconfig.tsbuildinfo +1 -0
  381. package/types.d.ts +6 -0
  382. package/types.js +1 -0
  383. package/utils/UseState.d.ts +3 -0
  384. package/utils/UseState.js +1 -0
  385. package/utils/blobToText.d.ts +1 -0
  386. package/utils/blobToText.js +13 -0
  387. package/utils/capitalize.d.ts +1 -0
  388. package/utils/capitalize.js +6 -0
  389. package/utils/clsx.d.ts +2 -0
  390. package/utils/clsx.js +5 -0
  391. package/utils/copy2DToClipboard.d.ts +1 -0
  392. package/utils/copy2DToClipboard.js +44 -0
  393. package/utils/cpfCpnjUtils.d.ts +3 -0
  394. package/utils/cpfCpnjUtils.js +43 -0
  395. package/utils/createLocalStorageStateHydration.d.ts +1 -0
  396. package/utils/createLocalStorageStateHydration.js +18 -0
  397. package/utils/createStateHydration.d.ts +3 -0
  398. package/utils/createStateHydration.js +49 -0
  399. package/utils/csvBlobToJson.d.ts +2 -0
  400. package/utils/csvBlobToJson.js +60 -0
  401. package/utils/downloadArrayAsCSV.d.ts +1 -0
  402. package/utils/downloadArrayAsCSV.js +34 -0
  403. package/utils/emailRegExp.d.ts +2 -0
  404. package/utils/emailRegExp.js +3 -0
  405. package/utils/fakeArray.d.ts +1 -0
  406. package/utils/fakeArray.js +3 -0
  407. package/utils/filterBoolean.d.ts +1 -0
  408. package/utils/filterBoolean.js +3 -0
  409. package/utils/formatClock.d.ts +1 -0
  410. package/utils/formatClock.js +21 -0
  411. package/utils/formatTime.d.ts +2 -0
  412. package/utils/formatTime.js +40 -0
  413. package/utils/getInitials.d.ts +4 -0
  414. package/utils/getInitials.js +8 -0
  415. package/utils/isBrowser.d.ts +12 -0
  416. package/utils/isBrowser.js +26 -0
  417. package/utils/ms.d.ts +6 -0
  418. package/utils/ms.js +31 -0
  419. package/utils/preventDefault.d.ts +1 -0
  420. package/utils/preventDefault.js +3 -0
  421. package/utils/recursiveChildrenMap.d.ts +2 -0
  422. package/utils/recursiveChildrenMap.js +16 -0
  423. package/utils/setSelectionRange.d.ts +1 -0
  424. package/utils/setSelectionRange.js +55 -0
  425. package/utils/smoothScrollToHref.d.ts +2 -0
  426. package/utils/smoothScrollToHref.js +10 -0
  427. package/utils/stopPropagation.d.ts +2 -0
  428. package/utils/stopPropagation.js +3 -0
  429. package/utils/stripHtml.d.ts +1 -0
  430. package/utils/stripHtml.js +4 -0
  431. package/utils/stripLineBreak.d.ts +1 -0
  432. package/utils/stripLineBreak.js +4 -0
  433. package/utils/stripMarkdown.d.ts +1 -0
  434. package/utils/stripMarkdown.js +28 -0
  435. package/utils/xlsxBlobToJson.d.ts +2 -0
  436. package/utils/xlsxBlobToJson.js +59 -0
@@ -0,0 +1,74 @@
1
+ import React, { Fragment } from "react";
2
+ import * as RDropdownMenu from "@radix-ui/react-dropdown-menu";
3
+ import clsx from "../../utils/clsx";
4
+ import { CheckIcon, ChevronRightIcon } from "@heroicons/react/20/solid";
5
+ import Link from "next/link";
6
+ import { dropdownCheckboxItemClassName, dropdownItemClassName, dropdownItemIndicatorClassName, dropdownLabelClassName, dropdownSeparatorClassName, } from "../../styles/Dropdown.classNames";
7
+ import { modalArrowClassName, modalContentClassName, } from "../../styles/Modal.classNames";
8
+ function DropdownMenuContent({ className, arrowClassName, children, sideOffset = 4, collisionPadding = 8, ...props }) {
9
+ return (<RDropdownMenu.Portal>
10
+ <RDropdownMenu.Content sideOffset={sideOffset} collisionPadding={collisionPadding} {...props} className={clsx(modalContentClassName, "ui-dropdown-menu-content", className)}>
11
+ {children}
12
+ <RDropdownMenu.Arrow className={clsx(modalArrowClassName, "ui-dropdown-menu-arrow", arrowClassName)}/>
13
+ </RDropdownMenu.Content>
14
+ </RDropdownMenu.Portal>);
15
+ }
16
+ function DropdownMenuSeparator({ className, ...props }) {
17
+ return (<RDropdownMenu.Separator {...props} className={clsx(dropdownSeparatorClassName, "ui-dropdown-menu-separator", className)}/>);
18
+ }
19
+ function DropdownMenuItem({ className, href, target, ...props }) {
20
+ const Wrapper = href ? Link : Fragment;
21
+ return (
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ <Wrapper {...(href ? { href, target } : {})}>
24
+ <RDropdownMenu.Item {...props} className={clsx(dropdownItemClassName, "ui-dropdown-menu-item", className)}/>
25
+ </Wrapper>);
26
+ }
27
+ function DropdownMenuLabel({ className, ...props }) {
28
+ return (<RDropdownMenu.Item {...props} className={clsx(dropdownLabelClassName, "ui-dropdown-menu-label", className)}/>);
29
+ }
30
+ function DropdownMenuItemIndicator({ className, ...props }) {
31
+ return (<RDropdownMenu.ItemIndicator className={clsx(dropdownItemIndicatorClassName, "ui-dropdown-menu-checkbox-item-indicator", className)} {...props}/>);
32
+ }
33
+ function DropdownMenuCheckboxItem({ className, children, indicatorClassName, ...props }) {
34
+ return (<RDropdownMenu.CheckboxItem {...props} className={clsx(dropdownCheckboxItemClassName, "ui-dropdown-menu-checkbox-item", className)}>
35
+ <DropdownMenuItemIndicator className={indicatorClassName}>
36
+ <CheckIcon />
37
+ </DropdownMenuItemIndicator>
38
+ {children}
39
+ </RDropdownMenu.CheckboxItem>);
40
+ }
41
+ function DropdownMenuSubContent({ className, children, sideOffset = 2, alignOffset = -5, ...props }) {
42
+ return (<RDropdownMenu.Portal>
43
+ <RDropdownMenu.SubContent sideOffset={sideOffset} alignOffset={alignOffset} {...props} className={clsx(modalContentClassName, "ui-dropdown-menu-sub-content", className)}>
44
+ {children}
45
+ </RDropdownMenu.SubContent>
46
+ </RDropdownMenu.Portal>);
47
+ }
48
+ function DropdownMenuSubTrigger({ className, href, children, ...props }) {
49
+ const Wrapper = href ? Link : Fragment;
50
+ return (
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ <Wrapper {...(href ? { href } : {})}>
53
+ <RDropdownMenu.SubTrigger {...props} className={clsx(dropdownItemClassName, "ui-dropdown-menu-sub-trigger", className)}>
54
+ {children}
55
+ <div className={clsx("absolute right-1.5 top-1.5 inline-flex items-center justify-center", "[&>svg]:h-4 [&>svg]:w-4")}>
56
+ <ChevronRightIcon />
57
+ </div>
58
+ </RDropdownMenu.SubTrigger>
59
+ </Wrapper>);
60
+ }
61
+ const DropdownMenu = {
62
+ Root: RDropdownMenu.Root,
63
+ Trigger: RDropdownMenu.Trigger,
64
+ Content: DropdownMenuContent,
65
+ Item: DropdownMenuItem,
66
+ Separator: DropdownMenuSeparator,
67
+ CheckboxItem: DropdownMenuCheckboxItem,
68
+ Label: DropdownMenuLabel,
69
+ ItemIndicator: DropdownMenuItemIndicator,
70
+ Sub: RDropdownMenu.Sub,
71
+ SubContent: DropdownMenuSubContent,
72
+ SubTrigger: DropdownMenuSubTrigger,
73
+ };
74
+ export default DropdownMenu;
@@ -0,0 +1,3 @@
1
+ import DropdownMenu from "./DropdownMenu";
2
+ export * from "./DropdownMenu";
3
+ export default DropdownMenu;
@@ -0,0 +1,3 @@
1
+ import DropdownMenu from "./DropdownMenu";
2
+ export * from "./DropdownMenu";
3
+ export default DropdownMenu;
@@ -0,0 +1,18 @@
1
+ import { Component, ErrorInfo, ReactNode } from "react";
2
+ export default class ErrorBoundary extends Component<{
3
+ title?: ReactNode;
4
+ content?: ReactNode;
5
+ tryAgain?: string;
6
+ children: ReactNode;
7
+ }, {
8
+ hasError: boolean;
9
+ }> {
10
+ constructor(props: {
11
+ children: ReactNode;
12
+ });
13
+ static getDerivedStateFromError(_error: Error): {
14
+ hasError: boolean;
15
+ };
16
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
17
+ render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
18
+ }
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { Component } from "react";
3
+ import Alert from "../Alert/Alert";
4
+ import Button from "../Button/Button";
5
+ export default class ErrorBoundary extends Component {
6
+ constructor(props) {
7
+ super(props);
8
+ // Define a state variable to track whether is an error or not
9
+ this.state = { hasError: false };
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ static getDerivedStateFromError(_error) {
13
+ // Update state so the next render will show the fallback UI
14
+ return { hasError: true };
15
+ }
16
+ componentDidCatch(error, errorInfo) {
17
+ console.error({ error, errorInfo });
18
+ }
19
+ render() {
20
+ // Check if the error is thrown
21
+ if (this.state.hasError) {
22
+ // You can render any custom fallback UI
23
+ return (<Alert variant="error" title={this.props.title || "Oops, there was an unexpected error"} actions={this.props.tryAgain && (<Button variant="text" color="error" onClick={() => this.setState({ hasError: false })}>
24
+ {this.props.tryAgain}
25
+ </Button>)}>
26
+ {this.props.content}
27
+ </Alert>);
28
+ }
29
+ // Return children components in case of no error
30
+ return this.props.children;
31
+ }
32
+ }
@@ -0,0 +1,3 @@
1
+ import ErrorBoundary from "./ErrorBoundary";
2
+ export * from "./ErrorBoundary";
3
+ export default ErrorBoundary;
@@ -0,0 +1,3 @@
1
+ import ErrorBoundary from "./ErrorBoundary";
2
+ export * from "./ErrorBoundary";
3
+ export default ErrorBoundary;
@@ -0,0 +1 @@
1
+ export default function Error404Page(): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import ErrorPage from "./ErrorPage";
2
+ export default function Error404Page() {
3
+ return (<ErrorPage error={404} title="Uh oh! I think you're lost." description="It looks like the page you're looking for doesn't exist."/>);
4
+ }
@@ -0,0 +1 @@
1
+ export default function Error500Page(): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import ErrorPage from "./ErrorPage";
2
+ export default function Error500Page() {
3
+ return (<ErrorPage error={500} title="Something bad just happened..." description="Our servers could not handle your request. Don't worry, our development team was already notified. Try refreshing the page."/>);
4
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ export type ErrorProps = {
3
+ error: number;
4
+ background?: string;
5
+ title: string;
6
+ description: string;
7
+ defaultActionLabel?: string;
8
+ defaultActionHref?: string;
9
+ action?: ReactNode;
10
+ };
11
+ export default function ErrorPage({ error, background, title, description, defaultActionLabel, defaultActionHref, action, }: ErrorProps): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import Button from "../Button/Button";
2
+ import { NextSeo } from "next-seo";
3
+ export default function ErrorPage({ error, background = "https://images.unsplash.com/photo-1545972154-9bb223aac798?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=3050&q=80&exp=8&con=-15&sat=-75", title, description, defaultActionLabel = "Go back home", defaultActionHref = "/", action = (<Button variant="text" href={defaultActionHref} className="inline-flex items-center rounded-md border border-transparent bg-white bg-opacity-75 px-4 py-2 text-sm font-medium text-black text-opacity-75 sm:bg-opacity-25 sm:hover:bg-opacity-50">
4
+ {defaultActionLabel}
5
+ </Button>), }) {
6
+ return (<main className="min-h-full bg-slate-400 bg-cover bg-top sm:bg-top" style={{
7
+ backgroundImage: `url("${background}")`,
8
+ }}>
9
+ <NextSeo title={error.toString()}/>
10
+ <div className="mx-auto max-w-7xl px-4 py-16 text-center sm:px-6 sm:py-24 lg:px-8 lg:py-48">
11
+ <p className="text-base font-semibold text-black text-opacity-50">
12
+ {error}
13
+ </p>
14
+ <h1 className="mt-2 text-4xl font-bold tracking-tight text-white sm:text-5xl">
15
+ {title}
16
+ </h1>
17
+ <p className="mt-2 text-lg font-medium text-black text-opacity-50">
18
+ {description}
19
+ </p>
20
+ <div className="mt-6">{action}</div>
21
+ </div>
22
+ </main>);
23
+ }
@@ -0,0 +1,47 @@
1
+ import { ComponentPropsWithRef, ReactNode } from "react";
2
+ import { InputProps } from "../Input";
3
+ import { FileSelectProps } from "../FileSelect";
4
+ export type FileFile = {
5
+ _id: string;
6
+ file: File;
7
+ description?: string;
8
+ name: string;
9
+ type: string;
10
+ size: number;
11
+ };
12
+ export type FileUrl = {
13
+ _id: string;
14
+ url: string;
15
+ description?: string;
16
+ name: string;
17
+ type: string;
18
+ size: number;
19
+ };
20
+ export type FileInputFile = FileFile | FileUrl;
21
+ declare function FileInput({ error, className, helpText, onChange, name, limit, label, id, required, onMouseOver, onMouseOut, readOnly, value, emptyText, downloadText, openText, fileDisplay, asyncUpload, onRejectFiles, loading, maxConcurrentUploads, fileAdditionalInfo, ref, fileSelectClassName, previewFileClassName, filesPerPage, ...props }: Pick<InputProps<false>, "error" | "className" | "helpText" | "name" | "label" | "id" | "required" | "onMouseOver" | "onMouseOut"> & Omit<FileSelectProps, "onAcceptFiles" | "onRejectFiles"> & {
22
+ readOnly?: boolean;
23
+ value?: FileInputFile[];
24
+ onChange?: (event: {
25
+ target: {
26
+ value: FileInputFile[];
27
+ };
28
+ }) => void;
29
+ emptyText?: string;
30
+ downloadText?: string;
31
+ openText?: string;
32
+ fileDisplay?: "info" | "preview" | "both";
33
+ asyncUpload?: (file: FileFile & {
34
+ _id: string;
35
+ }) => Promise<FileUrl & {
36
+ _id: string;
37
+ }>;
38
+ onRejectFiles?: (files: File[], reason: "type" | "size" | "limit" | "upload-error") => void;
39
+ loading?: boolean;
40
+ maxConcurrentUploads?: number;
41
+ fileAdditionalInfo?: (file: FileInputFile, index: number) => ReactNode;
42
+ fileSelectClassName?: string;
43
+ previewFileClassName?: string;
44
+ filesPerPage?: number;
45
+ }): import("react").JSX.Element;
46
+ export type FileInputProps = ComponentPropsWithRef<typeof FileInput>;
47
+ export default FileInput;
@@ -0,0 +1,144 @@
1
+ import clsx from "../../utils/clsx";
2
+ import { useCallback, useEffect, useRef, useState, } from "react";
3
+ import { useDeepCompareEffect, useUpdateEffect } from "react-use";
4
+ import { defaultHelpTextClassName, defaultLabelClassName, } from "../Input";
5
+ import FileSelect from "../FileSelect";
6
+ import isomorphicObjectId from "@majapisoftwares/next/utils/isomorphicObjectId";
7
+ import { isEqual } from "lodash-es";
8
+ import Text from "../Text";
9
+ import { PreviewFile } from "./PreviewFile";
10
+ import concurrentForOf from "@majapisoftwares/next/utils/concurrentForOf";
11
+ import paginated from "@majapisoftwares/next/utils/paginated";
12
+ import Pagination from "../Pagination";
13
+ function FileInput({ error, className, helpText, onChange, name, limit, label, id, required, onMouseOver, onMouseOut, readOnly, value, emptyText = "No files", downloadText = "Download", openText = "Open", fileDisplay, asyncUpload, onRejectFiles, loading, maxConcurrentUploads = 1, fileAdditionalInfo, ref, fileSelectClassName, previewFileClassName, filesPerPage = 10, ...props }) {
14
+ const [uploading, setUploading] = useState(false);
15
+ const [innerValue, setInnerValue] = useState(value || []);
16
+ const [currentPage, setCurrentPage] = useState(1);
17
+ const paginatedValue = paginated(innerValue, currentPage - 1, filesPerPage);
18
+ useEffect(() => {
19
+ const totalPages = Math.ceil(innerValue.length / filesPerPage);
20
+ if (currentPage > totalPages && totalPages > 0) {
21
+ setCurrentPage(totalPages);
22
+ }
23
+ }, [innerValue.length, currentPage, filesPerPage]);
24
+ useDeepCompareEffect(() => {
25
+ if (value && !isEqual(value, innerValue)) {
26
+ setInnerValue(value);
27
+ }
28
+ }, [{ value: value }]);
29
+ const innerRef = useRef({
30
+ get value() {
31
+ return innerValue;
32
+ },
33
+ set value(value) {
34
+ setInnerValue(value || []);
35
+ },
36
+ });
37
+ useEffect(() => {
38
+ if (ref) {
39
+ if (typeof ref === "function") {
40
+ ref(innerRef.current);
41
+ }
42
+ else {
43
+ try {
44
+ ref.current = innerRef.current;
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
+ }
47
+ catch (e) {
48
+ // do nothing
49
+ }
50
+ }
51
+ }
52
+ }, [ref]);
53
+ const handleAcceptFiles = async (files) => {
54
+ if (!asyncUpload) {
55
+ setInnerValue((value) => [
56
+ ...value,
57
+ ...files
58
+ .filter((_file, index) => !limit || index <= limit - value.length - 1)
59
+ .map((file) => ({
60
+ _id: isomorphicObjectId().toString(),
61
+ name: file.name,
62
+ file,
63
+ type: file.type,
64
+ size: file.size,
65
+ })),
66
+ ]);
67
+ }
68
+ else {
69
+ setUploading(true);
70
+ if (onRejectFiles) {
71
+ const rejectedFilesLimit = files.filter((_file, index) => !(!limit || index <= limit - innerValue.length - 1));
72
+ if (rejectedFilesLimit.length) {
73
+ onRejectFiles(rejectedFilesLimit, "limit");
74
+ }
75
+ }
76
+ const acceptedFiles = files.filter((_file, index) => !limit || index <= limit - innerValue.length - 1);
77
+ const filesNotUploaded = [];
78
+ await concurrentForOf(acceptedFiles, async (file) => {
79
+ try {
80
+ const uploadedFile = await asyncUpload({
81
+ _id: isomorphicObjectId().toString(),
82
+ name: file.name,
83
+ file,
84
+ type: file.type,
85
+ size: file.size,
86
+ });
87
+ setInnerValue((value) => [...value, uploadedFile]);
88
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
89
+ }
90
+ catch (e) {
91
+ filesNotUploaded.push(file);
92
+ }
93
+ }, maxConcurrentUploads);
94
+ if (onRejectFiles && filesNotUploaded.length) {
95
+ onRejectFiles(filesNotUploaded, "upload-error");
96
+ }
97
+ setUploading(false);
98
+ }
99
+ };
100
+ useUpdateEffect(() => {
101
+ if (onChange) {
102
+ onChange({
103
+ target: {
104
+ name,
105
+ value: innerValue.map((file) => ({
106
+ ...file,
107
+ url: file.file
108
+ ? URL.createObjectURL(file.file)
109
+ : file.url,
110
+ })),
111
+ },
112
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
+ });
114
+ }
115
+ // eslint-disable-next-line react-hooks/exhaustive-deps
116
+ }, [innerValue]);
117
+ const handleDeleteClick = useCallback((clickedFile) => () => {
118
+ setInnerValue((value) => [
119
+ ...value.filter((file) => file !== clickedFile),
120
+ ]);
121
+ }, []);
122
+ return (<div data-input-name={name} data-error={error ? "" : undefined} data-loading={loading ? "" : undefined} className={clsx("relative data-loading:animate-pulse", className)} onMouseOver={onMouseOver} onMouseOut={onMouseOut}>
123
+ {label && (<label htmlFor={id} className={defaultLabelClassName}>
124
+ {label}
125
+ {required && (<>
126
+ {" "}
127
+ <span className="text-red-500">*</span>
128
+ </>)}
129
+ </label>)}
130
+ <div className={clsx("grid grid-cols-1 gap-4", {
131
+ "md:grid-cols-2": !!innerValue.length,
132
+ "min-h-[140px]": !!innerValue.length || !readOnly,
133
+ })}>
134
+ {paginatedValue.map((file, index) => (<PreviewFile key={index} file={file} readOnly={readOnly} handleDeleteClick={handleDeleteClick(file)} downloadText={downloadText} display={fileDisplay} openText={openText} additionalInfo={fileAdditionalInfo} index={index} className={previewFileClassName}/>))}
135
+ {innerValue.length > filesPerPage && (<Pagination className="col-span-2 mx-auto" currentPage={currentPage} totalItems={innerValue.length} onChangePage={setCurrentPage} itemsPerPage={filesPerPage}/>)}
136
+ {readOnly && !innerValue.length && (<Text variant="secondary">{emptyText}</Text>)}
137
+ {!readOnly && (!limit || innerValue.length < limit) && (<FileSelect {...props} className={fileSelectClassName} id={id} onAcceptFiles={handleAcceptFiles} limit={limit ? limit - innerValue.length : undefined} uploading={uploading} onRejectFiles={onRejectFiles} error={error}/>)}
138
+ </div>
139
+ {helpText && (<div className={clsx(defaultHelpTextClassName, "in-data-error:text-error-500")}>
140
+ {helpText}
141
+ </div>)}
142
+ </div>);
143
+ }
144
+ export default FileInput;
@@ -0,0 +1,13 @@
1
+ import { FileInputFile } from "./FileInput";
2
+ import { ReactNode } from "react";
3
+ export declare function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, openText, display, additionalInfo, index, className, }: {
4
+ file: FileInputFile;
5
+ readOnly?: boolean;
6
+ handleDeleteClick: () => void;
7
+ downloadText: string;
8
+ openText: string;
9
+ display?: "info" | "preview" | "both";
10
+ additionalInfo?: (file: FileInputFile, index: number) => ReactNode;
11
+ index: number;
12
+ className?: string;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,55 @@
1
+ import Group from "../Group";
2
+ import { ArrowDownTrayIcon, DocumentIcon } from "@heroicons/react/24/outline";
3
+ import Stack from "../Stack";
4
+ import Text from "../Text";
5
+ import numeral from "numeral";
6
+ import Button from "../Button";
7
+ import { ArrowTopRightOnSquareIcon, TrashIcon, } from "@heroicons/react/20/solid";
8
+ import clsx from "../../utils/clsx";
9
+ const videoExtensions = [".mp4"];
10
+ const imageExtensions = [".png", ".jpg", ".jpeg", ".webp"];
11
+ export function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, openText, display = "info", additionalInfo, index, className, }) {
12
+ const url = file.file
13
+ ? URL.createObjectURL(file.file)
14
+ : file.url;
15
+ const isVideo = file.type?.startsWith("video") ||
16
+ videoExtensions.some((e) => url.endsWith(e));
17
+ const isImage = file.type?.startsWith("image") ||
18
+ imageExtensions.some((e) => url.endsWith(e));
19
+ if (display === "preview" && !isVideo && !isImage) {
20
+ display = "info";
21
+ }
22
+ return (<div className={clsx("group relative flex flex-wrap items-center justify-center rounded-md bg-zinc-200 dark:bg-zinc-800", className)}>
23
+ {["preview", "both"].includes(display) &&
24
+ (isVideo ? (<video className="max-h-96 rounded-md" src={url} controls/>) : (
25
+ // eslint-disable-next-line @next/next/no-img-element
26
+ <img src={url} alt={file.description} className="max-h-96 rounded-md"/>))}
27
+ {["info", "both"].includes(display) && (<Group className="w-full items-center gap-0">
28
+ {display === "info" && (<div className="m-2 mr-0 rounded-lg bg-zinc-300 p-2 dark:bg-zinc-800">
29
+ <DocumentIcon className="h-5 w-5"/>
30
+ </div>)}
31
+ <Stack className="w-full overflow-hidden p-3">
32
+ <Stack className="gap-1">
33
+ <div className="flex-1 truncate" title={file.name}>
34
+ {file.name}
35
+ </div>
36
+ {file.description && <div>{file.description}</div>}
37
+ <Text size="sm">{file.type}</Text>
38
+ {!!file.size && (<Text size="sm">{numeral(file.size).format("0b")}</Text>)}
39
+ {!url.startsWith("blob") && (<Group className="mr-auto">
40
+ <Button leading={<ArrowTopRightOnSquareIcon />} href={url} target="_blank">
41
+ {openText}
42
+ </Button>
43
+ <Button leading={<ArrowDownTrayIcon />} href={url} download={file.name}>
44
+ {downloadText}
45
+ </Button>
46
+ </Group>)}
47
+ </Stack>
48
+ {additionalInfo && additionalInfo(file, index)}
49
+ </Stack>
50
+ </Group>)}
51
+ {!readOnly && (<Button icon variant="filled" color="default" className="absolute top-2 right-2 group-hover:opacity-100 sm:opacity-0" onClick={handleDeleteClick}>
52
+ <TrashIcon />
53
+ </Button>)}
54
+ </div>);
55
+ }
@@ -0,0 +1,3 @@
1
+ import FileInput from "./FileInput";
2
+ export * from "./FileInput";
3
+ export default FileInput;
@@ -0,0 +1,3 @@
1
+ import FileInput from "./FileInput";
2
+ export * from "./FileInput";
3
+ export default FileInput;
@@ -0,0 +1,31 @@
1
+ import { ReactElement, ReactNode, Ref } from "react";
2
+ export interface FileSelectProps {
3
+ uploadAFileText?: string;
4
+ orDragAndDropText?: string;
5
+ upToText?: string;
6
+ anyFileText?: string;
7
+ dropFilesHereText?: string;
8
+ uploadingText?: string;
9
+ maxFileSize?: number | string;
10
+ allowedFileTypes?: string[];
11
+ id?: string;
12
+ limit?: number;
13
+ onAcceptFiles: (files: File[]) => void;
14
+ onRejectFiles?: (files: File[], reason: "type" | "size") => void;
15
+ helperText?: string;
16
+ className?: string;
17
+ error?: boolean;
18
+ icon?: ReactElement<{
19
+ className?: string;
20
+ }>;
21
+ uploading?: boolean;
22
+ disabled?: boolean;
23
+ additionalBottomInfo?: ReactNode;
24
+ ref?: Ref<HTMLInputElement>;
25
+ innerClassName?: string;
26
+ }
27
+ declare function FileSelect({ maxFileSize, allowedFileTypes, id, limit, onAcceptFiles, className, uploadAFileText, orDragAndDropText, upToText, anyFileText, dropFilesHereText, uploadingText, icon, uploading, disabled, additionalBottomInfo, onRejectFiles, error, ref, innerClassName, }: FileSelectProps): import("react").JSX.Element;
28
+ export default FileSelect;
29
+ export declare function FileSelectProvider({ children }: {
30
+ children: ReactNode;
31
+ }): import("react").JSX.Element;
@@ -0,0 +1,143 @@
1
+ import { cloneElement, useCallback, useEffect, useId, useState, } from "react";
2
+ import clsx from "../../utils/clsx";
3
+ import { DndProvider, useDrop } from "react-dnd";
4
+ import { HTML5Backend, NativeTypes } from "react-dnd-html5-backend";
5
+ import numeral from "numeral";
6
+ import { ArrowUpTrayIcon } from "@heroicons/react/24/solid";
7
+ import { DocumentIcon } from "@heroicons/react/24/outline";
8
+ import Loading from "../Loading";
9
+ const translateAllowedType = (type) => ({
10
+ "image/png": "PNG",
11
+ ".png": "PNG",
12
+ "image/jpeg": "JPG",
13
+ ".jpg": "JPG",
14
+ ".jpeg": "JPG",
15
+ ".gif": "GIF",
16
+ "image/gif": "GIF",
17
+ "video/mp4": "MP4",
18
+ ".mp4": "MP4",
19
+ ".csv": "CSV",
20
+ "audio/mpeg": "MP3",
21
+ "application/pdf": "PDF",
22
+ "text/csv": "CSV",
23
+ "application/msword": "DOC",
24
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "DOCX",
25
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "PPTX",
26
+ ".webp": "WEBP",
27
+ "image/webp": "WEBP",
28
+ })[type] || type;
29
+ const defaultIcon = <DocumentIcon />;
30
+ function checkAllowedFileTypesFn(file, allowedFileTypes) {
31
+ return (!allowedFileTypes ||
32
+ allowedFileTypes.includes(file.type) ||
33
+ allowedFileTypes.some((t) => file.name.endsWith(t)));
34
+ }
35
+ function FileSelect({ maxFileSize, allowedFileTypes, id, limit, onAcceptFiles, className, uploadAFileText = "Upload a file", orDragAndDropText = "or drag and drop", upToText = "up to", anyFileText = "Any file", dropFilesHereText = "Drop files here", uploadingText = "Uploading...", icon = defaultIcon, uploading, disabled, additionalBottomInfo, onRejectFiles, error, ref, innerClassName, }) {
36
+ const innerId = useId();
37
+ id = id || innerId;
38
+ maxFileSize =
39
+ typeof maxFileSize === "string"
40
+ ? numeral(maxFileSize).value() || undefined
41
+ : maxFileSize;
42
+ maxFileSize = maxFileSize || numeral("10MB").value() || undefined;
43
+ const checkAllowedFileTypes = useCallback((file) => checkAllowedFileTypesFn(file, allowedFileTypes), [allowedFileTypes]);
44
+ const handleFileBrowse = (event) => {
45
+ if (!event.target.files) {
46
+ throw Error("Files is falsy");
47
+ }
48
+ const files = Array.from(event.target.files);
49
+ const acceptedFiles = files.filter((file) => checkAllowedFileTypes(file) && file.size <= maxFileSize);
50
+ if (onRejectFiles) {
51
+ const rejectedFilesType = files.filter((file) => !checkAllowedFileTypes(file));
52
+ if (rejectedFilesType.length) {
53
+ onRejectFiles(rejectedFilesType, "type");
54
+ }
55
+ const rejectedFilesSize = files.filter((file) => file.size > maxFileSize);
56
+ if (rejectedFilesSize.length) {
57
+ onRejectFiles(rejectedFilesSize, "size");
58
+ }
59
+ }
60
+ onAcceptFiles(acceptedFiles);
61
+ event.target.value = "";
62
+ };
63
+ const [pasteEnabled, setPasteEnabled] = useState(false);
64
+ useOnPasteFiles(pasteEnabled, onAcceptFiles, allowedFileTypes);
65
+ const [{ canDrop, isOver }, drop] = useDrop(() => ({
66
+ accept: [NativeTypes.FILE],
67
+ drop(item) {
68
+ if (!disabled) {
69
+ let files = item.files;
70
+ files = files.filter(checkAllowedFileTypes);
71
+ onAcceptFiles(files);
72
+ }
73
+ },
74
+ collect: (monitor) => ({
75
+ isOver: monitor.isOver(),
76
+ canDrop: monitor.canDrop(),
77
+ }),
78
+ }));
79
+ return (<div ref={(ref) => {
80
+ drop(ref);
81
+ }} className={clsx("flex justify-center rounded-md border-2 border-dashed px-6 pt-5 pb-6", "border-zinc-300 hover:border-zinc-400 dark:border-zinc-700 dark:hover:border-zinc-600", "data-is-over:border-primary-300 data-is-over:dark:border-primary-700", "data-disabled:cursor-not-allowed data-disabled:border-zinc-200", "data-error:border-error-500", className)} data-is-over={isOver || undefined} data-error={error || undefined} data-disabled={disabled || undefined} onMouseMove={!disabled ? () => setPasteEnabled(true) : undefined} onMouseOut={!disabled ? () => setPasteEnabled(false) : undefined}>
82
+ {uploading ? (<div className={clsx("flex flex-col items-center justify-center gap-2 text-center", innerClassName)}>
83
+ <Loading className={clsx("h-10 w-10", {
84
+ "text-primary-500": isOver,
85
+ })}/>
86
+ <div>{uploadingText}</div>
87
+ </div>) : !canDrop || disabled ? (<div className={clsx("relative flex flex-col items-center justify-center gap-2 text-center", innerClassName)}>
88
+ {cloneElement(icon, {
89
+ className: clsx("mx-auto h-12 w-12 text-zinc-400", icon.props.className),
90
+ })}
91
+ <div className="text-sm">
92
+ <label htmlFor={id} className={clsx("text-primary-600 focus-within:ring-primary-500 hover:text-primary-500 relative rounded-md font-medium focus-within:ring-2 focus-within:ring-offset-2 focus-within:outline-hidden dark:ring-offset-slate-900", {
93
+ "cursor-pointer": !disabled,
94
+ "cursor-not-allowed": disabled,
95
+ })}>
96
+ <span>{uploadAFileText}</span>
97
+ {!disabled && (<input id={id} name={id} type="file" className="sr-only" accept={allowedFileTypes?.join(",")} onChange={handleFileBrowse} multiple={limit !== 1} ref={ref}/>)}
98
+ </label>
99
+ <span className="pl-1">{orDragAndDropText}</span>
100
+ </div>
101
+ <p className="text-xs text-zinc-500">
102
+ {allowedFileTypes
103
+ ? allowedFileTypes.map(translateAllowedType).join(", ")
104
+ : anyFileText}{" "}
105
+ {upToText} {numeral(maxFileSize).format("0b")}
106
+ </p>
107
+ {additionalBottomInfo}
108
+ </div>) : (<div className={clsx("flex flex-col items-center justify-center gap-2 text-center", innerClassName)}>
109
+ <ArrowUpTrayIcon className={clsx("w-10 text-7xl", {
110
+ "text-primary-500": isOver,
111
+ })}/>
112
+ <div>{dropFilesHereText}</div>
113
+ </div>)}
114
+ </div>);
115
+ }
116
+ export default FileSelect;
117
+ const useOnPasteFiles = (enabled, onAcceptFiles, allowedFileTypes) => {
118
+ useEffect(() => {
119
+ if (enabled) {
120
+ document.onpaste = function (event) {
121
+ const items =
122
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
+ (event.clipboardData || event.originalEvent.clipboardData)
124
+ .items;
125
+ for (const index in items) {
126
+ const item = items[index];
127
+ if (item.kind === "file") {
128
+ const file = item.getAsFile();
129
+ if (checkAllowedFileTypesFn(file, allowedFileTypes)) {
130
+ onAcceptFiles([file]);
131
+ }
132
+ }
133
+ }
134
+ };
135
+ return () => {
136
+ document.onpaste = null;
137
+ };
138
+ }
139
+ }, [allowedFileTypes, enabled, onAcceptFiles]);
140
+ };
141
+ export function FileSelectProvider({ children }) {
142
+ return <DndProvider backend={HTML5Backend}>{children}</DndProvider>;
143
+ }