@fairmint/ui 0.2.23 → 0.2.25

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.
@@ -19315,6 +19315,36 @@ const NumberInput = factory((_props, ref) => {
19315
19315
  );
19316
19316
  setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);
19317
19317
  };
19318
+ const handlePaste = (event) => {
19319
+ const pastedText = event.clipboardData.getData("text");
19320
+ const _decimalSeparator = others.decimalSeparator || ".";
19321
+ const separatorsToReplace = (allowedDecimalSeparators || [".", ","]).filter(
19322
+ (s) => s !== _decimalSeparator
19323
+ );
19324
+ if (separatorsToReplace.some((s) => pastedText.includes(s))) {
19325
+ event.preventDefault();
19326
+ let modifiedText = pastedText;
19327
+ separatorsToReplace.forEach((s) => {
19328
+ modifiedText = modifiedText.split(s).join(_decimalSeparator);
19329
+ });
19330
+ const input = inputRef.current;
19331
+ if (input) {
19332
+ const start = input.selectionStart ?? 0;
19333
+ const end = input.selectionEnd ?? 0;
19334
+ const currentValue = input.value;
19335
+ const newValue = currentValue.substring(0, start) + modifiedText + currentValue.substring(end);
19336
+ const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
19337
+ window.HTMLInputElement.prototype,
19338
+ "value"
19339
+ )?.set;
19340
+ nativeInputValueSetter?.call(input, newValue);
19341
+ input.dispatchEvent(new Event("change", { bubbles: true }));
19342
+ const cursorPos = start + modifiedText.length;
19343
+ setTimeout(() => adjustCursor(cursorPos), 0);
19344
+ }
19345
+ }
19346
+ others.onPaste?.(event);
19347
+ };
19318
19348
  const handleKeyDown = (event) => {
19319
19349
  onKeyDown?.(event);
19320
19350
  if (readOnly || !withKeyboardEvents) {
@@ -19439,6 +19469,7 @@ const NumberInput = factory((_props, ref) => {
19439
19469
  unstyled,
19440
19470
  __staticSelector: "NumberInput",
19441
19471
  decimalScale: allowDecimal ? decimalScale : 0,
19472
+ onPaste: handlePaste,
19442
19473
  onKeyDown: handleKeyDown,
19443
19474
  onKeyDownCapture: handleKeyDownCapture,
19444
19475
  rightSectionPointerEvents: rightSectionPointerEvents ?? (disabled ? "none" : void 0),
@@ -19928,6 +19959,7 @@ const PasswordInput$1 = factory((_props, ref) => {
19928
19959
  classNames: resolvedClassNames,
19929
19960
  styles: resolvedStyles,
19930
19961
  __staticSelector: "PasswordInput",
19962
+ __stylesApiProps: props,
19931
19963
  unstyled,
19932
19964
  withAsterisk,
19933
19965
  inputWrapperOrder,
@@ -19953,6 +19985,7 @@ const PasswordInput$1 = factory((_props, ref) => {
19953
19985
  radius,
19954
19986
  disabled,
19955
19987
  __staticSelector: "PasswordInput",
19988
+ __stylesApiProps: props,
19956
19989
  rightSectionWidth,
19957
19990
  rightSection: rightSection ?? visibilityToggleButton,
19958
19991
  variant,
@@ -20826,7 +20859,9 @@ const Tooltip$1 = factory((_props, ref) => {
20826
20859
  });
20827
20860
  const child = getSingleElementChild(children);
20828
20861
  if (!target && !child) {
20829
- return null;
20862
+ throw new Error(
20863
+ "[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported"
20864
+ );
20830
20865
  }
20831
20866
  if (target) {
20832
20867
  const transition2 = getTransitionProps(transitionProps, { duration: 100, transition: "fade" });
@@ -38333,6 +38368,90 @@ function formatDate(dateString) {
38333
38368
  function formatPercent(n, decimals = 2) {
38334
38369
  return `${n.toFixed(decimals)}%`;
38335
38370
  }
38371
+ const COUNTRY_LOCALES = {
38372
+ US: "en-US",
38373
+ CA: "en-CA",
38374
+ GB: "en-GB",
38375
+ IE: "en-IE",
38376
+ AU: "en-AU",
38377
+ NZ: "en-NZ",
38378
+ FR: "fr-FR",
38379
+ BE: "fr-BE",
38380
+ LU: "fr-LU",
38381
+ DE: "de-DE",
38382
+ AT: "de-AT",
38383
+ CH: "de-CH",
38384
+ NL: "nl-NL",
38385
+ ES: "es-ES",
38386
+ IT: "it-IT",
38387
+ PT: "pt-PT",
38388
+ BR: "pt-BR",
38389
+ SE: "sv-SE",
38390
+ NO: "nb-NO",
38391
+ DK: "da-DK",
38392
+ FI: "fi-FI",
38393
+ PL: "pl-PL",
38394
+ JP: "ja-JP",
38395
+ CN: "zh-CN",
38396
+ IN: "en-IN",
38397
+ SG: "en-SG"
38398
+ };
38399
+ function localeForCountry(country) {
38400
+ if (!country) return "en-US";
38401
+ const key = country.toUpperCase();
38402
+ return COUNTRY_LOCALES[key] ?? "en-US";
38403
+ }
38404
+ const toNumber = (value) => {
38405
+ if (typeof value === "number") return value;
38406
+ if (value.trim() === "") return Number.NaN;
38407
+ const parsed = Number(value);
38408
+ return Number.isFinite(parsed) ? parsed : Number.NaN;
38409
+ };
38410
+ function formatMonetary(monetary, options = {}) {
38411
+ const {
38412
+ locale: explicitLocale,
38413
+ country,
38414
+ fallbackCurrency = "USD",
38415
+ compactWholeNumbers = true
38416
+ } = options;
38417
+ if (monetary === null || monetary === void 0) return "";
38418
+ let amount;
38419
+ let currency;
38420
+ if (typeof monetary === "number" || typeof monetary === "string") {
38421
+ amount = toNumber(monetary);
38422
+ currency = fallbackCurrency.toUpperCase();
38423
+ } else {
38424
+ amount = toNumber(monetary.amount);
38425
+ currency = (monetary.currency || fallbackCurrency).toUpperCase();
38426
+ }
38427
+ if (!Number.isFinite(amount)) return "";
38428
+ const locale = explicitLocale ?? localeForCountry(country);
38429
+ let nativeFractionDigits = 2;
38430
+ try {
38431
+ const resolved = new Intl.NumberFormat(locale, {
38432
+ style: "currency",
38433
+ currency
38434
+ }).resolvedOptions().maximumFractionDigits;
38435
+ if (typeof resolved === "number") nativeFractionDigits = resolved;
38436
+ } catch {
38437
+ }
38438
+ const isWhole = Number.isInteger(amount);
38439
+ const minimumFractionDigits = compactWholeNumbers && isWhole ? 0 : nativeFractionDigits;
38440
+ const subUnitThreshold = 10 ** -nativeFractionDigits;
38441
+ const subUnit = Math.abs(amount) > 0 && Math.abs(amount) < subUnitThreshold;
38442
+ const maximumFractionDigits = subUnit ? Math.max(6, nativeFractionDigits) : nativeFractionDigits;
38443
+ try {
38444
+ return new Intl.NumberFormat(locale, {
38445
+ style: "currency",
38446
+ currency,
38447
+ minimumFractionDigits,
38448
+ maximumFractionDigits
38449
+ }).format(amount);
38450
+ } catch {
38451
+ const fallbackDigits = subUnit ? maximumFractionDigits : minimumFractionDigits;
38452
+ return `${amount.toFixed(fallbackDigits)} ${currency}`;
38453
+ }
38454
+ }
38336
38455
  const TABULAR_NUMS = { fontVariantNumeric: "tabular-nums" };
38337
38456
  function Currency({ value, precise = false, currency, style, ...rest }) {
38338
38457
  let formatted;
@@ -41133,6 +41252,7 @@ export {
41133
41252
  formatCurrency,
41134
41253
  formatCurrencyPrecise,
41135
41254
  formatDate,
41255
+ formatMonetary,
41136
41256
  formatNumber,
41137
41257
  formatPercent,
41138
41258
  formatPhone,
@@ -41146,6 +41266,7 @@ export {
41146
41266
  isEthereumAddress,
41147
41267
  isRemovableWalletType,
41148
41268
  isSystemWalletType,
41269
+ localeForCountry,
41149
41270
  neutralColors,
41150
41271
  normalizePhone,
41151
41272
  normalizeWalletType,