@utilitywarehouse/hearth-react-native 0.6.0 → 0.7.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/.storybook/main.ts +12 -6
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +6 -0
- package/build/components/BottomSheet/BottomSheetBackdrop.js +2 -2
- package/build/components/BottomSheet/BottomSheetFlatList.js +2 -2
- package/build/components/BottomSheet/BottomSheetHandle.js +2 -2
- package/build/components/Button/ButtonIcon.js +2 -1
- package/build/components/Button/ButtonRoot.js +2 -6
- package/build/components/Button/ButtonText.js +4 -1
- package/build/components/Card/Card.context.d.ts +7 -0
- package/build/components/Card/CardAction/CardAction.context.d.ts +9 -0
- package/build/components/Card/{CardAction.context.js → CardAction/CardAction.context.js} +7 -1
- package/build/components/Card/CardAction/CardAction.d.ts +18 -0
- package/build/components/Card/CardAction/CardAction.js +7 -0
- package/build/components/Card/CardAction/CardAction.props.d.ts +63 -0
- package/build/components/Card/CardAction/CardAction.props.js +1 -0
- package/build/components/Card/CardAction/CardActionContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionContent.js +13 -0
- package/build/components/Card/CardAction/CardActionHelperText.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionHelperText.js +13 -0
- package/build/components/Card/CardAction/CardActionIcon.d.ts +9 -0
- package/build/components/Card/CardAction/CardActionIcon.js +19 -0
- package/build/components/Card/CardAction/CardActionLeadingContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionLeadingContent.js +5 -0
- package/build/components/Card/CardAction/CardActionRoot.d.ts +12 -0
- package/build/components/Card/CardAction/CardActionRoot.js +155 -0
- package/build/components/Card/CardAction/CardActionText.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionText.js +9 -0
- package/build/components/Card/CardAction/CardActionTrailingContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionTrailingContent.js +5 -0
- package/build/components/Card/CardAction/CardActionTrailingIcon.d.ts +9 -0
- package/build/components/Card/CardAction/CardActionTrailingIcon.js +19 -0
- package/build/components/Card/CardAction/index.d.ts +10 -0
- package/build/components/Card/CardAction/index.js +9 -0
- package/build/components/Card/CardContent.d.ts +6 -0
- package/build/components/Card/CardContent.js +33 -0
- package/build/components/Card/CardPressHandler.context.d.ts +6 -0
- package/build/components/Card/CardPressHandler.context.js +6 -0
- package/build/components/Card/{CardAction.d.ts → CardPressHandler.d.ts} +3 -3
- package/build/components/Card/CardPressHandler.js +13 -0
- package/build/components/Card/CardRoot.js +103 -11
- package/build/components/Card/index.d.ts +3 -2
- package/build/components/Card/index.js +3 -2
- package/build/components/Checkbox/CheckboxIcon.js +2 -1
- package/build/components/Container/Container.js +3 -3
- package/build/components/CurrencyInput/CurrencyInput.js +1 -1
- package/build/components/Helper/HelperIcon.js +2 -1
- package/build/components/Icon/Icon.d.ts +2 -6
- package/build/components/IconButton/IconButtonIcon.js +2 -1
- package/build/components/IconContainer/IconContainer.d.ts +4 -3
- package/build/components/IconContainer/IconContainer.js +3 -3
- package/build/components/Input/InputField.js +4 -2
- package/build/components/Input/InputIcon.js +2 -1
- package/build/components/Link/LinkIcon.js +3 -2
- package/build/components/List/ListAction/ListActionTrailingIcon.js +2 -1
- package/build/components/List/ListItem/ListItemIcon.js +2 -1
- package/build/components/List/ListItem/ListItemTrailingIcon.js +2 -3
- package/build/components/Radio/RadioIcon.js +7 -2
- package/build/components/RadioCard/RadioCardIcon.js +3 -2
- package/build/components/Spinner/Spinner.js +2 -0
- package/build/components/Spinner/Spinner.web.js +2 -0
- package/build/components/Switch/Switch.js +5 -3
- package/build/components/Switch/Switch.web.js +1 -0
- package/build/components/Tabs/TabsList.js +6 -1
- package/build/components/Textarea/TextareaField.js +1 -1
- package/build/components/ToggleButton/ToggleButtonIcon.js +2 -1
- package/build/components/ToggleButton/ToggleButtonRoot.js +2 -2
- package/build/components/UnstyledIconButton/UnstyledIconButtonIcon.js +2 -1
- package/build/components/index.d.ts +1 -1
- package/build/components/index.js +1 -1
- package/build/core/index.d.ts +3 -3
- package/build/core/index.js +3 -3
- package/build/core/themes.d.ts +24 -12
- package/build/hooks/useColorMode.d.ts +1 -1
- package/build/hooks/useColorMode.js +7 -8
- package/build/tokens/components/dark/banner.d.ts +19 -0
- package/build/tokens/components/dark/banner.js +19 -0
- package/build/tokens/components/dark/card-action.d.ts +11 -0
- package/build/tokens/components/dark/card-action.js +10 -0
- package/build/tokens/components/dark/card-content.d.ts +25 -0
- package/build/tokens/components/dark/card-content.js +24 -0
- package/build/tokens/components/dark/drawer.d.ts +29 -0
- package/build/tokens/components/dark/drawer.js +28 -0
- package/build/tokens/components/dark/illustrations.d.ts +0 -1
- package/build/tokens/components/dark/illustrations.js +0 -1
- package/build/tokens/components/dark/index.d.ts +3 -0
- package/build/tokens/components/dark/index.js +3 -0
- package/build/tokens/components/light/banner.d.ts +19 -0
- package/build/tokens/components/light/banner.js +19 -0
- package/build/tokens/components/light/card-action.d.ts +11 -0
- package/build/tokens/components/light/card-action.js +10 -0
- package/build/tokens/components/light/card-content.d.ts +25 -0
- package/build/tokens/components/light/card-content.js +24 -0
- package/build/tokens/components/light/drawer.d.ts +29 -0
- package/build/tokens/components/light/drawer.js +28 -0
- package/build/tokens/components/light/illustrations.d.ts +0 -1
- package/build/tokens/components/light/illustrations.js +0 -1
- package/build/tokens/components/light/index.d.ts +3 -0
- package/build/tokens/components/light/index.js +3 -0
- package/build/tokens/layout.d.ts +6 -6
- package/build/tokens/layout.js +3 -3
- package/build/tokens/typography.d.ts +6 -0
- package/build/tokens/typography.js +3 -0
- package/docs/components/NextPrevPage.tsx +5 -5
- package/docs/components/VariantTitle.tsx +17 -7
- package/package.json +16 -14
- package/src/components/BottomSheet/BottomSheetBackdrop.tsx +2 -2
- package/src/components/BottomSheet/BottomSheetFlatList.tsx +2 -3
- package/src/components/BottomSheet/BottomSheetHandle.tsx +1 -1
- package/src/components/Button/ButtonIcon.tsx +2 -1
- package/src/components/Button/ButtonRoot.tsx +2 -6
- package/src/components/Button/ButtonText.tsx +4 -1
- package/src/components/Card/Card.context.ts +7 -0
- package/src/components/Card/Card.docs.mdx +212 -14
- package/src/components/Card/Card.stories.tsx +50 -3
- package/src/components/Card/CardAction/CardAction.context.ts +22 -0
- package/src/components/Card/CardAction/CardAction.props.ts +87 -0
- package/src/components/Card/CardAction/CardAction.stories.tsx +265 -0
- package/src/components/Card/CardAction/CardAction.tsx +10 -0
- package/src/components/Card/CardAction/CardActionContent.tsx +20 -0
- package/src/components/Card/CardAction/CardActionHelperText.tsx +21 -0
- package/src/components/Card/CardAction/CardActionIcon.tsx +32 -0
- package/src/components/Card/CardAction/CardActionLeadingContent.tsx +9 -0
- package/src/components/Card/CardAction/CardActionRoot.tsx +258 -0
- package/src/components/Card/CardAction/CardActionText.tsx +17 -0
- package/src/components/Card/CardAction/CardActionTrailingContent.tsx +9 -0
- package/src/components/Card/CardAction/CardActionTrailingIcon.tsx +32 -0
- package/src/components/Card/CardAction/index.ts +10 -0
- package/src/components/Card/CardContent.tsx +40 -0
- package/src/components/Card/CardPressHandler.context.ts +12 -0
- package/src/components/Card/CardPressHandler.tsx +20 -0
- package/src/components/Card/CardRoot.tsx +128 -13
- package/src/components/Card/index.ts +3 -2
- package/src/components/Checkbox/CheckboxIcon.tsx +2 -1
- package/src/components/Container/Container.tsx +3 -3
- package/src/components/CurrencyInput/CurrencyInput.tsx +1 -1
- package/src/components/Helper/HelperIcon.tsx +2 -1
- package/src/components/Icon/Icon.tsx +4 -3
- package/src/components/IconButton/IconButtonIcon.tsx +2 -1
- package/src/components/IconContainer/IconContainer.tsx +17 -19
- package/src/components/Input/InputField.tsx +2 -1
- package/src/components/Input/InputIcon.tsx +2 -1
- package/src/components/Link/LinkIcon.tsx +3 -2
- package/src/components/List/ListAction/ListActionTrailingIcon.tsx +2 -1
- package/src/components/List/ListItem/ListItemIcon.tsx +2 -1
- package/src/components/List/ListItem/ListItemTrailingIcon.tsx +2 -3
- package/src/components/Radio/RadioIcon.tsx +8 -3
- package/src/components/RadioCard/RadioCardIcon.tsx +4 -3
- package/src/components/Spinner/Spinner.tsx +2 -0
- package/src/components/Spinner/Spinner.web.tsx +2 -0
- package/src/components/Switch/Switch.tsx +10 -5
- package/src/components/Switch/Switch.web.tsx +5 -0
- package/src/components/Tabs/TabsList.tsx +2 -0
- package/src/components/Textarea/TextareaField.tsx +1 -1
- package/src/components/ToggleButton/ToggleButtonIcon.tsx +2 -1
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +2 -2
- package/src/components/UnstyledIconButton/UnstyledIconButtonIcon.tsx +2 -1
- package/src/components/index.ts +1 -9
- package/src/core/index.ts +14 -11
- package/src/hooks/useColorMode.ts +9 -12
- package/src/tokens/components/dark/banner.ts +19 -0
- package/src/tokens/components/dark/card-action.ts +11 -0
- package/src/tokens/components/dark/card-content.ts +25 -0
- package/src/tokens/components/dark/drawer.ts +29 -0
- package/src/tokens/components/dark/illustrations.ts +0 -1
- package/src/tokens/components/dark/index.ts +3 -0
- package/src/tokens/components/light/banner.ts +19 -0
- package/src/tokens/components/light/card-action.ts +11 -0
- package/src/tokens/components/light/card-content.ts +25 -0
- package/src/tokens/components/light/drawer.ts +29 -0
- package/src/tokens/components/light/illustrations.ts +0 -1
- package/src/tokens/components/light/index.ts +3 -0
- package/src/tokens/layout.ts +3 -3
- package/src/tokens/typography.ts +3 -0
- package/build/components/Card/CardAction.context.d.ts +0 -6
- package/build/components/Card/CardAction.js +0 -13
- package/src/components/Card/CardAction.context.ts +0 -12
- package/src/components/Card/CardAction.tsx +0 -18
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { View, ViewProps } from 'react-native';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
+
import { useCardContext } from './Card.context';
|
|
4
|
+
|
|
5
|
+
const CardContent = ({ children, style, ...props }: ViewProps) => {
|
|
6
|
+
const { noPadding, space } = useCardContext();
|
|
7
|
+
styles.useVariants({
|
|
8
|
+
noPadding,
|
|
9
|
+
space,
|
|
10
|
+
});
|
|
11
|
+
return (
|
|
12
|
+
<View style={[styles.container, style]} {...props}>
|
|
13
|
+
{children}
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
CardContent.displayName = 'CardContent';
|
|
19
|
+
|
|
20
|
+
const styles = StyleSheet.create(theme => ({
|
|
21
|
+
container: {
|
|
22
|
+
variants: {
|
|
23
|
+
space: theme.globalStyle.variants.space,
|
|
24
|
+
noPadding: {
|
|
25
|
+
true: {
|
|
26
|
+
padding: theme.components.card.mobile.paddingNone,
|
|
27
|
+
},
|
|
28
|
+
false: {
|
|
29
|
+
padding: {
|
|
30
|
+
base: theme.components.card.mobile.padding,
|
|
31
|
+
md: theme.components.card.tablet.padding,
|
|
32
|
+
lg: theme.components.card.desktop.padding,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
export default CardContent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
interface CardPressHandlerContextProps {
|
|
4
|
+
pressed?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const CardPressHandlerContext = createContext<CardPressHandlerContextProps>({});
|
|
8
|
+
|
|
9
|
+
export const useCardPressHandlerContext = (): CardPressHandlerContextProps => {
|
|
10
|
+
const context = useContext(CardPressHandlerContext);
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PropsWithChildren, useMemo } from 'react';
|
|
2
|
+
import { useCardContext } from './Card.context';
|
|
3
|
+
import { CardPressHandlerContext } from './CardPressHandler.context';
|
|
4
|
+
|
|
5
|
+
const CardPressHandler = ({ children }: PropsWithChildren<{ handlerToInherit?: string }>) => {
|
|
6
|
+
const { pressed } = useCardContext();
|
|
7
|
+
const context = useMemo(
|
|
8
|
+
() => ({
|
|
9
|
+
pressed,
|
|
10
|
+
}),
|
|
11
|
+
[pressed]
|
|
12
|
+
);
|
|
13
|
+
return (
|
|
14
|
+
<CardPressHandlerContext.Provider value={context}>{children}</CardPressHandlerContext.Provider>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
CardPressHandler.displayName = 'CardPressHandler';
|
|
19
|
+
|
|
20
|
+
export default CardPressHandler;
|
|
@@ -4,6 +4,72 @@ import { StyleSheet } from 'react-native-unistyles';
|
|
|
4
4
|
import { useStyleProps } from '../../hooks';
|
|
5
5
|
import { CardContext } from './Card.context';
|
|
6
6
|
import CardProps from './Card.props';
|
|
7
|
+
import CardContent from './CardContent';
|
|
8
|
+
|
|
9
|
+
// Helper to check if children contain specific component types
|
|
10
|
+
const checkForComponentType = (children: React.ReactNode, displayName: string): boolean => {
|
|
11
|
+
return React.Children.toArray(children).some(child => {
|
|
12
|
+
if (React.isValidElement(child)) {
|
|
13
|
+
// @ts-expect-error - type
|
|
14
|
+
if (child.type.displayName === displayName) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const childProps = child.props as any;
|
|
18
|
+
if (childProps.children) {
|
|
19
|
+
return checkForComponentType(childProps.children, displayName);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Helper to filter out specific component types from children
|
|
27
|
+
const filterChildren = (children: React.ReactNode, excludeDisplayName: string): React.ReactNode => {
|
|
28
|
+
return React.Children.map(children, child => {
|
|
29
|
+
if (React.isValidElement(child)) {
|
|
30
|
+
// @ts-expect-error - type
|
|
31
|
+
if (child.type.displayName === excludeDisplayName) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const childProps = child.props as any;
|
|
35
|
+
if (childProps.children) {
|
|
36
|
+
return React.cloneElement(child, {
|
|
37
|
+
...childProps,
|
|
38
|
+
children: filterChildren(childProps.children, excludeDisplayName),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return child;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Helper to extract specific component types from children
|
|
47
|
+
const extractChildren = (
|
|
48
|
+
children: React.ReactNode,
|
|
49
|
+
includeDisplayName: string,
|
|
50
|
+
markFirst = false
|
|
51
|
+
): React.ReactNode => {
|
|
52
|
+
let isFirstFound = false;
|
|
53
|
+
return React.Children.map(children, child => {
|
|
54
|
+
if (React.isValidElement(child)) {
|
|
55
|
+
// @ts-expect-error - type
|
|
56
|
+
if (child.type.displayName === includeDisplayName) {
|
|
57
|
+
const isFirst = markFirst && !isFirstFound;
|
|
58
|
+
if (isFirst) {
|
|
59
|
+
isFirstFound = true;
|
|
60
|
+
}
|
|
61
|
+
return markFirst
|
|
62
|
+
? React.cloneElement(child, { ...(child.props || {}), isFirst } as any)
|
|
63
|
+
: child;
|
|
64
|
+
}
|
|
65
|
+
const childProps = child.props as any;
|
|
66
|
+
if (childProps.children) {
|
|
67
|
+
return extractChildren(childProps.children, includeDisplayName, markFirst);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
7
73
|
|
|
8
74
|
// Helper that recursively collects onPress or other defined handlers from descendants
|
|
9
75
|
const collectChildActionHandlers = (
|
|
@@ -14,15 +80,15 @@ const collectChildActionHandlers = (
|
|
|
14
80
|
if (React.isValidElement(child)) {
|
|
15
81
|
const childProps = child.props as any;
|
|
16
82
|
// @ts-expect-error - type
|
|
17
|
-
if (child.type.displayName === '
|
|
83
|
+
if (child.type.displayName === 'CardPressHandler') {
|
|
18
84
|
const actionChildren = React.Children.toArray(childProps.children);
|
|
19
|
-
const
|
|
85
|
+
const handlerToInherit = childProps['handlerToInherit'] || 'onPress';
|
|
20
86
|
const firstChild = actionChildren[0];
|
|
21
87
|
if (
|
|
22
88
|
React.isValidElement(firstChild) &&
|
|
23
|
-
typeof (firstChild.props as any)[
|
|
89
|
+
typeof (firstChild.props as any)[handlerToInherit] === 'function'
|
|
24
90
|
) {
|
|
25
|
-
handlers.push((firstChild.props as any)[
|
|
91
|
+
handlers.push((firstChild.props as any)[handlerToInherit]);
|
|
26
92
|
}
|
|
27
93
|
}
|
|
28
94
|
if (childProps.children) {
|
|
@@ -48,6 +114,8 @@ const Card = ({
|
|
|
48
114
|
}: CardProps & { states?: { active?: boolean; disabled?: boolean } }) => {
|
|
49
115
|
const { active } = states || { active: false };
|
|
50
116
|
const childActionHandlers = collectChildActionHandlers(children as ReactNode);
|
|
117
|
+
const hasActions = checkForComponentType(children as ReactNode, 'CardAction');
|
|
118
|
+
const hasContent = checkForComponentType(children as ReactNode, 'CardContent');
|
|
51
119
|
// Extract style props using our custom hook
|
|
52
120
|
const { computedStyles, remainingProps } = useStyleProps(rest);
|
|
53
121
|
|
|
@@ -62,22 +130,69 @@ const Card = ({
|
|
|
62
130
|
const inheritChildAction = childActionHandlers.length > 0;
|
|
63
131
|
const showPressed = inheritChildAction || !!onPress;
|
|
64
132
|
|
|
133
|
+
const filteredChildren =
|
|
134
|
+
!hasContent && hasActions ? filterChildren(children as ReactNode, 'CardAction') : null;
|
|
135
|
+
|
|
136
|
+
// Check if there's any content besides CardActions
|
|
137
|
+
const hasOnlyActions =
|
|
138
|
+
hasActions &&
|
|
139
|
+
!hasContent &&
|
|
140
|
+
React.Children.toArray(filteredChildren).filter(child => child != null).length === 0;
|
|
141
|
+
|
|
142
|
+
const filteredCardActions =
|
|
143
|
+
!hasContent && hasActions
|
|
144
|
+
? extractChildren(children as ReactNode, 'CardAction', hasOnlyActions)
|
|
145
|
+
: null;
|
|
146
|
+
|
|
147
|
+
const context = useMemo(
|
|
148
|
+
() => ({
|
|
149
|
+
pressed: showPressed && active,
|
|
150
|
+
noPadding,
|
|
151
|
+
hasActions,
|
|
152
|
+
hasContent,
|
|
153
|
+
hasOnlyActions,
|
|
154
|
+
space,
|
|
155
|
+
variant,
|
|
156
|
+
}),
|
|
157
|
+
[showPressed, active, hasActions, hasContent, hasOnlyActions, noPadding, space, variant]
|
|
158
|
+
);
|
|
159
|
+
|
|
65
160
|
styles.useVariants({
|
|
66
161
|
variant,
|
|
67
162
|
colorScheme,
|
|
68
|
-
noPadding,
|
|
163
|
+
noPadding: noPadding || hasActions || hasContent,
|
|
69
164
|
active,
|
|
70
165
|
showPressed,
|
|
71
166
|
disabled,
|
|
72
|
-
space,
|
|
167
|
+
space: hasActions || hasContent ? 'none' : space,
|
|
73
168
|
});
|
|
74
169
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
170
|
+
const renderChildren = () => {
|
|
171
|
+
// Default: render children as-is
|
|
172
|
+
if (hasContent || !hasActions) {
|
|
173
|
+
return children as ReactNode;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Card has actions but no explicit CardContent
|
|
177
|
+
if (hasOnlyActions) {
|
|
178
|
+
// Only CardActions, no other content - render actions directly
|
|
179
|
+
return filteredCardActions as ReactNode;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (filteredChildren) {
|
|
183
|
+
// Has both actions and other content - wrap content and render actions below
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
<CardContent>{filteredChildren as ReactNode}</CardContent>
|
|
187
|
+
{filteredCardActions as ReactNode}
|
|
188
|
+
</>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Fallback
|
|
193
|
+
return children as ReactNode;
|
|
194
|
+
};
|
|
195
|
+
|
|
81
196
|
return (
|
|
82
197
|
<CardContext.Provider value={context}>
|
|
83
198
|
<Pressable
|
|
@@ -88,7 +203,7 @@ const Card = ({
|
|
|
88
203
|
accessible={showPressed}
|
|
89
204
|
importantForAccessibility={showPressed ? 'yes' : 'no'}
|
|
90
205
|
>
|
|
91
|
-
{
|
|
206
|
+
{renderChildren()}
|
|
92
207
|
</Pressable>
|
|
93
208
|
</CardContext.Provider>
|
|
94
209
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Card } from './Card';
|
|
2
2
|
export { useCardContext } from './Card.context';
|
|
3
|
-
export
|
|
4
|
-
export { default as
|
|
3
|
+
export * from './CardAction';
|
|
4
|
+
export { default as CardPressHandler } from './CardPressHandler';
|
|
5
|
+
export { useCardPressHandlerContext } from './CardPressHandler.context';
|
|
@@ -11,7 +11,8 @@ const CheckboxIcon = ({ style, ...props }: IconProps) => {
|
|
|
11
11
|
{...props}
|
|
12
12
|
style={
|
|
13
13
|
Platform.OS === 'web'
|
|
14
|
-
?
|
|
14
|
+
? // @ts-expect-error - style prop type issue
|
|
15
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
15
16
|
: ([styles.icon as ViewStyle, style] as any)
|
|
16
17
|
}
|
|
17
18
|
/>
|
|
@@ -37,9 +37,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
37
37
|
marginHorizontal:
|
|
38
38
|
typeof extra.margin === 'undefined' && typeof extra.marginHorizontal === 'undefined'
|
|
39
39
|
? {
|
|
40
|
-
base: theme.layout.mobile.container.
|
|
41
|
-
md: theme.layout.tablet.container.
|
|
42
|
-
lg: theme.layout.desktop.container.
|
|
40
|
+
base: theme.layout.mobile.container.marginHorizontal,
|
|
41
|
+
md: theme.layout.tablet.container.marginHorizontal,
|
|
42
|
+
lg: theme.layout.desktop.container.marginHorizontal,
|
|
43
43
|
}
|
|
44
44
|
: undefined,
|
|
45
45
|
...extra,
|
|
@@ -82,7 +82,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
82
82
|
input: {
|
|
83
83
|
fontSize: theme.typography.mobile.detailText['4xl'].fontSize,
|
|
84
84
|
fontFamily: theme.typography.mobile.detailText.fontFamily,
|
|
85
|
-
fontWeight: theme.typography.mobile.detailText.fontWeight
|
|
85
|
+
fontWeight: `${theme.typography.mobile.detailText.fontWeight}`,
|
|
86
86
|
paddingTop: 0,
|
|
87
87
|
paddingBottom: 0,
|
|
88
88
|
paddingLeft: 0,
|
|
@@ -12,7 +12,8 @@ const HelperIcon = (props: IconProps) => {
|
|
|
12
12
|
<Icon
|
|
13
13
|
style={
|
|
14
14
|
Platform.OS === 'web'
|
|
15
|
-
?
|
|
15
|
+
? // @ts-expect-error - style prop type issue
|
|
16
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
16
17
|
: ([styles.icon as StyleProp<ViewStyle>, props.style] as any)
|
|
17
18
|
}
|
|
18
19
|
{...props}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createIcon } from '@gluestack-ui/icon';
|
|
2
|
+
import type React from 'react';
|
|
2
3
|
import { useMemo } from 'react';
|
|
3
4
|
import { Svg } from 'react-native-svg';
|
|
4
5
|
import { withUnistyles } from 'react-native-unistyles';
|
|
@@ -44,8 +45,8 @@ const PrimitiveIcon = withUnistyles(
|
|
|
44
45
|
|
|
45
46
|
PrimitiveIcon.displayName = 'PrimitiveIcon';
|
|
46
47
|
|
|
47
|
-
export const Icon = createIcon({
|
|
48
|
-
Root: PrimitiveIcon,
|
|
49
|
-
})
|
|
48
|
+
export const Icon: React.ForwardRefExoticComponent<IconProps> = createIcon({
|
|
49
|
+
Root: PrimitiveIcon as any,
|
|
50
|
+
}) as React.ForwardRefExoticComponent<IconProps>;
|
|
50
51
|
|
|
51
52
|
export default Icon;
|
|
@@ -18,7 +18,8 @@ const IconButtonIcon = (props: IconProps) => {
|
|
|
18
18
|
{...props}
|
|
19
19
|
style={
|
|
20
20
|
Platform.OS === 'web'
|
|
21
|
-
?
|
|
21
|
+
? // @ts-expect-error - style prop type issue
|
|
22
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
22
23
|
: [styles.icon as ViewStyle, props.style]
|
|
23
24
|
}
|
|
24
25
|
>
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
|
-
import { StyleSheet
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
3
|
import { Icon } from '../Icon';
|
|
4
4
|
import type IconContainerProps from './IconContainer.props';
|
|
5
5
|
|
|
6
|
-
const IconContainer =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
styles.useVariants({ size, radiusNone, variant, color });
|
|
6
|
+
const IconContainer = ({
|
|
7
|
+
icon: IconComp,
|
|
8
|
+
size = 'md',
|
|
9
|
+
radiusNone = false,
|
|
10
|
+
variant = 'subtle',
|
|
11
|
+
color = 'pig',
|
|
12
|
+
style,
|
|
13
|
+
...props
|
|
14
|
+
}: IconContainerProps) => {
|
|
15
|
+
styles.useVariants({ size, radiusNone, variant, color });
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
17
|
+
return (
|
|
18
|
+
<View style={[styles.container, style]} {...props}>
|
|
19
|
+
{IconComp ? <Icon as={IconComp} style={styles.icon} /> : null}
|
|
20
|
+
</View>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
25
23
|
|
|
26
24
|
IconContainer.displayName = 'IconContainer';
|
|
27
25
|
|
|
@@ -15,6 +15,7 @@ const InputField = ({
|
|
|
15
15
|
|
|
16
16
|
if (inBottomSheet) {
|
|
17
17
|
return (
|
|
18
|
+
// @ts-expect-error - BottomSheetTextInput type issue
|
|
18
19
|
<BottomSheetTextInput
|
|
19
20
|
placeholderTextColor={color.text.secondary}
|
|
20
21
|
selectionColor={color.purple[700]}
|
|
@@ -52,7 +53,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
52
53
|
color: theme.color.text.primary,
|
|
53
54
|
fontSize: theme.typography.mobile.bodyText.md.fontSize,
|
|
54
55
|
fontFamily: theme.typography.mobile.bodyText.fontFamily,
|
|
55
|
-
fontWeight: theme.typography.mobile.bodyText.fontWeight
|
|
56
|
+
fontWeight: `${theme.typography.mobile.bodyText.fontWeight}`,
|
|
56
57
|
borderWidth: 0,
|
|
57
58
|
variants: {
|
|
58
59
|
focused: {
|
|
@@ -9,7 +9,8 @@ const InputIcon = ({ children, ...props }: IconProps & { as?: ComponentType }) =
|
|
|
9
9
|
{...props}
|
|
10
10
|
style={
|
|
11
11
|
Platform.OS === 'web'
|
|
12
|
-
?
|
|
12
|
+
? // @ts-expect-error - style prop type issue
|
|
13
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
13
14
|
: ([styles.icon as StyleProp<ViewStyle>, props.style] as any)
|
|
14
15
|
}
|
|
15
16
|
>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Platform, type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
-
import { useLinkContext } from './Link.context';
|
|
3
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
3
|
import { Icon } from '../Icon';
|
|
5
4
|
import IconProps from '../Icon/Icon.props';
|
|
5
|
+
import { useLinkContext } from './Link.context';
|
|
6
6
|
|
|
7
7
|
const LinkIcon = ({ children, ...props }: IconProps) => {
|
|
8
8
|
const { active, inverted, disabled } = useLinkContext();
|
|
@@ -13,7 +13,8 @@ const LinkIcon = ({ children, ...props }: IconProps) => {
|
|
|
13
13
|
{...props}
|
|
14
14
|
style={
|
|
15
15
|
Platform.OS === 'web'
|
|
16
|
-
?
|
|
16
|
+
? // @ts-expect-error - style prop type issue
|
|
17
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
17
18
|
: [styles.icon as StyleProp<ViewStyle>, props.style]
|
|
18
19
|
}
|
|
19
20
|
>
|
|
@@ -10,7 +10,8 @@ const ListActionTrailingIcon = ({ children, ...props }: IconProps & { as?: Compo
|
|
|
10
10
|
{...props}
|
|
11
11
|
style={
|
|
12
12
|
Platform.OS === 'web'
|
|
13
|
-
?
|
|
13
|
+
? // @ts-expect-error - style prop type issue
|
|
14
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
14
15
|
: ([styles.icon as StyleProp<ViewStyle>, props.style] as any)
|
|
15
16
|
}
|
|
16
17
|
>
|
|
@@ -9,7 +9,8 @@ const ListItemIcon = ({ children, ...props }: IconProps & { as?: ComponentType }
|
|
|
9
9
|
{...props}
|
|
10
10
|
style={
|
|
11
11
|
Platform.OS === 'web'
|
|
12
|
-
?
|
|
12
|
+
? // @ts-expect-error - style prop type issue
|
|
13
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
13
14
|
: ([styles.icon as StyleProp<ViewStyle>, props.style] as any)
|
|
14
15
|
}
|
|
15
16
|
>
|
|
@@ -10,7 +10,8 @@ const ListItemTrailingIcon = ({ children, ...props }: IconProps & { as?: Compone
|
|
|
10
10
|
{...props}
|
|
11
11
|
style={
|
|
12
12
|
Platform.OS === 'web'
|
|
13
|
-
?
|
|
13
|
+
? // @ts-expect-error - style prop type issue
|
|
14
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
14
15
|
: ([styles.icon as StyleProp<ViewStyle>, props.style] as any)
|
|
15
16
|
}
|
|
16
17
|
>
|
|
@@ -24,8 +25,6 @@ ListItemTrailingIcon.displayName = 'ListItemTrailingIcon';
|
|
|
24
25
|
const styles = StyleSheet.create(theme => ({
|
|
25
26
|
icon: {
|
|
26
27
|
color: theme.color.icon.primary,
|
|
27
|
-
width: 24,
|
|
28
|
-
height: 24,
|
|
29
28
|
},
|
|
30
29
|
}));
|
|
31
30
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Platform, StyleProp, ViewStyle } from 'react-native';
|
|
1
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
3
|
import { Icon } from '../Icon';
|
|
3
|
-
import { CircleIcon } from '../Icons';
|
|
4
4
|
import IconProps from '../Icon/Icon.props';
|
|
5
|
-
import {
|
|
5
|
+
import { CircleIcon } from '../Icons';
|
|
6
6
|
|
|
7
7
|
const RadioIcon = ({ style, ...props }: IconProps) => {
|
|
8
8
|
return (
|
|
@@ -11,7 +11,12 @@ const RadioIcon = ({ style, ...props }: IconProps) => {
|
|
|
11
11
|
{...props}
|
|
12
12
|
style={
|
|
13
13
|
Platform.OS === 'web'
|
|
14
|
-
?
|
|
14
|
+
? {
|
|
15
|
+
// @ts-expect-error - style prop type issue
|
|
16
|
+
...(styles.container as StyleProp<ViewStyle>),
|
|
17
|
+
// @ts-expect-error - style prop type issue
|
|
18
|
+
...(props.style as StyleProp<ViewStyle>),
|
|
19
|
+
}
|
|
15
20
|
: ([styles.container, style] as any)
|
|
16
21
|
}
|
|
17
22
|
/>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Platform, StyleProp, ViewStyle } from 'react-native';
|
|
1
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
3
|
import { Icon } from '../Icon';
|
|
3
|
-
import { CircleIcon } from '../Icons';
|
|
4
4
|
import IconProps from '../Icon/Icon.props';
|
|
5
|
-
import {
|
|
5
|
+
import { CircleIcon } from '../Icons';
|
|
6
6
|
|
|
7
7
|
const RadioCardIcon = ({ style, ...props }: IconProps) => {
|
|
8
8
|
return (
|
|
@@ -11,7 +11,8 @@ const RadioCardIcon = ({ style, ...props }: IconProps) => {
|
|
|
11
11
|
{...props}
|
|
12
12
|
style={
|
|
13
13
|
Platform.OS === 'web'
|
|
14
|
-
?
|
|
14
|
+
? // @ts-expect-error - style prop type issue
|
|
15
|
+
{ ...(styles.container as StyleProp<ViewStyle>), ...props.style }
|
|
15
16
|
: ([styles.container, style] as any)
|
|
16
17
|
}
|
|
17
18
|
/>
|
|
@@ -18,7 +18,9 @@ import { ColorValue } from '../../types';
|
|
|
18
18
|
import { getFlattenedColorValue } from '../../utils';
|
|
19
19
|
import type SpinnerProps from './Spinner.props';
|
|
20
20
|
|
|
21
|
+
// @ts-expect-error - Animated.View type issue
|
|
21
22
|
const AnimatedSvg = Animated.createAnimatedComponent(Svg as React.ComponentType<any>);
|
|
23
|
+
// @ts-expect-error - Animated.View type issue
|
|
22
24
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle as React.ComponentType<any>);
|
|
23
25
|
|
|
24
26
|
const SpinnerRoot = ({ size = 'md', color, ...props }: SpinnerProps) => {
|
|
@@ -18,7 +18,9 @@ import { ColorValue } from '../../types';
|
|
|
18
18
|
import { getFlattenedColorValue } from '../../utils';
|
|
19
19
|
import type SpinnerProps from './Spinner.props';
|
|
20
20
|
|
|
21
|
+
// @ts-expect-error - Animated.View type issue
|
|
21
22
|
const AnimatedSvg = Animated.createAnimatedComponent(Svg as React.ComponentType<any>);
|
|
23
|
+
// @ts-expect-error - Animated.View type issue
|
|
22
24
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle as React.ComponentType<any>);
|
|
23
25
|
|
|
24
26
|
const SpinnerRoot = ({ size = 'md', color, ...props }: SpinnerProps) => {
|
|
@@ -11,6 +11,7 @@ import Animated, {
|
|
|
11
11
|
withTiming,
|
|
12
12
|
} from 'react-native-reanimated';
|
|
13
13
|
import { StyleSheet } from 'react-native-unistyles';
|
|
14
|
+
import { useAnimatedTheme } from 'react-native-unistyles/reanimated';
|
|
14
15
|
import { useTheme } from '../../hooks';
|
|
15
16
|
import { Icon } from '../Icon';
|
|
16
17
|
import SwitchProps from './Switch.props';
|
|
@@ -23,6 +24,7 @@ const CustomSwitch = ({
|
|
|
23
24
|
...accessibilityProps
|
|
24
25
|
}: SwitchProps) => {
|
|
25
26
|
const { components, color } = useTheme();
|
|
27
|
+
const theme = useAnimatedTheme();
|
|
26
28
|
const SWITCH_WIDTH = size === 'medium' ? components.switch.md.width : components.switch.sm.width;
|
|
27
29
|
const THUMB_SIZE =
|
|
28
30
|
size === 'medium' ? components.switch.md.circle.size : components.switch.sm.circle.size;
|
|
@@ -34,17 +36,20 @@ const CustomSwitch = ({
|
|
|
34
36
|
const offset = useSharedValue(value ? SWITCH_WIDTH - THUMB_SIZE - PADDING * 2 : 0);
|
|
35
37
|
const progress = useSharedValue(value ? 1 : 0);
|
|
36
38
|
|
|
37
|
-
const animatedThumbStyle = useAnimatedStyle(
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
const animatedThumbStyle = useAnimatedStyle(
|
|
40
|
+
() => ({
|
|
41
|
+
transform: [{ translateX: offset.value }],
|
|
42
|
+
}),
|
|
43
|
+
[offset]
|
|
44
|
+
);
|
|
40
45
|
|
|
41
46
|
const animatedSwitchBackgroundStyle = useAnimatedStyle(() => {
|
|
42
47
|
const backgroundColor = interpolateColor(
|
|
43
48
|
progress.value,
|
|
44
49
|
[0, 1],
|
|
45
50
|
[
|
|
46
|
-
color.interactive.functional.surface.strong.default,
|
|
47
|
-
color.interactive.brand.surface.strong.default,
|
|
51
|
+
theme.value.color.interactive.functional.surface.strong.default,
|
|
52
|
+
theme.value.color.interactive.brand.surface.strong.default,
|
|
48
53
|
]
|
|
49
54
|
);
|
|
50
55
|
return { backgroundColor };
|
|
@@ -15,6 +15,7 @@ import { useTheme } from '../../hooks';
|
|
|
15
15
|
import { Icon } from '../Icon';
|
|
16
16
|
import SwitchProps from './Switch.props';
|
|
17
17
|
|
|
18
|
+
// @ts-expect-error - Animated.View type issue
|
|
18
19
|
const AnimatedView = Animated.createAnimatedComponent(View);
|
|
19
20
|
|
|
20
21
|
const CustomSwitch = ({
|
|
@@ -114,14 +115,18 @@ const CustomSwitch = ({
|
|
|
114
115
|
accessibilityHint={accessibilityProps.accessibilityHint}
|
|
115
116
|
{...accessibilityProps}
|
|
116
117
|
>
|
|
118
|
+
{/* @ts-expect-error - Animated.View type issue */}
|
|
117
119
|
<AnimatedView style={[styles.switch, animatedSwitchBackgroundStyle, animatedSwitchStyle]}>
|
|
120
|
+
{/* @ts-expect-error - Animated.View type issue */}
|
|
118
121
|
<AnimatedView style={[styles.thumb, animatedThumbStyle]}>
|
|
122
|
+
{/* @ts-expect-error - Animated.View type issue */}
|
|
119
123
|
<AnimatedView style={[styles.iconWrap, animatedTickStyle]}>
|
|
120
124
|
{(() => {
|
|
121
125
|
const IconAny = Icon as any;
|
|
122
126
|
return <IconAny as={TickSmallIcon} style={styles.icon as any} />;
|
|
123
127
|
})()}
|
|
124
128
|
</AnimatedView>
|
|
129
|
+
{/* @ts-expect-error - Animated.View type issue */}
|
|
125
130
|
<AnimatedView style={[styles.iconWrap, animatedCrossStyle]}>
|
|
126
131
|
{(() => {
|
|
127
132
|
const IconAny = Icon as any;
|
|
@@ -15,6 +15,7 @@ import { UnstyledIconButton } from '../UnstyledIconButton';
|
|
|
15
15
|
import { useTabsContext } from './Tabs.context';
|
|
16
16
|
import type TabsListProps from './TabsList.props';
|
|
17
17
|
|
|
18
|
+
// @ts-expect-error - Animated.View type issue
|
|
18
19
|
const Indicator = Animated.createAnimatedComponent(View);
|
|
19
20
|
|
|
20
21
|
const SCROLL_STEP_RATIO = 0.6;
|
|
@@ -112,6 +113,7 @@ const TabsList = ({ children, style, ...rest }: TabsListProps) => {
|
|
|
112
113
|
<View style={styles.container}>
|
|
113
114
|
{children}
|
|
114
115
|
<Indicator
|
|
116
|
+
// @ts-expect-error - Animated.View type issue
|
|
115
117
|
accessibilityElementsHidden
|
|
116
118
|
importantForAccessibility="no-hide-descendants"
|
|
117
119
|
style={[styles.indicator, indicatorStyle]}
|
|
@@ -33,7 +33,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
33
33
|
color: theme.color.text.primary,
|
|
34
34
|
fontSize: theme.typography.mobile.bodyText.md.fontSize,
|
|
35
35
|
fontFamily: theme.typography.mobile.bodyText.fontFamily,
|
|
36
|
-
fontWeight: theme.typography.mobile.bodyText.fontWeight
|
|
36
|
+
fontWeight: `${theme.typography.mobile.bodyText.fontWeight}`,
|
|
37
37
|
borderWidth: 0,
|
|
38
38
|
outlineWidth: 0,
|
|
39
39
|
_web: {
|