UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

29 lines (28 loc) 1.33 kB
"use client"; import _extends from "@babel/runtime-corejs3/helpers/esm/extends"; import React, { useContext } from 'react'; import classnames from 'classnames'; 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"; 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 React.createElement(NumberField, _extends({}, preparedProps, { className: classnames('dnb-forms-field-currency', props.className) })); } Currency._supportsSpacingProps = true; export default Currency; //# sourceMappingURL=Currency.js.map