@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.
- package/dist/fairmint-ui.cjs +122 -1
- package/dist/fairmint-ui.cjs.map +1 -1
- package/dist/fairmint-ui.js +122 -1
- package/dist/fairmint-ui.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/styles.css +11 -1
- package/dist/utils/format.d.ts +85 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/package.json +21 -12
package/dist/fairmint-ui.cjs
CHANGED
|
@@ -19333,6 +19333,36 @@ const NumberInput = factory((_props, ref) => {
|
|
|
19333
19333
|
);
|
|
19334
19334
|
setTimeout(() => adjustCursor(inputRef.current?.value.length), 0);
|
|
19335
19335
|
};
|
|
19336
|
+
const handlePaste = (event) => {
|
|
19337
|
+
const pastedText = event.clipboardData.getData("text");
|
|
19338
|
+
const _decimalSeparator = others.decimalSeparator || ".";
|
|
19339
|
+
const separatorsToReplace = (allowedDecimalSeparators || [".", ","]).filter(
|
|
19340
|
+
(s) => s !== _decimalSeparator
|
|
19341
|
+
);
|
|
19342
|
+
if (separatorsToReplace.some((s) => pastedText.includes(s))) {
|
|
19343
|
+
event.preventDefault();
|
|
19344
|
+
let modifiedText = pastedText;
|
|
19345
|
+
separatorsToReplace.forEach((s) => {
|
|
19346
|
+
modifiedText = modifiedText.split(s).join(_decimalSeparator);
|
|
19347
|
+
});
|
|
19348
|
+
const input = inputRef.current;
|
|
19349
|
+
if (input) {
|
|
19350
|
+
const start = input.selectionStart ?? 0;
|
|
19351
|
+
const end = input.selectionEnd ?? 0;
|
|
19352
|
+
const currentValue = input.value;
|
|
19353
|
+
const newValue = currentValue.substring(0, start) + modifiedText + currentValue.substring(end);
|
|
19354
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
|
19355
|
+
window.HTMLInputElement.prototype,
|
|
19356
|
+
"value"
|
|
19357
|
+
)?.set;
|
|
19358
|
+
nativeInputValueSetter?.call(input, newValue);
|
|
19359
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
19360
|
+
const cursorPos = start + modifiedText.length;
|
|
19361
|
+
setTimeout(() => adjustCursor(cursorPos), 0);
|
|
19362
|
+
}
|
|
19363
|
+
}
|
|
19364
|
+
others.onPaste?.(event);
|
|
19365
|
+
};
|
|
19336
19366
|
const handleKeyDown = (event) => {
|
|
19337
19367
|
onKeyDown?.(event);
|
|
19338
19368
|
if (readOnly || !withKeyboardEvents) {
|
|
@@ -19457,6 +19487,7 @@ const NumberInput = factory((_props, ref) => {
|
|
|
19457
19487
|
unstyled,
|
|
19458
19488
|
__staticSelector: "NumberInput",
|
|
19459
19489
|
decimalScale: allowDecimal ? decimalScale : 0,
|
|
19490
|
+
onPaste: handlePaste,
|
|
19460
19491
|
onKeyDown: handleKeyDown,
|
|
19461
19492
|
onKeyDownCapture: handleKeyDownCapture,
|
|
19462
19493
|
rightSectionPointerEvents: rightSectionPointerEvents ?? (disabled ? "none" : void 0),
|
|
@@ -19946,6 +19977,7 @@ const PasswordInput$1 = factory((_props, ref) => {
|
|
|
19946
19977
|
classNames: resolvedClassNames,
|
|
19947
19978
|
styles: resolvedStyles,
|
|
19948
19979
|
__staticSelector: "PasswordInput",
|
|
19980
|
+
__stylesApiProps: props,
|
|
19949
19981
|
unstyled,
|
|
19950
19982
|
withAsterisk,
|
|
19951
19983
|
inputWrapperOrder,
|
|
@@ -19971,6 +20003,7 @@ const PasswordInput$1 = factory((_props, ref) => {
|
|
|
19971
20003
|
radius,
|
|
19972
20004
|
disabled,
|
|
19973
20005
|
__staticSelector: "PasswordInput",
|
|
20006
|
+
__stylesApiProps: props,
|
|
19974
20007
|
rightSectionWidth,
|
|
19975
20008
|
rightSection: rightSection ?? visibilityToggleButton,
|
|
19976
20009
|
variant,
|
|
@@ -20844,7 +20877,9 @@ const Tooltip$1 = factory((_props, ref) => {
|
|
|
20844
20877
|
});
|
|
20845
20878
|
const child = getSingleElementChild(children);
|
|
20846
20879
|
if (!target && !child) {
|
|
20847
|
-
|
|
20880
|
+
throw new Error(
|
|
20881
|
+
"[@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"
|
|
20882
|
+
);
|
|
20848
20883
|
}
|
|
20849
20884
|
if (target) {
|
|
20850
20885
|
const transition2 = getTransitionProps(transitionProps, { duration: 100, transition: "fade" });
|
|
@@ -38351,6 +38386,90 @@ function formatDate(dateString) {
|
|
|
38351
38386
|
function formatPercent(n, decimals = 2) {
|
|
38352
38387
|
return `${n.toFixed(decimals)}%`;
|
|
38353
38388
|
}
|
|
38389
|
+
const COUNTRY_LOCALES = {
|
|
38390
|
+
US: "en-US",
|
|
38391
|
+
CA: "en-CA",
|
|
38392
|
+
GB: "en-GB",
|
|
38393
|
+
IE: "en-IE",
|
|
38394
|
+
AU: "en-AU",
|
|
38395
|
+
NZ: "en-NZ",
|
|
38396
|
+
FR: "fr-FR",
|
|
38397
|
+
BE: "fr-BE",
|
|
38398
|
+
LU: "fr-LU",
|
|
38399
|
+
DE: "de-DE",
|
|
38400
|
+
AT: "de-AT",
|
|
38401
|
+
CH: "de-CH",
|
|
38402
|
+
NL: "nl-NL",
|
|
38403
|
+
ES: "es-ES",
|
|
38404
|
+
IT: "it-IT",
|
|
38405
|
+
PT: "pt-PT",
|
|
38406
|
+
BR: "pt-BR",
|
|
38407
|
+
SE: "sv-SE",
|
|
38408
|
+
NO: "nb-NO",
|
|
38409
|
+
DK: "da-DK",
|
|
38410
|
+
FI: "fi-FI",
|
|
38411
|
+
PL: "pl-PL",
|
|
38412
|
+
JP: "ja-JP",
|
|
38413
|
+
CN: "zh-CN",
|
|
38414
|
+
IN: "en-IN",
|
|
38415
|
+
SG: "en-SG"
|
|
38416
|
+
};
|
|
38417
|
+
function localeForCountry(country) {
|
|
38418
|
+
if (!country) return "en-US";
|
|
38419
|
+
const key = country.toUpperCase();
|
|
38420
|
+
return COUNTRY_LOCALES[key] ?? "en-US";
|
|
38421
|
+
}
|
|
38422
|
+
const toNumber = (value) => {
|
|
38423
|
+
if (typeof value === "number") return value;
|
|
38424
|
+
if (value.trim() === "") return Number.NaN;
|
|
38425
|
+
const parsed = Number(value);
|
|
38426
|
+
return Number.isFinite(parsed) ? parsed : Number.NaN;
|
|
38427
|
+
};
|
|
38428
|
+
function formatMonetary(monetary, options = {}) {
|
|
38429
|
+
const {
|
|
38430
|
+
locale: explicitLocale,
|
|
38431
|
+
country,
|
|
38432
|
+
fallbackCurrency = "USD",
|
|
38433
|
+
compactWholeNumbers = true
|
|
38434
|
+
} = options;
|
|
38435
|
+
if (monetary === null || monetary === void 0) return "";
|
|
38436
|
+
let amount;
|
|
38437
|
+
let currency;
|
|
38438
|
+
if (typeof monetary === "number" || typeof monetary === "string") {
|
|
38439
|
+
amount = toNumber(monetary);
|
|
38440
|
+
currency = fallbackCurrency.toUpperCase();
|
|
38441
|
+
} else {
|
|
38442
|
+
amount = toNumber(monetary.amount);
|
|
38443
|
+
currency = (monetary.currency || fallbackCurrency).toUpperCase();
|
|
38444
|
+
}
|
|
38445
|
+
if (!Number.isFinite(amount)) return "";
|
|
38446
|
+
const locale = explicitLocale ?? localeForCountry(country);
|
|
38447
|
+
let nativeFractionDigits = 2;
|
|
38448
|
+
try {
|
|
38449
|
+
const resolved = new Intl.NumberFormat(locale, {
|
|
38450
|
+
style: "currency",
|
|
38451
|
+
currency
|
|
38452
|
+
}).resolvedOptions().maximumFractionDigits;
|
|
38453
|
+
if (typeof resolved === "number") nativeFractionDigits = resolved;
|
|
38454
|
+
} catch {
|
|
38455
|
+
}
|
|
38456
|
+
const isWhole = Number.isInteger(amount);
|
|
38457
|
+
const minimumFractionDigits = compactWholeNumbers && isWhole ? 0 : nativeFractionDigits;
|
|
38458
|
+
const subUnitThreshold = 10 ** -nativeFractionDigits;
|
|
38459
|
+
const subUnit = Math.abs(amount) > 0 && Math.abs(amount) < subUnitThreshold;
|
|
38460
|
+
const maximumFractionDigits = subUnit ? Math.max(6, nativeFractionDigits) : nativeFractionDigits;
|
|
38461
|
+
try {
|
|
38462
|
+
return new Intl.NumberFormat(locale, {
|
|
38463
|
+
style: "currency",
|
|
38464
|
+
currency,
|
|
38465
|
+
minimumFractionDigits,
|
|
38466
|
+
maximumFractionDigits
|
|
38467
|
+
}).format(amount);
|
|
38468
|
+
} catch {
|
|
38469
|
+
const fallbackDigits = subUnit ? maximumFractionDigits : minimumFractionDigits;
|
|
38470
|
+
return `${amount.toFixed(fallbackDigits)} ${currency}`;
|
|
38471
|
+
}
|
|
38472
|
+
}
|
|
38354
38473
|
const TABULAR_NUMS = { fontVariantNumeric: "tabular-nums" };
|
|
38355
38474
|
function Currency({ value, precise = false, currency, style, ...rest }) {
|
|
38356
38475
|
let formatted;
|
|
@@ -41150,6 +41269,7 @@ exports.fontSizes = fontSizes;
|
|
|
41150
41269
|
exports.formatCurrency = formatCurrency;
|
|
41151
41270
|
exports.formatCurrencyPrecise = formatCurrencyPrecise;
|
|
41152
41271
|
exports.formatDate = formatDate;
|
|
41272
|
+
exports.formatMonetary = formatMonetary;
|
|
41153
41273
|
exports.formatNumber = formatNumber;
|
|
41154
41274
|
exports.formatPercent = formatPercent;
|
|
41155
41275
|
exports.formatPhone = formatPhone;
|
|
@@ -41163,6 +41283,7 @@ exports.getWalletLabel = getWalletLabel;
|
|
|
41163
41283
|
exports.isEthereumAddress = isEthereumAddress;
|
|
41164
41284
|
exports.isRemovableWalletType = isRemovableWalletType;
|
|
41165
41285
|
exports.isSystemWalletType = isSystemWalletType;
|
|
41286
|
+
exports.localeForCountry = localeForCountry;
|
|
41166
41287
|
exports.neutralColors = neutralColors;
|
|
41167
41288
|
exports.normalizePhone = normalizePhone;
|
|
41168
41289
|
exports.normalizeWalletType = normalizeWalletType;
|