@carrier-dpx/air-react-library 0.7.32 → 0.7.35
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/package.json +2 -2
- package/src/components/AccentIndicator/AccentIndicator.horizontal.figma.tsx +56 -0
- package/src/components/AccentIndicator/AccentIndicator.tsx +56 -0
- package/src/components/AccentIndicator/AccentIndicator.vertical.figma.tsx +56 -0
- package/src/components/AccentIndicator/index.ts +4 -0
- package/src/components/AccentIndicator/styles.ts +28 -0
- package/src/components/AccentIndicator/types.ts +39 -0
- package/src/components/AccentIndicator/utils.ts +14 -0
- package/src/components/Alert/Alert.figma.tsx +160 -0
- package/src/components/Alert/Alert.tsx +90 -0
- package/src/components/Alert/AlertTitle.tsx +34 -0
- package/src/components/Alert/index.ts +9 -0
- package/src/components/Alert/styles.ts +80 -0
- package/src/components/Alert/types.ts +5 -0
- package/src/components/Checkbox/Checkbox.figma.tsx +2 -1
- package/src/components/List/List.figma.tsx +110 -0
- package/src/components/List/List.tsx +72 -0
- package/src/components/List/ListItem.figma.tsx +298 -0
- package/src/components/List/ListItem.tsx +58 -0
- package/src/components/List/ListItemAvatar.tsx +26 -0
- package/src/components/List/ListItemButton.tsx +42 -0
- package/src/components/List/ListItemIcon.tsx +41 -0
- package/src/components/List/ListItemSecondaryAction.tsx +28 -0
- package/src/components/List/ListItemText.tsx +46 -0
- package/src/components/List/ListSubheader.tsx +42 -0
- package/src/components/List/index.ts +25 -0
- package/src/components/Menu/Menu.figma.tsx +119 -0
- package/src/components/Menu/Menu.tsx +72 -0
- package/src/components/Menu/index.ts +3 -0
- package/src/components/Navbar/NavbarButtons/Item.figma.tsx +197 -16
- package/src/components/Radio/Radio.figma.tsx +2 -1
- package/src/components/Switch/Switch.figma.tsx +2 -1
- package/src/components/types/common.ts +22 -0
- package/src/components/utils/getAccentColor.ts +31 -0
- package/src/index.ts +17 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for List Component
|
|
3
|
+
*
|
|
4
|
+
* Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=19353-120893
|
|
5
|
+
*
|
|
6
|
+
* Figma Properties:
|
|
7
|
+
* - subheader (true, false) - boolean hide/show
|
|
8
|
+
*
|
|
9
|
+
* Structure:
|
|
10
|
+
* - Container: Frame wrapping Subheader and ListItem components
|
|
11
|
+
* - Subheader: Nested component "ListItems/List Subheader" with layer name "Subheader"
|
|
12
|
+
* - Contains Typography component with layer name "↪ Subheader"
|
|
13
|
+
* - List Item 1-10: Multiple ListItem instances with numbered layer names
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import figma from "@figma/code-connect";
|
|
17
|
+
import List from "./List";
|
|
18
|
+
import ListSubheader from "./ListSubheader";
|
|
19
|
+
import ListItem from "./ListItem";
|
|
20
|
+
import Typography from "../Typography";
|
|
21
|
+
|
|
22
|
+
figma.connect(
|
|
23
|
+
List,
|
|
24
|
+
"https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=19353-120893",
|
|
25
|
+
{
|
|
26
|
+
props: {
|
|
27
|
+
/**
|
|
28
|
+
* SUBHEADER VISIBILITY
|
|
29
|
+
* Maps Figma's "subheader" boolean property
|
|
30
|
+
* When true, shows the nested "Subheader" component
|
|
31
|
+
*/
|
|
32
|
+
subheader: figma.boolean("subheader"),
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* SUBHEADER TEXT CONTENT
|
|
36
|
+
* Maps text content from nested Typography component with layer name "Subheader/↪ Subheader"
|
|
37
|
+
* Using full path to avoid nested nestedProps
|
|
38
|
+
*/
|
|
39
|
+
subheaderText: figma.nestedProps("Subheader/↪ Subheader", {
|
|
40
|
+
children: figma.children("Subheader/↪ Subheader"),
|
|
41
|
+
}),
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* LIST ITEM CHILDREN
|
|
45
|
+
* Maps nested ListItem instances from Figma
|
|
46
|
+
* Each "List Item X" is an instance of the ListItem component
|
|
47
|
+
* We map each one individually using the exact layer names
|
|
48
|
+
*/
|
|
49
|
+
listItem1: figma.children("List Item 1"),
|
|
50
|
+
listItem2: figma.children("List Item 2"),
|
|
51
|
+
listItem3: figma.children("List Item 3"),
|
|
52
|
+
listItem4: figma.children("List Item 4"),
|
|
53
|
+
listItem5: figma.children("List Item 5"),
|
|
54
|
+
listItem6: figma.children("List Item 6"),
|
|
55
|
+
listItem7: figma.children("List Item 7"),
|
|
56
|
+
listItem8: figma.children("List Item 8"),
|
|
57
|
+
listItem9: figma.children("List Item 9"),
|
|
58
|
+
listItem10: figma.children("List Item 10"),
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* EXAMPLE CODE TEMPLATE
|
|
63
|
+
* Shows how List should be used with optional subheader and ListItem children
|
|
64
|
+
* Note: This example handles up to 10 list items. Adjust based on your design needs.
|
|
65
|
+
*/
|
|
66
|
+
example: ({ subheader, subheaderText, listItem1, listItem2, listItem3, listItem4, listItem5, listItem6, listItem7, listItem8, listItem9, listItem10 }) => {
|
|
67
|
+
// Handle case with subheader and multiple list items
|
|
68
|
+
if (subheader && subheaderText && subheaderText.children) {
|
|
69
|
+
return (
|
|
70
|
+
<List
|
|
71
|
+
subheader={
|
|
72
|
+
<ListSubheader>
|
|
73
|
+
<Typography variant="body2Semibold">
|
|
74
|
+
{subheaderText.children}
|
|
75
|
+
</Typography>
|
|
76
|
+
</ListSubheader>
|
|
77
|
+
}
|
|
78
|
+
>
|
|
79
|
+
{listItem1}
|
|
80
|
+
{listItem2}
|
|
81
|
+
{listItem3}
|
|
82
|
+
{listItem4}
|
|
83
|
+
{listItem5}
|
|
84
|
+
{listItem6}
|
|
85
|
+
{listItem7}
|
|
86
|
+
{listItem8}
|
|
87
|
+
{listItem9}
|
|
88
|
+
{listItem10}
|
|
89
|
+
</List>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Handle case without subheader
|
|
94
|
+
return (
|
|
95
|
+
<List>
|
|
96
|
+
{listItem1}
|
|
97
|
+
{listItem2}
|
|
98
|
+
{listItem3}
|
|
99
|
+
{listItem4}
|
|
100
|
+
{listItem5}
|
|
101
|
+
{listItem6}
|
|
102
|
+
{listItem7}
|
|
103
|
+
{listItem8}
|
|
104
|
+
{listItem9}
|
|
105
|
+
{listItem10}
|
|
106
|
+
</List>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
List as MuiList,
|
|
5
|
+
ListProps as MuiListProps,
|
|
6
|
+
CSSObject,
|
|
7
|
+
Theme,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import { styleTokens } from "../theme/constants/styleTokens";
|
|
10
|
+
import { getSxStyles } from "../utils/styles";
|
|
11
|
+
|
|
12
|
+
export interface ListProps extends MuiListProps {
|
|
13
|
+
maxHeight?: string;
|
|
14
|
+
// this may be updated later if Design needs any props to be removed
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The content of the subheader, normally `ListSubheader`.
|
|
18
|
+
*/
|
|
19
|
+
subheader?: React.ReactNode;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Toggles the display of the subheader. Set to `true` to show the subheader.
|
|
23
|
+
*/
|
|
24
|
+
showSubheader?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Added padding between the list
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
padded?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The List component is useful for organizing related content or actions in a vertical format.
|
|
34
|
+
*
|
|
35
|
+
* `import List from '@carrier-io/air-react/List'`
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const List = forwardRef<HTMLUListElement, ListProps>(
|
|
39
|
+
(
|
|
40
|
+
{ maxHeight, sx, subheader, showSubheader = true, padded = false, ...rest },
|
|
41
|
+
ref
|
|
42
|
+
) => {
|
|
43
|
+
return (
|
|
44
|
+
<MuiList
|
|
45
|
+
ref={ref}
|
|
46
|
+
{...rest}
|
|
47
|
+
sx={(theme: Theme) =>
|
|
48
|
+
({
|
|
49
|
+
backgroundColor: theme.palette.base?.background.paper,
|
|
50
|
+
maxHeight: maxHeight ?? "auto",
|
|
51
|
+
overflowY: maxHeight ? "auto" : "visible",
|
|
52
|
+
...(padded && {
|
|
53
|
+
".MuiListItem-root": {
|
|
54
|
+
padding: styleTokens.paddingItem,
|
|
55
|
+
},
|
|
56
|
+
".MuiListItemButton-root": {
|
|
57
|
+
padding: styleTokens.paddingItem,
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
...getSxStyles(theme, sx),
|
|
61
|
+
} as CSSObject)
|
|
62
|
+
}
|
|
63
|
+
subheader={showSubheader && subheader ? subheader : null}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
List.displayName = "List";
|
|
70
|
+
|
|
71
|
+
export default List;
|
|
72
|
+
export type { ListProps };
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for ListItem Component
|
|
3
|
+
*
|
|
4
|
+
* Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=22974-86899
|
|
5
|
+
*
|
|
6
|
+
* Figma Properties:
|
|
7
|
+
* - size (large: 48px, medium: 40px, small: 32px)
|
|
8
|
+
* - padded (true, false)
|
|
9
|
+
* - selected (true, false)
|
|
10
|
+
* - disabled (true, false)
|
|
11
|
+
* - disableGutters (true, false)
|
|
12
|
+
* - state (enabled, hover, focus) - visual state, not a prop
|
|
13
|
+
* - divider (true, false) - boolean hide/show
|
|
14
|
+
* - nesting (true, false) - boolean hide/show
|
|
15
|
+
* - startAdornment (true, false) - boolean hide/show
|
|
16
|
+
* - endAdornment (true, false) - boolean hide/show
|
|
17
|
+
* - statusStart (true, false) - boolean hide/show (uses AccentIndicator - to be added later)
|
|
18
|
+
* - statusEnd (true, false) - boolean hide/show (uses AccentIndicator - to be added later)
|
|
19
|
+
*
|
|
20
|
+
* Structure:
|
|
21
|
+
* - Labels (nested component): Contains header, label, and helperText Typography components
|
|
22
|
+
* - header (true, false) - Typography component
|
|
23
|
+
* - label (true, false) - Typography component
|
|
24
|
+
* - helperText (true, false) - Typography component
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import figma from "@figma/code-connect";
|
|
28
|
+
import ListItem from "./ListItem";
|
|
29
|
+
import ListItemText from "./ListItemText";
|
|
30
|
+
import Typography from "../Typography";
|
|
31
|
+
import AccentIndicator from "../AccentIndicator";
|
|
32
|
+
|
|
33
|
+
figma.connect(
|
|
34
|
+
ListItem,
|
|
35
|
+
"https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=22974-86899",
|
|
36
|
+
{
|
|
37
|
+
props: {
|
|
38
|
+
/**
|
|
39
|
+
* SIZE MAPPING
|
|
40
|
+
* Maps Figma's "size" property to React's "size" prop
|
|
41
|
+
* Figma: large (48px), medium (40px), small (32px)
|
|
42
|
+
*/
|
|
43
|
+
size: figma.enum("size", {
|
|
44
|
+
"large: 48px": "large",
|
|
45
|
+
"medium: 40px": "medium",
|
|
46
|
+
"small: 32px": "small",
|
|
47
|
+
large: "large",
|
|
48
|
+
medium: "medium",
|
|
49
|
+
small: "small",
|
|
50
|
+
}),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* PADDED MAPPING
|
|
54
|
+
* Maps Figma's "padded" boolean to React's "padded" prop
|
|
55
|
+
*/
|
|
56
|
+
padded: figma.boolean("padded"),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* SELECTED STATE
|
|
60
|
+
* Maps Figma's "selected" boolean to React's "selected" prop
|
|
61
|
+
*/
|
|
62
|
+
selected: figma.boolean("selected"),
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* DISABLED STATE
|
|
66
|
+
* Maps Figma's "disabled" boolean to React's "disabled" prop
|
|
67
|
+
*/
|
|
68
|
+
disabled: figma.boolean("disabled"),
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* DISABLE GUTTERS
|
|
72
|
+
* Maps Figma's "disableGutters" boolean to React's "disableGutters" prop
|
|
73
|
+
*/
|
|
74
|
+
disableGutters: figma.boolean("disableGutters"),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* DIVIDER VISIBILITY
|
|
78
|
+
* Maps Figma's "divider" boolean - controls divider visibility
|
|
79
|
+
*/
|
|
80
|
+
divider: figma.boolean("divider"),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* NESTING VISIBILITY
|
|
84
|
+
* Maps Figma's "nesting" boolean - controls nesting visibility
|
|
85
|
+
*/
|
|
86
|
+
nesting: figma.boolean("nesting"),
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* START ADORNMENT VISIBILITY
|
|
90
|
+
* Maps Figma's "startAdornment" boolean - controls start adornment visibility
|
|
91
|
+
*/
|
|
92
|
+
startAdornment: figma.boolean("startAdornment"),
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* END ADORNMENT VISIBILITY
|
|
96
|
+
* Maps Figma's "endAdornment" boolean - controls end adornment visibility
|
|
97
|
+
*/
|
|
98
|
+
endAdornment: figma.boolean("endAdornment"),
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* STATUS START ACCENT INDICATOR
|
|
102
|
+
* Maps nested AccentIndicator component instance when statusStart is visible
|
|
103
|
+
* The AccentIndicator is nested within the statusStart layer
|
|
104
|
+
* Uses figma.instance() to get the AccentIndicator component instance
|
|
105
|
+
*/
|
|
106
|
+
statusStart: figma.instance("statusStart"),
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* STATUS END ACCENT INDICATOR
|
|
110
|
+
* Maps nested AccentIndicator component instance when statusEnd is visible
|
|
111
|
+
* The AccentIndicator is nested within the statusEnd layer
|
|
112
|
+
* Uses figma.instance() to get the AccentIndicator component instance
|
|
113
|
+
*/
|
|
114
|
+
statusEnd: figma.instance("statusEnd"),
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* LABELS NESTED PROPERTIES
|
|
118
|
+
* Access properties from nested "Labels" component (layer name "Labels")
|
|
119
|
+
* Contains header, label, and helperText Typography components
|
|
120
|
+
*/
|
|
121
|
+
labels: figma.nestedProps("Labels", {
|
|
122
|
+
/**
|
|
123
|
+
* HEADER VISIBILITY
|
|
124
|
+
* Maps Figma's "header" boolean from nested "Labels" component
|
|
125
|
+
*/
|
|
126
|
+
header: figma.boolean("header"),
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* LABEL VISIBILITY
|
|
130
|
+
* Maps Figma's "label" boolean from nested "Labels" component
|
|
131
|
+
*/
|
|
132
|
+
label: figma.boolean("label"),
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* HELPER TEXT VISIBILITY
|
|
136
|
+
* Maps Figma's "helperText" boolean from nested "Labels" component
|
|
137
|
+
*/
|
|
138
|
+
helperText: figma.boolean("helperText"),
|
|
139
|
+
}),
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* HEADER TEXT CONTENT
|
|
143
|
+
* Maps text content from nested "Labels/header" Typography component
|
|
144
|
+
* Using full path to avoid nested nestedProps
|
|
145
|
+
*/
|
|
146
|
+
headerText: figma.nestedProps("Labels/header", {
|
|
147
|
+
children: figma.children("Labels/header"),
|
|
148
|
+
}),
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* LABEL TEXT CONTENT
|
|
152
|
+
* Maps text content from nested "Labels/label" Typography component
|
|
153
|
+
* Using full path to avoid nested nestedProps
|
|
154
|
+
*/
|
|
155
|
+
labelText: figma.nestedProps("Labels/label", {
|
|
156
|
+
children: figma.children("Labels/label"),
|
|
157
|
+
}),
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* HELPER TEXT CONTENT
|
|
161
|
+
* Maps text content from nested "Labels/helperText" Typography component
|
|
162
|
+
* Using full path to avoid nested nestedProps
|
|
163
|
+
*/
|
|
164
|
+
helperTextContent: figma.nestedProps("Labels/helperText", {
|
|
165
|
+
children: figma.children("Labels/helperText"),
|
|
166
|
+
}),
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* EXAMPLE CODE TEMPLATE
|
|
171
|
+
* Shows how ListItem should be used with optional labels, adornments, and AccentIndicators
|
|
172
|
+
*/
|
|
173
|
+
example: ({ size, padded, selected, disabled, disableGutters, divider, labels, statusStart, statusEnd, headerText, labelText, helperTextContent }) => {
|
|
174
|
+
// Handle case with header, label, and helperText
|
|
175
|
+
if (labels && labels.header && headerText && headerText.children && labels.label && labelText && labelText.children && labels.helperText && helperTextContent && helperTextContent.children) {
|
|
176
|
+
return (
|
|
177
|
+
<ListItem
|
|
178
|
+
size={size}
|
|
179
|
+
padded={padded}
|
|
180
|
+
selected={selected}
|
|
181
|
+
disabled={disabled}
|
|
182
|
+
disableGutters={disableGutters}
|
|
183
|
+
divider={divider}
|
|
184
|
+
>
|
|
185
|
+
{statusStart}
|
|
186
|
+
<Typography variant="body1Semibold">
|
|
187
|
+
{headerText.children}
|
|
188
|
+
</Typography>
|
|
189
|
+
<ListItemText
|
|
190
|
+
primary={labelText.children}
|
|
191
|
+
secondary={helperTextContent.children}
|
|
192
|
+
/>
|
|
193
|
+
{statusEnd}
|
|
194
|
+
</ListItem>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Handle case with header and label (no helperText)
|
|
199
|
+
if (labels && labels.header && headerText && headerText.children && labels.label && labelText && labelText.children) {
|
|
200
|
+
return (
|
|
201
|
+
<ListItem
|
|
202
|
+
size={size}
|
|
203
|
+
padded={padded}
|
|
204
|
+
selected={selected}
|
|
205
|
+
disabled={disabled}
|
|
206
|
+
disableGutters={disableGutters}
|
|
207
|
+
divider={divider}
|
|
208
|
+
>
|
|
209
|
+
{statusStart}
|
|
210
|
+
<Typography variant="body1Semibold">
|
|
211
|
+
{headerText.children}
|
|
212
|
+
</Typography>
|
|
213
|
+
<ListItemText
|
|
214
|
+
primary={labelText.children}
|
|
215
|
+
/>
|
|
216
|
+
{statusEnd}
|
|
217
|
+
</ListItem>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Handle case with label and helperText (no header)
|
|
222
|
+
if (labels && labels.label && labelText && labelText.children && labels.helperText && helperTextContent && helperTextContent.children) {
|
|
223
|
+
return (
|
|
224
|
+
<ListItem
|
|
225
|
+
size={size}
|
|
226
|
+
padded={padded}
|
|
227
|
+
selected={selected}
|
|
228
|
+
disabled={disabled}
|
|
229
|
+
disableGutters={disableGutters}
|
|
230
|
+
divider={divider}
|
|
231
|
+
>
|
|
232
|
+
{statusStart}
|
|
233
|
+
<ListItemText
|
|
234
|
+
primary={labelText.children}
|
|
235
|
+
secondary={helperTextContent.children}
|
|
236
|
+
/>
|
|
237
|
+
{statusEnd}
|
|
238
|
+
</ListItem>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Handle case with only label
|
|
243
|
+
if (labels && labels.label && labelText && labelText.children) {
|
|
244
|
+
return (
|
|
245
|
+
<ListItem
|
|
246
|
+
size={size}
|
|
247
|
+
padded={padded}
|
|
248
|
+
selected={selected}
|
|
249
|
+
disabled={disabled}
|
|
250
|
+
disableGutters={disableGutters}
|
|
251
|
+
divider={divider}
|
|
252
|
+
>
|
|
253
|
+
{statusStart}
|
|
254
|
+
<ListItemText
|
|
255
|
+
primary={labelText.children}
|
|
256
|
+
/>
|
|
257
|
+
{statusEnd}
|
|
258
|
+
</ListItem>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Handle case with only header
|
|
263
|
+
if (labels && labels.header && headerText && headerText.children) {
|
|
264
|
+
return (
|
|
265
|
+
<ListItem
|
|
266
|
+
size={size}
|
|
267
|
+
padded={padded}
|
|
268
|
+
selected={selected}
|
|
269
|
+
disabled={disabled}
|
|
270
|
+
disableGutters={disableGutters}
|
|
271
|
+
divider={divider}
|
|
272
|
+
>
|
|
273
|
+
{statusStart}
|
|
274
|
+
<Typography variant="body1Semibold">
|
|
275
|
+
{headerText.children}
|
|
276
|
+
</Typography>
|
|
277
|
+
{statusEnd}
|
|
278
|
+
</ListItem>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Fallback: ListItem with no labels
|
|
283
|
+
return (
|
|
284
|
+
<ListItem
|
|
285
|
+
size={size}
|
|
286
|
+
padded={padded}
|
|
287
|
+
selected={selected}
|
|
288
|
+
disabled={disabled}
|
|
289
|
+
disableGutters={disableGutters}
|
|
290
|
+
divider={divider}
|
|
291
|
+
>
|
|
292
|
+
{statusStart}
|
|
293
|
+
{statusEnd}
|
|
294
|
+
</ListItem>
|
|
295
|
+
);
|
|
296
|
+
},
|
|
297
|
+
}
|
|
298
|
+
);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { heightMap } from "../utils/HeightUtils";
|
|
3
|
+
import {
|
|
4
|
+
ListItem as MuiListItem,
|
|
5
|
+
ListItemProps as MuiListItemProps,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import { getSxStyles } from "../utils/styles";
|
|
8
|
+
import { CSSObject } from "@emotion/react";
|
|
9
|
+
import { styleTokens } from "../theme/constants/styleTokens";
|
|
10
|
+
|
|
11
|
+
export interface ListItemProps extends MuiListItemProps {
|
|
12
|
+
/**
|
|
13
|
+
* size of the component
|
|
14
|
+
*/
|
|
15
|
+
size?: keyof typeof heightMap;
|
|
16
|
+
/**
|
|
17
|
+
* If `true`, list item has padding on left and right.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
padded?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, the left and right padding is removed.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
disableGutters?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** ListItem
|
|
29
|
+
*
|
|
30
|
+
* `import ListItem from '@carrier-io/air-react/ListItem'`
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const ListItem = forwardRef<HTMLLIElement, ListItemProps>((props, ref) => {
|
|
34
|
+
const { size, sx, padded = true, disableGutters = false, ...rest } = props;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<MuiListItem
|
|
38
|
+
sx={(theme) =>
|
|
39
|
+
({
|
|
40
|
+
height: size ? heightMap[size] : "auto",
|
|
41
|
+
padding: disableGutters
|
|
42
|
+
? "0"
|
|
43
|
+
: padded
|
|
44
|
+
? `${styleTokens.padding.xsmall} ${styleTokens.padding.xlarge}`
|
|
45
|
+
: styleTokens.padding.xsmall,
|
|
46
|
+
...getSxStyles(theme, sx),
|
|
47
|
+
} as CSSObject)
|
|
48
|
+
}
|
|
49
|
+
{...rest}
|
|
50
|
+
ref={ref}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
ListItem.displayName = "ListItem";
|
|
56
|
+
|
|
57
|
+
export default ListItem;
|
|
58
|
+
export type { ListItemProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ListItemAvatar as MuiListItemAvatar,
|
|
5
|
+
ListItemAvatarProps as MuiListItemAvatarProps,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
|
|
8
|
+
export interface ListItemAvatarProps extends MuiListItemAvatarProps {
|
|
9
|
+
// this may be updated later if Design needs any props to be removed
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** ListItemAvatar
|
|
13
|
+
*
|
|
14
|
+
* `import ListItemAvatarProps from '@carrier-io/air-react/ListItemAvatar'`
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const ListItemAvatar = forwardRef<HTMLDivElement, ListItemAvatarProps>(
|
|
18
|
+
(props, ref) => {
|
|
19
|
+
return <MuiListItemAvatar {...props} ref={ref} />;
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
ListItemAvatar.displayName = "ListItemAvatar";
|
|
24
|
+
|
|
25
|
+
export default ListItemAvatar;
|
|
26
|
+
export type { ListItemAvatarProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ListItemButton as MuiListItemButton,
|
|
5
|
+
ListItemButtonProps as MuiListItemButtonProps,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import { Theme, styled } from "@mui/material/styles";
|
|
8
|
+
|
|
9
|
+
export interface ListItemButtonProps extends MuiListItemButtonProps {
|
|
10
|
+
// this may be updated later if Design needs any props to be removed
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** ListItemButton
|
|
14
|
+
*
|
|
15
|
+
* `import ListItemButton from '@carrier-io/air-react/ListItemButton'`
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const MuiListItemButtonStyled = styled(MuiListItemButton)(
|
|
19
|
+
({ theme }: { theme: Theme }) => ({
|
|
20
|
+
color: theme.palette.base?.state.active,
|
|
21
|
+
"&:hover": {
|
|
22
|
+
backgroundColor: theme.palette.base?.state.hover,
|
|
23
|
+
},
|
|
24
|
+
"&.Mui-selected": {
|
|
25
|
+
backgroundColor: theme.palette.base?.state.selected,
|
|
26
|
+
},
|
|
27
|
+
"&.Mui-selected:hover": {
|
|
28
|
+
backgroundColor: theme.palette.base?.state.selectedHover,
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const ListItemButton = forwardRef<HTMLDivElement, ListItemButtonProps>(
|
|
34
|
+
(props, ref) => {
|
|
35
|
+
return <MuiListItemButtonStyled {...props} ref={ref} />;
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
ListItemButton.displayName = "ListItemButton";
|
|
40
|
+
|
|
41
|
+
export default ListItemButton;
|
|
42
|
+
export type { ListItemButtonProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ListItemIcon as MuiListItemIcon,
|
|
5
|
+
ListItemIconProps as MuiListItemIconProps,
|
|
6
|
+
CSSObject,
|
|
7
|
+
Theme,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
|
|
10
|
+
import { getSxStyles } from "../utils/styles";
|
|
11
|
+
|
|
12
|
+
export interface ListItemIconProps extends MuiListItemIconProps {
|
|
13
|
+
// this may be updated later if Design needs any props to be removed
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** ListItemIcon
|
|
17
|
+
*
|
|
18
|
+
* `import ListItemIcon from '@carrier-io/air-react/ListItemIcon'`
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const ListItemIcon = forwardRef<HTMLDivElement, ListItemIconProps>(
|
|
22
|
+
(props, ref) => {
|
|
23
|
+
return (
|
|
24
|
+
<MuiListItemIcon
|
|
25
|
+
{...props}
|
|
26
|
+
sx={(theme: Theme) =>
|
|
27
|
+
({
|
|
28
|
+
color: theme.palette.base?.state.active,
|
|
29
|
+
...getSxStyles(theme, props.sx),
|
|
30
|
+
} as CSSObject)
|
|
31
|
+
}
|
|
32
|
+
ref={ref}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
ListItemIcon.displayName = "ListItemIcon";
|
|
39
|
+
|
|
40
|
+
export default ListItemIcon;
|
|
41
|
+
export type { ListItemIconProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ListItemSecondaryAction as MuiListItemSecondaryAction,
|
|
5
|
+
ListItemSecondaryActionProps as MuiListItemSecondaryActionProps,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
|
|
8
|
+
export interface ListItemSecondaryActionProps
|
|
9
|
+
extends MuiListItemSecondaryActionProps {
|
|
10
|
+
// this may be updated later if Design needs any props to be removed
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** ListItemSecondaryAction
|
|
14
|
+
*
|
|
15
|
+
* `import ListItemSecondaryAction from '@carrier-io/air-react/ListItemSecondaryAction'`
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const ListItemSecondaryAction = forwardRef<
|
|
19
|
+
HTMLDivElement,
|
|
20
|
+
ListItemSecondaryActionProps
|
|
21
|
+
>((props, ref) => {
|
|
22
|
+
return <MuiListItemSecondaryAction {...props} ref={ref} />;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
ListItemSecondaryAction.displayName = "ListItemSecondaryAction";
|
|
26
|
+
|
|
27
|
+
export default ListItemSecondaryAction;
|
|
28
|
+
export type { ListItemSecondaryActionProps };
|