@coinlist-co/react 0.12.1 → 0.12.2-rc.726778a

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.
@@ -5,7 +5,7 @@ import {
5
5
  SDK_LOGGER_NAME,
6
6
  loggerOverPino,
7
7
  publicClients
8
- } from "../chunk-DCW7NQXH.js";
8
+ } from "../chunk-C6F5FOFP.js";
9
9
  import {
10
10
  API_VERSION,
11
11
  ClientCredentialsOAuth,
@@ -25,7 +25,7 @@ import {
25
25
  fetchOffers,
26
26
  fetchOffersPage,
27
27
  internalLogger
28
- } from "../chunk-MOE5S6CE.js";
28
+ } from "../chunk-IRV5YU42.js";
29
29
 
30
30
  // src/server/core/api/api-client.ts
31
31
  var ApiClient = class {
@@ -166,6 +166,7 @@ __export(universal_exports, {
166
166
  formatBpsAsPercent: () => formatBpsAsPercent,
167
167
  formatCompactAmount: () => formatCompactAmount,
168
168
  formatRawAmount: () => formatRawAmount,
169
+ formatShareAmount: () => formatShareAmount,
169
170
  formattedPricePerShare: () => formattedPricePerShare,
170
171
  formattedUsdPrice: () => formattedUsdPrice,
171
172
  generatePKCEParams: () => generatePKCEParams,
@@ -1265,7 +1266,11 @@ function formatAmount(amount, locale, options) {
1265
1266
  const decimal = formatRawAmount(amount);
1266
1267
  let [integerPart, fractionPart = ""] = decimal.split(".");
1267
1268
  const maxFractionDigits = options?.maxFractionDigits;
1268
- const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
1269
+ const minFractionDigits = Math.min(
1270
+ options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1271
+ maxFractionDigits ?? amount.decimals,
1272
+ amount.decimals
1273
+ );
1269
1274
  if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1270
1275
  ({ integerPart, fractionPart } = roundFractionHalfUp(
1271
1276
  integerPart,
@@ -1273,7 +1278,8 @@ function formatAmount(amount, locale, options) {
1273
1278
  maxFractionDigits
1274
1279
  ));
1275
1280
  }
1276
- const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
1281
+ const trimmed = fractionPart.replace(/0+$/, "");
1282
+ const fraction = trimmed.padEnd(minFractionDigits, "0");
1277
1283
  const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1278
1284
  if (minFractionDigits === 0 && fraction === "") {
1279
1285
  return FormattedAmountUi(integerFormatted);
@@ -1342,6 +1348,14 @@ function assetAmount(amount, symbol) {
1342
1348
  return FormattedAmountAssetUi(`${amount} ${symbol}`);
1343
1349
  }
1344
1350
  var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1351
+ var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1352
+ var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1353
+ function formatShareAmount(amount, locale) {
1354
+ return formatAmount(amount, locale, {
1355
+ maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1356
+ minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1357
+ });
1358
+ }
1345
1359
  var USD_FRACTION_DIGITS = AssetDecimals(2);
1346
1360
  function formattedUsdPrice(amount, locale) {
1347
1361
  if (!amount) return NA_AMOUNT_ASSET_UI;
@@ -4006,6 +4020,7 @@ var User = {
4006
4020
  formatBpsAsPercent,
4007
4021
  formatCompactAmount,
4008
4022
  formatRawAmount,
4023
+ formatShareAmount,
4009
4024
  formattedPricePerShare,
4010
4025
  formattedUsdPrice,
4011
4026
  generatePKCEParams,