@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.
- package/dist/components/card/card.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/astro.d.ts +43 -0
- package/src/astro.js +2 -2
- package/src/components/@types/shared.ts +24 -0
- package/src/components/accordion/accordion.module.css +60 -0
- package/src/components/accordion/accordion.stories.tsx +117 -0
- package/src/components/accordion/accordion.tsx +105 -0
- package/src/components/animation/fade-in-lift.stories.tsx +81 -0
- package/src/components/animation/fade-in-lift.tsx +42 -0
- package/src/components/avatar/avatar.module.css +54 -0
- package/src/components/avatar/avatar.stories.tsx +28 -0
- package/src/components/avatar/avatar.tsx +19 -0
- package/src/components/button/@types/button.ts +17 -0
- package/src/components/button/button-group.module.css +17 -0
- package/src/components/button/button-group.stories.tsx +45 -0
- package/src/components/button/button-group.tsx +132 -0
- package/src/components/button/button-icon.stories.tsx +145 -0
- package/src/components/button/button-intents.stories.tsx +50 -0
- package/src/components/button/button-variants.stories.tsx +60 -0
- package/src/components/button/button.astro +86 -0
- package/src/components/button/button.module.css +533 -0
- package/src/components/button/button.tsx +81 -0
- package/src/components/button/control-buttons.module.css +144 -0
- package/src/components/button/control-buttons.stories.tsx +60 -0
- package/src/components/button/control-buttons.tsx +137 -0
- package/src/components/button/copy-button.module.css +31 -0
- package/src/components/button/copy-button.stories.tsx +50 -0
- package/src/components/button/copy-button.tsx +92 -0
- package/src/components/button/icon-button.astro +47 -0
- package/src/components/button/icon-button.tsx +44 -0
- package/src/components/button/index.ts +5 -0
- package/src/components/calendar/calendar.module.css +315 -0
- package/src/components/calendar/calendar.stories.tsx +139 -0
- package/src/components/calendar/calendar.tsx +173 -0
- package/src/components/card/card-content.astro +14 -0
- package/src/components/card/card-description.astro +14 -0
- package/src/components/card/card-footer.astro +14 -0
- package/src/components/card/card-header.astro +14 -0
- package/src/components/card/card-title.astro +14 -0
- package/src/components/card/card.astro +41 -0
- package/src/components/card/card.module.css +67 -0
- package/src/components/card/card.stories.tsx +61 -0
- package/src/components/card/card.tsx +86 -0
- package/src/components/container/container.astro +13 -0
- package/src/components/container/container.module.css +28 -0
- package/src/components/container/container.stories.tsx +42 -0
- package/src/components/container/container.tsx +23 -0
- package/src/components/dropdown/dropdown.module.css +131 -0
- package/src/components/dropdown/dropdown.stories.tsx +103 -0
- package/src/components/dropdown/dropdown.tsx +193 -0
- package/src/components/hamburger/hamburger.astro +30 -0
- package/src/components/hamburger/hamburger.tsx +66 -0
- package/src/components/input/@types/checkbox.ts +20 -0
- package/src/components/input/@types/input.ts +20 -0
- package/src/components/input/checkbox-group.tsx +78 -0
- package/src/components/input/checkbox.module.css +267 -0
- package/src/components/input/checkbox.stories.tsx +240 -0
- package/src/components/input/checkbox.tsx +95 -0
- package/src/components/input/error-text.astro +14 -0
- package/src/components/input/error-text.module.css +19 -0
- package/src/components/input/error-text.tsx +18 -0
- package/src/components/input/errors.tsx +37 -0
- package/src/components/input/help-text.astro +13 -0
- package/src/components/input/help-text.module.css +19 -0
- package/src/components/input/help-text.tsx +13 -0
- package/src/components/input/index.tsx +8 -0
- package/src/components/input/input-adornment.astro +26 -0
- package/src/components/input/input-adornment.module.css +18 -0
- package/src/components/input/input-adornment.tsx +36 -0
- package/src/components/input/input.astro +99 -0
- package/src/components/input/input.module.css +310 -0
- package/src/components/input/input.stories.tsx +174 -0
- package/src/components/input/input.tsx +103 -0
- package/src/components/input/label.astro +24 -0
- package/src/components/input/label.module.css +28 -0
- package/src/components/input/label.tsx +25 -0
- package/src/components/input/radio-group.module.css +219 -0
- package/src/components/input/radio-group.stories.tsx +73 -0
- package/src/components/input/radio-group.tsx +67 -0
- package/src/components/input/select.module.css +75 -0
- package/src/components/input/select.stories.tsx +34 -0
- package/src/components/input/select.tsx +115 -0
- package/src/components/input/text-area.module.css +9 -0
- package/src/components/input/text-area.stories.tsx +51 -0
- package/src/components/input/text-area.tsx +81 -0
- package/src/components/input/utils.ts +21 -0
- package/src/components/notifications/@types/alert.ts +12 -0
- package/src/components/notifications/@types/toast.ts +12 -0
- package/src/components/notifications/alert.module.css +114 -0
- package/src/components/notifications/alert.stories.tsx +39 -0
- package/src/components/notifications/alert.tsx +117 -0
- package/src/components/notifications/index.ts +2 -0
- package/src/components/notifications/toast.module.css +237 -0
- package/src/components/notifications/toast.stories.tsx +42 -0
- package/src/components/notifications/toast.tsx +124 -0
- package/src/components/overlay/index.stories.tsx +29 -0
- package/src/components/overlay/index.ts +2 -0
- package/src/components/overlay/overlay.module.css +41 -0
- package/src/components/overlay/overlay.tsx +61 -0
- package/src/components/pager/@types/index.ts +2 -0
- package/src/components/pager/ellipses.tsx +18 -0
- package/src/components/pager/event-pager.tsx +18 -0
- package/src/components/pager/first-button.tsx +53 -0
- package/src/components/pager/hooks/types/usePagination.ts +80 -0
- package/src/components/pager/hooks/usePagination.ts +140 -0
- package/src/components/pager/icons/first.tsx +33 -0
- package/src/components/pager/icons/index.tsx +4 -0
- package/src/components/pager/icons/last.tsx +33 -0
- package/src/components/pager/icons/next.tsx +20 -0
- package/src/components/pager/icons/previous.tsx +20 -0
- package/src/components/pager/index.ts +4 -0
- package/src/components/pager/last-button.tsx +57 -0
- package/src/components/pager/next-button.tsx +55 -0
- package/src/components/pager/number-button.tsx +83 -0
- package/src/components/pager/pagination.module.css +165 -0
- package/src/components/pager/pagination.stories.tsx +190 -0
- package/src/components/pager/pagination.tsx +266 -0
- package/src/components/pager/previous-button.tsx +51 -0
- package/src/components/scroll-area/scroll-area.module.css +80 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
- package/src/components/scroll-area/scroll-area.tsx +22 -0
- package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
- package/src/components/section/section.astro +13 -0
- package/src/components/section/section.module.css +7 -0
- package/src/components/section/section.tsx +23 -0
- package/src/components/shimmer/shimmer.module.css +53 -0
- package/src/components/shimmer/shimmer.stories.tsx +24 -0
- package/src/components/shimmer/shimmer.tsx +70 -0
- package/src/components/table/table.module.css +100 -0
- package/src/components/table/table.stories.tsx +95 -0
- package/src/components/table/table.tsx +165 -0
- package/src/components/tabs/tabs.module.css +64 -0
- package/src/components/tabs/tabs.stories.tsx +47 -0
- package/src/components/tabs/tabs.tsx +75 -0
- package/src/components/timeline/timeline.module.css +87 -0
- package/src/components/timeline/timeline.stories.tsx +50 -0
- package/src/components/timeline/timeline.tsx +177 -0
- package/src/components/tooltip/tooltip.module.css +55 -0
- package/src/components/tooltip/tooltip.stories.tsx +59 -0
- package/src/components/tooltip/tooltip.tsx +51 -0
- package/src/declarations.d.ts +4 -0
- package/src/hooks/use-media-query.ts +20 -0
- package/src/icons/activity-icon.tsx +40 -0
- package/src/icons/calendar-icon.tsx +39 -0
- package/src/icons/check-icon.tsx +33 -0
- package/src/icons/chevron-down-icon.tsx +39 -0
- package/src/icons/chevron-left-double-icon.tsx +58 -0
- package/src/icons/chevron-left-icon.tsx +58 -0
- package/src/icons/chevron-right-double-icon.tsx +58 -0
- package/src/icons/chevron-right-icon.tsx +58 -0
- package/src/icons/chevrons-up-down.tsx +37 -0
- package/src/icons/close-icon.astro +38 -0
- package/src/icons/close-icon.tsx +30 -0
- package/src/icons/copy-icon.tsx +35 -0
- package/src/icons/danger-icon.tsx +18 -0
- package/src/icons/dashboard-icon.tsx +41 -0
- package/src/icons/delete-icon.tsx +34 -0
- package/src/icons/document-icon.tsx +38 -0
- package/src/icons/download-icon.tsx +39 -0
- package/src/icons/edit-icon.tsx +35 -0
- package/src/icons/ellipsis-icon.tsx +38 -0
- package/src/icons/email-icon.tsx +33 -0
- package/src/icons/external-link-icon.tsx +39 -0
- package/src/icons/github-icon.tsx +27 -0
- package/src/icons/globe-icon.tsx +50 -0
- package/src/icons/google-icon.tsx +44 -0
- package/src/icons/gripper-vertical-icon.tsx +43 -0
- package/src/icons/history-icon.tsx +32 -0
- package/src/icons/home-icon.tsx +34 -0
- package/src/icons/icon-element.astro +27 -0
- package/src/icons/icon-element.tsx +32 -0
- package/src/icons/icon-sprite.tsx +18 -0
- package/src/icons/icons.module.css +147 -0
- package/src/icons/index.stories.tsx +25 -0
- package/src/icons/index.ts +39 -0
- package/src/icons/info-icon.tsx +18 -0
- package/src/icons/infonomic-icon.tsx +173 -0
- package/src/icons/light-icon.astro +36 -0
- package/src/icons/light-icon.tsx +29 -0
- package/src/icons/location-pin-icon.tsx +36 -0
- package/src/icons/moon-icon.astro +38 -0
- package/src/icons/moon-icon.tsx +42 -0
- package/src/icons/plus-icon.tsx +34 -0
- package/src/icons/primary-icon.tsx +22 -0
- package/src/icons/refresh-icon.tsx +33 -0
- package/src/icons/return-icon.tsx +36 -0
- package/src/icons/roles-icon.tsx +34 -0
- package/src/icons/search-icon.astro +40 -0
- package/src/icons/search-icon.tsx +29 -0
- package/src/icons/search-menu-icon.tsx +42 -0
- package/src/icons/settings-gear-icon.tsx +36 -0
- package/src/icons/settings-sliders-icon.tsx +43 -0
- package/src/icons/sign-out-icon.tsx +35 -0
- package/src/icons/source/icon-calendar.svg +1 -0
- package/src/icons/source/icon-check.svg +4 -0
- package/src/icons/source/icon-close.svg +3 -0
- package/src/icons/source/icon-coinbase.svg +9 -0
- package/src/icons/source/icon-copy.svg +4 -0
- package/src/icons/source/icon-document.svg +5 -0
- package/src/icons/source/icon-download.svg +4 -0
- package/src/icons/source/icon-edit.svg +6 -0
- package/src/icons/source/icon-eth-purple.svg +15 -0
- package/src/icons/source/icon-etherscan.svg +5 -0
- package/src/icons/source/icon-external-link.svg +4 -0
- package/src/icons/source/icon-globe.svg +7 -0
- package/src/icons/source/icon-gripper-vertical.svg +9 -0
- package/src/icons/source/icon-info.svg +4 -0
- package/src/icons/source/icon-infonomic.svg +43 -0
- package/src/icons/source/icon-ledger.svg +4 -0
- package/src/icons/source/icon-light.svg +3 -0
- package/src/icons/source/icon-location-pin.svg +8 -0
- package/src/icons/source/icon-logout.svg +6 -0
- package/src/icons/source/icon-metamask.svg +32 -0
- package/src/icons/source/icon-moon.svg +3 -0
- package/src/icons/source/icon-plus.svg +4 -0
- package/src/icons/source/icon-refresh.svg +4 -0
- package/src/icons/source/icon-return.svg +4 -0
- package/src/icons/source/icon-search-menu.svg +13 -0
- package/src/icons/source/icon-search.svg +3 -0
- package/src/icons/source/icon-settings-gear.svg +5 -0
- package/src/icons/source/icon-settings.svg +12 -0
- package/src/icons/source/icon-wallet.svg +3 -0
- package/src/icons/source/icon-walletconnect.svg +4 -0
- package/src/icons/source/icon-x.svg +4 -0
- package/src/icons/stopwatch-icon.tsx +39 -0
- package/src/icons/success-icon.tsx +18 -0
- package/src/icons/types/icon.ts +8 -0
- package/src/icons/user-icon.tsx +33 -0
- package/src/icons/users-icon.tsx +35 -0
- package/src/icons/wallet-icon.tsx +29 -0
- package/src/icons/warning-icon.tsx +18 -0
- package/src/icons/x-icon.tsx +33 -0
- package/src/loaders/ellipses.tsx +36 -0
- package/src/loaders/loaders.stories.tsx +46 -0
- package/src/loaders/ring.tsx +33 -0
- package/src/loaders/spinner.tsx +28 -0
- package/src/loaders/types/index.ts +6 -0
- package/src/react.ts +99 -0
- package/src/styles/base/animations.css +143 -0
- package/src/styles/base/base.css +5 -0
- package/src/styles/base/colors.css +163 -0
- package/src/styles/base/colors.stories.tsx +671 -0
- package/src/styles/base/reset.css +464 -0
- package/src/styles/base/typography.css +25 -0
- package/src/styles/base/vars.css +188 -0
- package/src/styles/components/card.css +20 -0
- package/src/styles/components/checkbox.css +55 -0
- package/src/styles/components/components.css +11 -0
- package/src/styles/components/directional-button.css +92 -0
- package/src/styles/components/dropdown.css +19 -0
- package/src/styles/components/fade-in-lift.css +13 -0
- package/src/styles/components/hamburger.css +107 -0
- package/src/styles/components/icon-element.css +4 -0
- package/src/styles/components/list-checkbox.css +60 -0
- package/src/styles/components/loaders.css +196 -0
- package/src/styles/components/popover.css +15 -0
- package/src/styles/components/scroll-to-top.css +89 -0
- package/src/styles/components/toast.css +18 -0
- package/src/styles/styles.css +6 -0
- package/src/styles/theme/autofill.css +58 -0
- package/src/styles/theme/scrollers.css +52 -0
- package/src/styles/theme/theme.css +130 -0
- package/src/styles/theme/theme.stories.tsx +33 -0
- package/src/styles/typography/code.stories.tsx +76 -0
- package/src/styles/typography/default.stories.tsx +51 -0
- package/src/styles/typography/fonts.css +30 -0
- package/src/styles/typography/lists.stories.tsx +50 -0
- package/src/styles/typography/prose.css +404 -0
- package/src/styles/typography/quote.stories.tsx +37 -0
- package/src/styles/typography.css +24 -0
- package/src/styles/utils/scroll-layout-shift.css +9 -0
- package/src/styles/utils/utility-classes.css +1278 -0
- package/src/styles/utils/utils.css +2 -0
- package/src/theme/theme-provider/index.ts +1 -0
- package/src/theme/theme-provider/provider.tsx +44 -0
- package/src/utils/capitalize.ts +6 -0
- package/src/utils/externalLinkProps.ts +6 -0
- package/src/utils/findMatch.ts +7 -0
- package/src/utils/getPortalRoot.ts +3 -0
- package/src/utils/isTouchDevice.ts +11 -0
- package/src/utils/objectsToArray.ts +15 -0
- package/src/utils/objectsToString.ts +5 -0
- package/src/utils/polymorphic.ts +16 -0
- package/src/utils/to-kebab-case.ts +5 -0
- package/src/widgets/datepicker/datepicker.module.css +189 -0
- package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
- package/src/widgets/datepicker/datepicker.tsx +310 -0
- package/src/widgets/drawer/drawer-container.tsx +26 -0
- package/src/widgets/drawer/drawer-content.tsx +26 -0
- package/src/widgets/drawer/drawer-context.tsx +49 -0
- package/src/widgets/drawer/drawer-header.tsx +27 -0
- package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
- package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
- package/src/widgets/drawer/drawer.module.css +116 -0
- package/src/widgets/drawer/drawer.stories.tsx +224 -0
- package/src/widgets/drawer/drawer.tsx +115 -0
- package/src/widgets/drawer/motionDomAnimation.ts +4 -0
- package/src/widgets/drawer/motionDomMax.ts +4 -0
- package/src/widgets/modal/modal-actions.tsx +26 -0
- package/src/widgets/modal/modal-container.tsx +26 -0
- package/src/widgets/modal/modal-content.tsx +26 -0
- package/src/widgets/modal/modal-header.tsx +27 -0
- package/src/widgets/modal/modal-wrapper.tsx +50 -0
- package/src/widgets/modal/modal.module.css +85 -0
- package/src/widgets/modal/modal.stories.tsx +71 -0
- package/src/widgets/modal/modal.tsx +110 -0
- package/src/widgets/modal/motionDomAnimation.ts +4 -0
- package/src/widgets/modal/motionDomMax.ts +4 -0
- package/src/widgets/search/index.ts +1 -0
- package/src/widgets/search/search.stories.tsx +18 -0
- package/src/widgets/search/search.tsx +186 -0
|
@@ -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
|
+
}
|