@ledgerhq/lumen-ui-rnative 0.1.69 → 0.1.70
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/module/lib/Components/animations/Pulse/Pulse.stories.js +7 -0
- package/dist/module/lib/Components/animations/Pulse/Pulse.stories.js.map +1 -1
- package/dist/module/lib/Components/animations/Spin/Spin.stories.js +7 -0
- package/dist/module/lib/Components/animations/Spin/Spin.stories.js.map +1 -1
- package/dist/module/lib/Components/core/AddressInput/AddressInput.stories.js +129 -136
- package/dist/module/lib/Components/core/AddressInput/AddressInput.stories.js.map +1 -1
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.stories.js +12 -6
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.stories.js.map +1 -1
- package/dist/module/lib/Components/core/AmountInput/AmountInput.stories.js +154 -176
- package/dist/module/lib/Components/core/AmountInput/AmountInput.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.stories.js +54 -47
- package/dist/module/lib/Components/core/Avatar/Avatar.stories.js.map +1 -1
- package/dist/module/lib/Components/core/AvatarButton/AvatarButton.stories.js +2 -9
- package/dist/module/lib/Components/core/AvatarButton/AvatarButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Banner/Banner.stories.js +48 -87
- package/dist/module/lib/Components/core/Banner/Banner.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Button/Button.figma.js +2 -1
- package/dist/module/lib/Components/core/Button/Button.figma.js.map +1 -1
- package/dist/module/lib/Components/core/Button/Button.mdx +2 -1
- package/dist/module/lib/Components/core/Button/Button.stories.js +34 -10
- package/dist/module/lib/Components/core/Button/Button.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Card/Card.mdx +6 -0
- package/dist/module/lib/Components/core/Card/Card.stories.js +63 -24
- package/dist/module/lib/Components/core/Card/Card.stories.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js +27 -85
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Checkbox/Checkbox.stories.js +1 -1
- package/dist/module/lib/Components/core/ContentBanner/ContentBanner.stories.js +8 -18
- package/dist/module/lib/Components/core/ContentBanner/ContentBanner.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DescriptionItem/DescriptionItem.stories.js +28 -0
- package/dist/module/lib/Components/core/DescriptionItem/DescriptionItem.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Divider/Divider.stories.js +7 -0
- package/dist/module/lib/Components/core/Divider/Divider.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DotCount/DotCount.stories.js +28 -0
- package/dist/module/lib/Components/core/DotCount/DotCount.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/DotIcon.stories.js +12 -0
- package/dist/module/lib/Components/core/DotIcon/DotIcon.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DotIndicator/DotIndicator.stories.js +21 -0
- package/dist/module/lib/Components/core/DotIndicator/DotIndicator.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.stories.js +21 -0
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.stories.js.map +1 -1
- package/dist/module/lib/Components/core/IconButton/IconButton.stories.js +17 -0
- package/dist/module/lib/Components/core/IconButton/IconButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/InteractiveIcon/InteractiveIcon.stories.js +15 -21
- package/dist/module/lib/Components/core/InteractiveIcon/InteractiveIcon.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.js +1 -1
- package/dist/module/lib/Components/core/Link/Link.mdx +32 -5
- package/dist/module/lib/Components/core/Link/Link.stories.js +35 -139
- package/dist/module/lib/Components/core/Link/Link.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.test.js +1 -1
- package/dist/module/lib/Components/core/ListItem/ListItem.stories.js +2 -41
- package/dist/module/lib/Components/core/ListItem/ListItem.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.stories.js +19 -12
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MediaButton/MediaButton.stories.js +2 -13
- package/dist/module/lib/Components/core/MediaButton/MediaButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MediaCard/MediaCard.stories.js +24 -50
- package/dist/module/lib/Components/core/MediaCard/MediaCard.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MediaImage/MediaImage.stories.js +1 -1
- package/dist/module/lib/Components/core/MediaImageGroup/MediaImageGroup.mdx +6 -0
- package/dist/module/lib/Components/core/MediaImageGroup/MediaImageGroup.stories.js +96 -22
- package/dist/module/lib/Components/core/MediaImageGroup/MediaImageGroup.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MediaTag/MediaTag.stories.js +9 -0
- package/dist/module/lib/Components/core/MediaTag/MediaTag.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.mdx +2 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +17 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -1
- package/dist/module/lib/Components/core/PageIndicator/PageIndicator.figma.js +1 -1
- package/dist/module/lib/Components/core/PageIndicator/PageIndicator.figma.js.map +1 -1
- package/dist/module/lib/Components/core/PageIndicator/PageIndicator.stories.js +56 -50
- package/dist/module/lib/Components/core/PageIndicator/PageIndicator.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Pagination/Pagination.figma.js +22 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.js +182 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.js.map +1 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.mdx +108 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.stories.js +121 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.test.js +338 -0
- package/dist/module/lib/Components/core/Pagination/Pagination.test.js.map +1 -0
- package/dist/module/lib/Components/core/Pagination/index.js +4 -0
- package/dist/module/lib/Components/core/Pagination/index.js.map +1 -0
- package/dist/module/lib/Components/core/Pagination/types.js +4 -0
- package/dist/module/lib/Components/core/Pagination/types.js.map +1 -0
- package/dist/module/lib/Components/core/SearchInput/SearchInput.stories.js +75 -67
- package/dist/module/lib/Components/core/SearchInput/SearchInput.stories.js.map +1 -1
- package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.stories.js +12 -0
- package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.stories.js.map +1 -1
- package/dist/module/lib/Components/core/SelectList/SelectList.mdx +3 -1
- package/dist/module/lib/Components/core/SelectList/SelectList.stories.js +3 -3
- package/dist/module/lib/Components/core/SelectList/SelectList.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Skeleton/Skeleton.stories.js +7 -0
- package/dist/module/lib/Components/core/Skeleton/Skeleton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Spinner/Spinner.stories.js +7 -0
- package/dist/module/lib/Components/core/Spinner/Spinner.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Spot/Spot.stories.js +20 -1
- package/dist/module/lib/Components/core/Spot/Spot.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js +7 -0
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Subheader/Subheader.stories.js +11 -1
- package/dist/module/lib/Components/core/Subheader/Subheader.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Switch/Switch.stories.js +21 -1
- package/dist/module/lib/Components/core/Switch/Switch.stories.js.map +1 -1
- package/dist/module/lib/Components/core/TabBar/TabBar.stories.js +17 -5
- package/dist/module/lib/Components/core/TabBar/TabBar.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Tag/Tag.stories.js +28 -0
- package/dist/module/lib/Components/core/Tag/Tag.stories.js.map +1 -1
- package/dist/module/lib/Components/core/TextInput/TextInput.stories.js +159 -196
- package/dist/module/lib/Components/core/TextInput/TextInput.stories.js.map +1 -1
- package/dist/module/lib/Components/core/TextInput/TextInput.test.js +2 -2
- package/dist/module/lib/Components/core/TextInput/TextInput.test.js.map +1 -1
- package/dist/module/lib/Components/core/Tile/Tile.stories.js +2 -35
- package/dist/module/lib/Components/core/Tile/Tile.stories.js.map +1 -1
- package/dist/module/lib/Components/core/TileButton/TileButton.stories.js +18 -8
- package/dist/module/lib/Components/core/TileButton/TileButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Timeline/Timeline.js +81 -67
- package/dist/module/lib/Components/core/Timeline/Timeline.js.map +1 -1
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js +46 -16
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js +8 -5
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js.map +1 -1
- package/dist/module/lib/Components/core/Toast/Toast.mdx +1 -1
- package/dist/module/lib/Components/core/Toast/Toast.stories.js +61 -58
- package/dist/module/lib/Components/core/Toast/Toast.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Toast/Toaster.test.js +1 -1
- package/dist/module/lib/Components/core/Toast/Toaster.test.js.map +1 -1
- package/dist/module/lib/Components/core/Tooltip/Tooltip.stories.js +31 -2
- package/dist/module/lib/Components/core/Tooltip/Tooltip.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Trend/Trend.stories.js +9 -0
- package/dist/module/lib/Components/core/Trend/Trend.stories.js.map +1 -1
- package/dist/module/lib/Components/core/index.js +1 -0
- package/dist/module/lib/Components/core/index.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js +5 -2
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.test.js +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.test.js.map +1 -1
- package/dist/module/lib/Components/primitives/Box/Box.stories.js +1 -18
- package/dist/module/lib/Components/primitives/Box/Box.stories.js.map +1 -1
- package/dist/module/lib/Components/primitives/Gradient/LinearGradient/LinearGradient.stories.js +36 -0
- package/dist/module/lib/Components/primitives/Gradient/LinearGradient/LinearGradient.stories.js.map +1 -1
- package/dist/module/lib/Components/primitives/Gradient/RadialGradient/RadialGradient.stories.js +1 -1
- package/dist/module/lib/Components/primitives/Pressable/Pressable.stories.js +1 -19
- package/dist/module/lib/Components/primitives/Pressable/Pressable.stories.js.map +1 -1
- package/dist/module/lib/Components/primitives/Text/Text.stories.js +1 -12
- package/dist/module/lib/Components/primitives/Text/Text.stories.js.map +1 -1
- package/dist/module/lib/Components/symbols/Icon/Icon.stories.js +128 -85
- package/dist/module/lib/Components/symbols/Icon/Icon.stories.js.map +1 -1
- package/dist/module/lib/Components/visualization/DonutChart/DonutChart.test.js +1 -1
- package/dist/module/lib/Components/visualization/DonutChart/DonutChart.test.js.map +1 -1
- package/dist/module/lib/Components/visualization/Line/utils.js +1 -1
- package/dist/module/lib/Components/visualization/LineChart/LineChart.stories.js +69 -0
- package/dist/module/lib/Components/visualization/LineChart/LineChart.stories.js.map +1 -1
- package/dist/module/lib/Components/visualization/LineChart/LineChart.test.js +1 -1
- package/dist/module/lib/Components/visualization/LineChart/LineChart.test.js.map +1 -1
- package/dist/module/lib/Components/visualization/Point/Point.stories.js +12 -0
- package/dist/module/lib/Components/visualization/Point/Point.stories.js.map +1 -1
- package/dist/module/lib/Components/visualization/Point/Point.test.js +1 -1
- package/dist/module/lib/Components/visualization/Point/usePointGeometry.js +1 -1
- package/dist/module/lib/Components/visualization/Point/utils.js +1 -1
- package/dist/module/lib/Components/visualization/Point/utils.test.js +2 -2
- package/dist/module/lib/Components/visualization/ReferenceLine/ReferenceLine.stories.js +23 -0
- package/dist/module/lib/Components/visualization/ReferenceLine/ReferenceLine.stories.js.map +1 -1
- package/dist/module/lib/Components/visualization/Scrubber/DefaultScrubberTooltip/utils.js +3 -3
- package/dist/module/lib/Components/visualization/Scrubber/DefaultScrubberTooltip/utils.js.map +1 -1
- package/dist/module/lib/Components/visualization/Scrubber/Scrubber.stories.js +35 -0
- package/dist/module/lib/Components/visualization/Scrubber/Scrubber.stories.js.map +1 -1
- package/dist/module/translations/locales/de.json +7 -0
- package/dist/module/translations/locales/en.json +7 -0
- package/dist/module/translations/locales/es.json +7 -0
- package/dist/module/translations/locales/fr.json +7 -0
- package/dist/module/translations/locales/ja.json +7 -0
- package/dist/module/translations/locales/ko.json +7 -0
- package/dist/module/translations/locales/pt.json +7 -0
- package/dist/module/translations/locales/ru.json +7 -0
- package/dist/module/translations/locales/th.json +7 -0
- package/dist/module/translations/locales/tr.json +7 -0
- package/dist/module/translations/locales/zh.json +7 -0
- package/dist/typescript/src/lib/Components/core/Pagination/Pagination.d.ts +15 -0
- package/dist/typescript/src/lib/Components/core/Pagination/Pagination.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Pagination/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/Pagination/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Pagination/types.d.ts +29 -0
- package/dist/typescript/src/lib/Components/core/Pagination/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts +2 -2
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/index.d.ts +1 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/internal/BaseButton/BaseButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/internal/BaseButton/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/internal/BaseButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/internal/BaseInput/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/Axis/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/CartesianChart/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/Line/utils.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/LineChart/types.d.ts +3 -3
- package/dist/typescript/src/lib/Components/visualization/Point/types.d.ts +3 -3
- package/dist/typescript/src/lib/Components/visualization/Point/usePointGeometry.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/Point/utils.d.ts +1 -1
- package/dist/typescript/src/translations/translations.d.ts +84 -0
- package/dist/typescript/src/translations/translations.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/lib/Components/animations/Pulse/Pulse.stories.tsx +1 -0
- package/src/lib/Components/animations/Spin/Spin.stories.tsx +1 -0
- package/src/lib/Components/core/AddressInput/AddressInput.stories.tsx +168 -123
- package/src/lib/Components/core/AmountDisplay/AmountDisplay.stories.tsx +7 -7
- package/src/lib/Components/core/AmountInput/AmountInput.stories.tsx +162 -158
- package/src/lib/Components/core/Avatar/Avatar.stories.tsx +37 -46
- package/src/lib/Components/core/AvatarButton/AvatarButton.stories.tsx +1 -8
- package/src/lib/Components/core/Banner/Banner.stories.tsx +8 -95
- package/src/lib/Components/core/Button/Button.figma.tsx +1 -0
- package/src/lib/Components/core/Button/Button.mdx +2 -1
- package/src/lib/Components/core/Button/Button.stories.tsx +13 -14
- package/src/lib/Components/core/Card/Card.mdx +6 -0
- package/src/lib/Components/core/Card/Card.stories.tsx +31 -27
- package/src/lib/Components/core/CardButton/CardButton.stories.tsx +14 -90
- package/src/lib/Components/core/Checkbox/Checkbox.stories.tsx +1 -1
- package/src/lib/Components/core/ContentBanner/ContentBanner.stories.tsx +1 -17
- package/src/lib/Components/core/DescriptionItem/DescriptionItem.stories.tsx +4 -0
- package/src/lib/Components/core/Divider/Divider.stories.tsx +1 -0
- package/src/lib/Components/core/DotCount/DotCount.stories.tsx +4 -0
- package/src/lib/Components/core/DotIcon/DotIcon.stories.tsx +8 -0
- package/src/lib/Components/core/DotIndicator/DotIndicator.stories.tsx +3 -0
- package/src/lib/Components/core/DotSymbol/DotSymbol.stories.tsx +3 -0
- package/src/lib/Components/core/IconButton/IconButton.stories.tsx +9 -0
- package/src/lib/Components/core/InteractiveIcon/InteractiveIcon.stories.tsx +16 -23
- package/src/lib/Components/core/Link/Link.mdx +32 -5
- package/src/lib/Components/core/Link/Link.stories.tsx +20 -146
- package/src/lib/Components/core/Link/Link.test.tsx +1 -1
- package/src/lib/Components/core/Link/Link.tsx +1 -1
- package/src/lib/Components/core/ListItem/ListItem.stories.tsx +0 -39
- package/src/lib/Components/core/MediaBanner/MediaBanner.stories.tsx +3 -14
- package/src/lib/Components/core/MediaButton/MediaButton.stories.tsx +1 -12
- package/src/lib/Components/core/MediaCard/MediaCard.stories.tsx +10 -53
- package/src/lib/Components/core/MediaImage/MediaImage.stories.tsx +1 -1
- package/src/lib/Components/core/MediaImageGroup/MediaImageGroup.mdx +6 -0
- package/src/lib/Components/core/MediaImageGroup/MediaImageGroup.stories.tsx +47 -15
- package/src/lib/Components/core/MediaTag/MediaTag.stories.tsx +3 -0
- package/src/lib/Components/core/MenuList/MenuList.mdx +2 -2
- package/src/lib/Components/core/MenuList/MenuList.stories.tsx +13 -1
- package/src/lib/Components/core/PageIndicator/PageIndicator.figma.tsx +1 -1
- package/src/lib/Components/core/PageIndicator/PageIndicator.stories.tsx +45 -42
- package/src/lib/Components/core/Pagination/Pagination.figma.tsx +25 -0
- package/src/lib/Components/core/Pagination/Pagination.mdx +108 -0
- package/src/lib/Components/core/Pagination/Pagination.stories.tsx +90 -0
- package/src/lib/Components/core/Pagination/Pagination.test.tsx +346 -0
- package/src/lib/Components/core/Pagination/Pagination.tsx +200 -0
- package/src/lib/Components/core/Pagination/index.ts +2 -0
- package/src/lib/Components/core/Pagination/types.ts +29 -0
- package/src/lib/Components/core/SearchInput/SearchInput.stories.tsx +91 -66
- package/src/lib/Components/core/SegmentedControl/SegmentedControl.stories.tsx +2 -0
- package/src/lib/Components/core/SelectList/SelectList.mdx +3 -1
- package/src/lib/Components/core/SelectList/SelectList.stories.tsx +3 -3
- package/src/lib/Components/core/Skeleton/Skeleton.stories.tsx +1 -0
- package/src/lib/Components/core/Spinner/Spinner.stories.tsx +1 -0
- package/src/lib/Components/core/Spot/Spot.stories.tsx +10 -1
- package/src/lib/Components/core/Stepper/Stepper.stories.tsx +1 -0
- package/src/lib/Components/core/Subheader/Subheader.stories.tsx +5 -2
- package/src/lib/Components/core/Switch/Switch.stories.tsx +17 -1
- package/src/lib/Components/core/TabBar/TabBar.stories.tsx +15 -5
- package/src/lib/Components/core/Tag/Tag.stories.tsx +4 -0
- package/src/lib/Components/core/TextInput/TextInput.stories.tsx +186 -174
- package/src/lib/Components/core/TextInput/TextInput.test.tsx +2 -2
- package/src/lib/Components/core/Tile/Tile.stories.tsx +0 -33
- package/src/lib/Components/core/TileButton/TileButton.stories.tsx +9 -7
- package/src/lib/Components/core/Timeline/Timeline.stories.tsx +20 -1
- package/src/lib/Components/core/Timeline/Timeline.test.tsx +12 -8
- package/src/lib/Components/core/Timeline/Timeline.tsx +79 -75
- package/src/lib/Components/core/Toast/Toast.mdx +1 -1
- package/src/lib/Components/core/Toast/Toast.stories.tsx +55 -66
- package/src/lib/Components/core/Toast/Toaster.test.tsx +1 -1
- package/src/lib/Components/core/Tooltip/Tooltip.stories.tsx +7 -3
- package/src/lib/Components/core/Trend/Trend.stories.tsx +3 -0
- package/src/lib/Components/core/index.ts +1 -0
- package/src/lib/Components/internal/BaseButton/BaseButton.test.tsx +1 -0
- package/src/lib/Components/internal/BaseButton/BaseButton.tsx +3 -0
- package/src/lib/Components/internal/BaseButton/types.ts +2 -1
- package/src/lib/Components/internal/BaseInput/types.ts +1 -1
- package/src/lib/Components/primitives/Box/Box.stories.tsx +1 -18
- package/src/lib/Components/primitives/Gradient/LinearGradient/LinearGradient.stories.tsx +12 -0
- package/src/lib/Components/primitives/Gradient/RadialGradient/RadialGradient.stories.tsx +1 -1
- package/src/lib/Components/primitives/Pressable/Pressable.stories.tsx +0 -18
- package/src/lib/Components/primitives/Text/Text.stories.tsx +1 -12
- package/src/lib/Components/symbols/Icon/Icon.stories.tsx +133 -94
- package/src/lib/Components/visualization/Axis/types.ts +1 -1
- package/src/lib/Components/visualization/CartesianChart/types.ts +1 -1
- package/src/lib/Components/visualization/DonutChart/DonutChart.test.tsx +1 -1
- package/src/lib/Components/visualization/Line/utils.ts +1 -1
- package/src/lib/Components/visualization/LineChart/LineChart.stories.tsx +15 -0
- package/src/lib/Components/visualization/LineChart/LineChart.test.tsx +1 -1
- package/src/lib/Components/visualization/LineChart/types.ts +3 -3
- package/src/lib/Components/visualization/Point/Point.stories.tsx +2 -0
- package/src/lib/Components/visualization/Point/Point.test.tsx +1 -1
- package/src/lib/Components/visualization/Point/types.ts +3 -3
- package/src/lib/Components/visualization/Point/usePointGeometry.ts +1 -1
- package/src/lib/Components/visualization/Point/utils.test.ts +2 -2
- package/src/lib/Components/visualization/Point/utils.ts +1 -1
- package/src/lib/Components/visualization/ReferenceLine/ReferenceLine.stories.tsx +5 -0
- package/src/lib/Components/visualization/Scrubber/DefaultScrubberTooltip/utils.ts +3 -3
- package/src/lib/Components/visualization/Scrubber/Scrubber.stories.tsx +5 -0
- package/src/translations/locales/de.json +7 -0
- package/src/translations/locales/en.json +7 -0
- package/src/translations/locales/es.json +7 -0
- package/src/translations/locales/fr.json +7 -0
- package/src/translations/locales/ja.json +7 -0
- package/src/translations/locales/ko.json +7 -0
- package/src/translations/locales/pt.json +7 -0
- package/src/translations/locales/ru.json +7 -0
- package/src/translations/locales/th.json +7 -0
- package/src/translations/locales/tr.json +7 -0
- package/src/translations/locales/zh.json +7 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import {
|
|
2
|
+
afterEach,
|
|
3
|
+
beforeEach,
|
|
4
|
+
describe,
|
|
5
|
+
expect,
|
|
6
|
+
it,
|
|
7
|
+
jest,
|
|
8
|
+
} from '@jest/globals';
|
|
9
|
+
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
10
|
+
import { getPaginationRange } from '@ledgerhq/lumen-utils-shared';
|
|
11
|
+
import { fireEvent, render, screen } from '@testing-library/react-native';
|
|
12
|
+
import type { ReactNode } from 'react';
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { ScrollView } from 'react-native';
|
|
15
|
+
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
16
|
+
import { Pagination } from './Pagination';
|
|
17
|
+
|
|
18
|
+
const TestWrapper = ({
|
|
19
|
+
children,
|
|
20
|
+
locale = 'en',
|
|
21
|
+
}: {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
locale?: 'en' | 'fr';
|
|
24
|
+
}) => (
|
|
25
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale={locale}>
|
|
26
|
+
{children}
|
|
27
|
+
</ThemeProvider>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// Jest has no layout engine, so layouts are simulated: 1-digit pages and
|
|
31
|
+
// ellipses are 40 wide, 2-digit pages 48, separated by an 8 gap.
|
|
32
|
+
const ITEM_GAP = 8;
|
|
33
|
+
const getItemWidth = (item: number | string): number =>
|
|
34
|
+
typeof item === 'number' ? 32 + String(item).length * 8 : 40;
|
|
35
|
+
|
|
36
|
+
const fireLayout = (
|
|
37
|
+
element: Parameters<typeof fireEvent>[0],
|
|
38
|
+
x: number,
|
|
39
|
+
width: number,
|
|
40
|
+
): void => {
|
|
41
|
+
fireEvent(element, 'layout', {
|
|
42
|
+
nativeEvent: { layout: { x, y: 0, width, height: 40 } },
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const layoutPages = (page: number, totalPages: number): void => {
|
|
47
|
+
let x = 0;
|
|
48
|
+
for (const item of getPaginationRange(page, totalPages)) {
|
|
49
|
+
const width = getItemWidth(item);
|
|
50
|
+
if (typeof item === 'number') {
|
|
51
|
+
fireLayout(screen.getByLabelText(`Page ${item}`), x, width);
|
|
52
|
+
}
|
|
53
|
+
x += width + ITEM_GAP;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const layoutViewport = (width: number): void => {
|
|
58
|
+
fireLayout(screen.UNSAFE_getByType(ScrollView), 0, width);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const ControlledPagination = ({ initialPage }: { initialPage: number }) => {
|
|
62
|
+
const [page, setPage] = useState(initialPage);
|
|
63
|
+
return <Pagination page={page} totalPages={20} onPageChange={setPage} />;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
describe('Pagination', () => {
|
|
67
|
+
it('should render page buttons with the active page selected', () => {
|
|
68
|
+
render(
|
|
69
|
+
<TestWrapper>
|
|
70
|
+
<Pagination page={2} totalPages={5} onPageChange={jest.fn()} />
|
|
71
|
+
</TestWrapper>,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect(screen.getByLabelText('Pagination')).toBeTruthy();
|
|
75
|
+
expect(screen.getByLabelText('Page 2')).toBeSelected();
|
|
76
|
+
expect(screen.getByLabelText('Page 3')).not.toBeSelected();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should call onPageChange when a page is pressed', () => {
|
|
80
|
+
const onPageChange = jest.fn();
|
|
81
|
+
|
|
82
|
+
render(
|
|
83
|
+
<TestWrapper>
|
|
84
|
+
<Pagination page={1} totalPages={5} onPageChange={onPageChange} />
|
|
85
|
+
</TestWrapper>,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
fireEvent.press(screen.getByLabelText('Page 3'));
|
|
89
|
+
|
|
90
|
+
expect(onPageChange).toHaveBeenCalledWith(3);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should call onPageChange with the adjacent pages from previous and next', () => {
|
|
94
|
+
const onPageChange = jest.fn();
|
|
95
|
+
|
|
96
|
+
render(
|
|
97
|
+
<TestWrapper>
|
|
98
|
+
<Pagination page={2} totalPages={5} onPageChange={onPageChange} />
|
|
99
|
+
</TestWrapper>,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
fireEvent.press(screen.getByLabelText('Previous page'));
|
|
103
|
+
fireEvent.press(screen.getByLabelText('Next page'));
|
|
104
|
+
|
|
105
|
+
expect(onPageChange).toHaveBeenNthCalledWith(1, 1);
|
|
106
|
+
expect(onPageChange).toHaveBeenNthCalledWith(2, 3);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should disable previous on the first page and next on the last page', () => {
|
|
110
|
+
const onPageChange = jest.fn();
|
|
111
|
+
|
|
112
|
+
const { rerender } = render(
|
|
113
|
+
<TestWrapper>
|
|
114
|
+
<Pagination page={1} totalPages={5} onPageChange={onPageChange} />
|
|
115
|
+
</TestWrapper>,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
fireEvent.press(screen.getByLabelText('Previous page'));
|
|
119
|
+
|
|
120
|
+
rerender(
|
|
121
|
+
<TestWrapper>
|
|
122
|
+
<Pagination page={5} totalPages={5} onPageChange={onPageChange} />
|
|
123
|
+
</TestWrapper>,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
fireEvent.press(screen.getByLabelText('Next page'));
|
|
127
|
+
|
|
128
|
+
expect(onPageChange).not.toHaveBeenCalled();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should clamp page above totalPages to totalPages', () => {
|
|
132
|
+
render(
|
|
133
|
+
<TestWrapper>
|
|
134
|
+
<Pagination page={99} totalPages={5} onPageChange={jest.fn()} />
|
|
135
|
+
</TestWrapper>,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
expect(screen.getByLabelText('Page 5')).toBeSelected();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should collapse distant pages behind ellipsis markers hidden from assistive technology', () => {
|
|
142
|
+
render(
|
|
143
|
+
<TestWrapper>
|
|
144
|
+
<Pagination page={10} totalPages={20} onPageChange={jest.fn()} />
|
|
145
|
+
</TestWrapper>,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect(screen.queryByText('…')).toBeNull();
|
|
149
|
+
expect(
|
|
150
|
+
screen.getAllByText('…', { includeHiddenElements: true }),
|
|
151
|
+
).toHaveLength(2);
|
|
152
|
+
expect(screen.queryByLabelText('Page 5')).toBeNull();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should render the page buttons inside a horizontal scroll view', () => {
|
|
156
|
+
render(
|
|
157
|
+
<TestWrapper>
|
|
158
|
+
<Pagination page={10} totalPages={20} onPageChange={jest.fn()} />
|
|
159
|
+
</TestWrapper>,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
expect(screen.UNSAFE_getByType(ScrollView).props.horizontal).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('active page visibility', () => {
|
|
166
|
+
let scrollTo: jest.SpiedFunction<ScrollView['scrollTo']>;
|
|
167
|
+
|
|
168
|
+
beforeEach(() => {
|
|
169
|
+
scrollTo = jest
|
|
170
|
+
.spyOn(ScrollView.prototype, 'scrollTo')
|
|
171
|
+
.mockImplementation(() => undefined);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
afterEach(() => {
|
|
175
|
+
scrollTo.mockRestore();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should center the active page once the row is laid out', () => {
|
|
179
|
+
render(
|
|
180
|
+
<TestWrapper>
|
|
181
|
+
<Pagination page={10} totalPages={20} onPageChange={jest.fn()} />
|
|
182
|
+
</TestWrapper>,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
layoutPages(10, 20);
|
|
186
|
+
expect(scrollTo).not.toHaveBeenCalled();
|
|
187
|
+
|
|
188
|
+
layoutViewport(240);
|
|
189
|
+
|
|
190
|
+
// Page 10 spans 144–192, so its center (168) minus half the viewport.
|
|
191
|
+
expect(scrollTo).toHaveBeenCalledTimes(1);
|
|
192
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 48, animated: false });
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('should follow the active page across an ellipsis boundary', () => {
|
|
196
|
+
render(
|
|
197
|
+
<TestWrapper>
|
|
198
|
+
<ControlledPagination initialPage={3} />
|
|
199
|
+
</TestWrapper>,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
layoutPages(3, 20);
|
|
203
|
+
layoutViewport(160);
|
|
204
|
+
// Page 3 spans 96–136 in [1 2 3 4 5 … 20].
|
|
205
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 36, animated: false });
|
|
206
|
+
|
|
207
|
+
fireEvent.press(screen.getByLabelText('Next page'));
|
|
208
|
+
expect(screen.getByLabelText('Page 4')).toBeSelected();
|
|
209
|
+
expect(screen.queryByLabelText('Page 2')).toBeNull();
|
|
210
|
+
|
|
211
|
+
layoutPages(4, 20);
|
|
212
|
+
// Page 4 spans 144–184 in [1 … 3 4 5 … 20].
|
|
213
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 84, animated: false });
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('should scroll to an already measured page when the row does not move', () => {
|
|
217
|
+
render(
|
|
218
|
+
<TestWrapper>
|
|
219
|
+
<ControlledPagination initialPage={1} />
|
|
220
|
+
</TestWrapper>,
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
layoutPages(1, 20);
|
|
224
|
+
layoutViewport(80);
|
|
225
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 0, animated: false });
|
|
226
|
+
|
|
227
|
+
// [1 2 3 4 5 … 20] is unchanged, so no layout event follows the press.
|
|
228
|
+
fireEvent.press(screen.getByLabelText('Next page'));
|
|
229
|
+
|
|
230
|
+
// Page 2 spans 48–88.
|
|
231
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 28, animated: false });
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('should scroll once a newly shown page is measured', () => {
|
|
235
|
+
const { rerender } = render(
|
|
236
|
+
<TestWrapper>
|
|
237
|
+
<Pagination page={10} totalPages={20} onPageChange={jest.fn()} />
|
|
238
|
+
</TestWrapper>,
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
layoutPages(10, 20);
|
|
242
|
+
layoutViewport(240);
|
|
243
|
+
scrollTo.mockClear();
|
|
244
|
+
|
|
245
|
+
rerender(
|
|
246
|
+
<TestWrapper>
|
|
247
|
+
<Pagination page={15} totalPages={20} onPageChange={jest.fn()} />
|
|
248
|
+
</TestWrapper>,
|
|
249
|
+
);
|
|
250
|
+
expect(scrollTo).not.toHaveBeenCalled();
|
|
251
|
+
|
|
252
|
+
layoutPages(15, 20);
|
|
253
|
+
// Page 15 spans 152–200 in [1 … 14 15 16 … 20].
|
|
254
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 56, animated: false });
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should recenter when the viewport is resized', () => {
|
|
258
|
+
render(
|
|
259
|
+
<TestWrapper>
|
|
260
|
+
<Pagination page={10} totalPages={20} onPageChange={jest.fn()} />
|
|
261
|
+
</TestWrapper>,
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
layoutPages(10, 20);
|
|
265
|
+
layoutViewport(240);
|
|
266
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 48, animated: false });
|
|
267
|
+
|
|
268
|
+
layoutViewport(320);
|
|
269
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 8, animated: false });
|
|
270
|
+
|
|
271
|
+
// Wider than the content's left half: clamped to the start.
|
|
272
|
+
layoutViewport(400);
|
|
273
|
+
expect(scrollTo).toHaveBeenLastCalledWith({ x: 0, animated: false });
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should return null when totalPages is 0', () => {
|
|
278
|
+
render(
|
|
279
|
+
<TestWrapper>
|
|
280
|
+
<Pagination
|
|
281
|
+
testID='pagination'
|
|
282
|
+
page={1}
|
|
283
|
+
totalPages={0}
|
|
284
|
+
onPageChange={jest.fn()}
|
|
285
|
+
/>
|
|
286
|
+
</TestWrapper>,
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
expect(screen.queryByTestId('pagination')).toBeNull();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe('compact density', () => {
|
|
293
|
+
it('should render the current of total label instead of page buttons', () => {
|
|
294
|
+
render(
|
|
295
|
+
<TestWrapper>
|
|
296
|
+
<Pagination
|
|
297
|
+
page={2}
|
|
298
|
+
totalPages={8}
|
|
299
|
+
density='compact'
|
|
300
|
+
onPageChange={jest.fn()}
|
|
301
|
+
/>
|
|
302
|
+
</TestWrapper>,
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
expect(screen.getByText('2 of 8')).toBeTruthy();
|
|
306
|
+
expect(screen.queryByLabelText('Page 2')).toBeNull();
|
|
307
|
+
expect(screen.UNSAFE_queryByType(ScrollView)).toBeNull();
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('should localize the label', () => {
|
|
311
|
+
render(
|
|
312
|
+
<TestWrapper locale='fr'>
|
|
313
|
+
<Pagination
|
|
314
|
+
page={2}
|
|
315
|
+
totalPages={8}
|
|
316
|
+
density='compact'
|
|
317
|
+
onPageChange={jest.fn()}
|
|
318
|
+
/>
|
|
319
|
+
</TestWrapper>,
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
expect(screen.getByText('2 sur 8')).toBeTruthy();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('should navigate with previous and next', () => {
|
|
326
|
+
const onPageChange = jest.fn();
|
|
327
|
+
|
|
328
|
+
render(
|
|
329
|
+
<TestWrapper>
|
|
330
|
+
<Pagination
|
|
331
|
+
page={2}
|
|
332
|
+
totalPages={8}
|
|
333
|
+
density='compact'
|
|
334
|
+
onPageChange={onPageChange}
|
|
335
|
+
/>
|
|
336
|
+
</TestWrapper>,
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
fireEvent.press(screen.getByLabelText('Previous page'));
|
|
340
|
+
fireEvent.press(screen.getByLabelText('Next page'));
|
|
341
|
+
|
|
342
|
+
expect(onPageChange).toHaveBeenNthCalledWith(1, 1);
|
|
343
|
+
expect(onPageChange).toHaveBeenNthCalledWith(2, 3);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
});
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { getPaginationRange } from '@ledgerhq/lumen-utils-shared';
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
3
|
+
import type { LayoutChangeEvent, LayoutRectangle } from 'react-native';
|
|
4
|
+
import { ScrollView } from 'react-native';
|
|
5
|
+
import { useStyleSheet } from '../../../../styles';
|
|
6
|
+
import { useCommonTranslation } from '../../../../translations';
|
|
7
|
+
import { Box } from '../../primitives/Box';
|
|
8
|
+
import { Text } from '../../primitives/Text';
|
|
9
|
+
import { ChevronLeft, ChevronRight } from '../../symbols';
|
|
10
|
+
import { Button } from '../Button';
|
|
11
|
+
import { IconButton } from '../IconButton';
|
|
12
|
+
import type { PaginationProps } from './types';
|
|
13
|
+
|
|
14
|
+
const usePaginationStyles = () =>
|
|
15
|
+
useStyleSheet(
|
|
16
|
+
(t) => ({
|
|
17
|
+
root: {
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
maxWidth: '100%',
|
|
21
|
+
gap: t.spacings.s8,
|
|
22
|
+
padding: t.spacings.s4,
|
|
23
|
+
},
|
|
24
|
+
scroll: { flexGrow: 0, flexShrink: 1 },
|
|
25
|
+
scrollContent: {
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
gap: t.spacings.s8,
|
|
29
|
+
},
|
|
30
|
+
pageOfTotal: {
|
|
31
|
+
...t.typographies.body2SemiBold,
|
|
32
|
+
color: t.colors.text.base,
|
|
33
|
+
paddingHorizontal: t.spacings.s4,
|
|
34
|
+
},
|
|
35
|
+
ellipsis: {
|
|
36
|
+
width: t.sizes.s40,
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
},
|
|
40
|
+
ellipsisText: {
|
|
41
|
+
...t.typographies.body2,
|
|
42
|
+
color: t.colors.text.muted,
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
[],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Keeps the active page centered in the scrollable range, so navigating with
|
|
50
|
+
* the arrows never leaves it off-screen.
|
|
51
|
+
*/
|
|
52
|
+
const useScrollToActivePage = (activePage: number) => {
|
|
53
|
+
const scrollRef = useRef<ScrollView>(null);
|
|
54
|
+
const viewportWidth = useRef(0);
|
|
55
|
+
const pageLayouts = useRef(new Map<number, LayoutRectangle>());
|
|
56
|
+
|
|
57
|
+
const scrollToActivePage = useCallback((): void => {
|
|
58
|
+
const layout = pageLayouts.current.get(activePage);
|
|
59
|
+
if (!layout || !viewportWidth.current) return;
|
|
60
|
+
scrollRef.current?.scrollTo({
|
|
61
|
+
x: Math.max(0, layout.x + layout.width / 2 - viewportWidth.current / 2),
|
|
62
|
+
animated: false,
|
|
63
|
+
});
|
|
64
|
+
}, [activePage]);
|
|
65
|
+
|
|
66
|
+
useEffect(scrollToActivePage, [scrollToActivePage]);
|
|
67
|
+
|
|
68
|
+
const onViewportLayout = (event: LayoutChangeEvent): void => {
|
|
69
|
+
viewportWidth.current = event.nativeEvent.layout.width;
|
|
70
|
+
scrollToActivePage();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onPageLayout = (page: number, event: LayoutChangeEvent): void => {
|
|
74
|
+
pageLayouts.current.set(page, event.nativeEvent.layout);
|
|
75
|
+
if (page === activePage) scrollToActivePage();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return { scrollRef, onViewportLayout, onPageLayout };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Pagination navigation for lists and other paginated content.
|
|
83
|
+
*
|
|
84
|
+
* @see [Figma – Pagination](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=11768-12849&m=dev)
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* <Pagination
|
|
88
|
+
* page={page}
|
|
89
|
+
* totalPages={10}
|
|
90
|
+
* onPageChange={setPage}
|
|
91
|
+
* />
|
|
92
|
+
*/
|
|
93
|
+
export const Pagination = ({
|
|
94
|
+
page,
|
|
95
|
+
totalPages,
|
|
96
|
+
onPageChange,
|
|
97
|
+
siblingCount = 1,
|
|
98
|
+
density = 'expanded',
|
|
99
|
+
lx,
|
|
100
|
+
style,
|
|
101
|
+
ref,
|
|
102
|
+
...props
|
|
103
|
+
}: PaginationProps) => {
|
|
104
|
+
const { t } = useCommonTranslation();
|
|
105
|
+
const styles = usePaginationStyles();
|
|
106
|
+
const clampedPage = Math.min(Math.max(page, 1), Math.max(totalPages, 1));
|
|
107
|
+
const { scrollRef, onViewportLayout, onPageLayout } =
|
|
108
|
+
useScrollToActivePage(clampedPage);
|
|
109
|
+
|
|
110
|
+
if (totalPages <= 0) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const isCompact = density === 'compact';
|
|
115
|
+
const items = isCompact
|
|
116
|
+
? []
|
|
117
|
+
: getPaginationRange(clampedPage, totalPages, Math.max(siblingCount, 0));
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Box
|
|
121
|
+
ref={ref}
|
|
122
|
+
accessibilityLabel={t('components.pagination.navigationAriaLabel')}
|
|
123
|
+
lx={lx}
|
|
124
|
+
style={[styles.root, style]}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
<IconButton
|
|
128
|
+
icon={ChevronLeft}
|
|
129
|
+
size='sm'
|
|
130
|
+
appearance='gray'
|
|
131
|
+
disabled={clampedPage <= 1}
|
|
132
|
+
accessibilityLabel={t('components.pagination.previousPageAriaLabel')}
|
|
133
|
+
onPress={() => onPageChange(clampedPage - 1)}
|
|
134
|
+
/>
|
|
135
|
+
{isCompact && (
|
|
136
|
+
<Text
|
|
137
|
+
accessibilityLiveRegion='polite'
|
|
138
|
+
numberOfLines={1}
|
|
139
|
+
style={styles.pageOfTotal}
|
|
140
|
+
>
|
|
141
|
+
{t('components.pagination.pageOfTotal', {
|
|
142
|
+
current: clampedPage,
|
|
143
|
+
total: totalPages,
|
|
144
|
+
})}
|
|
145
|
+
</Text>
|
|
146
|
+
)}
|
|
147
|
+
{!isCompact && (
|
|
148
|
+
<ScrollView
|
|
149
|
+
ref={scrollRef}
|
|
150
|
+
horizontal
|
|
151
|
+
showsHorizontalScrollIndicator={false}
|
|
152
|
+
style={styles.scroll}
|
|
153
|
+
contentContainerStyle={styles.scrollContent}
|
|
154
|
+
onLayout={onViewportLayout}
|
|
155
|
+
>
|
|
156
|
+
{items.map((item) => {
|
|
157
|
+
if (typeof item === 'string') {
|
|
158
|
+
return (
|
|
159
|
+
<Box
|
|
160
|
+
key={item}
|
|
161
|
+
importantForAccessibility='no-hide-descendants'
|
|
162
|
+
accessibilityElementsHidden
|
|
163
|
+
style={styles.ellipsis}
|
|
164
|
+
>
|
|
165
|
+
<Text style={styles.ellipsisText}>…</Text>
|
|
166
|
+
</Box>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const isActive = item === clampedPage;
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Button
|
|
174
|
+
key={item}
|
|
175
|
+
size='sm'
|
|
176
|
+
appearance={isActive ? 'gray' : 'no-background'}
|
|
177
|
+
accessibilityLabel={t('components.pagination.pageAriaLabel', {
|
|
178
|
+
page: item,
|
|
179
|
+
})}
|
|
180
|
+
accessibilityState={{ selected: isActive }}
|
|
181
|
+
onLayout={(event) => onPageLayout(item, event)}
|
|
182
|
+
onPress={() => onPageChange(item)}
|
|
183
|
+
>
|
|
184
|
+
{item}
|
|
185
|
+
</Button>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</ScrollView>
|
|
189
|
+
)}
|
|
190
|
+
<IconButton
|
|
191
|
+
icon={ChevronRight}
|
|
192
|
+
size='sm'
|
|
193
|
+
appearance='gray'
|
|
194
|
+
disabled={clampedPage >= totalPages}
|
|
195
|
+
accessibilityLabel={t('components.pagination.nextPageAriaLabel')}
|
|
196
|
+
onPress={() => onPageChange(clampedPage + 1)}
|
|
197
|
+
/>
|
|
198
|
+
</Box>
|
|
199
|
+
);
|
|
200
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Density } from '@ledgerhq/lumen-utils-shared';
|
|
2
|
+
import type { StyledViewProps } from '../../../../styles';
|
|
3
|
+
|
|
4
|
+
export type PaginationProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Current page, 1-indexed.
|
|
7
|
+
*/
|
|
8
|
+
page: number;
|
|
9
|
+
/**
|
|
10
|
+
* Total number of pages.
|
|
11
|
+
* If `<= 0`, the component returns `null`.
|
|
12
|
+
*/
|
|
13
|
+
totalPages: number;
|
|
14
|
+
/**
|
|
15
|
+
* Callback fired when the user selects a different page.
|
|
16
|
+
*/
|
|
17
|
+
onPageChange: (page: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Number of page buttons shown on each side of the current page.
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
siblingCount?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The density of the pagination. Compact replaces the page buttons with a
|
|
25
|
+
* "current of total" label, for tight spaces such as narrow screens.
|
|
26
|
+
* @default 'expanded'
|
|
27
|
+
*/
|
|
28
|
+
density?: Density;
|
|
29
|
+
} & Omit<StyledViewProps, 'children'>;
|