@yenio-pld/blocks 1.2.0-rc.16 → 1.2.0-rc.18

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 CHANGED
@@ -179,6 +179,32 @@ function avatarFallbackStyle(name) {
179
179
  function cn(...inputs) {
180
180
  return tailwindMerge.twMerge(clsx.clsx(inputs));
181
181
  }
182
+ var SIZE_CLASS = {
183
+ sm: "max-w-[140px]",
184
+ md: "max-w-[220px]",
185
+ lg: "max-w-[280px]"
186
+ };
187
+ function ProductIllustration({
188
+ src,
189
+ alt = "",
190
+ className,
191
+ size = "md"
192
+ }) {
193
+ return /* @__PURE__ */ jsxRuntime.jsx(
194
+ "img",
195
+ {
196
+ src,
197
+ alt,
198
+ loading: "lazy",
199
+ decoding: "async",
200
+ className: cn(
201
+ "mx-auto h-auto w-full object-contain",
202
+ SIZE_CLASS[size],
203
+ className
204
+ )
205
+ }
206
+ );
207
+ }
182
208
  function LoadingState({
183
209
  label,
184
210
  className
@@ -236,6 +262,7 @@ function EmptyState({
236
262
  description,
237
263
  action,
238
264
  icon: Icon = lucideReact.Inbox,
265
+ illustration,
239
266
  variant = "default",
240
267
  className
241
268
  }) {
@@ -250,7 +277,14 @@ function EmptyState({
250
277
  ),
251
278
  children: [
252
279
  /* @__PURE__ */ jsxRuntime.jsxs(empty_js.EmptyHeader, { className: "gap-3", children: [
253
- /* @__PURE__ */ jsxRuntime.jsx(
280
+ illustration ? /* @__PURE__ */ jsxRuntime.jsx(empty_js.EmptyMedia, { variant: "default", className: "mb-0 w-full max-w-[240px]", children: /* @__PURE__ */ jsxRuntime.jsx(
281
+ ProductIllustration,
282
+ {
283
+ src: illustration.src,
284
+ alt: illustration.alt ?? "",
285
+ size: isCompact ? "sm" : "md"
286
+ }
287
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx(
254
288
  empty_js.EmptyMedia,
255
289
  {
256
290
  variant: "icon",
@@ -603,6 +637,7 @@ function DataTableBody({
603
637
  rowKey,
604
638
  emptyTitle,
605
639
  emptyDescription,
640
+ emptyIllustration,
606
641
  skeletonRows
607
642
  }) {
608
643
  switch (mode) {
@@ -621,7 +656,8 @@ function DataTableBody({
621
656
  {
622
657
  variant: "compact",
623
658
  title: emptyTitle,
624
- description: emptyDescription
659
+ description: emptyDescription,
660
+ illustration: emptyIllustration
625
661
  }
626
662
  ) }) });
627
663
  case "rows":
@@ -646,6 +682,7 @@ function DataTable({
646
682
  toolbar,
647
683
  emptyTitle,
648
684
  emptyDescription,
685
+ emptyIllustration,
649
686
  loading = false,
650
687
  skeletonRows = DATA_TABLE_DEFAULT_SKELETON_ROWS,
651
688
  loadMore,
@@ -667,6 +704,7 @@ function DataTable({
667
704
  rowKey,
668
705
  emptyTitle,
669
706
  emptyDescription,
707
+ emptyIllustration,
670
708
  skeletonRows
671
709
  }
672
710
  ) })
@@ -4655,6 +4693,161 @@ function PhoneInput({
4655
4693
  }
4656
4694
  );
4657
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
+ }
4658
4851
  var DEFAULT_LABELS2 = {
4659
4852
  uploadAria: "Upload image",
4660
4853
  uploadHint: "Click to upload",
@@ -6673,7 +6866,7 @@ function OptionRow({
6673
6866
  ),
6674
6867
  ...props,
6675
6868
  children: [
6676
- icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-5", children: icon }) : null,
6869
+ icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground [&_img]:size-9 [&_img]:object-contain [&_svg]:size-5", children: icon }) : null,
6677
6870
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
6678
6871
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-wrap items-center gap-2", children: [
6679
6872
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-foreground", children: title }),
@@ -7110,7 +7303,7 @@ function SectionCard({
7110
7303
  ] }),
7111
7304
  headerAction ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: headerAction }) : null
7112
7305
  ] }),
7113
- /* @__PURE__ */ jsxRuntime.jsx(card_js.CardContent, { children }),
7306
+ children != null ? /* @__PURE__ */ jsxRuntime.jsx(card_js.CardContent, { children }) : null,
7114
7307
  footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end border-t border-border/60 px-6 pb-6 pt-4", children: footer }) : null
7115
7308
  ]
7116
7309
  }
@@ -7775,6 +7968,7 @@ exports.MatchReview = MatchReview;
7775
7968
  exports.MetricChartCard = MetricChartCard;
7776
7969
  exports.MetricEmptyState = MetricEmptyState;
7777
7970
  exports.MetricSkeleton = MetricSkeleton;
7971
+ exports.MoneyInput = MoneyInput;
7778
7972
  exports.NavTabs = NavTabs;
7779
7973
  exports.NavigationProgress = NavigationProgress;
7780
7974
  exports.NotificationBell = NotificationBell;
@@ -7785,6 +7979,7 @@ exports.PageTitleSkeleton = PageTitleSkeleton;
7785
7979
  exports.PaginatedCombobox = PaginatedCombobox;
7786
7980
  exports.PasswordInput = PasswordInput;
7787
7981
  exports.PhoneInput = PhoneInput;
7982
+ exports.ProductIllustration = ProductIllustration;
7788
7983
  exports.QueueLayout = QueueLayout;
7789
7984
  exports.RfcInput = RfcInput;
7790
7985
  exports.RiskBadge = RiskBadge;
@@ -7812,7 +8007,9 @@ exports.TaxRegimePicker = TaxRegimePicker;
7812
8007
  exports.ThemeSwitcher = ThemeSwitcher;
7813
8008
  exports.TimeRangePicker = TimeRangePicker;
7814
8009
  exports.WizardLayout = WizardLayout;
8010
+ exports.appendMoneyDigit = appendMoneyDigit;
7815
8011
  exports.avatarFallbackStyle = avatarFallbackStyle;
8012
+ exports.backspaceMoneyMinor = backspaceMoneyMinor;
7816
8013
  exports.cn = cn;
7817
8014
  exports.cookieConsentAllowsReplay = cookieConsentAllowsReplay;
7818
8015
  exports.cookieDomainFromHostname = cookieDomainFromHostname;
@@ -7826,6 +8023,7 @@ exports.fileMatchesAccept = fileMatchesAccept;
7826
8023
  exports.filterCountries = filterCountries;
7827
8024
  exports.filterTaxRegimes = filterTaxRegimes;
7828
8025
  exports.formatCountryOptionLabel = formatCountryOptionLabel;
8026
+ exports.formatMoney = formatMoney;
7829
8027
  exports.formatTaxRegimeOptionLabel = formatTaxRegimeOptionLabel;
7830
8028
  exports.getAvatarColors = getAvatarColors;
7831
8029
  exports.getInitials = getInitials;
@@ -7837,6 +8035,7 @@ exports.matchClaimIsUnverified = matchClaimIsUnverified;
7837
8035
  exports.normalizeCurpInput = normalizeCurpInput;
7838
8036
  exports.normalizeRfc = normalizeRfc;
7839
8037
  exports.parseCookieConsent = parseCookieConsent;
8038
+ exports.parseMoneyToMinor = parseMoneyToMinor;
7840
8039
  exports.partRanges = partRanges;
7841
8040
  exports.progressFromBytes = progressFromBytes;
7842
8041
  exports.queueRowKeyDown = queueRowKeyDown;