@utilitywarehouse/hearth-react-native 0.16.2 → 0.17.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 +14 -14
- package/CHANGELOG.md +132 -0
- package/build/components/Card/CardAction/CardActionRoot.js +12 -2
- package/build/components/Card/CardActions.context.d.ts +6 -0
- package/build/components/Card/CardActions.context.js +5 -0
- package/build/components/Card/CardActions.d.ts +7 -0
- package/build/components/Card/CardActions.js +29 -0
- package/build/components/Card/CardRoot.js +16 -104
- package/build/components/Card/helpers.d.ts +8 -0
- package/build/components/Card/helpers.js +146 -0
- package/build/components/Card/index.d.ts +2 -0
- package/build/components/Card/index.js +2 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.d.ts +1 -1
- package/build/components/ExpandableCard/ExpandableCardGroup.js +2 -2
- package/build/components/ExpandableCard/ExpandableCardGroup.props.d.ts +4 -0
- package/build/components/Input/Input.js +4 -3
- package/build/components/Input/Input.props.d.ts +9 -0
- package/build/components/List/List.context.d.ts +4 -2
- package/build/components/List/List.context.js +0 -2
- package/build/components/List/List.d.ts +1 -1
- package/build/components/List/List.js +25 -38
- package/build/components/List/List.props.d.ts +1 -0
- package/build/components/List/ListAction/ListAction.js +24 -7
- package/build/components/List/ListAction/ListAction.props.d.ts +1 -0
- package/build/components/List/ListItem/ListItemRoot.js +12 -4
- package/build/utils/isThemedImageProps.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/Card/Card.docs.mdx +224 -66
- package/src/components/Card/Card.stories.tsx +29 -25
- package/src/components/Card/CardAction/CardAction.stories.tsx +239 -93
- package/src/components/Card/CardAction/CardActionRoot.tsx +15 -2
- package/src/components/Card/CardActions.context.ts +12 -0
- package/src/components/Card/CardActions.tsx +40 -0
- package/src/components/Card/CardRoot.tsx +27 -132
- package/src/components/Card/helpers.tsx +195 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/ExpandableCard/ExpandableCard.figma.tsx +33 -38
- package/src/components/ExpandableCard/ExpandableCardGroup.figma.tsx +34 -17
- package/src/components/ExpandableCard/ExpandableCardGroup.props.ts +5 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.tsx +2 -0
- package/src/components/HighlightBanner/HighlightBanner.figma.tsx +46 -0
- package/src/components/IconButton/IconButton.figma.tsx +20 -30
- package/src/components/IconContainer/IconContainer.figma.tsx +7 -13
- package/src/components/IndicatorIconButton/IndicatorIconButton.figma.tsx +16 -0
- package/src/components/Input/Input.docs.mdx +55 -15
- package/src/components/Input/Input.figma.tsx +106 -40
- package/src/components/Input/Input.props.ts +9 -0
- package/src/components/Input/Input.tsx +21 -0
- package/src/components/Link/Link.figma.tsx +31 -38
- package/src/components/List/List.context.ts +2 -4
- package/src/components/List/List.docs.mdx +10 -5
- package/src/components/List/List.figma.tsx +42 -28
- package/src/components/List/List.props.ts +1 -0
- package/src/components/List/List.stories.tsx +43 -0
- package/src/components/List/List.tsx +38 -51
- package/src/components/List/ListAction/ListAction.figma.tsx +5 -13
- package/src/components/List/ListAction/ListAction.props.ts +1 -0
- package/src/components/List/ListAction/ListAction.tsx +40 -10
- package/src/components/List/ListItem/ListItem.figma.tsx +43 -27
- package/src/components/List/ListItem/ListItemRoot.tsx +15 -4
- package/src/utils/isThemedImageProps.ts +1 -1
- package/src/components/InlineLink/InlineLink.figma.tsx +0 -33
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import List from
|
|
3
|
-
import figma from "@figma/code-connect"
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { List } from '../';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
figma.connect(List, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=2437%3A621', {
|
|
5
|
+
props: {
|
|
6
|
+
container: figma.enum('Container', {
|
|
7
|
+
'Subtle White': 'subtleWhite',
|
|
8
|
+
'Emphasis White': 'emphasisWhite',
|
|
9
|
+
'Subtle Warm White': 'subtleWarmWhite',
|
|
10
|
+
'Emphasis Warm White': 'emphasisWarmWhite',
|
|
11
|
+
}),
|
|
12
|
+
sectionHeader: figma.boolean('Section header?', {
|
|
13
|
+
true: figma.nestedProps('Section Header', {
|
|
14
|
+
heading: figma.string('Heading'),
|
|
15
|
+
helperText: figma.boolean('Helper text?', {
|
|
16
|
+
true: figma.string('Helper text'),
|
|
17
|
+
}),
|
|
18
|
+
trailingContent: figma.boolean('Trailing content?', {
|
|
19
|
+
true: figma.nestedProps('Trailing content', {
|
|
20
|
+
headerTrailingContent: figma.instance('Variant'),
|
|
21
|
+
}),
|
|
22
|
+
}),
|
|
23
|
+
invalidText: figma.enum('State', {
|
|
24
|
+
Invalid: figma.nestedProps('Validation Text', {
|
|
25
|
+
invalidText: figma.string('Text'),
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
24
28
|
}),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
example: (props) => <List container={props.container} />,
|
|
29
|
+
}),
|
|
30
|
+
listItems: figma.children('List Item'),
|
|
31
|
+
listActions: figma.children('List Action'),
|
|
30
32
|
},
|
|
31
|
-
|
|
33
|
+
example: props => (
|
|
34
|
+
<List
|
|
35
|
+
container={props.container}
|
|
36
|
+
heading={props.sectionHeader?.heading}
|
|
37
|
+
helperText={props.sectionHeader?.helperText}
|
|
38
|
+
headerTrailingContent={props.sectionHeader?.trailingContent?.headerTrailingContent}
|
|
39
|
+
invalidText={props.sectionHeader?.invalidText?.invalidText}
|
|
40
|
+
>
|
|
41
|
+
{props.listItems}
|
|
42
|
+
{props.listActions}
|
|
43
|
+
</List>
|
|
44
|
+
),
|
|
45
|
+
});
|
|
@@ -233,6 +233,49 @@ export const WithCustomListItemComponent: Story = {
|
|
|
233
233
|
),
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
+
const CustomListAction = () => (
|
|
237
|
+
<ListAction
|
|
238
|
+
heading="Custom List Action"
|
|
239
|
+
onPress={() => console.log('Custom List Action pressed')}
|
|
240
|
+
/>
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const CustomNull = () => null;
|
|
244
|
+
|
|
245
|
+
export const WithMappedCustomListItems: Story = {
|
|
246
|
+
parameters: {
|
|
247
|
+
controls: { include: [] },
|
|
248
|
+
},
|
|
249
|
+
render: () => {
|
|
250
|
+
const listData = [
|
|
251
|
+
{ heading: 'Custom Item 1', helperText: 'Supporting text 1' },
|
|
252
|
+
{ heading: 'Custom Item 2', helperText: 'Supporting text 2' },
|
|
253
|
+
{ heading: 'Custom Item 3', helperText: 'Supporting text 3' },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<List container="subtleWarmWhite">
|
|
258
|
+
<CustomNull />
|
|
259
|
+
<ListItem
|
|
260
|
+
heading="Refer a friend"
|
|
261
|
+
helperText="Get rewarded with a friend"
|
|
262
|
+
leadingContent={<ListItemIcon as={UserMediumIcon} />}
|
|
263
|
+
trailingContent={<ListItemTrailingIcon as={ChevronRightSmallIcon} />}
|
|
264
|
+
onPress={() => console.log('Refer a friend pressed')}
|
|
265
|
+
/>
|
|
266
|
+
{listData.map((item, index) => (
|
|
267
|
+
<CustomListItem key={index} />
|
|
268
|
+
))}
|
|
269
|
+
{listData.map((item, index) => (
|
|
270
|
+
<CustomListAction key={index} />
|
|
271
|
+
))}
|
|
272
|
+
<CustomListAction />
|
|
273
|
+
<CustomListAction />
|
|
274
|
+
</List>
|
|
275
|
+
);
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
|
|
236
279
|
export const WithListAction: Story = {
|
|
237
280
|
parameters: {
|
|
238
281
|
controls: { include: [] },
|
|
@@ -1,55 +1,22 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { View
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { Card } from '../Card';
|
|
5
5
|
import { SectionHeader } from '../SectionHeader';
|
|
6
|
-
import { ListContext
|
|
6
|
+
import { ListContext } from './List.context';
|
|
7
7
|
import type ListProps from './List.props';
|
|
8
|
-
import { ListAction } from './ListAction';
|
|
9
|
-
import { ListItem } from './ListItem';
|
|
10
8
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!found) {
|
|
20
|
-
if (child.type === ListItem || child.type === ListAction) {
|
|
21
|
-
found = true;
|
|
22
|
-
return (
|
|
23
|
-
<ListFirstItemContext.Provider value={true}>{child}</ListFirstItemContext.Provider>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// If the child has nested children, process them recursively
|
|
28
|
-
if (
|
|
29
|
-
React.isValidElement(child) &&
|
|
30
|
-
child.props &&
|
|
31
|
-
typeof child.props === 'object' &&
|
|
32
|
-
child.props !== null &&
|
|
33
|
-
'children' in child.props &&
|
|
34
|
-
child.props.children
|
|
35
|
-
) {
|
|
36
|
-
const clonedChildren = recursiveClone((child.props as any).children);
|
|
37
|
-
return React.cloneElement(child, { children: clonedChildren } as any);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
found = true;
|
|
41
|
-
return <ListFirstItemContext.Provider value={true}>{child}</ListFirstItemContext.Provider>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return child;
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return recursiveClone(children) as ViewProps['children'];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const List = ({ children, heading, helperText, headerTrailingContent, ...props }: ListProps) => {
|
|
9
|
+
const List = ({
|
|
10
|
+
children,
|
|
11
|
+
heading,
|
|
12
|
+
helperText,
|
|
13
|
+
headerTrailingContent,
|
|
14
|
+
invalidText,
|
|
15
|
+
...props
|
|
16
|
+
}: ListProps) => {
|
|
52
17
|
const { loading, disabled, container = 'none' } = props;
|
|
18
|
+
const orderRef = useRef<string[]>([]);
|
|
19
|
+
const [firstItemId, setFirstItemId] = useState<string | undefined>(undefined);
|
|
53
20
|
const containerToCard: {
|
|
54
21
|
variant: 'subtle' | 'emphasis';
|
|
55
22
|
colorScheme: 'neutralStrong' | 'neutralSubtle';
|
|
@@ -60,8 +27,27 @@ const List = ({ children, heading, helperText, headerTrailingContent, ...props }
|
|
|
60
27
|
? 'neutralStrong'
|
|
61
28
|
: 'neutralSubtle',
|
|
62
29
|
};
|
|
63
|
-
|
|
64
|
-
const
|
|
30
|
+
|
|
31
|
+
const registerItem = useCallback((id: string) => {
|
|
32
|
+
if (!orderRef.current.includes(id)) {
|
|
33
|
+
orderRef.current.push(id);
|
|
34
|
+
}
|
|
35
|
+
const nextFirst = orderRef.current[0];
|
|
36
|
+
setFirstItemId(prev => (prev === nextFirst ? prev : nextFirst));
|
|
37
|
+
return () => {
|
|
38
|
+
orderRef.current = orderRef.current.filter(currentId => currentId !== id);
|
|
39
|
+
const nextFirst = orderRef.current[0];
|
|
40
|
+
setFirstItemId(prev => (prev === nextFirst ? prev : nextFirst));
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const value = {
|
|
45
|
+
loading,
|
|
46
|
+
disabled,
|
|
47
|
+
container,
|
|
48
|
+
firstItemId,
|
|
49
|
+
registerItem,
|
|
50
|
+
};
|
|
65
51
|
styles.useVariants({ disabled });
|
|
66
52
|
return (
|
|
67
53
|
<ListContext.Provider value={value}>
|
|
@@ -71,14 +57,15 @@ const List = ({ children, heading, helperText, headerTrailingContent, ...props }
|
|
|
71
57
|
heading={heading}
|
|
72
58
|
helperText={helperText}
|
|
73
59
|
trailingContent={headerTrailingContent}
|
|
60
|
+
invalidText={invalidText}
|
|
74
61
|
/>
|
|
75
62
|
) : null}
|
|
76
63
|
{container === 'none' ? (
|
|
77
|
-
<View>{
|
|
64
|
+
<View>{children}</View>
|
|
78
65
|
) : (
|
|
79
|
-
React.Children.count(
|
|
66
|
+
React.Children.count(children) > 0 && (
|
|
80
67
|
<Card {...containerToCard} noPadding style={styles.card}>
|
|
81
|
-
<>{
|
|
68
|
+
<>{children}</>
|
|
82
69
|
</Card>
|
|
83
70
|
)
|
|
84
71
|
)}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
2
|
import ListAction from './ListAction';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
7
|
-
* You should check this is correct, and update the `example` function
|
|
8
|
-
* to return the code example you'd like to see in Figma
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
4
|
figma.connect(
|
|
12
5
|
ListAction,
|
|
13
6
|
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=9661%3A5128',
|
|
14
7
|
{
|
|
15
8
|
props: {
|
|
16
|
-
// These props were automatically mapped based on your linked code:
|
|
17
9
|
heading: figma.string('Action heading'),
|
|
18
10
|
disabled: figma.enum('State', {
|
|
19
11
|
Disabled: true,
|
|
20
12
|
}),
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
loading: figma.enum('State', {
|
|
14
|
+
Loading: true,
|
|
23
15
|
}),
|
|
24
|
-
// No matching props could be found for these Figma properties:
|
|
25
|
-
// "actionHeading": figma.string('Action heading')
|
|
26
16
|
},
|
|
27
|
-
example: props =>
|
|
17
|
+
example: props => (
|
|
18
|
+
<ListAction heading={props.heading} disabled={props.disabled} loading={props.loading} />
|
|
19
|
+
),
|
|
28
20
|
}
|
|
29
21
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createPressable } from '@gluestack-ui/pressable';
|
|
2
2
|
import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
-
import {
|
|
3
|
+
import { useId, useLayoutEffect } from 'react';
|
|
4
|
+
import { Pressable, View, ViewStyle } from 'react-native';
|
|
4
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import {
|
|
6
|
+
import { Skeleton } from '../../Skeleton';
|
|
7
|
+
import { useListContext } from '../List.context';
|
|
6
8
|
import type ListActionProps from './ListAction.props';
|
|
7
9
|
import ListActionContent from './ListActionContent';
|
|
8
10
|
import ListActionText from './ListActionText';
|
|
@@ -13,11 +15,12 @@ const ListActionRoot = ({
|
|
|
13
15
|
heading,
|
|
14
16
|
disabled,
|
|
15
17
|
variant = 'subtle',
|
|
18
|
+
loading,
|
|
16
19
|
...props
|
|
17
20
|
}: ListActionProps & { states?: { active?: boolean; disabled?: boolean } }) => {
|
|
18
21
|
const { onPress } = props;
|
|
19
22
|
const listContext = useListContext();
|
|
20
|
-
const
|
|
23
|
+
const { registerItem, firstItemId } = listContext;
|
|
21
24
|
|
|
22
25
|
const { active } = props.states || { active: false };
|
|
23
26
|
|
|
@@ -33,6 +36,17 @@ const ListActionRoot = ({
|
|
|
33
36
|
|
|
34
37
|
const isDisabled = disabled || listContext?.disabled || false;
|
|
35
38
|
const listItemVariant = getListContainer() || variant;
|
|
39
|
+
const actionId = useId();
|
|
40
|
+
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
if (!registerItem) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return registerItem(actionId);
|
|
47
|
+
}, [actionId, registerItem]);
|
|
48
|
+
|
|
49
|
+
const isFirstChild = firstItemId === actionId;
|
|
36
50
|
|
|
37
51
|
const testID = props.testID || 'list-action';
|
|
38
52
|
|
|
@@ -41,7 +55,7 @@ const ListActionRoot = ({
|
|
|
41
55
|
disabled: isDisabled,
|
|
42
56
|
active,
|
|
43
57
|
showDisabled: !listContext?.disabled && disabled,
|
|
44
|
-
isFirstChild
|
|
58
|
+
isFirstChild,
|
|
45
59
|
container: listContext?.container,
|
|
46
60
|
});
|
|
47
61
|
|
|
@@ -52,12 +66,21 @@ const ListActionRoot = ({
|
|
|
52
66
|
style={[styles.container, props.style as ViewStyle]}
|
|
53
67
|
disabled={isDisabled || !onPress}
|
|
54
68
|
>
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
{loading ? (
|
|
70
|
+
<View style={styles.loadingWrap}>
|
|
71
|
+
<Skeleton style={{ flex: 1, maxWidth: 166 }} width="auto" height={24} borderRadius="sm" />
|
|
72
|
+
<Skeleton width={24} height={24} borderRadius="sm" />
|
|
73
|
+
</View>
|
|
74
|
+
) : (
|
|
75
|
+
<>
|
|
76
|
+
<ListActionContent>
|
|
77
|
+
<ListActionText>{heading}</ListActionText>
|
|
78
|
+
</ListActionContent>
|
|
79
|
+
<ListActionTrailingContent style={styles.centeredTrailingIcon}>
|
|
80
|
+
<ListActionTrailingIcon as={ChevronRightSmallIcon} />
|
|
81
|
+
</ListActionTrailingContent>
|
|
82
|
+
</>
|
|
83
|
+
)}
|
|
61
84
|
</Pressable>
|
|
62
85
|
);
|
|
63
86
|
};
|
|
@@ -129,6 +152,13 @@ const styles = StyleSheet.create(theme => ({
|
|
|
129
152
|
centeredTrailingIcon: {
|
|
130
153
|
justifyContent: 'center',
|
|
131
154
|
},
|
|
155
|
+
loadingWrap: {
|
|
156
|
+
flexDirection: 'row',
|
|
157
|
+
justifyContent: 'space-between',
|
|
158
|
+
alignItems: 'center',
|
|
159
|
+
width: '100%',
|
|
160
|
+
gap: theme.space['200'],
|
|
161
|
+
},
|
|
132
162
|
}));
|
|
133
163
|
|
|
134
164
|
export default ListAction;
|
|
@@ -1,40 +1,56 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import ListItem from '
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
7
|
-
* You should check this is correct, and update the `example` function
|
|
8
|
-
* to return the code example you'd like to see in Figma
|
|
9
|
-
*/
|
|
2
|
+
import { ListItem } from '../';
|
|
10
3
|
|
|
11
4
|
figma.connect(ListItem, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=2421%3A1628', {
|
|
12
5
|
props: {
|
|
13
|
-
// These props were automatically mapped based on your linked code:
|
|
14
6
|
loading: figma.enum('State', {
|
|
15
7
|
Loading: true,
|
|
16
8
|
}),
|
|
17
9
|
disabled: figma.enum('State', {
|
|
18
10
|
Disabled: true,
|
|
19
11
|
}),
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
leadingContent: figma.boolean('Leading content?', {
|
|
13
|
+
true: figma.nestedProps('Leading content', {
|
|
14
|
+
variant: figma.enum('Variant', {
|
|
15
|
+
Icon: figma.instance('Icon-24'),
|
|
16
|
+
'Icon Container': figma.children('Icon Container'),
|
|
17
|
+
Avatar: figma.children('Avatar'),
|
|
18
|
+
Indicator: figma.children('Indicator'),
|
|
19
|
+
}),
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
trailingContent: figma.boolean('Trailing Content?', {
|
|
23
|
+
true: figma.nestedProps('Trailing content', {
|
|
24
|
+
variant: figma.enum('Variant', {
|
|
25
|
+
Icon: figma.instance('Icon-20'),
|
|
26
|
+
Link: figma.children('Link'),
|
|
27
|
+
Button: figma.children('Button'),
|
|
28
|
+
Switch: figma.children('Switch'),
|
|
29
|
+
Transaction: figma.children('Transaction'),
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
heading: figma.string('List heading'),
|
|
34
|
+
helperText: figma.boolean('Helper text?', {
|
|
35
|
+
true: figma.string('Helper text'),
|
|
36
|
+
}),
|
|
37
|
+
badge: figma.boolean('Badge?', {
|
|
38
|
+
true: figma.children('Badge'),
|
|
39
|
+
}),
|
|
40
|
+
numericValue: figma.boolean('Numerical value?', {
|
|
41
|
+
true: figma.string('Numerical value'),
|
|
22
42
|
}),
|
|
23
|
-
// No matching props could be found for these Figma properties:
|
|
24
|
-
// "listHeading": figma.string('List heading'),
|
|
25
|
-
// "helperText": figma.boolean('Helper text?'),
|
|
26
|
-
// "helperText": figma.string('Helper text'),
|
|
27
|
-
// "customContent": figma.instance('Custom content'),
|
|
28
|
-
// "badge": figma.boolean('Badge?'),
|
|
29
|
-
// "leadingContent": figma.boolean('Leading content?'),
|
|
30
|
-
// "trailingContent": figma.boolean('Trailing Content?'),
|
|
31
|
-
// "numericalValue": figma.boolean('Numerical value?'),
|
|
32
|
-
// "numericalValue": figma.string('Numerical value'),
|
|
33
|
-
// "variant": figma.enum('Variant', {
|
|
34
|
-
// "Default": "default",
|
|
35
|
-
// "Custom": "custom"
|
|
36
|
-
// }),
|
|
37
|
-
// "paddingNone": figma.boolean('Padding None?')
|
|
38
43
|
},
|
|
39
|
-
example: props =>
|
|
44
|
+
example: props => (
|
|
45
|
+
<ListItem
|
|
46
|
+
heading={props.heading}
|
|
47
|
+
helperText={props.helperText}
|
|
48
|
+
badge={props.badge}
|
|
49
|
+
numericValue={props.numericValue}
|
|
50
|
+
loading={props.loading}
|
|
51
|
+
disabled={props.disabled}
|
|
52
|
+
leadingContent={props.leadingContent?.variant}
|
|
53
|
+
trailingContent={props.trailingContent?.variant}
|
|
54
|
+
/>
|
|
55
|
+
),
|
|
40
56
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
2
|
-
import { useMemo } from 'react';
|
|
2
|
+
import { useId, useLayoutEffect, useMemo } from 'react';
|
|
3
3
|
import { Pressable, ViewStyle } from 'react-native';
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
import { DetailText } from '../../DetailText';
|
|
6
6
|
import { Skeleton } from '../../Skeleton';
|
|
7
|
-
import { useListContext
|
|
7
|
+
import { useListContext } from '../List.context';
|
|
8
8
|
import { IListItemContext, ListItemContext } from './ListItem.context';
|
|
9
9
|
import type ListItemProps from './ListItem.props';
|
|
10
10
|
import ListItemContent from './ListItemContent';
|
|
@@ -33,8 +33,19 @@ const ListItemRoot = ({
|
|
|
33
33
|
}: ListItemProps & { states?: { active?: boolean; disabled?: boolean } }) => {
|
|
34
34
|
const { onPress } = props;
|
|
35
35
|
const listContext = useListContext();
|
|
36
|
-
const
|
|
36
|
+
const { registerItem, firstItemId } = listContext;
|
|
37
37
|
const { active } = states || { active: false };
|
|
38
|
+
const itemId = useId();
|
|
39
|
+
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
if (!registerItem) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return registerItem(itemId);
|
|
46
|
+
}, [itemId, registerItem]);
|
|
47
|
+
|
|
48
|
+
const isFirstChild = firstItemId === itemId;
|
|
38
49
|
|
|
39
50
|
const getListContainer = (): ListItemProps['variant'] => {
|
|
40
51
|
if (listContext?.container?.includes('subtle')) {
|
|
@@ -60,7 +71,7 @@ const ListItemRoot = ({
|
|
|
60
71
|
active,
|
|
61
72
|
disabled: isDisabled || isLoading,
|
|
62
73
|
showDisabled: !listContext.disabled && disabled,
|
|
63
|
-
isFirstChild
|
|
74
|
+
isFirstChild,
|
|
64
75
|
container: listContext?.container,
|
|
65
76
|
});
|
|
66
77
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageProps } from 'react-native';
|
|
2
|
-
import { ThemedImageProps } from '
|
|
2
|
+
import { ThemedImageProps } from '../components';
|
|
3
3
|
|
|
4
4
|
const isThemedImageProps = (props: ThemedImageProps | ImageProps): props is ThemedImageProps => {
|
|
5
5
|
return 'light' in props && 'dark' in props;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import InlineLink from "./InlineLink"
|
|
3
|
-
import figma from "@figma/code-connect"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* -- This file was auto-generated by Code Connect --
|
|
7
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
8
|
-
* You should check this is correct, and update the `example` function
|
|
9
|
-
* to return the code example you'd like to see in Figma
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
figma.connect(
|
|
13
|
-
InlineLink,
|
|
14
|
-
"https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=7051%3A25641",
|
|
15
|
-
{
|
|
16
|
-
props: {
|
|
17
|
-
// These props were automatically mapped based on your linked code:
|
|
18
|
-
inverted: figma.boolean("Inverted?"),
|
|
19
|
-
disabled: figma.enum("State", {
|
|
20
|
-
Active: true,
|
|
21
|
-
}),
|
|
22
|
-
// No matching props could be found for these Figma properties:
|
|
23
|
-
// "iconLeft": figma.boolean('Icon left?'),
|
|
24
|
-
// "iconRight": figma.boolean('Icon right?'),
|
|
25
|
-
// "iconRight": figma.instance('Icon Right'),
|
|
26
|
-
// "iconLeft": figma.instance('Icon Left'),
|
|
27
|
-
// "text": figma.string('Text')
|
|
28
|
-
},
|
|
29
|
-
example: (props) => (
|
|
30
|
-
<InlineLink inverted={props.inverted} disabled={props.disabled} />
|
|
31
|
-
),
|
|
32
|
-
},
|
|
33
|
-
)
|