@carrier-dpx/air-react-library 0.7.33 → 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.
Files changed (32) hide show
  1. package/package.json +2 -2
  2. package/src/components/AccentIndicator/AccentIndicator.horizontal.figma.tsx +56 -0
  3. package/src/components/AccentIndicator/AccentIndicator.tsx +56 -0
  4. package/src/components/AccentIndicator/AccentIndicator.vertical.figma.tsx +56 -0
  5. package/src/components/AccentIndicator/index.ts +4 -0
  6. package/src/components/AccentIndicator/styles.ts +28 -0
  7. package/src/components/AccentIndicator/types.ts +39 -0
  8. package/src/components/AccentIndicator/utils.ts +14 -0
  9. package/src/components/Alert/Alert.figma.tsx +160 -0
  10. package/src/components/Alert/Alert.tsx +90 -0
  11. package/src/components/Alert/AlertTitle.tsx +34 -0
  12. package/src/components/Alert/index.ts +9 -0
  13. package/src/components/Alert/styles.ts +80 -0
  14. package/src/components/Alert/types.ts +5 -0
  15. package/src/components/List/List.figma.tsx +110 -0
  16. package/src/components/List/List.tsx +72 -0
  17. package/src/components/List/ListItem.figma.tsx +298 -0
  18. package/src/components/List/ListItem.tsx +58 -0
  19. package/src/components/List/ListItemAvatar.tsx +26 -0
  20. package/src/components/List/ListItemButton.tsx +42 -0
  21. package/src/components/List/ListItemIcon.tsx +41 -0
  22. package/src/components/List/ListItemSecondaryAction.tsx +28 -0
  23. package/src/components/List/ListItemText.tsx +46 -0
  24. package/src/components/List/ListSubheader.tsx +42 -0
  25. package/src/components/List/index.ts +25 -0
  26. package/src/components/Menu/Menu.figma.tsx +119 -0
  27. package/src/components/Menu/Menu.tsx +72 -0
  28. package/src/components/Menu/index.ts +3 -0
  29. package/src/components/Navbar/NavbarButtons/Item.figma.tsx +197 -16
  30. package/src/components/types/common.ts +22 -0
  31. package/src/components/utils/getAccentColor.ts +31 -0
  32. package/src/index.ts +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrier-dpx/air-react-library",
3
- "version": "0.7.33",
3
+ "version": "0.7.35",
4
4
  "description": "Air web React component library for Figma Make",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -52,7 +52,7 @@
52
52
  "devDependencies": {
53
53
  "@emotion/react": "^11.11.0",
54
54
  "@emotion/styled": "^11.11.0",
55
- "@figma/code-connect": "^1.3.13",
55
+ "@figma/code-connect": "^1.4.0",
56
56
  "@mui/material": "^5.15.0",
57
57
  "@types/react": "^18.0.0",
58
58
  "@types/react-dom": "^18.0.0",
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Figma Code Connect Configuration for AccentIndicator Component (Horizontal)
3
+ *
4
+ * Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=37586-2804
5
+ *
6
+ * Figma Properties:
7
+ * - type (primary, secondary, error, warning, success, info)
8
+ * - alignment (top, bottom)
9
+ */
10
+
11
+ import figma from "@figma/code-connect";
12
+ import AccentIndicator from "./AccentIndicator";
13
+
14
+ figma.connect(
15
+ AccentIndicator,
16
+ "https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=37586-2804",
17
+ {
18
+ props: {
19
+ /**
20
+ * TYPE MAPPING
21
+ * Maps Figma's "type" property to React's "severity" prop
22
+ * Controls the color of the AccentIndicator
23
+ */
24
+ severity: figma.enum("type", {
25
+ primary: "primary",
26
+ secondary: "secondary",
27
+ error: "error",
28
+ warning: "warning",
29
+ success: "success",
30
+ info: "info",
31
+ }),
32
+
33
+ /**
34
+ * ALIGNMENT MAPPING
35
+ * Maps Figma's "alignment" property to React's "alignment" prop
36
+ * Horizontal orientation supports: top, bottom
37
+ */
38
+ alignment: figma.enum("alignment", {
39
+ top: "top",
40
+ bottom: "bottom",
41
+ }),
42
+ },
43
+
44
+ /**
45
+ * EXAMPLE CODE TEMPLATE
46
+ * Horizontal AccentIndicator - sets orientation="horizontal"
47
+ */
48
+ example: ({ severity, alignment }) => (
49
+ <AccentIndicator
50
+ severity={severity}
51
+ orientation="horizontal"
52
+ alignment={alignment}
53
+ />
54
+ ),
55
+ }
56
+ );
@@ -0,0 +1,56 @@
1
+ import React, { FC } from "react";
2
+ import clsx from "clsx";
3
+ import Box from "../Box";
4
+ import styles from "./styles";
5
+ import { styled } from "@mui/material/styles";
6
+ import { Orientation, Position, AccentType } from "../types/common";
7
+ import { AccentIndicatorProps } from "./types";
8
+ import { getAccentColor } from "../utils/getAccentColor";
9
+
10
+ const AccentIndicatorStyled = styled(Box)(styles.indicator);
11
+
12
+ const baseClassName = "accent-indicator";
13
+
14
+ /** The AccentIndicator pattern is a visual cue intended to attract the user's attention and communicate severity level information.
15
+ *
16
+ * //Default Import
17
+ * `import AccentIndicator from '@carrier-io/air-react/AccentIndicator'`
18
+ *
19
+ * //Named Import
20
+ * `import { AccentIndicator } from '@carrier-io/air-react'`
21
+ */
22
+
23
+ export const AccentIndicator: FC<AccentIndicatorProps> = ({
24
+ sx,
25
+ className,
26
+ severity = AccentType.Primary,
27
+ customBgColor = "",
28
+ orientation = Orientation.Vertical,
29
+ alignment = Position.Right,
30
+ ...rest
31
+ }) => {
32
+ const bgColor = customBgColor || getAccentColor(severity);
33
+ return (
34
+ <AccentIndicatorStyled
35
+ role="accent"
36
+ severity={severity}
37
+ alignment={alignment}
38
+ custombgcolor={bgColor}
39
+ orientation={orientation}
40
+ className={clsx(
41
+ baseClassName,
42
+ className,
43
+ `${baseClassName}--${orientation}`,
44
+ `align--${alignment}`,
45
+ {
46
+ [`${baseClassName}--${severity}`]: customBgColor === "" && severity,
47
+ }
48
+ )}
49
+ sx={sx}
50
+ {...rest}
51
+ />
52
+ );
53
+ };
54
+
55
+ export default AccentIndicator;
56
+ export type { AccentIndicatorProps };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Figma Code Connect Configuration for AccentIndicator Component (Vertical)
3
+ *
4
+ * Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=37586-2779
5
+ *
6
+ * Figma Properties:
7
+ * - type (primary, secondary, error, warning, success, info)
8
+ * - alignment (left, right)
9
+ */
10
+
11
+ import figma from "@figma/code-connect";
12
+ import AccentIndicator from "./AccentIndicator";
13
+
14
+ figma.connect(
15
+ AccentIndicator,
16
+ "https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=37586-2779",
17
+ {
18
+ props: {
19
+ /**
20
+ * TYPE MAPPING
21
+ * Maps Figma's "type" property to React's "severity" prop
22
+ * Controls the color of the AccentIndicator
23
+ */
24
+ severity: figma.enum("type", {
25
+ primary: "primary",
26
+ secondary: "secondary",
27
+ error: "error",
28
+ warning: "warning",
29
+ success: "success",
30
+ info: "info",
31
+ }),
32
+
33
+ /**
34
+ * ALIGNMENT MAPPING
35
+ * Maps Figma's "alignment" property to React's "alignment" prop
36
+ * Vertical orientation supports: left, right
37
+ */
38
+ alignment: figma.enum("alignment", {
39
+ left: "left",
40
+ right: "right",
41
+ }),
42
+ },
43
+
44
+ /**
45
+ * EXAMPLE CODE TEMPLATE
46
+ * Vertical AccentIndicator - sets orientation="vertical"
47
+ */
48
+ example: ({ severity, alignment }) => (
49
+ <AccentIndicator
50
+ severity={severity}
51
+ orientation="vertical"
52
+ alignment={alignment}
53
+ />
54
+ ),
55
+ }
56
+ );
@@ -0,0 +1,4 @@
1
+ export { AccentIndicator as default } from "./AccentIndicator";
2
+
3
+ export * from "./AccentIndicator";
4
+ export * from "./types";
@@ -0,0 +1,28 @@
1
+ import { setBorderRadius } from "./utils";
2
+ import { AccentIndicatorStyles } from "./types";
3
+ import { Orientation, Position } from "../types/common";
4
+
5
+ export default {
6
+ indicator: ({
7
+ custombgcolor,
8
+ orientation,
9
+ alignment,
10
+ }: AccentIndicatorStyles) => {
11
+ const placementStyles =
12
+ orientation === Orientation.Horizontal
13
+ ? {
14
+ width: "100%",
15
+ height: "2px",
16
+ }
17
+ : {
18
+ width: "2px",
19
+ height: "100%",
20
+ };
21
+
22
+ return {
23
+ backgroundColor: custombgcolor,
24
+ borderRadius: setBorderRadius(alignment as Position),
25
+ ...placementStyles,
26
+ };
27
+ },
28
+ };
@@ -0,0 +1,39 @@
1
+ import { SxProps } from "@mui/material";
2
+ import { Orientation, Position, AccentType } from "../types/common";
3
+ import { Theme } from "@mui/material/styles";
4
+
5
+ export interface AccentIndicatorProps {
6
+ /**
7
+ * Override or extend the styles applied to the component.
8
+ */
9
+ sx?: SxProps<Theme>;
10
+ /**
11
+ * The type of the component.
12
+ * @default 'Primary'
13
+ */
14
+ severity?: AccentType;
15
+ /**
16
+ * The custom background color of the component.
17
+ */
18
+ customBgColor?: string;
19
+ /**
20
+ * Override extend the styles applied to the component.
21
+ */
22
+ className?: string;
23
+ /**
24
+ * The orientation to use.
25
+ * @default 'Vertical'
26
+ */
27
+ orientation?: Orientation;
28
+
29
+ /**
30
+ * alignment of the AccentIndicator edge tips
31
+ * @default 'left'
32
+ */
33
+ alignment?: Position;
34
+ }
35
+
36
+ export interface AccentIndicatorStyles
37
+ extends Omit<AccentIndicatorProps, "className" | "sx"> {
38
+ custombgcolor?: string;
39
+ }
@@ -0,0 +1,14 @@
1
+ import { Position } from "../types/common";
2
+
3
+ export const setBorderRadius = (align: Position): string => {
4
+ switch (align) {
5
+ case "top":
6
+ return "4px 4px 0 0";
7
+ case "bottom":
8
+ return "0 0 4px 4px";
9
+ case "right":
10
+ return "0 4px 4px 0";
11
+ default:
12
+ return "4px 0 0 4px";
13
+ }
14
+ };
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Figma Code Connect Configuration for Alert Component
3
+ *
4
+ * Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=6595-48211
5
+ *
6
+ * Figma Properties:
7
+ * - variant (standard, outlined, filled)
8
+ * - color (error, success, info, warning)
9
+ * - title (true, false) - from nested "Content" component (UnstyledAlert), shows/hides Title Typography
10
+ * - action (true, false) - from nested "Content" component (UnstyledAlert), shows/hides Action Button
11
+ *
12
+ * Structure:
13
+ * - Content (UnstyledAlert): Contains Title and Description Typography components
14
+ * - Title: Typography component (shown when title=true)
15
+ * - Description: Typography component (children of Alert)
16
+ */
17
+
18
+ import figma from "@figma/code-connect";
19
+ import Alert from "./Alert";
20
+ import AlertTitle from "./AlertTitle";
21
+ import Typography from "../Typography";
22
+ import Button from "../Button";
23
+
24
+ figma.connect(
25
+ Alert,
26
+ "https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=6595-48211",
27
+ {
28
+ props: {
29
+ /**
30
+ * VARIANT MAPPING
31
+ * Maps Figma's "variant" property to React's "variant" prop
32
+ */
33
+ variant: figma.enum("variant", {
34
+ standard: "standard",
35
+ outlined: "outlined",
36
+ filled: "filled",
37
+ }),
38
+
39
+ /**
40
+ * COLOR MAPPING
41
+ * Maps Figma's "color" property to React's "color" prop
42
+ */
43
+ color: figma.enum("color", {
44
+ error: "error",
45
+ success: "success",
46
+ info: "info",
47
+ warning: "warning",
48
+ }),
49
+
50
+ /**
51
+ * CONTENT NESTED PROPERTIES
52
+ * Access properties from nested "Content" component (UnstyledAlert)
53
+ * Contains title/action booleans and nested Typography components
54
+ */
55
+ content: figma.nestedProps("Content", {
56
+ /**
57
+ * TITLE VISIBILITY
58
+ * Maps Figma's "title" boolean from nested "Content" component
59
+ * When true, shows the nested "Title" Typography component
60
+ */
61
+ title: figma.boolean("title"),
62
+
63
+ /**
64
+ * ACTION BUTTON VISIBILITY
65
+ * Maps Figma's "action" boolean from nested "Content" component
66
+ * When true, shows the Action Button
67
+ */
68
+ action: figma.boolean("action"),
69
+ }),
70
+
71
+ /**
72
+ * TITLE TEXT CONTENT
73
+ * Maps text content from nested "Content/Title" Typography component
74
+ * Using full path to avoid nested nestedProps
75
+ */
76
+ titleText: figma.nestedProps("Content/Title", {
77
+ children: figma.children("Content/Title"),
78
+ }),
79
+
80
+ /**
81
+ * DESCRIPTION TEXT CONTENT
82
+ * Maps text content from nested "Content/Description" Typography component
83
+ * Using full path to avoid nested nestedProps
84
+ */
85
+ descriptionText: figma.nestedProps("Content/Description", {
86
+ children: figma.children("Content/Description"),
87
+ }),
88
+ },
89
+
90
+ /**
91
+ * EXAMPLE CODE TEMPLATE
92
+ * Shows how Alert should be used with optional title and action button
93
+ */
94
+ example: ({ variant, color, content, titleText, descriptionText }) => {
95
+ // Handle case with title, description, and action
96
+ if (content && content.title && content.action && titleText && titleText.children && descriptionText && descriptionText.children) {
97
+ return (
98
+ <Alert
99
+ variant={variant}
100
+ color={color}
101
+ action={<Button variant="text" size="small">Action</Button>}
102
+ >
103
+ <AlertTitle>
104
+ {titleText.children}
105
+ </AlertTitle>
106
+ {descriptionText.children}
107
+ </Alert>
108
+ );
109
+ }
110
+
111
+ // Handle case with title and description (no action)
112
+ if (content && content.title && titleText && titleText.children && descriptionText && descriptionText.children) {
113
+ return (
114
+ <Alert
115
+ variant={variant}
116
+ color={color}
117
+ >
118
+ <AlertTitle>
119
+ {titleText.children}
120
+ </AlertTitle>
121
+ {descriptionText.children}
122
+ </Alert>
123
+ );
124
+ }
125
+
126
+ // Handle case with description and action (no title)
127
+ if (content && content.action && descriptionText && descriptionText.children) {
128
+ return (
129
+ <Alert
130
+ variant={variant}
131
+ color={color}
132
+ action={<Button variant="text" size="small">Action</Button>}
133
+ >
134
+ {descriptionText.children}
135
+ </Alert>
136
+ );
137
+ }
138
+
139
+ // Handle case with only description
140
+ if (descriptionText && descriptionText.children) {
141
+ return (
142
+ <Alert
143
+ variant={variant}
144
+ color={color}
145
+ >
146
+ {descriptionText.children}
147
+ </Alert>
148
+ );
149
+ }
150
+
151
+ // Fallback: Alert with no content
152
+ return (
153
+ <Alert
154
+ variant={variant}
155
+ color={color}
156
+ />
157
+ );
158
+ },
159
+ }
160
+ );
@@ -0,0 +1,90 @@
1
+ import { forwardRef } from "react";
2
+
3
+ import MuiAlert from "@mui/material/Alert";
4
+ import { styled } from "@mui/material/styles";
5
+ import WarningIcon from "@mui/icons-material/Warning";
6
+ import ErrorIcon from "@mui/icons-material/Error";
7
+ import InfoIcon from "@mui/icons-material/Info";
8
+ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
9
+ import CloseIcon from "@mui/icons-material/Close";
10
+
11
+ import IconButton from "../IconButton";
12
+ import styles from "./styles";
13
+ import { AlertProps } from "./types";
14
+
15
+ const StyledAlert = styled(MuiAlert)(styles);
16
+
17
+ /** The Alert component provides contextual feedback through description, iconography, and color.
18
+ *
19
+ * // Default import
20
+ * import Alert from '@carrier-io/air-react/Alert'
21
+ *
22
+ * // Named import
23
+ * import { Alert } from '@carrier-io/air-react'
24
+ */
25
+ const Alert = forwardRef<HTMLDivElement, AlertProps>(
26
+ (
27
+ {
28
+ onClose,
29
+ severity = "warning",
30
+ variant = "standard",
31
+ color,
32
+ iconMapping = {
33
+ // Default value for success icon passed here to prevent import React inside FleetThemeConfigs
34
+ success: <CheckCircleIcon fontSize="inherit" />,
35
+ },
36
+ action,
37
+ ...rest
38
+ },
39
+ ref
40
+ ) => {
41
+ const alertColor = color ?? severity;
42
+
43
+ const resolvedIconMapping = {
44
+ warning: <WarningIcon fontSize="inherit" />,
45
+ error: <ErrorIcon fontSize="inherit" />,
46
+ info: <InfoIcon fontSize="inherit" />,
47
+ success: <CheckCircleIcon fontSize="inherit" />,
48
+ ...iconMapping,
49
+ };
50
+
51
+ return (
52
+ <StyledAlert
53
+ color={color}
54
+ severity={severity}
55
+ variant={variant}
56
+ iconMapping={resolvedIconMapping}
57
+ action={
58
+ <>
59
+ {action}
60
+ {onClose && (
61
+ <IconButton
62
+ aria-label="Close"
63
+ onClick={onClose}
64
+ sx={{
65
+ width: "28px",
66
+ height: "28px",
67
+ fontSize: "20px",
68
+ color: (theme) =>
69
+ variant == "filled"
70
+ ? theme.palette[alertColor]?.contrastText
71
+ : theme.palette.base?.state.active,
72
+ marginLeft: "12px",
73
+ }}
74
+ >
75
+ <CloseIcon fontSize="inherit" />
76
+ </IconButton>
77
+ )}
78
+ </>
79
+ }
80
+ {...rest}
81
+ ref={ref}
82
+ />
83
+ );
84
+ }
85
+ );
86
+
87
+ Alert.displayName = "Alert";
88
+
89
+ export default Alert;
90
+ export type { AlertProps };
@@ -0,0 +1,34 @@
1
+ import { forwardRef } from "react";
2
+
3
+ import MuiAlertTitle, {
4
+ AlertTitleProps as MuiAlertTitleProps,
5
+ } from "@mui/material/AlertTitle";
6
+ import { styled } from "@mui/material/styles";
7
+
8
+ export interface AlertTitleProps extends MuiAlertTitleProps {
9
+ // this may be updated later if Design needs any props to be removed
10
+ }
11
+
12
+ /** AlertTitle
13
+ * An AlertTitle is used to add a title to the Alert Component. It is used as a sub-component/child along with the Alert Component.
14
+ *
15
+ * // Default import
16
+ * import AlertTitle from '@carrier-io/air-react/Alert'
17
+ *
18
+ * // Named import
19
+ * import { AlertTitle } from '@carrier-io/air-react'
20
+ */
21
+
22
+ const MuiAlertTitleStyled = styled(MuiAlertTitle)(({ theme }) => ({
23
+ margin: 0,
24
+ ...theme.typography.body1Semibold,
25
+ }));
26
+
27
+ const AlertTitle = forwardRef<HTMLDivElement, AlertTitleProps>((props, ref) => {
28
+ return <MuiAlertTitleStyled {...props} ref={ref} />;
29
+ });
30
+
31
+ AlertTitle.displayName = "AlertTitle";
32
+
33
+ export default AlertTitle;
34
+ export type { AlertTitleProps };
@@ -0,0 +1,9 @@
1
+ // Alert component family exports
2
+ export { default } from "./Alert"; // For: import Alert from "Alert"
3
+ export { default as Alert } from "./Alert"; // For: import { Alert } from "Alert"
4
+ export * from "./Alert"; // For: AlertProps, etc.
5
+
6
+ export { default as AlertTitle } from "./AlertTitle";
7
+ export * from "./AlertTitle";
8
+
9
+ export * from "./types";
@@ -0,0 +1,80 @@
1
+ import { AlertProps, alertClasses } from "@mui/material/Alert";
2
+ import { StyledComponentDefaultProps } from "../types/common";
3
+
4
+ const styles = ({
5
+ theme,
6
+ color,
7
+ variant,
8
+ severity = "warning",
9
+ }: AlertProps & StyledComponentDefaultProps) => {
10
+ const alertColor = color ?? severity;
11
+
12
+ // Standard variant styles
13
+ const standardStyles =
14
+ variant === "standard"
15
+ ? {
16
+ backgroundColor: theme.palette[alertColor]?.background,
17
+ color: theme.palette.base?.text.primary,
18
+ }
19
+ : {};
20
+
21
+ // Outlined variant styles
22
+ const outlinedStyles =
23
+ variant === "outlined"
24
+ ? {
25
+ backgroundColor: theme.palette.base?.background.paper,
26
+ borderColor: theme.palette[alertColor]?.main,
27
+ color: theme.palette.base?.text.primary,
28
+ }
29
+ : {};
30
+
31
+ // Filled variant styles
32
+ const filledStyles =
33
+ variant === "filled"
34
+ ? {
35
+ backgroundColor: theme.palette[alertColor]?.main,
36
+ color: theme.palette[alertColor]?.contrastText,
37
+ }
38
+ : {};
39
+
40
+ // Icon color based on variant
41
+ const iconColor =
42
+ variant === "filled"
43
+ ? theme.palette[alertColor]?.contrastText
44
+ : theme.palette[alertColor]?.main;
45
+
46
+ return {
47
+ ...standardStyles,
48
+ ...outlinedStyles,
49
+ ...filledStyles,
50
+ [`.${alertClasses.icon}`]: {
51
+ opacity: 1,
52
+ alignItems: "center",
53
+ fontSize: "20px",
54
+ color: iconColor,
55
+ },
56
+ "&.MuiPaper-rounded": {
57
+ borderRadius: 4,
58
+ },
59
+ "& .MuiAlert-message": {
60
+ alignItems: "flex-start",
61
+ display: "flex",
62
+ flexDirection: "column",
63
+ justifyContent: "center",
64
+ ...theme.typography.body2Semibold,
65
+ },
66
+ "& .MuiAlert-action": {
67
+ alignItems: "center",
68
+ paddingTop: 0,
69
+ marginRight: 0,
70
+ "& .MuiButtonBase-root.MuiButton-root": {
71
+ color: `${theme.palette[alertColor]?.main} !important`,
72
+ "&:hover": {
73
+ color: `${theme.palette[alertColor]?.main} !important`,
74
+ },
75
+ },
76
+ },
77
+ };
78
+ };
79
+
80
+ export default styles;
@@ -0,0 +1,5 @@
1
+ import { AlertProps as MuiAlertProps } from "@mui/material/Alert";
2
+
3
+ export interface AlertProps extends MuiAlertProps {
4
+ // this may be updated later if Design needs any props to be removed
5
+ }