@infonomic/uikit 1.5.0 → 2.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 (370) hide show
  1. package/dist/components/button/button-group.d.ts +1 -1
  2. package/dist/components/button/button-group.d.ts.map +1 -1
  3. package/dist/components/button/button-group.js +1 -1
  4. package/dist/components/button/button.d.ts.map +1 -1
  5. package/dist/components/button/button.js +1 -1
  6. package/dist/components/button/control-buttons.d.ts.map +1 -1
  7. package/dist/components/button/control-buttons.js +3 -3
  8. package/dist/components/button/copy-button.d.ts.map +1 -1
  9. package/dist/components/button/copy-button.js +2 -2
  10. package/dist/components/button/icon-button.d.ts.map +1 -1
  11. package/dist/components/button/icon-button.js +1 -1
  12. package/dist/components/button/index.js +17 -1
  13. package/dist/components/card/card.d.ts.map +1 -1
  14. package/dist/components/dropdown/dropdown.d.ts +1 -1
  15. package/dist/components/dropdown/dropdown.d.ts.map +1 -1
  16. package/dist/components/input/checkbox.d.ts.map +1 -1
  17. package/dist/components/input/checkbox.js +4 -4
  18. package/dist/components/input/error-text.d.ts.map +1 -1
  19. package/dist/components/input/error-text.js +1 -1
  20. package/dist/components/input/help-text.d.ts.map +1 -1
  21. package/dist/components/input/help-text.js +1 -1
  22. package/dist/components/input/input-adornment.d.ts.map +1 -1
  23. package/dist/components/input/input-adornment.js +1 -1
  24. package/dist/components/input/input.d.ts.map +1 -1
  25. package/dist/components/input/input.js +3 -3
  26. package/dist/components/input/label.d.ts.map +1 -1
  27. package/dist/components/input/label.js +1 -1
  28. package/dist/components/input/radio-group.js +1 -1
  29. package/dist/components/input/select.d.ts +1 -1
  30. package/dist/components/input/select.d.ts.map +1 -1
  31. package/dist/components/input/select.js +3 -3
  32. package/dist/components/input/text-area.d.ts.map +1 -1
  33. package/dist/components/input/text-area.js +3 -3
  34. package/dist/components/notifications/alert.d.ts.map +1 -1
  35. package/dist/components/notifications/alert.js +2 -2
  36. package/dist/components/notifications/toast.js +4 -4
  37. package/dist/components/pager/ellipses.d.ts.map +1 -1
  38. package/dist/components/pager/ellipses.js +1 -1
  39. package/dist/components/pager/first-button.d.ts.map +1 -1
  40. package/dist/components/pager/first-button.js +2 -2
  41. package/dist/components/pager/last-button.d.ts.map +1 -1
  42. package/dist/components/pager/last-button.js +2 -2
  43. package/dist/components/pager/next-button.d.ts.map +1 -1
  44. package/dist/components/pager/next-button.js +2 -2
  45. package/dist/components/pager/number-button.d.ts.map +1 -1
  46. package/dist/components/pager/number-button.js +2 -2
  47. package/dist/components/pager/pagination.d.ts +1 -1
  48. package/dist/components/pager/pagination.d.ts.map +1 -1
  49. package/dist/components/pager/pagination.js +5 -5
  50. package/dist/components/pager/previous-button.d.ts.map +1 -1
  51. package/dist/components/pager/previous-button.js +2 -2
  52. package/dist/components/scroll-area/scroll-area.js +1 -1
  53. package/dist/components/table/table.d.ts.map +1 -1
  54. package/dist/components/table/table.js +2 -2
  55. package/dist/components/tabs/tabs.d.ts +1 -1
  56. package/dist/components/tabs/tabs.d.ts.map +1 -1
  57. package/dist/components/tabs/tabs.js +1 -1
  58. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  59. package/dist/icons/index.js +1 -17
  60. package/package.json +9 -5
  61. package/src/astro.d.ts +43 -0
  62. package/src/astro.js +2 -2
  63. package/src/components/@types/shared.ts +24 -0
  64. package/src/components/accordion/accordion.module.css +60 -0
  65. package/src/components/accordion/accordion.stories.tsx +117 -0
  66. package/src/components/accordion/accordion.tsx +105 -0
  67. package/src/components/animation/fade-in-lift.stories.tsx +81 -0
  68. package/src/components/animation/fade-in-lift.tsx +42 -0
  69. package/src/components/avatar/avatar.module.css +54 -0
  70. package/src/components/avatar/avatar.stories.tsx +28 -0
  71. package/src/components/avatar/avatar.tsx +19 -0
  72. package/src/components/button/@types/button.ts +17 -0
  73. package/src/components/button/button-group.module.css +17 -0
  74. package/src/components/button/button-group.stories.tsx +45 -0
  75. package/src/components/button/button-group.tsx +132 -0
  76. package/src/components/button/button-icon.stories.tsx +145 -0
  77. package/src/components/button/button-intents.stories.tsx +50 -0
  78. package/src/components/button/button-variants.stories.tsx +60 -0
  79. package/src/components/button/button.astro +86 -0
  80. package/src/components/button/button.module.css +533 -0
  81. package/src/components/button/button.tsx +81 -0
  82. package/src/components/button/control-buttons.module.css +144 -0
  83. package/src/components/button/control-buttons.stories.tsx +60 -0
  84. package/src/components/button/control-buttons.tsx +137 -0
  85. package/src/components/button/copy-button.module.css +31 -0
  86. package/src/components/button/copy-button.stories.tsx +50 -0
  87. package/src/components/button/copy-button.tsx +92 -0
  88. package/src/components/button/icon-button.astro +47 -0
  89. package/src/components/button/icon-button.tsx +44 -0
  90. package/src/components/button/index.ts +5 -0
  91. package/src/components/calendar/calendar.module.css +315 -0
  92. package/src/components/calendar/calendar.stories.tsx +139 -0
  93. package/src/components/calendar/calendar.tsx +173 -0
  94. package/src/components/card/card-content.astro +14 -0
  95. package/src/components/card/card-description.astro +14 -0
  96. package/src/components/card/card-footer.astro +14 -0
  97. package/src/components/card/card-header.astro +14 -0
  98. package/src/components/card/card-title.astro +14 -0
  99. package/src/components/card/card.astro +41 -0
  100. package/src/components/card/card.module.css +67 -0
  101. package/src/components/card/card.stories.tsx +61 -0
  102. package/src/components/card/card.tsx +86 -0
  103. package/src/components/container/container.astro +13 -0
  104. package/src/components/container/container.module.css +28 -0
  105. package/src/components/container/container.stories.tsx +42 -0
  106. package/src/components/container/container.tsx +23 -0
  107. package/src/components/dropdown/dropdown.module.css +131 -0
  108. package/src/components/dropdown/dropdown.stories.tsx +103 -0
  109. package/src/components/dropdown/dropdown.tsx +193 -0
  110. package/src/components/hamburger/hamburger.astro +30 -0
  111. package/src/components/hamburger/hamburger.tsx +66 -0
  112. package/src/components/input/@types/checkbox.ts +20 -0
  113. package/src/components/input/@types/input.ts +20 -0
  114. package/src/components/input/checkbox-group.tsx +78 -0
  115. package/src/components/input/checkbox.module.css +267 -0
  116. package/src/components/input/checkbox.stories.tsx +240 -0
  117. package/src/components/input/checkbox.tsx +95 -0
  118. package/src/components/input/error-text.astro +14 -0
  119. package/src/components/input/error-text.module.css +19 -0
  120. package/src/components/input/error-text.tsx +18 -0
  121. package/src/components/input/errors.tsx +37 -0
  122. package/src/components/input/help-text.astro +13 -0
  123. package/src/components/input/help-text.module.css +19 -0
  124. package/src/components/input/help-text.tsx +13 -0
  125. package/src/components/input/index.tsx +8 -0
  126. package/src/components/input/input-adornment.astro +26 -0
  127. package/src/components/input/input-adornment.module.css +18 -0
  128. package/src/components/input/input-adornment.tsx +36 -0
  129. package/src/components/input/input.astro +99 -0
  130. package/src/components/input/input.module.css +310 -0
  131. package/src/components/input/input.stories.tsx +174 -0
  132. package/src/components/input/input.tsx +103 -0
  133. package/src/components/input/label.astro +24 -0
  134. package/src/components/input/label.module.css +28 -0
  135. package/src/components/input/label.tsx +25 -0
  136. package/src/components/input/radio-group.module.css +219 -0
  137. package/src/components/input/radio-group.stories.tsx +73 -0
  138. package/src/components/input/radio-group.tsx +67 -0
  139. package/src/components/input/select.module.css +75 -0
  140. package/src/components/input/select.stories.tsx +34 -0
  141. package/src/components/input/select.tsx +115 -0
  142. package/src/components/input/text-area.module.css +9 -0
  143. package/src/components/input/text-area.stories.tsx +51 -0
  144. package/src/components/input/text-area.tsx +81 -0
  145. package/src/components/input/utils.ts +21 -0
  146. package/src/components/notifications/@types/alert.ts +12 -0
  147. package/src/components/notifications/@types/toast.ts +12 -0
  148. package/src/components/notifications/alert.module.css +114 -0
  149. package/src/components/notifications/alert.stories.tsx +39 -0
  150. package/src/components/notifications/alert.tsx +117 -0
  151. package/src/components/notifications/index.ts +2 -0
  152. package/src/components/notifications/toast.module.css +237 -0
  153. package/src/components/notifications/toast.stories.tsx +42 -0
  154. package/src/components/notifications/toast.tsx +124 -0
  155. package/src/components/overlay/index.stories.tsx +29 -0
  156. package/src/components/overlay/index.ts +2 -0
  157. package/src/components/overlay/overlay.module.css +41 -0
  158. package/src/components/overlay/overlay.tsx +61 -0
  159. package/src/components/pager/@types/index.ts +2 -0
  160. package/src/components/pager/ellipses.tsx +18 -0
  161. package/src/components/pager/event-pager.tsx +18 -0
  162. package/src/components/pager/first-button.tsx +53 -0
  163. package/src/components/pager/hooks/types/usePagination.ts +80 -0
  164. package/src/components/pager/hooks/usePagination.ts +140 -0
  165. package/src/components/pager/icons/first.tsx +33 -0
  166. package/src/components/pager/icons/index.tsx +4 -0
  167. package/src/components/pager/icons/last.tsx +33 -0
  168. package/src/components/pager/icons/next.tsx +20 -0
  169. package/src/components/pager/icons/previous.tsx +20 -0
  170. package/src/components/pager/index.ts +4 -0
  171. package/src/components/pager/last-button.tsx +57 -0
  172. package/src/components/pager/next-button.tsx +55 -0
  173. package/src/components/pager/number-button.tsx +83 -0
  174. package/src/components/pager/pagination.module.css +165 -0
  175. package/src/components/pager/pagination.stories.tsx +190 -0
  176. package/src/components/pager/pagination.tsx +266 -0
  177. package/src/components/pager/previous-button.tsx +51 -0
  178. package/src/components/scroll-area/scroll-area.module.css +80 -0
  179. package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
  180. package/src/components/scroll-area/scroll-area.tsx +22 -0
  181. package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
  182. package/src/components/section/section.astro +13 -0
  183. package/src/components/section/section.module.css +7 -0
  184. package/src/components/section/section.tsx +23 -0
  185. package/src/components/shimmer/shimmer.module.css +53 -0
  186. package/src/components/shimmer/shimmer.stories.tsx +24 -0
  187. package/src/components/shimmer/shimmer.tsx +70 -0
  188. package/src/components/table/table.module.css +100 -0
  189. package/src/components/table/table.stories.tsx +95 -0
  190. package/src/components/table/table.tsx +165 -0
  191. package/src/components/tabs/tabs.module.css +64 -0
  192. package/src/components/tabs/tabs.stories.tsx +47 -0
  193. package/src/components/tabs/tabs.tsx +75 -0
  194. package/src/components/timeline/timeline.module.css +87 -0
  195. package/src/components/timeline/timeline.stories.tsx +50 -0
  196. package/src/components/timeline/timeline.tsx +177 -0
  197. package/src/components/tooltip/tooltip.module.css +55 -0
  198. package/src/components/tooltip/tooltip.stories.tsx +59 -0
  199. package/src/components/tooltip/tooltip.tsx +51 -0
  200. package/src/declarations.d.ts +4 -0
  201. package/src/hooks/use-media-query.ts +20 -0
  202. package/src/icons/activity-icon.tsx +40 -0
  203. package/src/icons/calendar-icon.tsx +39 -0
  204. package/src/icons/check-icon.tsx +33 -0
  205. package/src/icons/chevron-down-icon.tsx +39 -0
  206. package/src/icons/chevron-left-double-icon.tsx +58 -0
  207. package/src/icons/chevron-left-icon.tsx +58 -0
  208. package/src/icons/chevron-right-double-icon.tsx +58 -0
  209. package/src/icons/chevron-right-icon.tsx +58 -0
  210. package/src/icons/chevrons-up-down.tsx +37 -0
  211. package/src/icons/close-icon.astro +38 -0
  212. package/src/icons/close-icon.tsx +30 -0
  213. package/src/icons/copy-icon.tsx +35 -0
  214. package/src/icons/danger-icon.tsx +18 -0
  215. package/src/icons/dashboard-icon.tsx +41 -0
  216. package/src/icons/delete-icon.tsx +34 -0
  217. package/src/icons/document-icon.tsx +38 -0
  218. package/src/icons/download-icon.tsx +39 -0
  219. package/src/icons/edit-icon.tsx +35 -0
  220. package/src/icons/ellipsis-icon.tsx +38 -0
  221. package/src/icons/email-icon.tsx +33 -0
  222. package/src/icons/external-link-icon.tsx +39 -0
  223. package/src/icons/github-icon.tsx +27 -0
  224. package/src/icons/globe-icon.tsx +50 -0
  225. package/src/icons/google-icon.tsx +44 -0
  226. package/src/icons/gripper-vertical-icon.tsx +43 -0
  227. package/src/icons/history-icon.tsx +32 -0
  228. package/src/icons/home-icon.tsx +34 -0
  229. package/src/icons/icon-element.astro +27 -0
  230. package/src/icons/icon-element.tsx +32 -0
  231. package/src/icons/icon-sprite.tsx +18 -0
  232. package/src/icons/icons.module.css +147 -0
  233. package/src/icons/index.stories.tsx +25 -0
  234. package/src/icons/index.ts +39 -0
  235. package/src/icons/info-icon.tsx +18 -0
  236. package/src/icons/infonomic-icon.tsx +173 -0
  237. package/src/icons/light-icon.astro +36 -0
  238. package/src/icons/light-icon.tsx +29 -0
  239. package/src/icons/location-pin-icon.tsx +36 -0
  240. package/src/icons/moon-icon.astro +38 -0
  241. package/src/icons/moon-icon.tsx +42 -0
  242. package/src/icons/plus-icon.tsx +34 -0
  243. package/src/icons/primary-icon.tsx +22 -0
  244. package/src/icons/refresh-icon.tsx +33 -0
  245. package/src/icons/return-icon.tsx +36 -0
  246. package/src/icons/roles-icon.tsx +34 -0
  247. package/src/icons/search-icon.astro +40 -0
  248. package/src/icons/search-icon.tsx +29 -0
  249. package/src/icons/search-menu-icon.tsx +42 -0
  250. package/src/icons/settings-gear-icon.tsx +36 -0
  251. package/src/icons/settings-sliders-icon.tsx +43 -0
  252. package/src/icons/sign-out-icon.tsx +35 -0
  253. package/src/icons/source/icon-calendar.svg +1 -0
  254. package/src/icons/source/icon-check.svg +4 -0
  255. package/src/icons/source/icon-close.svg +3 -0
  256. package/src/icons/source/icon-coinbase.svg +9 -0
  257. package/src/icons/source/icon-copy.svg +4 -0
  258. package/src/icons/source/icon-document.svg +5 -0
  259. package/src/icons/source/icon-download.svg +4 -0
  260. package/src/icons/source/icon-edit.svg +6 -0
  261. package/src/icons/source/icon-eth-purple.svg +15 -0
  262. package/src/icons/source/icon-etherscan.svg +5 -0
  263. package/src/icons/source/icon-external-link.svg +4 -0
  264. package/src/icons/source/icon-globe.svg +7 -0
  265. package/src/icons/source/icon-gripper-vertical.svg +9 -0
  266. package/src/icons/source/icon-info.svg +4 -0
  267. package/src/icons/source/icon-infonomic.svg +43 -0
  268. package/src/icons/source/icon-ledger.svg +4 -0
  269. package/src/icons/source/icon-light.svg +3 -0
  270. package/src/icons/source/icon-location-pin.svg +8 -0
  271. package/src/icons/source/icon-logout.svg +6 -0
  272. package/src/icons/source/icon-metamask.svg +32 -0
  273. package/src/icons/source/icon-moon.svg +3 -0
  274. package/src/icons/source/icon-plus.svg +4 -0
  275. package/src/icons/source/icon-refresh.svg +4 -0
  276. package/src/icons/source/icon-return.svg +4 -0
  277. package/src/icons/source/icon-search-menu.svg +13 -0
  278. package/src/icons/source/icon-search.svg +3 -0
  279. package/src/icons/source/icon-settings-gear.svg +5 -0
  280. package/src/icons/source/icon-settings.svg +12 -0
  281. package/src/icons/source/icon-wallet.svg +3 -0
  282. package/src/icons/source/icon-walletconnect.svg +4 -0
  283. package/src/icons/source/icon-x.svg +4 -0
  284. package/src/icons/stopwatch-icon.tsx +39 -0
  285. package/src/icons/success-icon.tsx +18 -0
  286. package/src/icons/types/icon.ts +8 -0
  287. package/src/icons/user-icon.tsx +33 -0
  288. package/src/icons/users-icon.tsx +35 -0
  289. package/src/icons/wallet-icon.tsx +29 -0
  290. package/src/icons/warning-icon.tsx +18 -0
  291. package/src/icons/x-icon.tsx +33 -0
  292. package/src/loaders/ellipses.tsx +36 -0
  293. package/src/loaders/loaders.stories.tsx +46 -0
  294. package/src/loaders/ring.tsx +33 -0
  295. package/src/loaders/spinner.tsx +28 -0
  296. package/src/loaders/types/index.ts +6 -0
  297. package/src/react.ts +99 -0
  298. package/src/styles/base/animations.css +143 -0
  299. package/src/styles/base/base.css +5 -0
  300. package/src/styles/base/colors.css +163 -0
  301. package/src/styles/base/colors.stories.tsx +671 -0
  302. package/src/styles/base/reset.css +464 -0
  303. package/src/styles/base/typography.css +25 -0
  304. package/src/styles/base/vars.css +188 -0
  305. package/src/styles/components/card.css +20 -0
  306. package/src/styles/components/checkbox.css +55 -0
  307. package/src/styles/components/components.css +11 -0
  308. package/src/styles/components/directional-button.css +92 -0
  309. package/src/styles/components/dropdown.css +19 -0
  310. package/src/styles/components/fade-in-lift.css +13 -0
  311. package/src/styles/components/hamburger.css +107 -0
  312. package/src/styles/components/icon-element.css +4 -0
  313. package/src/styles/components/list-checkbox.css +60 -0
  314. package/src/styles/components/loaders.css +196 -0
  315. package/src/styles/components/popover.css +15 -0
  316. package/src/styles/components/scroll-to-top.css +89 -0
  317. package/src/styles/components/toast.css +18 -0
  318. package/src/styles/styles.css +6 -0
  319. package/src/styles/theme/autofill.css +58 -0
  320. package/src/styles/theme/scrollers.css +52 -0
  321. package/src/styles/theme/theme.css +130 -0
  322. package/src/styles/theme/theme.stories.tsx +33 -0
  323. package/src/styles/typography/code.stories.tsx +76 -0
  324. package/src/styles/typography/default.stories.tsx +51 -0
  325. package/src/styles/typography/fonts.css +30 -0
  326. package/src/styles/typography/lists.stories.tsx +50 -0
  327. package/src/styles/typography/prose.css +404 -0
  328. package/src/styles/typography/quote.stories.tsx +37 -0
  329. package/src/styles/typography.css +24 -0
  330. package/src/styles/utils/scroll-layout-shift.css +9 -0
  331. package/src/styles/utils/utility-classes.css +1278 -0
  332. package/src/styles/utils/utils.css +2 -0
  333. package/src/theme/theme-provider/index.ts +1 -0
  334. package/src/theme/theme-provider/provider.tsx +44 -0
  335. package/src/utils/capitalize.ts +6 -0
  336. package/src/utils/externalLinkProps.ts +6 -0
  337. package/src/utils/findMatch.ts +7 -0
  338. package/src/utils/getPortalRoot.ts +3 -0
  339. package/src/utils/isTouchDevice.ts +11 -0
  340. package/src/utils/objectsToArray.ts +15 -0
  341. package/src/utils/objectsToString.ts +5 -0
  342. package/src/utils/polymorphic.ts +16 -0
  343. package/src/utils/to-kebab-case.ts +5 -0
  344. package/src/widgets/datepicker/datepicker.module.css +189 -0
  345. package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
  346. package/src/widgets/datepicker/datepicker.tsx +310 -0
  347. package/src/widgets/drawer/drawer-container.tsx +26 -0
  348. package/src/widgets/drawer/drawer-content.tsx +26 -0
  349. package/src/widgets/drawer/drawer-context.tsx +49 -0
  350. package/src/widgets/drawer/drawer-header.tsx +27 -0
  351. package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
  352. package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
  353. package/src/widgets/drawer/drawer.module.css +116 -0
  354. package/src/widgets/drawer/drawer.stories.tsx +224 -0
  355. package/src/widgets/drawer/drawer.tsx +115 -0
  356. package/src/widgets/drawer/motionDomAnimation.ts +4 -0
  357. package/src/widgets/drawer/motionDomMax.ts +4 -0
  358. package/src/widgets/modal/modal-actions.tsx +26 -0
  359. package/src/widgets/modal/modal-container.tsx +26 -0
  360. package/src/widgets/modal/modal-content.tsx +26 -0
  361. package/src/widgets/modal/modal-header.tsx +27 -0
  362. package/src/widgets/modal/modal-wrapper.tsx +50 -0
  363. package/src/widgets/modal/modal.module.css +85 -0
  364. package/src/widgets/modal/modal.stories.tsx +71 -0
  365. package/src/widgets/modal/modal.tsx +110 -0
  366. package/src/widgets/modal/motionDomAnimation.ts +4 -0
  367. package/src/widgets/modal/motionDomMax.ts +4 -0
  368. package/src/widgets/search/index.ts +1 -0
  369. package/src/widgets/search/search.stories.tsx +18 -0
  370. package/src/widgets/search/search.tsx +186 -0
@@ -0,0 +1,266 @@
1
+ 'use client'
2
+
3
+ import cx from 'classnames'
4
+ // usePagination hook from...
5
+ // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/usePagination/usePagination.js
6
+ // https://github.com/mui/material-ui/blob/master/LICENSE
7
+ /* eslint-disable react/jsx-pascal-case */
8
+ import React, { useContext } from 'react'
9
+ import type { Variant } from './@types'
10
+
11
+ import { Ellipses } from './ellipses.js'
12
+ import { FirstButton } from './first-button'
13
+ import type { UsePaginationItem, UsePaginationProps } from './hooks/types/usePagination'
14
+ import { usePagination } from './hooks/usePagination'
15
+ import { LastButton } from './last-button'
16
+ import { NextButton } from './next-button'
17
+ import { NumberButton } from './number-button'
18
+ import styles from './pagination.module.css'
19
+ import { PreviousButton } from './previous-button'
20
+
21
+ const PAGINATION_NAME = 'Pagination'
22
+ const ROOT_NAME = 'Root'
23
+ const PAGER_NAME = 'Pager'
24
+
25
+ export interface PagerContextType {
26
+ variant: Variant
27
+ count: number
28
+ currentPage: number
29
+ hideNextButton?: boolean
30
+ hidePrevButton?: boolean
31
+ items: UsePaginationItem[]
32
+ showFirstButton?: boolean
33
+ showLastButton?: boolean
34
+ eventsEnabled?: boolean
35
+ }
36
+
37
+ export const PagerContext = React.createContext<PagerContextType>({
38
+ variant: 'default',
39
+ count: 1,
40
+ currentPage: 1,
41
+ hideNextButton: false,
42
+ hidePrevButton: false,
43
+ items: [],
44
+ showFirstButton: false,
45
+ showLastButton: false,
46
+ eventsEnabled: false,
47
+ })
48
+
49
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
+ // Pagination
51
+
52
+ /**
53
+ * See ./hooks/types/usePagination.ts
54
+ */
55
+ export interface PaginationProps extends UsePaginationProps {
56
+ className?: string
57
+ 'aria-label'?: string
58
+ variant?: Variant
59
+ children?: React.ReactNode
60
+ }
61
+
62
+ export const Pagination = ({
63
+ children,
64
+ variant = 'default',
65
+ ...rest
66
+ }: PaginationProps): React.JSX.Element => {
67
+ const { items } = usePagination({
68
+ ...rest,
69
+ })
70
+
71
+ const {
72
+ count,
73
+ page: currentPage,
74
+ hideNextButton,
75
+ hidePrevButton,
76
+ showFirstButton,
77
+ showLastButton,
78
+ onChange,
79
+ } = rest
80
+
81
+ const eventsEnabled = onChange != null
82
+
83
+ const context = React.useMemo(() => {
84
+ return {
85
+ variant,
86
+ items,
87
+ count,
88
+ currentPage,
89
+ hideNextButton,
90
+ hidePrevButton,
91
+ showFirstButton,
92
+ showLastButton,
93
+ eventsEnabled,
94
+ }
95
+ }, [
96
+ variant,
97
+ items,
98
+ count,
99
+ currentPage,
100
+ hideNextButton,
101
+ hidePrevButton,
102
+ showFirstButton,
103
+ showLastButton,
104
+ eventsEnabled,
105
+ ])
106
+
107
+ return <PagerContext value={context}>{children}</PagerContext>
108
+ }
109
+
110
+ Pagination.displayName = PAGINATION_NAME
111
+
112
+ // Hook helper usePager
113
+ export function usePager(): PagerContextType {
114
+ const context = useContext(PagerContext)
115
+ if (context === undefined) {
116
+ throw new Error('usePager must be used within a PagerContext')
117
+ }
118
+ return context
119
+ }
120
+
121
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
+ // First, Previous, Next, Last and Page number buttons
123
+
124
+ // Define the ref type based on asChild prop
125
+ export type RefType = React.Ref<HTMLButtonElement> | React.Ref<HTMLElement>
126
+
127
+ // Your existing types...
128
+ type AsButton = { asChild?: false } & React.ComponentRef<'button'>
129
+
130
+ // Or AsSlot
131
+ interface AsSlot {
132
+ asChild?: true
133
+ }
134
+
135
+ export type PagerButtonProps = {
136
+ className?: string
137
+ disabled?: boolean
138
+ children?: React.ReactNode
139
+ onClick?: React.ReactEventHandler<Element> | undefined
140
+ } & (AsButton | AsSlot)
141
+
142
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143
+ // Pager container component
144
+ export interface PagerProps {
145
+ children?: React.ReactNode
146
+ renderFirst?: (key: string, item: UsePaginationItem) => React.ReactNode
147
+ renderPrevious?: (key: string, item: UsePaginationItem) => React.ReactNode
148
+ renderPageNumber?: (key: string, item: UsePaginationItem) => React.ReactNode
149
+ renderNext?: (key: string, item: UsePaginationItem) => React.ReactNode
150
+ renderLast?: (key: string, item: UsePaginationItem, count: number) => React.ReactNode
151
+ renderEllipses?: (key: string) => React.ReactNode
152
+ }
153
+
154
+ const Pager = ({
155
+ renderFirst = (key, item) => (
156
+ <Pagination.First key={key} disabled={item.disabled} onClick={item.onClick} />
157
+ ),
158
+ renderPrevious = (key, item) => (
159
+ <Pagination.Previous key={key} disabled={item.disabled} onClick={item.onClick} />
160
+ ),
161
+ renderPageNumber = (key, item) => (
162
+ <Pagination.Number
163
+ key={key}
164
+ page={item.page}
165
+ disabled={item.disabled}
166
+ selected={item.selected}
167
+ activeClassName="active"
168
+ onClick={item.onClick}
169
+ />
170
+ ),
171
+ renderNext = (key, item) => (
172
+ <Pagination.Next key={key} page={item.page} disabled={item.disabled} onClick={item.onClick} />
173
+ ),
174
+ renderLast = (key, item, count) => (
175
+ <Pagination.Last key={key} disabled={item.disabled} count={count} onClick={item.onClick} />
176
+ ),
177
+ renderEllipses = (key) => <Ellipses key={key} />,
178
+ }: PagerProps): React.JSX.Element => {
179
+ const { items, count } = React.useContext(PagerContext)
180
+
181
+ return (
182
+ <>
183
+ {items.map((item, index) => {
184
+ const key = `${item.page}-${index}`
185
+ switch (item.type) {
186
+ case 'start-ellipsis':
187
+ case 'end-ellipsis':
188
+ return renderEllipses(key)
189
+ case 'first':
190
+ return renderFirst(key, item)
191
+ case 'previous':
192
+ return renderPrevious(key, item)
193
+ case 'page':
194
+ return renderPageNumber(key, item)
195
+ case 'next':
196
+ return renderNext(key, item)
197
+ case 'last':
198
+ return renderLast(key, item, count)
199
+ default:
200
+ return null
201
+ }
202
+ })}
203
+ </>
204
+ )
205
+ }
206
+
207
+ Pager.displayName = PAGER_NAME
208
+
209
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210
+ // Root
211
+ export type RootElement = React.ComponentRef<'nav'>
212
+ type PrimitiveRootProps = React.ComponentPropsWithoutRef<'nav'>
213
+
214
+ export interface RootProps extends PrimitiveRootProps {
215
+ className?: string
216
+ itemsClassName?: string
217
+ dataTestId?: string
218
+ ariaLabel?: string
219
+ children?: React.ReactNode
220
+ }
221
+
222
+ const Root = ({
223
+ ref,
224
+ className,
225
+ itemsClassName,
226
+ children,
227
+ ariaLabel,
228
+ dataTestId,
229
+ ...rest
230
+ }: RootProps & {
231
+ ref?: React.RefObject<RootElement>
232
+ }) => {
233
+ const { variant } = usePager()
234
+
235
+ return (
236
+ <nav
237
+ data-testid={dataTestId}
238
+ ref={ref}
239
+ className={cx('pagination-root', styles['pagination-root'], 'pagination-root', className)}
240
+ {...rest}
241
+ aria-label={ariaLabel ?? 'Pager navigation'}
242
+ >
243
+ <ul
244
+ className={cx(
245
+ 'pagination-items',
246
+ styles['pagination-items'],
247
+ styles[variant],
248
+ itemsClassName
249
+ )}
250
+ >
251
+ {children}
252
+ </ul>
253
+ </nav>
254
+ )
255
+ }
256
+
257
+ Root.displayName = ROOT_NAME
258
+
259
+ Pagination.Pager = Pager
260
+ Pagination.Root = Root
261
+ Pagination.First = FirstButton
262
+ Pagination.Previous = PreviousButton
263
+ Pagination.Number = NumberButton
264
+ Pagination.Next = NextButton
265
+ Pagination.Last = LastButton
266
+ Pagination.Ellipses = Ellipses
@@ -0,0 +1,51 @@
1
+ 'use client'
2
+
3
+ import { ChevronLeftIcon } from '@radix-ui/react-icons'
4
+ import { Slot } from '@radix-ui/react-slot'
5
+ import cx from 'classnames'
6
+ import type React from 'react'
7
+ import type { PagerButtonProps, RefType } from './pagination'
8
+ import { usePager } from './pagination'
9
+
10
+ import styles from './pagination.module.css'
11
+
12
+ export const PreviousButton = ({
13
+ ref,
14
+ className,
15
+ disabled,
16
+ asChild,
17
+ children,
18
+ ...rest
19
+ }: PagerButtonProps & {
20
+ ref?: React.RefObject<RefType>
21
+ }) => {
22
+ const Comp = asChild != null ? Slot : ('button' as React.ElementType)
23
+ const { showFirstButton, variant } = usePager()
24
+
25
+ const aria = disabled ? { 'aria-disabled': true } : { 'aria-label': 'Previous' }
26
+
27
+ return (
28
+ <li className={styles['mobile-toggle']}>
29
+ <Comp
30
+ ref={ref}
31
+ className={cx(
32
+ styles['previous-button'],
33
+ styles[variant],
34
+
35
+ { [styles['rounded-left']]: showFirstButton == null || showFirstButton === false },
36
+ 'pagination-previous',
37
+ className
38
+ )}
39
+ disabled={disabled}
40
+ title="Previous"
41
+ data-testid="pagination-previous"
42
+ {...aria}
43
+ {...rest}
44
+ >
45
+ {(asChild ?? false) ? children : <ChevronLeftIcon />}
46
+ </Comp>
47
+ </li>
48
+ )
49
+ }
50
+
51
+ PreviousButton.displayName = 'PreviousButton'
@@ -0,0 +1,80 @@
1
+ @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
2
+
3
+ @layer infonomic-components {
4
+ .root {
5
+ border-radius: 4px;
6
+ overflow: hidden;
7
+ background-color: inherit;
8
+ --scrollbar-size: 10px;
9
+ }
10
+
11
+ .viewport {
12
+ width: 100%;
13
+ height: 100%;
14
+ border-radius: inherit;
15
+ }
16
+
17
+ .scrollbar {
18
+ display: flex;
19
+ /* ensures no selection */
20
+ user-select: none;
21
+ /* disable browser handling of all panning and zooming gestures on touch devices */
22
+ touch-action: none;
23
+ padding: 2px;
24
+ background: var(--gray-50);
25
+ transition: background 160ms ease-out;
26
+
27
+ &:hover {
28
+ background: var(--gray-50);
29
+ }
30
+
31
+ &[data-orientation="vertical"] {
32
+ width: var(--scrollbar-size);
33
+ }
34
+
35
+ &[data-orientation="horizontal"] {
36
+ flex-direction: column;
37
+ height: var(--scrollbar-size);
38
+ }
39
+ }
40
+
41
+ .scrollbar:is(:global(.dark) *) {
42
+ background: var(--canvas-700);
43
+
44
+ &:hover {
45
+ background: var(--canvas-700);
46
+ }
47
+ }
48
+
49
+ .thumb {
50
+ flex: 1;
51
+ background: var(--primary-100);
52
+ border-radius: var(--border-radius-sm);
53
+ position: relative;
54
+
55
+ /* increase target size for touch devices https://www.w3.org/WAI/WCAG21/Understanding/target-size.html */
56
+ &::before {
57
+ content: "";
58
+ position: absolute;
59
+ top: 50%;
60
+ left: 50%;
61
+ transform: translate(-50%, -50%);
62
+ width: 100%;
63
+ height: 100%;
64
+ min-width: 44px;
65
+ min-height: 44px;
66
+ }
67
+ }
68
+
69
+ .thumb:is(:global(.dark) *) {
70
+ background: var(--primary-400);
71
+ }
72
+
73
+ .corner {
74
+ background: var(--gray-50);
75
+ }
76
+
77
+ .corner:is(:global(.dark) *) {
78
+ background: var(--canvas-700);
79
+ }
80
+ }
@@ -0,0 +1,33 @@
1
+ import type { Meta } from '@storybook/react-vite'
2
+
3
+ import { ScrollArea as ScrollAreaComponent } from './scroll-area.js'
4
+
5
+ const meta: Meta<typeof ScrollAreaComponent> = {
6
+ /* 👇 The title prop is optional.
7
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
8
+ * to learn how to generate automatic titles
9
+ */
10
+ title: 'Components/ScrollArea',
11
+ component: ScrollAreaComponent,
12
+ }
13
+
14
+ export default meta
15
+
16
+ const TAGS = Array.from({ length: 50 }).map((_, i, a) => `v1.2.0-beta.${a.length - i}`)
17
+
18
+ export const ScrollArea = (): React.JSX.Element => {
19
+ return (
20
+ <div style={{ height: '100vh' }}>
21
+ <ScrollAreaComponent
22
+ style={{ width: '200px', height: '300px', margin: '0 auto', border: '1px solid #ccc' }}
23
+ >
24
+ <div style={{ padding: '15px 20px' }}>
25
+ <div>Tags</div>
26
+ {TAGS.map((tag) => (
27
+ <div key={tag}>{tag}</div>
28
+ ))}
29
+ </div>
30
+ </ScrollAreaComponent>
31
+ </div>
32
+ )
33
+ }
@@ -0,0 +1,22 @@
1
+ import cx from 'classnames'
2
+ import { ScrollArea as ScrollAreaPrimitive } from 'radix-ui'
3
+
4
+ import type React from 'react'
5
+ import styles from './scroll-area.module.css'
6
+
7
+ interface ScrollAreaProps extends React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> {}
8
+
9
+ export const ScrollArea = ({ children, style, className }: ScrollAreaProps) => (
10
+ <ScrollAreaPrimitive.Root style={style} className={cx('scroll-area', styles.root, className)}>
11
+ <ScrollAreaPrimitive.Viewport className={styles.viewport}>
12
+ {children}
13
+ </ScrollAreaPrimitive.Viewport>
14
+ <ScrollAreaPrimitive.Scrollbar className={styles.scrollbar} orientation="vertical">
15
+ <ScrollAreaPrimitive.Thumb className={styles.thumb} />
16
+ </ScrollAreaPrimitive.Scrollbar>
17
+ <ScrollAreaPrimitive.Scrollbar className={styles.scrollbar} orientation="horizontal">
18
+ <ScrollAreaPrimitive.Thumb className={styles.thumb} />
19
+ </ScrollAreaPrimitive.Scrollbar>
20
+ <ScrollAreaPrimitive.Corner className={styles.corner} />
21
+ </ScrollAreaPrimitive.Root>
22
+ )
@@ -0,0 +1,59 @@
1
+ 'use client'
2
+
3
+ import type React from 'react'
4
+ import { useEffect, useState } from 'react'
5
+
6
+ type ScrollToTopIntrinsicProps = React.JSX.IntrinsicElements['button']
7
+ interface ScrollToTopProps extends ScrollToTopIntrinsicProps {
8
+ offset?: number
9
+ }
10
+
11
+ export type { ScrollToTopProps }
12
+
13
+ export const ScrollToTop = function ScrollToTop({
14
+ ref,
15
+ offset = -65,
16
+ ...rest
17
+ }: ScrollToTopProps & {
18
+ ref?: React.RefObject<HTMLButtonElement>
19
+ }) {
20
+ const [show, setShow] = useState(false)
21
+
22
+ const handleScrollToTopClick = (): void => {
23
+ window.scrollTo({ top: offset, left: 0, behavior: 'smooth' })
24
+ }
25
+
26
+ useEffect(() => {
27
+ const handleCheck = (): void => {
28
+ const scrollTop = window.scrollY
29
+ if (scrollTop > 200) {
30
+ setShow(true)
31
+ } else {
32
+ setShow(false)
33
+ }
34
+ }
35
+ if (typeof window !== 'undefined') {
36
+ window.addEventListener('scroll', handleCheck)
37
+ }
38
+ return () => {
39
+ window.removeEventListener('scroll', handleCheck)
40
+ }
41
+ }, [])
42
+
43
+ return (
44
+ <button
45
+ ref={ref}
46
+ {...rest}
47
+ onClick={handleScrollToTopClick}
48
+ type="button"
49
+ id="scroll-to-top"
50
+ className={`btn-to-top ${show && 'btn-floating'}`}
51
+ >
52
+ <span>
53
+ <svg className="icon" focusable="false" aria-hidden="true" viewBox="0 0 51 32">
54
+ <path d="M25.4,9.8L45.6,30l4.5-4.5L25.4,0.8L0.8,25.4L5.3,30L25.4,9.8z" />
55
+ </svg>
56
+ </span>
57
+ </button>
58
+ )
59
+ }
@@ -0,0 +1,13 @@
1
+ ---
2
+ interface Props {
3
+ class?: string
4
+ }
5
+
6
+ import styles from './section.module.css'
7
+
8
+ const { class: className, ...rest } = Astro.props as Props
9
+ ---
10
+
11
+ <section class:list={[styles.section, className]} {...rest}>
12
+ <slot />
13
+ </section>
@@ -0,0 +1,7 @@
1
+ @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
2
+
3
+ @layer infonomic-components {
4
+ .section {
5
+ position: relative;
6
+ }
7
+ }
@@ -0,0 +1,23 @@
1
+ import type React from 'react'
2
+
3
+ import cx from 'classnames'
4
+
5
+ import styles from './section.module.css'
6
+
7
+ type SectionIntrinsicProps = React.JSX.IntrinsicElements['section']
8
+ export interface SectionProps extends SectionIntrinsicProps {}
9
+
10
+ export const Section = function Section({
11
+ ref,
12
+ className,
13
+ children,
14
+ ...rest
15
+ }: SectionProps & {
16
+ ref?: React.RefObject<HTMLElement>
17
+ }): React.JSX.Element {
18
+ return (
19
+ <section className={cx(styles.section, className)} ref={ref} {...rest}>
20
+ {children}
21
+ </section>
22
+ )
23
+ }
@@ -0,0 +1,53 @@
1
+ @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
2
+
3
+ /* 'border-collapse w-full text-sm text-left text-gray-700 dark:text-gray-400 m-0', */
4
+ @layer infonomic-components {
5
+ .shimmer {
6
+ position: relative;
7
+ overflow: hidden;
8
+ background-color: #f0f0f0;
9
+ background-image: linear-gradient(90deg,
10
+ transparent,
11
+ rgba(255, 255, 255, 0.6),
12
+ transparent);
13
+ background-size: 200% 100%;
14
+ animation: shimmer 1.5s infinite;
15
+ }
16
+
17
+ .shimmer:is(:global(.dark) *) {
18
+ background-color: #141414;
19
+ background-image: linear-gradient(90deg,
20
+ transparent,
21
+ rgba(255, 255, 255, 0.01),
22
+ transparent);
23
+ }
24
+
25
+ .shimmerContainer {
26
+ display: flex;
27
+ flex-direction: column;
28
+ }
29
+
30
+ .rectangular {
31
+ border-radius: 0.25rem;
32
+ }
33
+
34
+ .text {
35
+ border-radius: 0.125rem;
36
+ height: 1rem;
37
+ }
38
+
39
+ .circular {
40
+ border-radius: 50%;
41
+ aspect-ratio: 1;
42
+ }
43
+
44
+ @keyframes shimmer {
45
+ 0% {
46
+ background-position: -200% 0;
47
+ }
48
+
49
+ 100% {
50
+ background-position: 200% 0;
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,24 @@
1
+ import type { Meta } from '@storybook/react-vite'
2
+
3
+ import { Shimmer as ShimmerComponent } from './shimmer.js'
4
+
5
+ const meta: Meta<typeof ShimmerComponent> = {
6
+ /* 👇 The title prop is optional.
7
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
8
+ * to learn how to generate automatic titles
9
+ */
10
+ title: 'Components/Shimmer',
11
+ component: ShimmerComponent,
12
+ }
13
+
14
+ export default meta
15
+
16
+ export const Shimmer = (): React.JSX.Element => {
17
+ return (
18
+ <div style={{ height: '100vh' }}>
19
+ <ShimmerComponent variant="text" width="100%" borderRadius="4px" height="1rem" lines={5}>
20
+ <div style={{ width: '100%' }} />
21
+ </ShimmerComponent>
22
+ </div>
23
+ )
24
+ }