PHP 8.2.30
Preview: getLocaleConfig.ts Size: 1.25 KB
/home/byroehnu/easepaybiz.easetack.com/node_modules/react-currency-input-field/src/components/utils/getLocaleConfig.ts

import { IntlConfig } from '../CurrencyInputProps';

type LocaleConfig = {
  currencySymbol: string;
  groupSeparator: string;
  decimalSeparator: string;
  prefix: string;
  suffix: string;
};

const defaultConfig: LocaleConfig = {
  currencySymbol: '',
  groupSeparator: '',
  decimalSeparator: '',
  prefix: '',
  suffix: '',
};

/**
 * Get locale config from input or default
 */
export const getLocaleConfig = (intlConfig?: IntlConfig): LocaleConfig => {
  const { locale, currency, ...formatOptions } = intlConfig || {};
  const numberFormatter = locale
    ? new Intl.NumberFormat(locale, {
        ...formatOptions,
        ...(currency && { currency, style: 'currency' }),
      })
    : new Intl.NumberFormat();

  return numberFormatter.formatToParts(1000.1).reduce((prev, curr, i): LocaleConfig => {
    if (curr.type === 'currency') {
      if (i === 0) {
        return { ...prev, currencySymbol: curr.value, prefix: curr.value };
      } else {
        return { ...prev, currencySymbol: curr.value, suffix: curr.value };
      }
    }
    if (curr.type === 'group') {
      return { ...prev, groupSeparator: curr.value };
    }
    if (curr.type === 'decimal') {
      return { ...prev, decimalSeparator: curr.value };
    }

    return prev;
  }, defaultConfig);
};

Directory Contents

Dirs: 1 × Files: 15

Name Size Perms Modified Actions
__tests__ DIR
- drwxr-xr-x 2026-03-14 01:49:06
Edit Download
127 B lr--r--r-- 2026-03-14 01:49:06
Edit Download
195 B lrw-r--r-- 2026-03-05 00:20:02
Edit Download
2.62 KB lrw-r--r-- 2026-03-05 00:20:06
Edit Download
295 B lrw-r--r-- 2026-03-05 00:20:10
Edit Download
946 B lrw-r--r-- 2026-03-05 00:20:11
Edit Download
5.26 KB lrw-r--r-- 2026-03-05 00:20:12
Edit Download
1.25 KB lrw-r--r-- 2026-03-05 00:20:13
Edit Download
475 B lrw-r--r-- 2026-03-05 00:20:13
Edit Download
258 B lrw-r--r-- 2026-03-05 00:20:14
Edit Download
84 B lrw-r--r-- 2026-03-05 00:20:14
Edit Download
718 B lrw-r--r-- 2026-03-05 00:20:15
Edit Download
1.15 KB lrw-r--r-- 2026-03-05 00:20:15
Edit Download
320 B lrw-r--r-- 2026-03-05 00:20:16
Edit Download
280 B lrw-r--r-- 2026-03-05 00:20:16
Edit Download
1.41 KB lrw-r--r-- 2026-03-05 00:20:16
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).