/** * Contains the property view currency renderer * * @module */ import { IPropertyViewCurrencyRendererProps } from "../../../internal/components/PropertyView/PropertyViewCurrency"; import React from "react"; import Box from "@mui/material/Box"; /** * The property view currency renderer itself * * supported args: * - NullComponent: a react component to render instead of the default when the value is null * - nullComponentArgs: an object to pass as props to the null component * - nullNode: a react node to render instead of the default when the value is null * - className: the class name for the root span container * - convertedValueClassName: the class name for the actual value * - convertedSymbolClassName: the class name for the symbol that value has * - convertedClassName: the class name for the converted value * - originalClassName: the class name for the original value (if there is one) * - originalSymbolClassName: the class name for the original value symbol (if there is one) * * @param props the props passed by the handler * @returns a react element */ export default function PropertyViewCurrencyRenderer(props: IPropertyViewCurrencyRendererProps) { const rootClassName = props.args.className || null; const rootSx = props.args.rootSx || null; const valueClassName = props.args.convertedValueClassName || null; const valueSx = props.args.convertedValueSx || null; const symbolClassName = props.args.convertedSymbolClassName || null; const symbolSx = props.args.convertedSymbolSx || null; const convertedClassName = props.args.convertedClassName || null; const convertedSx = props.args.convertedSx || null; const originalClassName = props.args.originalClassName || null; const originalValueClassName = props.args.originalValueClassName || null; const originalSymbolClassName = props.args.originalSymbolClassName || null; const originalSx = props.args.originalSx || null; const originalValueSx = props.args.originalValueSx || null; const originalSymbolSx = props.args.originalSymbolSx || null; if (props.currentValue === null && props.args.nullNode) { return ( {props.args.nullNode} ); } else if (props.currentValue === null && props.args.NullComponent) { const NullComponent = props.args.NullComponent; const nullArgs = props.args.nullComponentArgs; return ( ); } else if (props.currentValue === null) { return ( ); } const mainCurrency = props.convertedCurrency || props.originalCurrency; const mainStrValue = props.convertedStrValue || props.originalStrValue; if (props.format === "$N") { return ( {mainCurrency.symbol} {mainStrValue} {!props.args.hideOriginalIfConverted && props.convertedCurrency ? {props.originalCurrency.symbol} {props.originalStrValue} : null} ); } return ( {mainStrValue} {mainCurrency.symbol} {!props.args.hideOriginalIfConverted && props.convertedCurrency ? {props.originalStrValue} {props.originalCurrency.symbol} : null} ); }