@ceed/cds 1.4.5 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ interface CurrencyInputProps {
19
19
  error?: boolean;
20
20
  helperText?: React.ReactNode;
21
21
  useMinorUnit?: boolean;
22
+ placeholder?: string;
22
23
  }
23
24
  declare const CurrencyInput: React.ForwardRefExoticComponent<Omit<CurrencyInputProps & Omit<InputProps, "defaultValue" | "onChange" | "value"> & MotionProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
24
25
  export { CurrencyInput };
@@ -1,4 +1,7 @@
1
- export declare const useCurrencySetting: (currencyCode?: "USD" | "KRW" | "BHD") => {
1
+ export declare const useCurrencySetting: (props: {
2
+ currency?: "USD" | "KRW" | "BHD" | undefined;
3
+ placeholder?: string | undefined;
4
+ }) => {
2
5
  symbol: string;
3
6
  thousandSeparator: string;
4
7
  decimalSeparator: string;
package/dist/index.cjs CHANGED
@@ -1907,16 +1907,17 @@ var CURRENCY_DECIMAL_MAP = {
1907
1907
  ZAR: 2,
1908
1908
  ZMW: 2
1909
1909
  };
1910
- var useCurrencySetting = (currencyCode = "USD") => {
1910
+ var useCurrencySetting = (props) => {
1911
+ const { currency = "USD", placeholder } = props;
1911
1912
  const [symbol, thousandSeparator, decimalSeparator, ...rest] = new import_intl_messageformat.default(
1912
- `{amount, number, ::currency/${currencyCode} unit-width-narrow}`
1913
+ `{amount, number, ::currency/${currency} unit-width-narrow}`
1913
1914
  ).format({ amount: 1e3 }).toString().replace(/\d/g, "").split("");
1914
- const decimalScale = CURRENCY_DECIMAL_MAP[currencyCode];
1915
+ const decimalScale = CURRENCY_DECIMAL_MAP[currency];
1915
1916
  return {
1916
1917
  symbol: `${symbol} `,
1917
1918
  thousandSeparator,
1918
1919
  decimalSeparator,
1919
- placeholder: decimalSeparator ? `${symbol} 0${decimalSeparator}${Array.from(Array(decimalScale)).map(() => 0).join("")}` : `${symbol} 0`,
1920
+ placeholder: placeholder ? `${symbol} ${placeholder}` : decimalSeparator ? `${symbol} 0${decimalSeparator}${Array.from(Array(decimalScale)).map(() => 0).join("")}` : `${symbol} 0`,
1920
1921
  fixedDecimalScale: !!decimalSeparator,
1921
1922
  decimalScale
1922
1923
  };
@@ -1971,7 +1972,7 @@ var CurrencyInput = import_react17.default.forwardRef(function CurrencyInput2(in
1971
1972
  placeholder,
1972
1973
  fixedDecimalScale,
1973
1974
  decimalScale
1974
- } = useCurrencySetting(currency);
1975
+ } = useCurrencySetting(props);
1975
1976
  const [_value, setValue] = useControlledState(
1976
1977
  props.value,
1977
1978
  props.defaultValue,
package/dist/index.js CHANGED
@@ -1844,16 +1844,17 @@ var CURRENCY_DECIMAL_MAP = {
1844
1844
  ZAR: 2,
1845
1845
  ZMW: 2
1846
1846
  };
1847
- var useCurrencySetting = (currencyCode = "USD") => {
1847
+ var useCurrencySetting = (props) => {
1848
+ const { currency = "USD", placeholder } = props;
1848
1849
  const [symbol, thousandSeparator, decimalSeparator, ...rest] = new IntlMessageFormat(
1849
- `{amount, number, ::currency/${currencyCode} unit-width-narrow}`
1850
+ `{amount, number, ::currency/${currency} unit-width-narrow}`
1850
1851
  ).format({ amount: 1e3 }).toString().replace(/\d/g, "").split("");
1851
- const decimalScale = CURRENCY_DECIMAL_MAP[currencyCode];
1852
+ const decimalScale = CURRENCY_DECIMAL_MAP[currency];
1852
1853
  return {
1853
1854
  symbol: `${symbol} `,
1854
1855
  thousandSeparator,
1855
1856
  decimalSeparator,
1856
- placeholder: decimalSeparator ? `${symbol} 0${decimalSeparator}${Array.from(Array(decimalScale)).map(() => 0).join("")}` : `${symbol} 0`,
1857
+ placeholder: placeholder ? `${symbol} ${placeholder}` : decimalSeparator ? `${symbol} 0${decimalSeparator}${Array.from(Array(decimalScale)).map(() => 0).join("")}` : `${symbol} 0`,
1857
1858
  fixedDecimalScale: !!decimalSeparator,
1858
1859
  decimalScale
1859
1860
  };
@@ -1908,7 +1909,7 @@ var CurrencyInput = React15.forwardRef(function CurrencyInput2(inProps, ref) {
1908
1909
  placeholder,
1909
1910
  fixedDecimalScale,
1910
1911
  decimalScale
1911
- } = useCurrencySetting(currency);
1912
+ } = useCurrencySetting(props);
1912
1913
  const [_value, setValue] = useControlledState(
1913
1914
  props.value,
1914
1915
  props.defaultValue,