@utilitywarehouse/hearth-react-native 0.4.2 → 0.5.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +44 -0
- package/build/components/Alert/AlertTitle.js +6 -6
- package/build/components/Badge/Badge.js +3 -3
- package/build/components/Badge/Badge.props.d.ts +1 -0
- package/build/components/Button/ButtonRoot.js +4 -0
- package/build/components/Button/ButtonText.js +2 -2
- package/build/components/Card/CardRoot.js +1 -1
- package/build/components/Carousel/Carousel.context.d.ts +4 -0
- package/build/components/Carousel/Carousel.context.js +4 -0
- package/build/components/Carousel/Carousel.d.ts +6 -0
- package/build/components/Carousel/Carousel.js +278 -0
- package/build/components/Carousel/Carousel.props.d.ts +65 -0
- package/build/components/Carousel/Carousel.props.js +1 -0
- package/build/components/Carousel/CarouselControlItem.d.ts +24 -0
- package/build/components/Carousel/CarouselControlItem.js +64 -0
- package/build/components/Carousel/CarouselControls.d.ts +4 -0
- package/build/components/Carousel/CarouselControls.js +74 -0
- package/build/components/Carousel/CarouselItem.d.ts +6 -0
- package/build/components/Carousel/CarouselItem.js +38 -0
- package/build/components/Carousel/index.d.ts +5 -0
- package/build/components/Carousel/index.js +5 -0
- package/build/components/DescriptionList/DescriptionList.d.ts +1 -1
- package/build/components/DescriptionList/DescriptionList.js +2 -2
- package/build/components/DescriptionList/DescriptionList.props.d.ts +1 -8
- package/build/components/DescriptionList/DescriptionListItem.d.ts +1 -1
- package/build/components/DescriptionList/DescriptionListItem.js +4 -3
- package/build/components/DescriptionList/DescriptionListItem.props.d.ts +3 -8
- package/build/components/IndicatorIconButton/IndicatorIconButton.d.ts +6 -0
- package/build/components/IndicatorIconButton/IndicatorIconButton.js +26 -0
- package/build/components/IndicatorIconButton/IndicatorIconButton.props.d.ts +8 -0
- package/build/components/IndicatorIconButton/IndicatorIconButton.props.js +1 -0
- package/build/components/IndicatorIconButton/index.d.ts +2 -0
- package/build/components/IndicatorIconButton/index.js +1 -0
- package/build/components/Link/LinkText.js +3 -3
- package/build/components/List/List.context.d.ts +0 -2
- package/build/components/List/List.d.ts +1 -1
- package/build/components/List/List.js +5 -5
- package/build/components/List/List.props.d.ts +1 -9
- package/build/components/List/ListAction/ListAction.d.ts +18 -0
- package/build/components/List/ListAction/ListAction.js +103 -0
- package/build/components/List/ListAction/ListAction.props.d.ts +8 -0
- package/build/components/List/ListAction/ListAction.props.js +1 -0
- package/build/components/List/ListAction/ListActionContent.d.ts +6 -0
- package/build/components/List/ListAction/ListActionContent.js +14 -0
- package/build/components/List/ListAction/ListActionText.d.ts +6 -0
- package/build/components/List/ListAction/ListActionText.js +7 -0
- package/build/components/List/ListAction/ListActionTrailingContent.d.ts +6 -0
- package/build/components/List/ListAction/ListActionTrailingContent.js +5 -0
- package/build/components/List/ListAction/ListActionTrailingIcon.d.ts +9 -0
- package/build/components/List/ListAction/ListActionTrailingIcon.js +18 -0
- package/build/components/List/ListAction/index.d.ts +6 -0
- package/build/components/List/ListAction/index.js +5 -0
- package/build/components/List/ListItem/ListItem.context.d.ts +1 -1
- package/build/components/List/ListItem/ListItem.props.d.ts +9 -5
- package/build/components/List/ListItem/ListItemRoot.d.ts +1 -1
- package/build/components/List/ListItem/ListItemRoot.js +10 -12
- package/build/components/List/ListItem/index.d.ts +4 -4
- package/build/components/List/ListItem/index.js +3 -3
- package/build/components/List/index.d.ts +1 -0
- package/build/components/List/index.js +1 -0
- package/build/components/ProgressStepper/ProgressStep.d.ts +10 -0
- package/build/components/ProgressStepper/ProgressStep.js +100 -0
- package/build/components/ProgressStepper/ProgressStepper.d.ts +6 -0
- package/build/components/ProgressStepper/ProgressStepper.js +22 -0
- package/build/components/ProgressStepper/ProgressStepper.props.d.ts +22 -0
- package/build/components/ProgressStepper/ProgressStepper.props.js +1 -0
- package/build/components/ProgressStepper/ProgressStepperRoot.d.ts +6 -0
- package/build/components/ProgressStepper/ProgressStepperRoot.js +16 -0
- package/build/components/ProgressStepper/index.d.ts +3 -0
- package/build/components/ProgressStepper/index.js +2 -0
- package/build/components/SectionHeader/SectionHeader.d.ts +1 -1
- package/build/components/SectionHeader/SectionHeader.js +6 -3
- package/build/components/SectionHeader/SectionHeader.props.d.ts +9 -16
- package/build/components/SectionHeader/SectionHeaderTrailingContent.d.ts +6 -0
- package/build/components/SectionHeader/SectionHeaderTrailingContent.js +13 -0
- package/build/components/SectionHeader/index.d.ts +1 -0
- package/build/components/SectionHeader/index.js +1 -0
- package/build/components/Tabs/Tab.js +2 -2
- package/build/components/ToggleButton/ToggleButtonText.js +2 -2
- package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +4 -1
- package/build/components/index.d.ts +3 -0
- package/build/components/index.js +3 -0
- package/build/core/themes.d.ts +12 -24
- package/build/tokens/components/dark/button.d.ts +1 -1
- package/build/tokens/components/dark/button.js +1 -1
- package/build/tokens/components/dark/dialog.d.ts +1 -0
- package/build/tokens/components/dark/dialog.js +1 -0
- package/build/tokens/components/dark/illustrations.d.ts +1 -0
- package/build/tokens/components/dark/illustrations.js +1 -0
- package/build/tokens/components/dark/toast.d.ts +4 -1
- package/build/tokens/components/dark/toast.js +4 -1
- package/build/tokens/components/light/button.d.ts +1 -1
- package/build/tokens/components/light/button.js +1 -1
- package/build/tokens/components/light/dialog.d.ts +1 -0
- package/build/tokens/components/light/dialog.js +1 -0
- package/build/tokens/components/light/illustrations.d.ts +1 -0
- package/build/tokens/components/light/illustrations.js +1 -0
- package/build/tokens/components/light/toast.d.ts +4 -1
- package/build/tokens/components/light/toast.js +4 -1
- package/build/tokens/layout.d.ts +6 -12
- package/build/tokens/layout.js +3 -6
- package/docs/components/AllComponents.web.tsx +86 -4
- package/docs/components/BadgeList.tsx +20 -56
- package/docs/components/SwitchList.tsx +4 -8
- package/docs/getting-started.mdx +30 -14
- package/docs/introduction.mdx +1 -1
- package/package.json +4 -4
- package/src/components/Alert/AlertTitle.tsx +7 -7
- package/src/components/Badge/Badge.props.ts +1 -0
- package/src/components/Badge/Badge.tsx +3 -2
- package/src/components/Button/ButtonRoot.tsx +4 -0
- package/src/components/Button/ButtonText.tsx +3 -3
- package/src/components/Card/CardRoot.tsx +2 -0
- package/src/components/Carousel/Carousel.context.tsx +8 -0
- package/src/components/Carousel/Carousel.docs.mdx +389 -0
- package/src/components/Carousel/Carousel.props.ts +89 -0
- package/src/components/Carousel/Carousel.stories.tsx +317 -0
- package/src/components/Carousel/Carousel.tsx +444 -0
- package/src/components/Carousel/CarouselControlItem.tsx +87 -0
- package/src/components/Carousel/CarouselControls.tsx +150 -0
- package/src/components/Carousel/CarouselItem.tsx +68 -0
- package/src/components/Carousel/index.ts +6 -0
- package/src/components/DescriptionList/DescriptionList.docs.mdx +24 -27
- package/src/components/DescriptionList/DescriptionList.props.ts +1 -8
- package/src/components/DescriptionList/DescriptionList.stories.tsx +13 -19
- package/src/components/DescriptionList/DescriptionList.tsx +2 -14
- package/src/components/DescriptionList/DescriptionListItem.props.ts +3 -8
- package/src/components/DescriptionList/DescriptionListItem.tsx +13 -21
- package/src/components/IndicatorIconButton/IndicatorIconButton.docs.mdx +85 -0
- package/src/components/IndicatorIconButton/IndicatorIconButton.props.ts +12 -0
- package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +142 -0
- package/src/components/IndicatorIconButton/IndicatorIconButton.tsx +36 -0
- package/src/components/IndicatorIconButton/index.tsx +2 -0
- package/src/components/Link/LinkText.tsx +4 -4
- package/src/components/List/List.context.ts +0 -1
- package/src/components/List/List.docs.mdx +376 -179
- package/src/components/List/List.props.ts +1 -9
- package/src/components/List/List.stories.tsx +289 -38
- package/src/components/List/List.tsx +5 -26
- package/src/components/List/ListAction/ListAction.props.ts +10 -0
- package/src/components/List/ListAction/ListAction.tsx +133 -0
- package/src/components/List/ListAction/ListActionContent.tsx +21 -0
- package/src/components/List/ListAction/ListActionText.tsx +14 -0
- package/src/components/List/ListAction/ListActionTrailingContent.tsx +9 -0
- package/src/components/List/ListAction/ListActionTrailingIcon.tsx +32 -0
- package/src/components/List/ListAction/index.ts +6 -0
- package/src/components/List/ListItem/ListItem.context.ts +1 -1
- package/src/components/List/ListItem/ListItem.props.ts +9 -5
- package/src/components/List/ListItem/ListItemRoot.tsx +18 -14
- package/src/components/List/ListItem/index.ts +4 -4
- package/src/components/List/index.ts +1 -0
- package/src/components/ProgressStepper/ProgressStep.tsx +134 -0
- package/src/components/ProgressStepper/ProgressStepper.docs.mdx +87 -0
- package/src/components/ProgressStepper/ProgressStepper.props.ts +27 -0
- package/src/components/ProgressStepper/ProgressStepper.stories.tsx +108 -0
- package/src/components/ProgressStepper/ProgressStepper.tsx +26 -0
- package/src/components/ProgressStepper/ProgressStepperRoot.tsx +32 -0
- package/src/components/ProgressStepper/index.ts +3 -0
- package/src/components/SectionHeader/SectionHeader.props.ts +9 -16
- package/src/components/SectionHeader/SectionHeader.stories.tsx +28 -18
- package/src/components/SectionHeader/SectionHeader.tsx +18 -19
- package/src/components/SectionHeader/SectionHeaderTrailingContent.tsx +20 -0
- package/src/components/SectionHeader/Sectionheader.docs.mdx +9 -24
- package/src/components/SectionHeader/index.ts +1 -0
- package/src/components/Switch/Switch.docs.mdx +0 -4
- package/src/components/Tabs/Tab.tsx +4 -2
- package/src/components/ToggleButton/ToggleButtonText.tsx +3 -3
- package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
- package/src/components/index.ts +3 -0
- package/src/tokens/components/dark/button.ts +1 -1
- package/src/tokens/components/dark/dialog.ts +1 -0
- package/src/tokens/components/dark/illustrations.ts +1 -0
- package/src/tokens/components/dark/toast.ts +4 -1
- package/src/tokens/components/light/button.ts +1 -1
- package/src/tokens/components/light/dialog.ts +1 -0
- package/src/tokens/components/light/illustrations.ts +1 -0
- package/src/tokens/components/light/toast.ts +4 -1
- package/src/tokens/layout.ts +3 -6
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @utilitywarehouse/hearth-react-native@0.
|
|
2
|
+
> @utilitywarehouse/hearth-react-native@0.5.0 lint /home/runner/work/hearth/hearth/packages/react-native
|
|
3
3
|
> TIMING=1 eslint --max-warnings 0
|
|
4
4
|
|
|
5
5
|
Rule | Time (ms) | Relative
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @utilitywarehouse/hearth-react-native
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#583](https://github.com/utilitywarehouse/hearth/pull/583) [`a31ab40`](https://github.com/utilitywarehouse/hearth/commit/a31ab40e4ccf4533aae2df16cc456d6db92d4e7b) Thanks [@jordmccord](https://github.com/jordmccord)! - Adds `Carousel` component
|
|
8
|
+
|
|
9
|
+
- [#567](https://github.com/utilitywarehouse/hearth/pull/567) [`b6869cf`](https://github.com/utilitywarehouse/hearth/commit/b6869cfaca7b3a5aacb27c06733f0243b6faa02a) Thanks [@MichalCiesliczka](https://github.com/MichalCiesliczka)! - Adds `ProgressStepper` component
|
|
10
|
+
|
|
11
|
+
- [#596](https://github.com/utilitywarehouse/hearth/pull/596) [`61f1073`](https://github.com/utilitywarehouse/hearth/commit/61f10735a42445b6e4eb90282a2b340317f1ec08) Thanks [@jordmccord](https://github.com/jordmccord)! - `List` component updates:
|
|
12
|
+
|
|
13
|
+
- [BREAKING] The `text` prop in `ListItem` is now `heading`.
|
|
14
|
+
- Added `ListAction` component.
|
|
15
|
+
- Added `badge` prop to `ListItem`.
|
|
16
|
+
- Added `numericValue` prop to `ListItem`.
|
|
17
|
+
- Removes `divider` prop from `List` and `ListItem`; dividers are now handled automatically.
|
|
18
|
+
|
|
19
|
+
- [#585](https://github.com/utilitywarehouse/hearth/pull/585) [`4894c34`](https://github.com/utilitywarehouse/hearth/commit/4894c34acaadcbbaba78fd64be2f8ae862200e1f) Thanks [@dorota-uw](https://github.com/dorota-uw)! - [BREAKING] `DescriptionListItem` updates:
|
|
20
|
+
|
|
21
|
+
- Removed `Link` props: `linkText`, `linkHref`, `linkIcon`, `linkIconPosition`, `linkOnPress`, `linkTarget`, `linkShowIcon`.
|
|
22
|
+
- Added `trailingContent` prop to allow custom trailing content (e.g. Link, Button).
|
|
23
|
+
- Added validation text support to `DescriptionListItem` via `invalidText` prop.
|
|
24
|
+
|
|
25
|
+
- [#572](https://github.com/utilitywarehouse/hearth/pull/572) [`9fa6499`](https://github.com/utilitywarehouse/hearth/commit/9fa6499b6eb1534c2ce7dc4352b1f848b94786ec) Thanks [@MichalCiesliczka](https://github.com/MichalCiesliczka)! - Adds `IndicatorIconButton` component
|
|
26
|
+
|
|
27
|
+
- [#596](https://github.com/utilitywarehouse/hearth/pull/596) [`61f1073`](https://github.com/utilitywarehouse/hearth/commit/61f10735a42445b6e4eb90282a2b340317f1ec08) Thanks [@jordmccord](https://github.com/jordmccord)! - [BREAKING] `SectionHeader` updates:
|
|
28
|
+
|
|
29
|
+
- Removed `Link` props: `linkText`, `linkOnPress`, `linkAccessibilityLabel`.
|
|
30
|
+
- Added `trailingContent` prop to allow custom trailing content (e.g. Link, Button).
|
|
31
|
+
- Added `badge` prop to display a `Badge` next to the heading.
|
|
32
|
+
- Adds `invalidText` prop for validation messages.
|
|
33
|
+
|
|
34
|
+
- [#596](https://github.com/utilitywarehouse/hearth/pull/596) [`61f1073`](https://github.com/utilitywarehouse/hearth/commit/61f10735a42445b6e4eb90282a2b340317f1ec08) Thanks [@jordmccord](https://github.com/jordmccord)! - [BREAKING] Migrates `DescriptionList` `SectionHeader` to use `headerTrailingContent`
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- [#596](https://github.com/utilitywarehouse/hearth/pull/596) [`61f1073`](https://github.com/utilitywarehouse/hearth/commit/61f10735a42445b6e4eb90282a2b340317f1ec08) Thanks [@jordmccord](https://github.com/jordmccord)! - Updates all interactive components fonts
|
|
39
|
+
|
|
40
|
+
- [#589](https://github.com/utilitywarehouse/hearth/pull/589) [`635a392`](https://github.com/utilitywarehouse/hearth/commit/635a392c80e883790e3fe2cae3b22453288911f1) Thanks [@dorota-uw](https://github.com/dorota-uw)! - Added underline to Ghost button
|
|
41
|
+
|
|
42
|
+
- [#596](https://github.com/utilitywarehouse/hearth/pull/596) [`61f1073`](https://github.com/utilitywarehouse/hearth/commit/61f10735a42445b6e4eb90282a2b340317f1ec08) Thanks [@jordmccord](https://github.com/jordmccord)! - Upgrade `@utilitywarehouse/hearth-react-native-icons` to `0.6.0`
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [[`e707eec`](https://github.com/utilitywarehouse/hearth/commit/e707eec790550cab71f2541c26a38c5691e9cbca)]:
|
|
45
|
+
- @utilitywarehouse/hearth-react-native-icons@0.7.0
|
|
46
|
+
|
|
3
47
|
## 0.4.2
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
-
import {
|
|
3
|
+
import { BodyText } from '../BodyText';
|
|
4
4
|
import { useAlertContext } from './Alert.context';
|
|
5
5
|
const AlertTitle = ({ children, style, ...props }) => {
|
|
6
6
|
const { colorScheme } = useAlertContext();
|
|
7
7
|
styles.useVariants({ colorScheme });
|
|
8
|
-
return (_jsx(
|
|
8
|
+
return (_jsx(BodyText, { size: "md", weight: "semibold", style: [styles.title, style], ...props, children: children }));
|
|
9
9
|
};
|
|
10
10
|
const styles = StyleSheet.create(theme => ({
|
|
11
11
|
title: {
|
|
12
12
|
variants: {
|
|
13
13
|
colorScheme: {
|
|
14
14
|
info: {
|
|
15
|
-
color: theme.color.feedback.info.foreground,
|
|
15
|
+
color: theme.color.feedback.info.foreground.default,
|
|
16
16
|
},
|
|
17
17
|
positive: {
|
|
18
|
-
color: theme.color.feedback.positive.foreground,
|
|
18
|
+
color: theme.color.feedback.positive.foreground.default,
|
|
19
19
|
},
|
|
20
20
|
danger: {
|
|
21
|
-
color: theme.color.feedback.danger.foreground,
|
|
21
|
+
color: theme.color.feedback.danger.foreground.default,
|
|
22
22
|
},
|
|
23
23
|
warning: {
|
|
24
|
-
color: theme.color.feedback.warning.foreground,
|
|
24
|
+
color: theme.color.feedback.warning.foreground.default,
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
},
|
|
@@ -6,11 +6,11 @@ import { BadgeContext } from './Badge.context';
|
|
|
6
6
|
import BadgeIcon from './BadgeIcon';
|
|
7
7
|
import BadgeText from './BadgeText';
|
|
8
8
|
const Badge = ({ children, ...props }) => {
|
|
9
|
-
const { variant = 'subtle', icon, colorScheme = 'info', flatBase = false, size = 'sm', style, ...rest } = props;
|
|
9
|
+
const { variant = 'subtle', icon, colorScheme = 'info', flatBase = false, size = 'sm', style, text, ...rest } = props;
|
|
10
10
|
const value = useMemo(() => ({ colorScheme, flatBase, variant, size }), [colorScheme, flatBase, variant, size]);
|
|
11
|
-
const childIsText = typeof children === 'string' || typeof children === 'number';
|
|
11
|
+
const childIsText = typeof children === 'string' || typeof children === 'number' || !!text;
|
|
12
12
|
styles.useVariants({ colorScheme, flatBase, variant, size });
|
|
13
|
-
return (_jsx(BadgeContext.Provider, { value: value, children: _jsxs(View, { ...rest, style: [styles.container, style], children: [!!icon && _jsx(BadgeIcon, { as: icon }), childIsText ? _jsx(BadgeText, { children: children }) : children] }) }));
|
|
13
|
+
return (_jsx(BadgeContext.Provider, { value: value, children: _jsxs(View, { ...rest, style: [styles.container, style], children: [!!icon && _jsx(BadgeIcon, { as: icon }), childIsText ? _jsx(BadgeText, { children: text ?? children }) : children] }) }));
|
|
14
14
|
};
|
|
15
15
|
Badge.displayName = 'Badge';
|
|
16
16
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -79,6 +79,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
79
79
|
ghost: {
|
|
80
80
|
backgroundColor: 'transparent',
|
|
81
81
|
borderWidth: 0,
|
|
82
|
+
textDecoration: 'underline',
|
|
82
83
|
},
|
|
83
84
|
},
|
|
84
85
|
size: {
|
|
@@ -324,6 +325,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
324
325
|
variant: 'ghost',
|
|
325
326
|
colorScheme: 'functional',
|
|
326
327
|
styles: {
|
|
328
|
+
textDecorationColor: theme.color.interactive.functional.foreground.subtle,
|
|
327
329
|
_web: {
|
|
328
330
|
_hover: {
|
|
329
331
|
backgroundColor: theme.color.interactive.functional.surface.subtle.hover,
|
|
@@ -371,6 +373,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
371
373
|
variant: 'ghost',
|
|
372
374
|
colorScheme: 'affirmative',
|
|
373
375
|
styles: {
|
|
376
|
+
textDecorationColor: theme.color.interactive.affirmative.foreground.subtle,
|
|
374
377
|
_web: {
|
|
375
378
|
_hover: {
|
|
376
379
|
backgroundColor: theme.color.interactive.affirmative.surface.subtle.hover,
|
|
@@ -394,6 +397,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
394
397
|
variant: 'ghost',
|
|
395
398
|
colorScheme: 'destructive',
|
|
396
399
|
styles: {
|
|
400
|
+
textDecorationColor: theme.color.interactive.destructive.foreground.subtle,
|
|
397
401
|
_web: {
|
|
398
402
|
_hover: {
|
|
399
403
|
backgroundColor: theme.color.interactive.destructive.surface.subtle.hover,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
-
import {
|
|
3
|
+
import { BodyText } from '../BodyText';
|
|
4
4
|
import { useButtonContext } from './Button.context';
|
|
5
5
|
const ButtonText = ({ children, ...props }) => {
|
|
6
6
|
const { colorScheme, variant, inverted, disabled } = useButtonContext();
|
|
7
7
|
styles.useVariants({ colorScheme, variant, inverted, disabled });
|
|
8
|
-
return (_jsx(
|
|
8
|
+
return (_jsx(BodyText, { size: "md", weight: "semibold", ...props, style: [styles.text, props.style], children: children }));
|
|
9
9
|
};
|
|
10
10
|
ButtonText.displayName = 'ButtonText';
|
|
11
11
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -49,7 +49,7 @@ const Card = ({ children, variant = 'subtle', colorScheme = 'neutralStrong', noP
|
|
|
49
49
|
const context = useMemo(() => ({
|
|
50
50
|
pressed: showPressed && active,
|
|
51
51
|
}), [showPressed, active]);
|
|
52
|
-
return (_jsx(CardContext.Provider, { value: context, children: _jsx(Pressable, { ...remainingProps, disabled: disabled, style: [styles.card, computedStyles, style], onPress: handlePress, children: children }) }));
|
|
52
|
+
return (_jsx(CardContext.Provider, { value: context, children: _jsx(Pressable, { ...remainingProps, disabled: disabled, style: [styles.card, computedStyles, style], onPress: handlePress, accessible: showPressed, importantForAccessibility: showPressed ? 'yes' : 'no', children: children }) }));
|
|
53
53
|
};
|
|
54
54
|
Card.displayName = 'Card';
|
|
55
55
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CarouselProps } from './Carousel.props';
|
|
2
|
+
declare const Carousel: {
|
|
3
|
+
({ centered, children, disabled, inactiveItemOpacity, itemWidth, onSnapToItem, showOverflow, style, width, itemsStyle, activeIndex: initialActiveIndex, showControls, showNavigation, controlsStyle, controlsItemStyle, controlsActiveItemStyle, controlsAccessibilityHidden, inverted, ref, ...props }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default Carousel;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { FlatList, Platform, ScrollView, View, } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import CarouselContext from './Carousel.context';
|
|
6
|
+
import { CarouselControls } from './CarouselControls';
|
|
7
|
+
import { CarouselItem } from './CarouselItem';
|
|
8
|
+
const Carousel = ({ centered = false, children, disabled = false, inactiveItemOpacity = 1, itemWidth, onSnapToItem, showOverflow = false, style, width, itemsStyle, activeIndex: initialActiveIndex = 0, showControls = true, showNavigation = false, controlsStyle, controlsItemStyle, controlsActiveItemStyle, controlsAccessibilityHidden = true, inverted = false, ref, ...props }) => {
|
|
9
|
+
const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
|
|
10
|
+
const [numItems, setNumItems] = useState(0);
|
|
11
|
+
const scrollViewRef = useRef(null);
|
|
12
|
+
const flatListRef = useRef(null);
|
|
13
|
+
const isWeb = Platform.OS === 'web';
|
|
14
|
+
const isProgrammaticScroll = useRef(false);
|
|
15
|
+
// Expose scroll methods through ref
|
|
16
|
+
useImperativeHandle(ref, () => ({
|
|
17
|
+
scrollToIndex: ({ index, animated = true }) => {
|
|
18
|
+
if (isWeb && scrollViewRef.current) {
|
|
19
|
+
isProgrammaticScroll.current = true;
|
|
20
|
+
const itemWidthValue = itemWidth || width;
|
|
21
|
+
const offset = centered ? (width - (itemWidth || width)) / 2 : 0;
|
|
22
|
+
const scrollX = index * itemWidthValue - offset;
|
|
23
|
+
scrollViewRef.current.scrollTo({ x: scrollX, animated: animated ?? true });
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
isProgrammaticScroll.current = false;
|
|
26
|
+
}, 500);
|
|
27
|
+
}
|
|
28
|
+
else if (flatListRef.current) {
|
|
29
|
+
flatListRef.current.scrollToIndex({ index, animated: animated ?? true });
|
|
30
|
+
}
|
|
31
|
+
setActiveIndex(index);
|
|
32
|
+
},
|
|
33
|
+
scrollToOffset: ({ offset, animated = true, }) => {
|
|
34
|
+
if (isWeb && scrollViewRef.current) {
|
|
35
|
+
isProgrammaticScroll.current = true;
|
|
36
|
+
scrollViewRef.current.scrollTo({ x: offset, animated: animated ?? true });
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
isProgrammaticScroll.current = false;
|
|
39
|
+
}, 500);
|
|
40
|
+
}
|
|
41
|
+
else if (flatListRef.current) {
|
|
42
|
+
flatListRef.current.scrollToOffset({ offset, animated: animated ?? true });
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
}), [isWeb, itemWidth, width, centered]);
|
|
46
|
+
// Recursively check if CarouselControls exists in the children tree
|
|
47
|
+
const hasCarouselControlsInTree = (node) => {
|
|
48
|
+
if (!node)
|
|
49
|
+
return false;
|
|
50
|
+
if (typeof node === 'object' && 'type' in node) {
|
|
51
|
+
if (node.type === CarouselControls ||
|
|
52
|
+
node.type?.displayName === 'CarouselControls') {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
// Check children recursively
|
|
56
|
+
if ('props' in node && node.props && typeof node.props === 'object') {
|
|
57
|
+
const props = node.props;
|
|
58
|
+
if (props.children) {
|
|
59
|
+
const childArray = Children.toArray(props.children);
|
|
60
|
+
return childArray.some(child => hasCarouselControlsInTree(child));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
// Filter only CarouselItem children for the carousel
|
|
67
|
+
const { carouselItems, otherChildren, hasCarouselControls } = useMemo(() => {
|
|
68
|
+
const childrenArray = Children.toArray(children);
|
|
69
|
+
const carouselItems = [];
|
|
70
|
+
const otherChildren = [];
|
|
71
|
+
childrenArray.forEach(child => {
|
|
72
|
+
if (typeof child === 'object' &&
|
|
73
|
+
'type' in child &&
|
|
74
|
+
(child.type === CarouselItem || child.type?.displayName === 'CarouselItem')) {
|
|
75
|
+
carouselItems.push(child);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
otherChildren.push(child);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Recursively check if any CarouselControls exist in the tree
|
|
82
|
+
const hasCarouselControls = childrenArray.some(child => hasCarouselControlsInTree(child));
|
|
83
|
+
return { carouselItems, otherChildren, hasCarouselControls };
|
|
84
|
+
}, [children]);
|
|
85
|
+
const innerMargin = width - (itemWidth || width);
|
|
86
|
+
const containerStyles = {
|
|
87
|
+
marginHorizontal: centered ? innerMargin / 2 : 0,
|
|
88
|
+
overflow: showOverflow ? 'visible' : 'hidden',
|
|
89
|
+
};
|
|
90
|
+
const context = useMemo(() => ({
|
|
91
|
+
activeIndex,
|
|
92
|
+
numItems: carouselItems.length,
|
|
93
|
+
setActiveIndex,
|
|
94
|
+
setNumItems,
|
|
95
|
+
controlsAccessibilityHidden,
|
|
96
|
+
inverted,
|
|
97
|
+
disabled,
|
|
98
|
+
}), [
|
|
99
|
+
activeIndex,
|
|
100
|
+
carouselItems.length,
|
|
101
|
+
setActiveIndex,
|
|
102
|
+
setNumItems,
|
|
103
|
+
controlsAccessibilityHidden,
|
|
104
|
+
inverted,
|
|
105
|
+
disabled,
|
|
106
|
+
]);
|
|
107
|
+
// On web, we need to prevent overflow from expanding the container
|
|
108
|
+
const webContainerStyles = isWeb
|
|
109
|
+
? {
|
|
110
|
+
width,
|
|
111
|
+
maxWidth: width,
|
|
112
|
+
overflow: 'hidden', // Always clip on web to prevent expansion
|
|
113
|
+
}
|
|
114
|
+
: {};
|
|
115
|
+
// For web centered layouts, add padding to content container
|
|
116
|
+
const webContentContainerStyle = isWeb && centered
|
|
117
|
+
? {
|
|
118
|
+
paddingHorizontal: innerMargin / 2,
|
|
119
|
+
}
|
|
120
|
+
: {};
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
setNumItems((carouselItems || []).length);
|
|
123
|
+
}, [carouselItems, setNumItems]);
|
|
124
|
+
// Set initial scroll position on web
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (isWeb && scrollViewRef.current && initialActiveIndex > 0) {
|
|
127
|
+
// Use setTimeout to ensure ScrollView is mounted
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
if (scrollViewRef.current) {
|
|
130
|
+
const itemWidthValue = itemWidth || width;
|
|
131
|
+
const offset = centered ? innerMargin / 2 : 0;
|
|
132
|
+
const scrollX = initialActiveIndex * itemWidthValue - offset;
|
|
133
|
+
scrollViewRef.current.scrollTo({ x: scrollX, animated: false });
|
|
134
|
+
}
|
|
135
|
+
}, 0);
|
|
136
|
+
}
|
|
137
|
+
}, [isWeb, initialActiveIndex, itemWidth, width, centered, innerMargin]);
|
|
138
|
+
// Scroll to active index when it changes (for programmatic navigation)
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!isProgrammaticScroll.current) {
|
|
141
|
+
isProgrammaticScroll.current = true;
|
|
142
|
+
if (isWeb && scrollViewRef.current) {
|
|
143
|
+
const itemWidthValue = itemWidth || width;
|
|
144
|
+
const offset = centered ? innerMargin / 2 : 0;
|
|
145
|
+
const scrollX = activeIndex * itemWidthValue - offset;
|
|
146
|
+
scrollViewRef.current.scrollTo({ x: scrollX, animated: true });
|
|
147
|
+
}
|
|
148
|
+
else if (!isWeb &&
|
|
149
|
+
flatListRef.current &&
|
|
150
|
+
activeIndex >= 0 &&
|
|
151
|
+
activeIndex < carouselItems.length) {
|
|
152
|
+
flatListRef.current.scrollToIndex({ index: activeIndex, animated: true });
|
|
153
|
+
}
|
|
154
|
+
setTimeout(() => {
|
|
155
|
+
isProgrammaticScroll.current = false;
|
|
156
|
+
}, 500);
|
|
157
|
+
}
|
|
158
|
+
}, [activeIndex, isWeb, itemWidth, width, centered, innerMargin, carouselItems.length]);
|
|
159
|
+
// Web scroll handler - track scroll position
|
|
160
|
+
const handleWebScroll = useCallback((event) => {
|
|
161
|
+
if (!isWeb || isProgrammaticScroll.current)
|
|
162
|
+
return;
|
|
163
|
+
const scrollX = event.nativeEvent.contentOffset.x;
|
|
164
|
+
const itemWidthValue = itemWidth || width;
|
|
165
|
+
// For centered layouts, account for the padding offset
|
|
166
|
+
const offset = centered ? innerMargin / 2 : 0;
|
|
167
|
+
const index = Math.round((scrollX + offset) / itemWidthValue);
|
|
168
|
+
if (index >= 0 && index < carouselItems.length && index !== activeIndex) {
|
|
169
|
+
setActiveIndex?.(index);
|
|
170
|
+
}
|
|
171
|
+
}, [
|
|
172
|
+
activeIndex,
|
|
173
|
+
centered,
|
|
174
|
+
innerMargin,
|
|
175
|
+
isWeb,
|
|
176
|
+
itemWidth,
|
|
177
|
+
carouselItems.length,
|
|
178
|
+
setActiveIndex,
|
|
179
|
+
width,
|
|
180
|
+
]);
|
|
181
|
+
// Web scroll end handler - update when scroll completes
|
|
182
|
+
const handleWebScrollEnd = useCallback((event) => {
|
|
183
|
+
if (!isWeb || isProgrammaticScroll.current)
|
|
184
|
+
return;
|
|
185
|
+
const scrollX = event.nativeEvent.contentOffset.x;
|
|
186
|
+
const itemWidthValue = itemWidth || width;
|
|
187
|
+
// For centered layouts, account for the padding offset
|
|
188
|
+
const offset = centered ? innerMargin / 2 : 0;
|
|
189
|
+
const index = Math.round((scrollX + offset) / itemWidthValue);
|
|
190
|
+
if (index >= 0 && index < carouselItems.length) {
|
|
191
|
+
setActiveIndex?.(index);
|
|
192
|
+
onSnapToItem?.(index);
|
|
193
|
+
}
|
|
194
|
+
}, [
|
|
195
|
+
centered,
|
|
196
|
+
innerMargin,
|
|
197
|
+
isWeb,
|
|
198
|
+
itemWidth,
|
|
199
|
+
carouselItems.length,
|
|
200
|
+
onSnapToItem,
|
|
201
|
+
setActiveIndex,
|
|
202
|
+
width,
|
|
203
|
+
]);
|
|
204
|
+
// Native viewable items handler
|
|
205
|
+
const handleViewableItemsChanged = useCallback(({ viewableItems }) => {
|
|
206
|
+
if (!viewableItems.length) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const index = viewableItems[viewableItems.length - 1].index || 0;
|
|
210
|
+
setActiveIndex?.(index);
|
|
211
|
+
onSnapToItem?.(index);
|
|
212
|
+
}, [onSnapToItem, setActiveIndex]);
|
|
213
|
+
const controls = (_jsx(CarouselControls, { style: [styles.controls, controlsStyle], itemStyle: controlsItemStyle, activeItemStyle: controlsActiveItemStyle, showNavigation: showNavigation, accessibilityHidden: controlsAccessibilityHidden }));
|
|
214
|
+
// Render for web using ScrollView with scroll snap
|
|
215
|
+
if (isWeb) {
|
|
216
|
+
return (_jsx(CarouselContext.Provider, { value: context, children: _jsxs(View, { style: style, children: [_jsx(ScrollView, { horizontal: true, onScroll: handleWebScroll, onMomentumScrollEnd: handleWebScrollEnd, onScrollEndDrag: handleWebScrollEnd, ref: scrollViewRef, scrollEnabled: !disabled, pointerEvents: disabled ? 'none' : 'auto', scrollEventThrottle: 16, showsHorizontalScrollIndicator: false, snapToInterval: itemWidth || width, snapToAlignment: centered ? 'center' : 'start', decelerationRate: "fast", style: [styles.webContainer, webContainerStyles, itemsStyle], contentContainerStyle: [styles.webContentContainer, webContentContainerStyle], ...props, children: carouselItems.map((item, index) => cloneElement(item, {
|
|
217
|
+
active: index === activeIndex,
|
|
218
|
+
inactiveOpacity: inactiveItemOpacity,
|
|
219
|
+
key: item?.key || item.props?.id || index,
|
|
220
|
+
width: itemWidth || width,
|
|
221
|
+
style: [
|
|
222
|
+
item.props?.style,
|
|
223
|
+
styles.webItem,
|
|
224
|
+
centered ? styles.webItemCentered : styles.webItemStart,
|
|
225
|
+
],
|
|
226
|
+
})) }), showControls && !hasCarouselControls && controls, otherChildren] }) }));
|
|
227
|
+
}
|
|
228
|
+
// Render for native using FlatList
|
|
229
|
+
return (_jsx(CarouselContext.Provider, { value: context, children: _jsxs(View, { style: style, children: [_jsx(FlatList, { ref: flatListRef, bounces: false, data: carouselItems, decelerationRate: "fast", disableIntervalMomentum // Prevents scrolling more than one item at a time
|
|
230
|
+
: true, getItemLayout: (_, index) => ({
|
|
231
|
+
length: itemWidth || width,
|
|
232
|
+
offset: (itemWidth || width) * index,
|
|
233
|
+
index,
|
|
234
|
+
}), horizontal: true, initialScrollIndex: activeIndex, pagingEnabled: true, onViewableItemsChanged: handleViewableItemsChanged, overScrollMode: "never" // Prevents stretching of first and last items when reaching each end of the carousel (Android only)
|
|
235
|
+
, removeClippedSubviews: !showOverflow, renderItem: ({ index, item }) => cloneElement(item, {
|
|
236
|
+
active: index === activeIndex,
|
|
237
|
+
inactiveOpacity: inactiveItemOpacity,
|
|
238
|
+
key: item?.key || item.props?.id || index,
|
|
239
|
+
width: itemWidth || width,
|
|
240
|
+
}), scrollEnabled: !disabled, showsHorizontalScrollIndicator: false, snapToInterval: itemWidth || width, snapToAlignment: "center", style: [itemsStyle, containerStyles], viewabilityConfig: { itemVisiblePercentThreshold: 51 }, ...props }), showControls && !hasCarouselControls && controls, otherChildren] }) }));
|
|
241
|
+
};
|
|
242
|
+
Carousel.displayName = 'Carousel';
|
|
243
|
+
const styles = StyleSheet.create(theme => ({
|
|
244
|
+
controls: {
|
|
245
|
+
marginTop: theme.space['200'],
|
|
246
|
+
},
|
|
247
|
+
webContainer: {
|
|
248
|
+
_web: {
|
|
249
|
+
scrollSnapType: 'x mandatory',
|
|
250
|
+
WebkitOverflowScrolling: 'touch',
|
|
251
|
+
overflowX: 'scroll',
|
|
252
|
+
overflowY: 'hidden',
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
webContentContainer: {
|
|
256
|
+
_web: {
|
|
257
|
+
display: 'flex',
|
|
258
|
+
flexDirection: 'row',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
webItem: {
|
|
262
|
+
_web: {
|
|
263
|
+
scrollSnapStop: 'always',
|
|
264
|
+
flexShrink: 0,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
webItemCentered: {
|
|
268
|
+
_web: {
|
|
269
|
+
scrollSnapAlign: 'center',
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
webItemStart: {
|
|
273
|
+
_web: {
|
|
274
|
+
scrollSnapAlign: 'start',
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
}));
|
|
278
|
+
export default Carousel;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { FlatListProps, PressableProps, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
export interface CarouselRef {
|
|
4
|
+
scrollToIndex: (params: {
|
|
5
|
+
index: number;
|
|
6
|
+
animated?: boolean | null;
|
|
7
|
+
}) => void;
|
|
8
|
+
scrollToOffset: (params: {
|
|
9
|
+
offset: number;
|
|
10
|
+
animated?: boolean | null;
|
|
11
|
+
}) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface CarouselContextValue {
|
|
14
|
+
activeIndex: number;
|
|
15
|
+
numItems: number;
|
|
16
|
+
setActiveIndex: (index: number) => void;
|
|
17
|
+
setNumItems: (count: number) => void;
|
|
18
|
+
controlsAccessibilityHidden?: boolean;
|
|
19
|
+
inverted?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface CarouselItemProps extends ViewProps {
|
|
23
|
+
active?: boolean;
|
|
24
|
+
key?: string | number;
|
|
25
|
+
inactiveOpacity?: number;
|
|
26
|
+
width?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface CarouselProps extends Omit<FlatListProps<ReactElement<CarouselItemProps>>, 'accessibilityActions' | 'accessibilityLabel' | 'accessibilityRole' | 'accessible' | 'bounces' | 'children' | 'data' | 'decelerationRate' | 'getItemLayout' | 'horizontal' | 'pagingEnabled' | 'onAccessibilityAction' | 'onViewableItemsChanged' | 'overScrollMode' | 'renderItem' | 'showsHorizontalScrollIndicator' | 'snapToInterval' | 'snapToAlignment' | 'viewabilityConfig' | 'style'> {
|
|
29
|
+
activeIndex?: number;
|
|
30
|
+
centered?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
inactiveItemOpacity?: number;
|
|
33
|
+
itemWidth?: number;
|
|
34
|
+
onSnapToItem?: (index: number) => void;
|
|
35
|
+
showOverflow?: boolean;
|
|
36
|
+
width: number;
|
|
37
|
+
children?: ViewProps['children'];
|
|
38
|
+
itemsStyle?: FlatListProps<ReactElement<CarouselItemProps>>['style'];
|
|
39
|
+
style?: ViewStyle;
|
|
40
|
+
showControls?: boolean;
|
|
41
|
+
showNavigation?: boolean;
|
|
42
|
+
controlsStyle?: ViewProps['style'];
|
|
43
|
+
controlsItemStyle?: ViewProps['style'];
|
|
44
|
+
controlsActiveItemStyle?: ViewProps['style'];
|
|
45
|
+
controlsAccessibilityHidden?: boolean;
|
|
46
|
+
ref?: React.Ref<CarouselRef>;
|
|
47
|
+
inverted?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface CarouselProviderProps {
|
|
50
|
+
initialActiveIndex?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface CarouselControlsProps extends ViewProps {
|
|
53
|
+
itemStyle?: ViewProps['style'];
|
|
54
|
+
activeItemStyle?: ViewProps['style'];
|
|
55
|
+
showNavigation?: boolean;
|
|
56
|
+
onPressPrev?: () => void;
|
|
57
|
+
onPressNext?: () => void;
|
|
58
|
+
accessibilityHidden?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface CarouselControlsItemProps extends Omit<PressableProps, 'style'> {
|
|
61
|
+
active: boolean;
|
|
62
|
+
index: number;
|
|
63
|
+
style?: ViewProps['style'];
|
|
64
|
+
activeStyle?: ViewProps['style'];
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CarouselControlsItemProps } from './Carousel.props';
|
|
2
|
+
export declare const CarouselControlItemRoot: ({ active, style, index, activeStyle, onPress, disabled, ...props }: CarouselControlsItemProps & {
|
|
3
|
+
states?: {
|
|
4
|
+
active?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const CarouselControlItem: import("react").ForwardRefExoticComponent<CarouselControlsItemProps & {
|
|
9
|
+
states?: {
|
|
10
|
+
active?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
} & Omit<import("react-native").PressableProps, "children"> & {
|
|
14
|
+
tabIndex?: 0 | -1 | undefined;
|
|
15
|
+
} & {
|
|
16
|
+
children?: import("react").ReactNode | (({ hovered, pressed, focused, focusVisible, disabled, }: {
|
|
17
|
+
hovered?: boolean | undefined;
|
|
18
|
+
pressed?: boolean | undefined;
|
|
19
|
+
focused?: boolean | undefined;
|
|
20
|
+
focusVisible?: boolean | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
}) => import("react").ReactNode);
|
|
23
|
+
} & import("react").RefAttributes<unknown>>;
|
|
24
|
+
export default CarouselControlItem;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createPressable } from '@gluestack-ui/pressable';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { Pressable, View } from 'react-native';
|
|
5
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
+
import CarouselContext from './Carousel.context';
|
|
7
|
+
export const CarouselControlItemRoot = ({ active, style, index, activeStyle, onPress, disabled, ...props }) => {
|
|
8
|
+
const { inverted, numItems } = useContext(CarouselContext);
|
|
9
|
+
styles.useVariants({ active, inverted });
|
|
10
|
+
return (_jsx(Pressable, { style: [styles.item, active && activeStyle], onPress: onPress, disabled: disabled, accessibilityLabel: `Page ${index + 1} of ${numItems}`, ...props, children: _jsx(View, { style: [styles.circle, style] }) }));
|
|
11
|
+
};
|
|
12
|
+
const CarouselControlItem = createPressable({
|
|
13
|
+
Root: CarouselControlItemRoot,
|
|
14
|
+
});
|
|
15
|
+
CarouselControlItem.displayName = 'CarouselControlItem';
|
|
16
|
+
const styles = StyleSheet.create(theme => ({
|
|
17
|
+
item: {
|
|
18
|
+
width: 24,
|
|
19
|
+
height: 24,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
},
|
|
23
|
+
circle: {
|
|
24
|
+
width: theme.components.carouselControl.size,
|
|
25
|
+
height: theme.components.carouselControl.size,
|
|
26
|
+
borderRadius: theme.borderRadius.full,
|
|
27
|
+
borderColor: theme.color.interactive.functional.border.subtle,
|
|
28
|
+
borderWidth: theme.borderWidth[2],
|
|
29
|
+
backgroundColor: 'transparent',
|
|
30
|
+
paddingTop: theme.space['100'],
|
|
31
|
+
overflow: 'hidden',
|
|
32
|
+
_hover: {
|
|
33
|
+
backgroundColor: theme.color.interactive.functional.surface.subtle.hover,
|
|
34
|
+
},
|
|
35
|
+
variants: {
|
|
36
|
+
active: {
|
|
37
|
+
true: {
|
|
38
|
+
backgroundColor: theme.color.interactive.functional.foreground.subtle,
|
|
39
|
+
_hover: {
|
|
40
|
+
backgroundColor: theme.color.interactive.functional.foreground.subtle,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
inverted: {
|
|
45
|
+
true: {
|
|
46
|
+
borderColor: theme.color.interactive.functional.border.inverted,
|
|
47
|
+
_hover: {
|
|
48
|
+
backgroundColor: theme.color.interactive.functional.surface.subtle.inverted.hover,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
compoundVariants: [
|
|
54
|
+
{
|
|
55
|
+
active: true,
|
|
56
|
+
inverted: true,
|
|
57
|
+
styles: {
|
|
58
|
+
backgroundColor: theme.color.interactive.functional.foreground.inverted,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
}));
|
|
64
|
+
export default CarouselControlItem;
|