UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

33 lines (32 loc) 1.39 kB
"use client"; import React, { useContext } from 'react'; import clsx from 'clsx'; import SharedContext from "../../../../shared/Context.js"; import { getCurrencySymbol } from "../../../../components/number-format/NumberUtils.js"; import { CURRENCY } from "../../../../shared/defaults.js"; import useDataValue from "../../hooks/useDataValue.js"; import NumberField from "../Number/index.js"; import withComponentMarkers from "../../../../shared/helpers/withComponentMarkers.js"; import { jsx as _jsx } from "react/jsx-runtime"; function Currency(props) { var _props$placeholder; const sharedContext = useContext(SharedContext); const { getSourceValue } = useDataValue(); const currencyValue = getSourceValue(props.currency); const preparedProps = { ...props, currency: currencyValue !== null && currencyValue !== void 0 ? currencyValue : CURRENCY, placeholder: (_props$placeholder = props.placeholder) !== null && _props$placeholder !== void 0 ? _props$placeholder : getCurrencySymbol(sharedContext === null || sharedContext === void 0 ? void 0 : sharedContext.locale, currencyValue, props.currencyDisplay) }; return _jsx(NumberField, { ...preparedProps, className: clsx('dnb-forms-field-currency', props.className) }); } withComponentMarkers(Currency, { _supportsSpacingProps: true }); export default Currency; //# sourceMappingURL=Currency.js.map