@yenio-pld/blocks 1.2.0-rc.17 → 1.2.0-rc.19
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/index.cjs +160 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +156 -1
- package/dist/index.js.map +1 -1
- package/dist/ui/alert-dialog.js +4 -1
- package/dist/ui/alert-dialog.js.map +1 -1
- package/dist/ui/dialog.js +3 -1
- package/dist/ui/dialog.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4693,6 +4693,161 @@ function PhoneInput({
|
|
|
4693
4693
|
}
|
|
4694
4694
|
);
|
|
4695
4695
|
}
|
|
4696
|
+
|
|
4697
|
+
// src/lib/money.ts
|
|
4698
|
+
var MAX_MINOR = Number.MAX_SAFE_INTEGER;
|
|
4699
|
+
function formatMoney(valueMinor, currency, locale = "es-MX") {
|
|
4700
|
+
if (valueMinor === null || !Number.isFinite(valueMinor)) return "";
|
|
4701
|
+
const minor = Math.abs(Math.trunc(valueMinor));
|
|
4702
|
+
return new Intl.NumberFormat(locale, {
|
|
4703
|
+
style: "currency",
|
|
4704
|
+
currency,
|
|
4705
|
+
minimumFractionDigits: 2,
|
|
4706
|
+
maximumFractionDigits: 2
|
|
4707
|
+
}).format(minor / 100);
|
|
4708
|
+
}
|
|
4709
|
+
function appendMoneyDigit(valueMinor, digit) {
|
|
4710
|
+
if (!Number.isInteger(digit) || digit < 0 || digit > 9) return valueMinor;
|
|
4711
|
+
const base = valueMinor ?? 0;
|
|
4712
|
+
const next = base * 10 + digit;
|
|
4713
|
+
if (!Number.isSafeInteger(next) || next > MAX_MINOR) return valueMinor;
|
|
4714
|
+
return next === 0 ? null : next;
|
|
4715
|
+
}
|
|
4716
|
+
function backspaceMoneyMinor(valueMinor) {
|
|
4717
|
+
if (valueMinor === null || valueMinor === 0) return null;
|
|
4718
|
+
const next = Math.trunc(valueMinor / 10);
|
|
4719
|
+
return next === 0 ? null : next;
|
|
4720
|
+
}
|
|
4721
|
+
function parseMoneyToMinor(raw) {
|
|
4722
|
+
const trimmed = raw.trim();
|
|
4723
|
+
if (!trimmed) return null;
|
|
4724
|
+
const digits = trimmed.replace(/[^\d.]/g, "");
|
|
4725
|
+
if (!digits) return null;
|
|
4726
|
+
const parts = digits.split(".");
|
|
4727
|
+
if (parts.length > 2) return null;
|
|
4728
|
+
const whole = parts[0] ?? "";
|
|
4729
|
+
const frac = parts[1] ?? "";
|
|
4730
|
+
if (!/^\d*$/.test(whole) || !/^\d{0,2}$/.test(frac)) return null;
|
|
4731
|
+
if (!whole && !frac) return null;
|
|
4732
|
+
const parsed = Number(`${whole || "0"}.${frac.padEnd(2, "0")}`);
|
|
4733
|
+
if (!Number.isFinite(parsed) || parsed < 0) return null;
|
|
4734
|
+
const minor = Math.round(parsed * 100);
|
|
4735
|
+
if (!Number.isSafeInteger(minor) || minor < 0) return null;
|
|
4736
|
+
if (minor === 0) return null;
|
|
4737
|
+
return minor;
|
|
4738
|
+
}
|
|
4739
|
+
var ROW_CLASS2 = "flex w-full min-w-0 items-stretch overflow-hidden rounded-lg border border-input bg-transparent transition-colors outline-none focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40";
|
|
4740
|
+
function currencyLabel(currency, mxnLabel, usdLabel) {
|
|
4741
|
+
return currency === "USD" ? usdLabel : mxnLabel;
|
|
4742
|
+
}
|
|
4743
|
+
function MoneyInput({
|
|
4744
|
+
valueMinor,
|
|
4745
|
+
onValueMinorChange,
|
|
4746
|
+
currency = "MXN",
|
|
4747
|
+
currencies = ["MXN", "USD"],
|
|
4748
|
+
showCurrencySwitch = false,
|
|
4749
|
+
onCurrencyChange,
|
|
4750
|
+
locale = "es-MX",
|
|
4751
|
+
moneySize = "default",
|
|
4752
|
+
mxnLabel = "MXN",
|
|
4753
|
+
usdLabel = "USD",
|
|
4754
|
+
className,
|
|
4755
|
+
disabled,
|
|
4756
|
+
id,
|
|
4757
|
+
name,
|
|
4758
|
+
"aria-invalid": ariaInvalid,
|
|
4759
|
+
"aria-label": ariaLabel,
|
|
4760
|
+
placeholder,
|
|
4761
|
+
...props
|
|
4762
|
+
}) {
|
|
4763
|
+
const display = formatMoney(valueMinor, currency, locale);
|
|
4764
|
+
const switchable = showCurrencySwitch && currencies.length > 1 && onCurrencyChange;
|
|
4765
|
+
function applyDigit(digit) {
|
|
4766
|
+
onValueMinorChange(appendMoneyDigit(valueMinor, digit));
|
|
4767
|
+
}
|
|
4768
|
+
function onKeyDown(event) {
|
|
4769
|
+
if (disabled) return;
|
|
4770
|
+
if (event.key >= "0" && event.key <= "9") {
|
|
4771
|
+
event.preventDefault();
|
|
4772
|
+
applyDigit(Number(event.key));
|
|
4773
|
+
return;
|
|
4774
|
+
}
|
|
4775
|
+
if (event.key === "Backspace" || event.key === "Delete") {
|
|
4776
|
+
event.preventDefault();
|
|
4777
|
+
onValueMinorChange(backspaceMoneyMinor(valueMinor));
|
|
4778
|
+
return;
|
|
4779
|
+
}
|
|
4780
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey) {
|
|
4781
|
+
event.preventDefault();
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
function onPaste(event) {
|
|
4785
|
+
if (disabled) return;
|
|
4786
|
+
const text = event.clipboardData.getData("text");
|
|
4787
|
+
const parsed = parseMoneyToMinor(text);
|
|
4788
|
+
if (parsed === null && text.trim()) return;
|
|
4789
|
+
event.preventDefault();
|
|
4790
|
+
onValueMinorChange(parsed);
|
|
4791
|
+
}
|
|
4792
|
+
const sizeClass = moneySize === "large" ? "h-14 text-2xl tabular-nums" : "tabular-nums";
|
|
4793
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4794
|
+
"div",
|
|
4795
|
+
{
|
|
4796
|
+
"aria-invalid": ariaInvalid,
|
|
4797
|
+
className: cn(
|
|
4798
|
+
ROW_CLASS2,
|
|
4799
|
+
disabled ? "pointer-events-none cursor-not-allowed bg-input/50 opacity-50 dark:bg-input/80" : null,
|
|
4800
|
+
className
|
|
4801
|
+
),
|
|
4802
|
+
children: [
|
|
4803
|
+
switchable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4804
|
+
"div",
|
|
4805
|
+
{
|
|
4806
|
+
className: "flex shrink-0 items-stretch border-r border-input",
|
|
4807
|
+
role: "group",
|
|
4808
|
+
"aria-label": "Currency",
|
|
4809
|
+
children: currencies.map((code) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4810
|
+
button_js.Button,
|
|
4811
|
+
{
|
|
4812
|
+
type: "button",
|
|
4813
|
+
variant: currency === code ? "secondary" : "ghost",
|
|
4814
|
+
className: "h-full min-w-14 rounded-none px-2 text-xs font-semibold",
|
|
4815
|
+
disabled,
|
|
4816
|
+
"aria-pressed": currency === code,
|
|
4817
|
+
onClick: () => onCurrencyChange(code),
|
|
4818
|
+
children: currencyLabel(code, mxnLabel, usdLabel)
|
|
4819
|
+
},
|
|
4820
|
+
code
|
|
4821
|
+
))
|
|
4822
|
+
}
|
|
4823
|
+
) : null,
|
|
4824
|
+
name ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: valueMinor ?? "" }) : null,
|
|
4825
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4826
|
+
input_js.Input,
|
|
4827
|
+
{
|
|
4828
|
+
...props,
|
|
4829
|
+
"aria-invalid": ariaInvalid,
|
|
4830
|
+
"aria-label": ariaLabel,
|
|
4831
|
+
autoComplete: "off",
|
|
4832
|
+
className: cn(
|
|
4833
|
+
"h-full min-w-0 flex-1 border-0 bg-transparent shadow-none focus-visible:ring-0",
|
|
4834
|
+
sizeClass
|
|
4835
|
+
),
|
|
4836
|
+
disabled,
|
|
4837
|
+
id,
|
|
4838
|
+
inputMode: "numeric",
|
|
4839
|
+
placeholder,
|
|
4840
|
+
type: "text",
|
|
4841
|
+
value: display,
|
|
4842
|
+
readOnly: true,
|
|
4843
|
+
onKeyDown,
|
|
4844
|
+
onPaste
|
|
4845
|
+
}
|
|
4846
|
+
)
|
|
4847
|
+
]
|
|
4848
|
+
}
|
|
4849
|
+
);
|
|
4850
|
+
}
|
|
4696
4851
|
var DEFAULT_LABELS2 = {
|
|
4697
4852
|
uploadAria: "Upload image",
|
|
4698
4853
|
uploadHint: "Click to upload",
|
|
@@ -7813,6 +7968,7 @@ exports.MatchReview = MatchReview;
|
|
|
7813
7968
|
exports.MetricChartCard = MetricChartCard;
|
|
7814
7969
|
exports.MetricEmptyState = MetricEmptyState;
|
|
7815
7970
|
exports.MetricSkeleton = MetricSkeleton;
|
|
7971
|
+
exports.MoneyInput = MoneyInput;
|
|
7816
7972
|
exports.NavTabs = NavTabs;
|
|
7817
7973
|
exports.NavigationProgress = NavigationProgress;
|
|
7818
7974
|
exports.NotificationBell = NotificationBell;
|
|
@@ -7851,7 +8007,9 @@ exports.TaxRegimePicker = TaxRegimePicker;
|
|
|
7851
8007
|
exports.ThemeSwitcher = ThemeSwitcher;
|
|
7852
8008
|
exports.TimeRangePicker = TimeRangePicker;
|
|
7853
8009
|
exports.WizardLayout = WizardLayout;
|
|
8010
|
+
exports.appendMoneyDigit = appendMoneyDigit;
|
|
7854
8011
|
exports.avatarFallbackStyle = avatarFallbackStyle;
|
|
8012
|
+
exports.backspaceMoneyMinor = backspaceMoneyMinor;
|
|
7855
8013
|
exports.cn = cn;
|
|
7856
8014
|
exports.cookieConsentAllowsReplay = cookieConsentAllowsReplay;
|
|
7857
8015
|
exports.cookieDomainFromHostname = cookieDomainFromHostname;
|
|
@@ -7865,6 +8023,7 @@ exports.fileMatchesAccept = fileMatchesAccept;
|
|
|
7865
8023
|
exports.filterCountries = filterCountries;
|
|
7866
8024
|
exports.filterTaxRegimes = filterTaxRegimes;
|
|
7867
8025
|
exports.formatCountryOptionLabel = formatCountryOptionLabel;
|
|
8026
|
+
exports.formatMoney = formatMoney;
|
|
7868
8027
|
exports.formatTaxRegimeOptionLabel = formatTaxRegimeOptionLabel;
|
|
7869
8028
|
exports.getAvatarColors = getAvatarColors;
|
|
7870
8029
|
exports.getInitials = getInitials;
|
|
@@ -7876,6 +8035,7 @@ exports.matchClaimIsUnverified = matchClaimIsUnverified;
|
|
|
7876
8035
|
exports.normalizeCurpInput = normalizeCurpInput;
|
|
7877
8036
|
exports.normalizeRfc = normalizeRfc;
|
|
7878
8037
|
exports.parseCookieConsent = parseCookieConsent;
|
|
8038
|
+
exports.parseMoneyToMinor = parseMoneyToMinor;
|
|
7879
8039
|
exports.partRanges = partRanges;
|
|
7880
8040
|
exports.progressFromBytes = progressFromBytes;
|
|
7881
8041
|
exports.queueRowKeyDown = queueRowKeyDown;
|