import React from 'react'; import Box from '@mui/material/Box'; import Tooltip from '@mui/material/Tooltip'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import type { SxProps, Theme } from '@mui/material/styles'; import { Typography } from '../../atoms/Typography'; // ─── Types ─────────────────────────────────────────────────────────────────── /** Props for the FA LineItem molecule */ export interface LineItemProps { /** Item name/label */ name: string; /** Optional tooltip text explaining the item (shown via info icon) */ info?: string; /** Price in dollars — omit for complimentary/included items */ price?: number; /** Whether the price is an allowance (shows asterisk) */ isAllowance?: boolean; /** Custom price display — overrides `price` formatting (e.g. "Included", "TBC") */ priceLabel?: string; /** Visual weight — "default" for regular items, "total" for summary rows */ variant?: 'default' | 'total'; /** MUI sx prop for the root element */ sx?: SxProps; } // ─── Component ─────────────────────────────────────────────────────────────── /** * A single line item showing a name, optional info tooltip, and optional price. * * Used in package contents, order summaries, and invoices. The `info` prop * renders a small info icon with a tooltip — used by providers to explain * what each inclusion covers. * * Composes Typography + Tooltip. * * Usage: * ```tsx * * * * * ``` */ export const LineItem = React.forwardRef( ({ name, info, price, isAllowance = false, priceLabel, variant = 'default', sx }, ref) => { const isTotal = variant === 'total'; const formattedPrice = priceLabel ?? (price != null ? `$${price.toLocaleString('en-AU')}${isAllowance ? '*' : ''}` : undefined); return ( {/* Name + optional info icon */} {name} {info && ( )} {/* Price */} {formattedPrice && ( {formattedPrice} )} ); }, ); LineItem.displayName = 'LineItem'; export default LineItem;