@infonomic/uikit 2.0.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 (312) hide show
  1. package/dist/components/card/card.d.ts.map +1 -1
  2. package/package.json +9 -5
  3. package/src/astro.d.ts +43 -0
  4. package/src/astro.js +2 -2
  5. package/src/components/@types/shared.ts +24 -0
  6. package/src/components/accordion/accordion.module.css +60 -0
  7. package/src/components/accordion/accordion.stories.tsx +117 -0
  8. package/src/components/accordion/accordion.tsx +105 -0
  9. package/src/components/animation/fade-in-lift.stories.tsx +81 -0
  10. package/src/components/animation/fade-in-lift.tsx +42 -0
  11. package/src/components/avatar/avatar.module.css +54 -0
  12. package/src/components/avatar/avatar.stories.tsx +28 -0
  13. package/src/components/avatar/avatar.tsx +19 -0
  14. package/src/components/button/@types/button.ts +17 -0
  15. package/src/components/button/button-group.module.css +17 -0
  16. package/src/components/button/button-group.stories.tsx +45 -0
  17. package/src/components/button/button-group.tsx +132 -0
  18. package/src/components/button/button-icon.stories.tsx +145 -0
  19. package/src/components/button/button-intents.stories.tsx +50 -0
  20. package/src/components/button/button-variants.stories.tsx +60 -0
  21. package/src/components/button/button.astro +86 -0
  22. package/src/components/button/button.module.css +533 -0
  23. package/src/components/button/button.tsx +81 -0
  24. package/src/components/button/control-buttons.module.css +144 -0
  25. package/src/components/button/control-buttons.stories.tsx +60 -0
  26. package/src/components/button/control-buttons.tsx +137 -0
  27. package/src/components/button/copy-button.module.css +31 -0
  28. package/src/components/button/copy-button.stories.tsx +50 -0
  29. package/src/components/button/copy-button.tsx +92 -0
  30. package/src/components/button/icon-button.astro +47 -0
  31. package/src/components/button/icon-button.tsx +44 -0
  32. package/src/components/button/index.ts +5 -0
  33. package/src/components/calendar/calendar.module.css +315 -0
  34. package/src/components/calendar/calendar.stories.tsx +139 -0
  35. package/src/components/calendar/calendar.tsx +173 -0
  36. package/src/components/card/card-content.astro +14 -0
  37. package/src/components/card/card-description.astro +14 -0
  38. package/src/components/card/card-footer.astro +14 -0
  39. package/src/components/card/card-header.astro +14 -0
  40. package/src/components/card/card-title.astro +14 -0
  41. package/src/components/card/card.astro +41 -0
  42. package/src/components/card/card.module.css +67 -0
  43. package/src/components/card/card.stories.tsx +61 -0
  44. package/src/components/card/card.tsx +86 -0
  45. package/src/components/container/container.astro +13 -0
  46. package/src/components/container/container.module.css +28 -0
  47. package/src/components/container/container.stories.tsx +42 -0
  48. package/src/components/container/container.tsx +23 -0
  49. package/src/components/dropdown/dropdown.module.css +131 -0
  50. package/src/components/dropdown/dropdown.stories.tsx +103 -0
  51. package/src/components/dropdown/dropdown.tsx +193 -0
  52. package/src/components/hamburger/hamburger.astro +30 -0
  53. package/src/components/hamburger/hamburger.tsx +66 -0
  54. package/src/components/input/@types/checkbox.ts +20 -0
  55. package/src/components/input/@types/input.ts +20 -0
  56. package/src/components/input/checkbox-group.tsx +78 -0
  57. package/src/components/input/checkbox.module.css +267 -0
  58. package/src/components/input/checkbox.stories.tsx +240 -0
  59. package/src/components/input/checkbox.tsx +95 -0
  60. package/src/components/input/error-text.astro +14 -0
  61. package/src/components/input/error-text.module.css +19 -0
  62. package/src/components/input/error-text.tsx +18 -0
  63. package/src/components/input/errors.tsx +37 -0
  64. package/src/components/input/help-text.astro +13 -0
  65. package/src/components/input/help-text.module.css +19 -0
  66. package/src/components/input/help-text.tsx +13 -0
  67. package/src/components/input/index.tsx +8 -0
  68. package/src/components/input/input-adornment.astro +26 -0
  69. package/src/components/input/input-adornment.module.css +18 -0
  70. package/src/components/input/input-adornment.tsx +36 -0
  71. package/src/components/input/input.astro +99 -0
  72. package/src/components/input/input.module.css +310 -0
  73. package/src/components/input/input.stories.tsx +174 -0
  74. package/src/components/input/input.tsx +103 -0
  75. package/src/components/input/label.astro +24 -0
  76. package/src/components/input/label.module.css +28 -0
  77. package/src/components/input/label.tsx +25 -0
  78. package/src/components/input/radio-group.module.css +219 -0
  79. package/src/components/input/radio-group.stories.tsx +73 -0
  80. package/src/components/input/radio-group.tsx +67 -0
  81. package/src/components/input/select.module.css +75 -0
  82. package/src/components/input/select.stories.tsx +34 -0
  83. package/src/components/input/select.tsx +115 -0
  84. package/src/components/input/text-area.module.css +9 -0
  85. package/src/components/input/text-area.stories.tsx +51 -0
  86. package/src/components/input/text-area.tsx +81 -0
  87. package/src/components/input/utils.ts +21 -0
  88. package/src/components/notifications/@types/alert.ts +12 -0
  89. package/src/components/notifications/@types/toast.ts +12 -0
  90. package/src/components/notifications/alert.module.css +114 -0
  91. package/src/components/notifications/alert.stories.tsx +39 -0
  92. package/src/components/notifications/alert.tsx +117 -0
  93. package/src/components/notifications/index.ts +2 -0
  94. package/src/components/notifications/toast.module.css +237 -0
  95. package/src/components/notifications/toast.stories.tsx +42 -0
  96. package/src/components/notifications/toast.tsx +124 -0
  97. package/src/components/overlay/index.stories.tsx +29 -0
  98. package/src/components/overlay/index.ts +2 -0
  99. package/src/components/overlay/overlay.module.css +41 -0
  100. package/src/components/overlay/overlay.tsx +61 -0
  101. package/src/components/pager/@types/index.ts +2 -0
  102. package/src/components/pager/ellipses.tsx +18 -0
  103. package/src/components/pager/event-pager.tsx +18 -0
  104. package/src/components/pager/first-button.tsx +53 -0
  105. package/src/components/pager/hooks/types/usePagination.ts +80 -0
  106. package/src/components/pager/hooks/usePagination.ts +140 -0
  107. package/src/components/pager/icons/first.tsx +33 -0
  108. package/src/components/pager/icons/index.tsx +4 -0
  109. package/src/components/pager/icons/last.tsx +33 -0
  110. package/src/components/pager/icons/next.tsx +20 -0
  111. package/src/components/pager/icons/previous.tsx +20 -0
  112. package/src/components/pager/index.ts +4 -0
  113. package/src/components/pager/last-button.tsx +57 -0
  114. package/src/components/pager/next-button.tsx +55 -0
  115. package/src/components/pager/number-button.tsx +83 -0
  116. package/src/components/pager/pagination.module.css +165 -0
  117. package/src/components/pager/pagination.stories.tsx +190 -0
  118. package/src/components/pager/pagination.tsx +266 -0
  119. package/src/components/pager/previous-button.tsx +51 -0
  120. package/src/components/scroll-area/scroll-area.module.css +80 -0
  121. package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
  122. package/src/components/scroll-area/scroll-area.tsx +22 -0
  123. package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
  124. package/src/components/section/section.astro +13 -0
  125. package/src/components/section/section.module.css +7 -0
  126. package/src/components/section/section.tsx +23 -0
  127. package/src/components/shimmer/shimmer.module.css +53 -0
  128. package/src/components/shimmer/shimmer.stories.tsx +24 -0
  129. package/src/components/shimmer/shimmer.tsx +70 -0
  130. package/src/components/table/table.module.css +100 -0
  131. package/src/components/table/table.stories.tsx +95 -0
  132. package/src/components/table/table.tsx +165 -0
  133. package/src/components/tabs/tabs.module.css +64 -0
  134. package/src/components/tabs/tabs.stories.tsx +47 -0
  135. package/src/components/tabs/tabs.tsx +75 -0
  136. package/src/components/timeline/timeline.module.css +87 -0
  137. package/src/components/timeline/timeline.stories.tsx +50 -0
  138. package/src/components/timeline/timeline.tsx +177 -0
  139. package/src/components/tooltip/tooltip.module.css +55 -0
  140. package/src/components/tooltip/tooltip.stories.tsx +59 -0
  141. package/src/components/tooltip/tooltip.tsx +51 -0
  142. package/src/declarations.d.ts +4 -0
  143. package/src/hooks/use-media-query.ts +20 -0
  144. package/src/icons/activity-icon.tsx +40 -0
  145. package/src/icons/calendar-icon.tsx +39 -0
  146. package/src/icons/check-icon.tsx +33 -0
  147. package/src/icons/chevron-down-icon.tsx +39 -0
  148. package/src/icons/chevron-left-double-icon.tsx +58 -0
  149. package/src/icons/chevron-left-icon.tsx +58 -0
  150. package/src/icons/chevron-right-double-icon.tsx +58 -0
  151. package/src/icons/chevron-right-icon.tsx +58 -0
  152. package/src/icons/chevrons-up-down.tsx +37 -0
  153. package/src/icons/close-icon.astro +38 -0
  154. package/src/icons/close-icon.tsx +30 -0
  155. package/src/icons/copy-icon.tsx +35 -0
  156. package/src/icons/danger-icon.tsx +18 -0
  157. package/src/icons/dashboard-icon.tsx +41 -0
  158. package/src/icons/delete-icon.tsx +34 -0
  159. package/src/icons/document-icon.tsx +38 -0
  160. package/src/icons/download-icon.tsx +39 -0
  161. package/src/icons/edit-icon.tsx +35 -0
  162. package/src/icons/ellipsis-icon.tsx +38 -0
  163. package/src/icons/email-icon.tsx +33 -0
  164. package/src/icons/external-link-icon.tsx +39 -0
  165. package/src/icons/github-icon.tsx +27 -0
  166. package/src/icons/globe-icon.tsx +50 -0
  167. package/src/icons/google-icon.tsx +44 -0
  168. package/src/icons/gripper-vertical-icon.tsx +43 -0
  169. package/src/icons/history-icon.tsx +32 -0
  170. package/src/icons/home-icon.tsx +34 -0
  171. package/src/icons/icon-element.astro +27 -0
  172. package/src/icons/icon-element.tsx +32 -0
  173. package/src/icons/icon-sprite.tsx +18 -0
  174. package/src/icons/icons.module.css +147 -0
  175. package/src/icons/index.stories.tsx +25 -0
  176. package/src/icons/index.ts +39 -0
  177. package/src/icons/info-icon.tsx +18 -0
  178. package/src/icons/infonomic-icon.tsx +173 -0
  179. package/src/icons/light-icon.astro +36 -0
  180. package/src/icons/light-icon.tsx +29 -0
  181. package/src/icons/location-pin-icon.tsx +36 -0
  182. package/src/icons/moon-icon.astro +38 -0
  183. package/src/icons/moon-icon.tsx +42 -0
  184. package/src/icons/plus-icon.tsx +34 -0
  185. package/src/icons/primary-icon.tsx +22 -0
  186. package/src/icons/refresh-icon.tsx +33 -0
  187. package/src/icons/return-icon.tsx +36 -0
  188. package/src/icons/roles-icon.tsx +34 -0
  189. package/src/icons/search-icon.astro +40 -0
  190. package/src/icons/search-icon.tsx +29 -0
  191. package/src/icons/search-menu-icon.tsx +42 -0
  192. package/src/icons/settings-gear-icon.tsx +36 -0
  193. package/src/icons/settings-sliders-icon.tsx +43 -0
  194. package/src/icons/sign-out-icon.tsx +35 -0
  195. package/src/icons/source/icon-calendar.svg +1 -0
  196. package/src/icons/source/icon-check.svg +4 -0
  197. package/src/icons/source/icon-close.svg +3 -0
  198. package/src/icons/source/icon-coinbase.svg +9 -0
  199. package/src/icons/source/icon-copy.svg +4 -0
  200. package/src/icons/source/icon-document.svg +5 -0
  201. package/src/icons/source/icon-download.svg +4 -0
  202. package/src/icons/source/icon-edit.svg +6 -0
  203. package/src/icons/source/icon-eth-purple.svg +15 -0
  204. package/src/icons/source/icon-etherscan.svg +5 -0
  205. package/src/icons/source/icon-external-link.svg +4 -0
  206. package/src/icons/source/icon-globe.svg +7 -0
  207. package/src/icons/source/icon-gripper-vertical.svg +9 -0
  208. package/src/icons/source/icon-info.svg +4 -0
  209. package/src/icons/source/icon-infonomic.svg +43 -0
  210. package/src/icons/source/icon-ledger.svg +4 -0
  211. package/src/icons/source/icon-light.svg +3 -0
  212. package/src/icons/source/icon-location-pin.svg +8 -0
  213. package/src/icons/source/icon-logout.svg +6 -0
  214. package/src/icons/source/icon-metamask.svg +32 -0
  215. package/src/icons/source/icon-moon.svg +3 -0
  216. package/src/icons/source/icon-plus.svg +4 -0
  217. package/src/icons/source/icon-refresh.svg +4 -0
  218. package/src/icons/source/icon-return.svg +4 -0
  219. package/src/icons/source/icon-search-menu.svg +13 -0
  220. package/src/icons/source/icon-search.svg +3 -0
  221. package/src/icons/source/icon-settings-gear.svg +5 -0
  222. package/src/icons/source/icon-settings.svg +12 -0
  223. package/src/icons/source/icon-wallet.svg +3 -0
  224. package/src/icons/source/icon-walletconnect.svg +4 -0
  225. package/src/icons/source/icon-x.svg +4 -0
  226. package/src/icons/stopwatch-icon.tsx +39 -0
  227. package/src/icons/success-icon.tsx +18 -0
  228. package/src/icons/types/icon.ts +8 -0
  229. package/src/icons/user-icon.tsx +33 -0
  230. package/src/icons/users-icon.tsx +35 -0
  231. package/src/icons/wallet-icon.tsx +29 -0
  232. package/src/icons/warning-icon.tsx +18 -0
  233. package/src/icons/x-icon.tsx +33 -0
  234. package/src/loaders/ellipses.tsx +36 -0
  235. package/src/loaders/loaders.stories.tsx +46 -0
  236. package/src/loaders/ring.tsx +33 -0
  237. package/src/loaders/spinner.tsx +28 -0
  238. package/src/loaders/types/index.ts +6 -0
  239. package/src/react.ts +99 -0
  240. package/src/styles/base/animations.css +143 -0
  241. package/src/styles/base/base.css +5 -0
  242. package/src/styles/base/colors.css +163 -0
  243. package/src/styles/base/colors.stories.tsx +671 -0
  244. package/src/styles/base/reset.css +464 -0
  245. package/src/styles/base/typography.css +25 -0
  246. package/src/styles/base/vars.css +188 -0
  247. package/src/styles/components/card.css +20 -0
  248. package/src/styles/components/checkbox.css +55 -0
  249. package/src/styles/components/components.css +11 -0
  250. package/src/styles/components/directional-button.css +92 -0
  251. package/src/styles/components/dropdown.css +19 -0
  252. package/src/styles/components/fade-in-lift.css +13 -0
  253. package/src/styles/components/hamburger.css +107 -0
  254. package/src/styles/components/icon-element.css +4 -0
  255. package/src/styles/components/list-checkbox.css +60 -0
  256. package/src/styles/components/loaders.css +196 -0
  257. package/src/styles/components/popover.css +15 -0
  258. package/src/styles/components/scroll-to-top.css +89 -0
  259. package/src/styles/components/toast.css +18 -0
  260. package/src/styles/styles.css +6 -0
  261. package/src/styles/theme/autofill.css +58 -0
  262. package/src/styles/theme/scrollers.css +52 -0
  263. package/src/styles/theme/theme.css +130 -0
  264. package/src/styles/theme/theme.stories.tsx +33 -0
  265. package/src/styles/typography/code.stories.tsx +76 -0
  266. package/src/styles/typography/default.stories.tsx +51 -0
  267. package/src/styles/typography/fonts.css +30 -0
  268. package/src/styles/typography/lists.stories.tsx +50 -0
  269. package/src/styles/typography/prose.css +404 -0
  270. package/src/styles/typography/quote.stories.tsx +37 -0
  271. package/src/styles/typography.css +24 -0
  272. package/src/styles/utils/scroll-layout-shift.css +9 -0
  273. package/src/styles/utils/utility-classes.css +1278 -0
  274. package/src/styles/utils/utils.css +2 -0
  275. package/src/theme/theme-provider/index.ts +1 -0
  276. package/src/theme/theme-provider/provider.tsx +44 -0
  277. package/src/utils/capitalize.ts +6 -0
  278. package/src/utils/externalLinkProps.ts +6 -0
  279. package/src/utils/findMatch.ts +7 -0
  280. package/src/utils/getPortalRoot.ts +3 -0
  281. package/src/utils/isTouchDevice.ts +11 -0
  282. package/src/utils/objectsToArray.ts +15 -0
  283. package/src/utils/objectsToString.ts +5 -0
  284. package/src/utils/polymorphic.ts +16 -0
  285. package/src/utils/to-kebab-case.ts +5 -0
  286. package/src/widgets/datepicker/datepicker.module.css +189 -0
  287. package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
  288. package/src/widgets/datepicker/datepicker.tsx +310 -0
  289. package/src/widgets/drawer/drawer-container.tsx +26 -0
  290. package/src/widgets/drawer/drawer-content.tsx +26 -0
  291. package/src/widgets/drawer/drawer-context.tsx +49 -0
  292. package/src/widgets/drawer/drawer-header.tsx +27 -0
  293. package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
  294. package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
  295. package/src/widgets/drawer/drawer.module.css +116 -0
  296. package/src/widgets/drawer/drawer.stories.tsx +224 -0
  297. package/src/widgets/drawer/drawer.tsx +115 -0
  298. package/src/widgets/drawer/motionDomAnimation.ts +4 -0
  299. package/src/widgets/drawer/motionDomMax.ts +4 -0
  300. package/src/widgets/modal/modal-actions.tsx +26 -0
  301. package/src/widgets/modal/modal-container.tsx +26 -0
  302. package/src/widgets/modal/modal-content.tsx +26 -0
  303. package/src/widgets/modal/modal-header.tsx +27 -0
  304. package/src/widgets/modal/modal-wrapper.tsx +50 -0
  305. package/src/widgets/modal/modal.module.css +85 -0
  306. package/src/widgets/modal/modal.stories.tsx +71 -0
  307. package/src/widgets/modal/modal.tsx +110 -0
  308. package/src/widgets/modal/motionDomAnimation.ts +4 -0
  309. package/src/widgets/modal/motionDomMax.ts +4 -0
  310. package/src/widgets/search/index.ts +1 -0
  311. package/src/widgets/search/search.stories.tsx +18 -0
  312. package/src/widgets/search/search.tsx +186 -0
@@ -0,0 +1,4 @@
1
+ export * from './hooks/usePagination'
2
+ export * from './pagination'
3
+ export * from './icons/index'
4
+ export * from './event-pager'
@@ -0,0 +1,57 @@
1
+ 'use client'
2
+
3
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions */
4
+
5
+ import { DoubleArrowRightIcon } from '@radix-ui/react-icons'
6
+ import { Slot } from '@radix-ui/react-slot'
7
+ import cx from 'classnames'
8
+ import type React from 'react'
9
+ import type { PagerButtonProps, RefType } from './pagination'
10
+ import { usePager } from './pagination'
11
+
12
+ import styles from './pagination.module.css'
13
+
14
+ export type LastButtonProps = PagerButtonProps & {
15
+ count: number
16
+ }
17
+
18
+ export const LastButton = ({
19
+ ref,
20
+ className,
21
+ disabled,
22
+ count,
23
+ asChild,
24
+ children,
25
+ ...rest
26
+ }: LastButtonProps & {
27
+ ref?: React.RefObject<RefType>
28
+ }) => {
29
+ const { variant } = usePager()
30
+ const Comp = asChild != null ? Slot : ('button' as React.ElementType)
31
+
32
+ const aria = disabled ? { 'aria-disabled': true } : { 'aria-label': 'Last' }
33
+
34
+ return (
35
+ <li className={styles['mobile-toggle']}>
36
+ <Comp
37
+ ref={ref}
38
+ className={cx(
39
+ styles['last-button'],
40
+ styles[variant],
41
+ styles['rounded-right'],
42
+ 'pagination-last',
43
+ className
44
+ )}
45
+ disabled={disabled}
46
+ title="Last"
47
+ data-testid="pagination-last"
48
+ {...aria}
49
+ {...rest}
50
+ >
51
+ {(asChild ?? false) ? children : <DoubleArrowRightIcon />}
52
+ </Comp>
53
+ </li>
54
+ )
55
+ }
56
+
57
+ LastButton.displayName = 'LastButton'
@@ -0,0 +1,55 @@
1
+ 'use client'
2
+
3
+ import { ChevronRightIcon } 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 type NextButtonProps = PagerButtonProps & {
13
+ page: number | null
14
+ }
15
+
16
+ export const NextButton = ({
17
+ ref,
18
+ className,
19
+ disabled,
20
+ page,
21
+ asChild,
22
+ children,
23
+ ...rest
24
+ }: NextButtonProps & {
25
+ ref?: React.RefObject<RefType>
26
+ }) => {
27
+ const Comp = asChild != null ? Slot : ('button' as React.ElementType)
28
+ const { variant, showLastButton } = usePager()
29
+
30
+ const aria = disabled ? { 'aria-disabled': true } : { 'aria-label': 'Next' }
31
+
32
+ return (
33
+ <li className={styles['mobile-toggle']}>
34
+ <Comp
35
+ ref={ref}
36
+ className={cx(
37
+ styles['next-button'],
38
+ [styles[variant]],
39
+ { [styles['rounded-right']]: showLastButton == null || showLastButton === false },
40
+ 'pagination-next',
41
+ className
42
+ )}
43
+ disabled={disabled}
44
+ title="Next"
45
+ data-testid="pagination-next"
46
+ {...aria}
47
+ {...rest}
48
+ >
49
+ {(asChild ?? false) ? children : <ChevronRightIcon />}
50
+ </Comp>
51
+ </li>
52
+ )
53
+ }
54
+
55
+ NextButton.displayName = 'NextButton'
@@ -0,0 +1,83 @@
1
+ 'use client'
2
+
3
+ import { Slot } from '@radix-ui/react-slot'
4
+ import cx from 'classnames'
5
+ import type React from 'react'
6
+ import { useMediaQuery } from '../../hooks/use-media-query'
7
+
8
+ import type { PagerButtonProps, RefType } from './pagination'
9
+ import { usePager } from './pagination'
10
+
11
+ import styles from './pagination.module.css'
12
+
13
+ export type NumberButtonProps = PagerButtonProps & {
14
+ page: number | null
15
+ activeClassName?: string
16
+ selected?: boolean
17
+ }
18
+
19
+ export const NumberButton = ({
20
+ ref,
21
+ page,
22
+ className,
23
+ disabled,
24
+ activeClassName,
25
+ asChild,
26
+ children,
27
+ ...rest
28
+ }: NumberButtonProps & {
29
+ ref?: React.RefObject<RefType>
30
+ }) => {
31
+ const mobile = useMediaQuery('(max-width: 640px)')
32
+ const {
33
+ variant,
34
+ currentPage,
35
+ count,
36
+ showFirstButton,
37
+ showLastButton,
38
+ hideNextButton,
39
+ hidePrevButton,
40
+ } = usePager()
41
+
42
+ const Comp = asChild != null ? Slot : ('button' as React.ElementType)
43
+
44
+ const active = page === currentPage
45
+
46
+ return (
47
+ <li className="flex">
48
+ <Comp
49
+ ref={ref}
50
+ className={cx(
51
+ styles['number-button'],
52
+ [styles[variant]],
53
+ { [styles.active]: active === true, active: active === true },
54
+ {
55
+ [styles['rounded-left']]:
56
+ page === 1 && ((!(showFirstButton ?? false) && (hidePrevButton ?? false)) || mobile),
57
+ },
58
+ {
59
+ [styles['rounded-right']]:
60
+ page === count &&
61
+ ((!(showLastButton ?? false) && (hideNextButton ?? false)) || mobile),
62
+ },
63
+ 'pagination-number',
64
+ className
65
+ )}
66
+ data-testid={
67
+ cx({
68
+ 'pager-number-active': currentPage === page,
69
+ [`pager-number-${page}`]: currentPage !== page,
70
+ }).length > 0 || undefined
71
+ }
72
+ disabled={disabled}
73
+ aria-current={currentPage === page}
74
+ aria-label={currentPage === page ? `Current Page, Page ${page}` : `Page ${page}`}
75
+ {...rest}
76
+ >
77
+ {(asChild ?? false) ? children : <>{page}</>}
78
+ </Comp>
79
+ </li>
80
+ )
81
+ }
82
+
83
+ NumberButton.displayName = 'NumberButton'
@@ -0,0 +1,165 @@
1
+ @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
2
+
3
+ @layer infonomic-components {
4
+ .pagination-root {
5
+ display: flex;
6
+ padding: 0;
7
+ align-items: center;
8
+ }
9
+
10
+ .pagination-items {
11
+ display: flex;
12
+ align-items: center;
13
+ list-style: none;
14
+ }
15
+
16
+ .pagination-items {
17
+ display: flex;
18
+ align-items: center;
19
+ list-style: none;
20
+ }
21
+
22
+ .pagination-items.dashboard li,
23
+ .pagination-items.default li {
24
+ margin-right: -1px;
25
+ }
26
+
27
+ .pagination-items.classic li {
28
+ margin-right: 0;
29
+ }
30
+
31
+ .pagination-items.classic {
32
+ gap: 6px;
33
+ }
34
+
35
+ .number-button.dashboard.rounded-left,
36
+ .number-button.default.rounded-left,
37
+ .first-button.dashboard.rounded-left,
38
+ .first-button.default.rounded-left,
39
+ .previous-button.dashboard.rounded-left,
40
+ .previous-button.default.rounded-left,
41
+ .last-button.dashboard.rounded-left,
42
+ .last-button.default.rounded-left,
43
+ .next-button.dashboard.rounded-left,
44
+ .next-button.default.rounded-left {
45
+ border-top-left-radius: var(--border-radius-sm);
46
+ border-bottom-left-radius: var(--border-radius-sm);
47
+ }
48
+
49
+ .number-button.dashboard.rounded-right,
50
+ .number-button.default.rounded-right,
51
+ .first-button.dashboard.rounded-right,
52
+ .first-button.default.rounded-right,
53
+ .previous-button.dashboard.rounded-right,
54
+ .previous-button.default.rounded-right,
55
+ .last-button.dashboard.rounded-right,
56
+ .last-button.default.rounded-right,
57
+ .next-button.dashboard.rounded-right,
58
+ .next-button.default.rounded-right {
59
+ border-top-right-radius: var(--border-radius-sm);
60
+ border-bottom-right-radius: var(--border-radius-sm);
61
+ }
62
+
63
+ .ellipses,
64
+ .last-button,
65
+ .next-button,
66
+ .previous-button,
67
+ .first-button,
68
+ .number-button {
69
+ margin-left: 0;
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ height: 32px;
74
+ line-height: 1;
75
+ border: 1px solid var(--primary-500);
76
+ background-color: white;
77
+ color: var(--gray-900);
78
+ font-size: var(--font-size-sm);
79
+ }
80
+
81
+
82
+ .previous-button,
83
+ .last-button,
84
+ .next-button,
85
+ .first-button {
86
+ width: 38px;
87
+ }
88
+
89
+ .ellipses,
90
+ .number-button {
91
+ min-width: 42px;
92
+ }
93
+
94
+ .last-button:hover,
95
+ .next-button:hover,
96
+ .number-button:hover,
97
+ .previous-button:hover,
98
+ .first-button:hover {
99
+ color: white;
100
+ background-color: var(--primary-600);
101
+ }
102
+
103
+ .last-button:disabled,
104
+ .last-button[disabled],
105
+ .next-button:disabled,
106
+ .next-button[disabled],
107
+ .number-button:disabled,
108
+ .number-button[disabled],
109
+ .previous-button:disabled,
110
+ .previous-button[disabled],
111
+ .first-button:disabled,
112
+ .first-button[disabled] {
113
+ cursor: default;
114
+ }
115
+
116
+ .number-button.active {
117
+ background-color: var(--primary-600);
118
+ color: white;
119
+ }
120
+
121
+
122
+ /* Opinionated mobile */
123
+ .mobile-toggle {
124
+ display: none;
125
+ }
126
+
127
+ @media(min-width: 640px) {
128
+
129
+ .mobile-toggle {
130
+ display: flex;
131
+ }
132
+ }
133
+
134
+ /* 🌙 Dark via `.dark` class. We rely on the
135
+ * consuming application to detect a user's preferred
136
+ * color scheme - either by header or cookie, and set
137
+ * a root html class accordingly
138
+ */
139
+ :global(.dark) {
140
+
141
+ .ellipses,
142
+ .number-button,
143
+ .next-button,
144
+ .last-button,
145
+ .previous-button,
146
+ .first-button {
147
+ border-color: var(--canvas-700);
148
+ background-color: var(--canvas-800);
149
+ color: var(--gray-200);
150
+ }
151
+
152
+ .number-button:hover,
153
+ .next-button:hover,
154
+ .last-button:hover,
155
+ .previous-button:hover,
156
+ .first-button:hover {
157
+ background-color: var(--canvas-700);
158
+ }
159
+
160
+ .number-button.active {
161
+ background-color: var(--primary-500);
162
+ color: white;
163
+ }
164
+ }
165
+ }
@@ -0,0 +1,190 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import React from 'react'
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react-vite'
5
+
6
+ import { EventPager } from './event-pager.js'
7
+
8
+ const meta: Meta<typeof EventPager> = {
9
+ /* 👇 The title prop is optional.
10
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
11
+ * to learn how to generate automatic titles
12
+ */
13
+ title: 'Components/Pager',
14
+ component: EventPager,
15
+ }
16
+
17
+ export default meta
18
+
19
+ const DefaultPager = (): React.JSX.Element => {
20
+ const [page, setPage] = React.useState(1)
21
+
22
+ const handlePageChange = (event: any, number: number): void => {
23
+ setPage(number)
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <style>
29
+ {`
30
+ .event-pager {
31
+ margin-bottom: 1rem;
32
+ }
33
+ `}
34
+ </style>
35
+ <div style={{ marginBottom: '2rem', maxWidth: '600px' }}>
36
+ <p style={{ marginBottom: '1rem' }}>Stateful Pagers: Current page: {page}</p>
37
+ <EventPager
38
+ page={page}
39
+ count={24}
40
+ className="event-pager"
41
+ onChange={handlePageChange}
42
+ showFirstButton
43
+ showLastButton
44
+ componentName="pager1"
45
+ aria-label="Pager 1"
46
+ />
47
+ <EventPager
48
+ page={page}
49
+ count={24}
50
+ className="event-pager"
51
+ onChange={handlePageChange}
52
+ componentName="pager2"
53
+ aria-label="Pager 2"
54
+ />
55
+ <EventPager
56
+ page={page}
57
+ count={24}
58
+ className="event-pager"
59
+ onChange={handlePageChange}
60
+ componentName="pager3"
61
+ hideNextButton
62
+ hidePrevButton
63
+ aria-label="Pager 3"
64
+ />
65
+ </div>
66
+ </>
67
+ )
68
+ }
69
+
70
+ const ClassicPager = (): React.JSX.Element => {
71
+ const [page, setPage] = React.useState(1)
72
+
73
+ const handlePageChange = (event: any, number: number): void => {
74
+ setPage(number)
75
+ }
76
+
77
+ return (
78
+ <>
79
+ <style>
80
+ {`
81
+ .event-pager {
82
+ margin-bottom: 1rem;
83
+ }
84
+ `}
85
+ </style>
86
+ <div style={{ marginBottom: '2rem', maxWidth: '600px' }}>
87
+ <p style={{ marginBottom: '1rem' }}>Stateful Pagers: Current page: {page}</p>
88
+ <EventPager
89
+ variant="classic"
90
+ className="event-pager"
91
+ page={page}
92
+ count={24}
93
+ onChange={handlePageChange}
94
+ showFirstButton
95
+ showLastButton
96
+ componentName="pager1"
97
+ aria-label="Pager 1"
98
+ />
99
+ <EventPager
100
+ variant="classic"
101
+ className="event-pager"
102
+ page={page}
103
+ count={24}
104
+ onChange={handlePageChange}
105
+ componentName="pager2"
106
+ aria-label="Pager 2"
107
+ />
108
+ <EventPager
109
+ variant="classic"
110
+ className="event-pager"
111
+ page={page}
112
+ count={24}
113
+ onChange={handlePageChange}
114
+ componentName="pager3"
115
+ hideNextButton
116
+ hidePrevButton
117
+ aria-label="Pager 3"
118
+ />
119
+ </div>
120
+ </>
121
+ )
122
+ }
123
+
124
+ const DashboardPager = (): React.JSX.Element => {
125
+ const [page, setPage] = React.useState(1)
126
+
127
+ const handlePageChange = (event: any, number: number): void => {
128
+ setPage(number)
129
+ }
130
+
131
+ return (
132
+ <>
133
+ <style>
134
+ {`
135
+ .event-pager {
136
+ margin-bottom: 1rem;
137
+ }
138
+ `}
139
+ </style>
140
+ <div style={{ marginBottom: '2rem', maxWidth: '600px' }}>
141
+ <p style={{ marginBottom: '1rem' }}>Stateful Pagers: Current page: {page}</p>
142
+ <EventPager
143
+ variant="dashboard"
144
+ className="event-pager"
145
+ page={page}
146
+ count={24}
147
+ onChange={handlePageChange}
148
+ showFirstButton
149
+ showLastButton
150
+ componentName="pager1"
151
+ aria-label="Pager 1"
152
+ />
153
+ <EventPager
154
+ variant="dashboard"
155
+ className="event-pager"
156
+ page={page}
157
+ count={24}
158
+ onChange={handlePageChange}
159
+ componentName="pager2"
160
+ aria-label="Pager 2"
161
+ />
162
+ <EventPager
163
+ variant="dashboard"
164
+ className="event-pager"
165
+ page={page}
166
+ count={24}
167
+ onChange={handlePageChange}
168
+ componentName="pager3"
169
+ hideNextButton
170
+ hidePrevButton
171
+ aria-label="Pager 3"
172
+ />
173
+ </div>
174
+ </>
175
+ )
176
+ }
177
+
178
+ type Story = StoryObj<typeof EventPager>
179
+
180
+ export const Default: Story = {
181
+ render: () => <DefaultPager />,
182
+ }
183
+
184
+ export const Classic: Story = {
185
+ render: () => <ClassicPager />,
186
+ }
187
+
188
+ export const Dashboard: Story = {
189
+ render: () => <DashboardPager />,
190
+ }