UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

42 lines (41 loc) 1.95 kB
"use strict"; "use client"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); var _clsx = require("clsx"); var _Context = _interopRequireDefault(require("../../../../shared/Context.js")); var _NumberUtils = require("../../../../components/number-format/NumberUtils.js"); var _defaults = require("../../../../shared/defaults.js"); var _useDataValue = _interopRequireDefault(require("../../hooks/useDataValue.js")); var _index = require("../../utils/json-pointer/index.js"); var _index2 = _interopRequireDefault(require("../Number/index.js")); var _withComponentMarkers = _interopRequireDefault(require("../../../../shared/helpers/withComponentMarkers.js")); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function Currency(props) { var _props$placeholder; const sharedContext = (0, _react.useContext)(_Context.default); const currencyPath = (0, _index.isPath)(props.currency) ? props.currency : undefined; const { value: currencyPathValue, getSourceValue } = (0, _useDataValue.default)(currencyPath); const currencyValue = currencyPath ? currencyPathValue : getSourceValue(props.currency); const preparedProps = { ...props, currency: currencyValue !== null && currencyValue !== void 0 ? currencyValue : _defaults.CURRENCY, placeholder: (_props$placeholder = props.placeholder) !== null && _props$placeholder !== void 0 ? _props$placeholder : (0, _NumberUtils.getCurrencySymbol)(sharedContext?.locale, currencyValue, props.currencyDisplay) }; return (0, _jsxRuntime.jsx)(_index2.default, { ...preparedProps, className: (0, _clsx.clsx)('dnb-forms-field-currency', props.className) }); } (0, _withComponentMarkers.default)(Currency, { _supportsSpacingProps: true }); var _default = exports.default = Currency; //# sourceMappingURL=Currency.js.map