@selectwin/kit 0.1.199 → 0.1.201

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.
@@ -0,0 +1,52 @@
1
+ import { useRef as e, useState as t } from "react";
2
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ //#region src/internal/buttonParts.tsx
4
+ function a({ variant: e, size: t, inline: n, tone: r, className: i }) {
5
+ return `select-btn select-btn--${e}${t === "md" ? "" : ` select-btn--${t}`}${n ? " select-btn--auto" : ""}${r === "critical" ? " select-btn--critical" : ""}${i ? ` ${i}` : ""}`;
6
+ }
7
+ function o(n, i) {
8
+ let [a, o] = t([]), s = e(0);
9
+ return {
10
+ handlePointerDown: (e) => {
11
+ var t, r;
12
+ if (i == null || i(e), n || typeof window < "u" && (t = (r = window).matchMedia) != null && t.call(r, "(prefers-reduced-motion: reduce)").matches) return;
13
+ let a = e.currentTarget.getBoundingClientRect(), c = Math.max(a.width, a.height) * 2, l = s.current++;
14
+ o((t) => [...t, {
15
+ key: l,
16
+ style: {
17
+ width: c,
18
+ height: c,
19
+ left: e.clientX - a.left - c / 2,
20
+ top: e.clientY - a.top - c / 2
21
+ }
22
+ }]);
23
+ },
24
+ nodes: a.map((e) => /* @__PURE__ */ r("span", {
25
+ className: "select-btn__ripple",
26
+ style: e.style,
27
+ "aria-hidden": "true",
28
+ onAnimationEnd: () => o((t) => t.filter((t) => t.key !== e.key))
29
+ }, e.key))
30
+ };
31
+ }
32
+ function s({ ripples: e, loading: t = !1, icon: a, trailingIcon: o, children: s }) {
33
+ return /* @__PURE__ */ i(n, { children: [
34
+ e,
35
+ t ? /* @__PURE__ */ r("span", {
36
+ className: "select-spinner",
37
+ "aria-hidden": "true"
38
+ }) : a && /* @__PURE__ */ r("span", {
39
+ className: "select-btn__icon",
40
+ children: a
41
+ }),
42
+ /* @__PURE__ */ r("span", { children: s }),
43
+ !t && o && /* @__PURE__ */ r("span", {
44
+ className: "select-btn__icon select-btn__icon--trailing",
45
+ children: o
46
+ })
47
+ ] });
48
+ }
49
+ //#endregion
50
+ export { s as ButtonContent, a as selectButtonClass, o as useSelectRipple };
51
+
52
+ //# sourceMappingURL=buttonParts.js.map
@@ -1,9 +1,8 @@
1
- /**
2
- * Brazilian document (CPF/CNPJ) helpers. The masked value is for display only —
3
- * always send the CLEAN (digits-only) value to the backend (validation runs on
4
- * the digits; nothing upstream strips the mask for you).
5
- */
1
+ /** O valor limpo: só dígitos e letras, em maiúsculas (o CPF e o CNPJ numérico seguem só com dígitos). */
6
2
  export declare function cleanDocument(value: string | null | undefined): string;
7
3
  export declare function documentType(value: string | null | undefined): 'CPF' | 'CNPJ' | '';
8
- /** Masks for display: CPF 000.000.000-00, CNPJ 00.000.000/0000-00. */
4
+ /**
5
+ * Masks for display: CPF 000.000.000-00, CNPJ 00.000.000/0000-00 (o alfanumérico, AA.AAA.AAA/AAAA-00). Só com dígitos,
6
+ * até 11 é o CPF; com uma letra, só pode ser o CNPJ, e a máscara dele vem desde o primeiro caractere.
7
+ */
9
8
  export declare function formatDocument(value: string | null | undefined): string;
@@ -1,16 +1,17 @@
1
1
  //#region src/internal/document.ts
2
- function e(e) {
3
- return (e ?? "").replace(/\D/g, "");
2
+ var e = /^\d{11}$/, t = /^[0-9A-Z]{12}\d{2}$/;
3
+ function n(e) {
4
+ return (e ?? "").toUpperCase().replace(/[^0-9A-Z]/g, "");
4
5
  }
5
- function t(t) {
6
- let n = e(t);
7
- return n.length === 11 ? "CPF" : n.length === 14 ? "CNPJ" : "";
6
+ function r(r) {
7
+ let i = n(r);
8
+ return e.test(i) ? "CPF" : t.test(i) ? "CNPJ" : "";
8
9
  }
9
- function n(t) {
10
- let n = e(t).slice(0, 14);
11
- return n.length <= 11 ? n.replace(/^(\d{3})(\d)/, "$1.$2").replace(/^(\d{3})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1-$2") : n.replace(/^(\d{2})(\d)/, "$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1/$2").replace(/(\d{4})(\d)/, "$1-$2");
10
+ function i(e) {
11
+ let t = n(e).slice(0, 14);
12
+ return t.length <= 11 && /^\d*$/.test(t) ? t.replace(/^(\d{3})(\d)/, "$1.$2").replace(/^(\d{3})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1-$2") : t.replace(/^([0-9A-Z]{2})([0-9A-Z])/, "$1.$2").replace(/^([0-9A-Z]{2})\.([0-9A-Z]{3})([0-9A-Z])/, "$1.$2.$3").replace(/\.([0-9A-Z]{3})([0-9A-Z])/, ".$1/$2").replace(/([0-9A-Z]{4})([0-9A-Z])/, "$1-$2");
12
13
  }
13
14
  //#endregion
14
- export { e as cleanDocument, t as documentType, n as formatDocument };
15
+ export { n as cleanDocument, r as documentType, i as formatDocument };
15
16
 
16
17
  //# sourceMappingURL=document.js.map
@@ -1,8 +1,9 @@
1
+ import { SelectLocaleCode } from '../SelectLocale';
1
2
  /** Coerce a value to a finite number. The backend frequently returns money fields
2
3
  * as numeric STRINGS ("45998"), so coerce before any math/format —
3
4
  * otherwise every amount renders as R$ 0,00. */
4
5
  export declare function toNumber(value: unknown): number;
5
- /** Cents → "R$ 1.234,56". Accepts numeric strings; null/NaN → "R$ 0,00". */
6
- export declare function centsToBRL(cents: number | string | null | undefined): string;
7
- /** A reais value (already divided) → BRL string. */
8
- export declare function formatBRL(value: number): string;
6
+ /** Cents → "R$ 1.234,56" (ou "R$1,234.56" em inglês). Accepts numeric strings; null/NaN → "R$ 0,00". */
7
+ export declare function centsToBRL(cents: number | string | null | undefined, locale?: SelectLocaleCode): string;
8
+ /** A reais value (already divided) → BRL string, no idioma dado. */
9
+ export declare function formatBRL(value: number, locale?: SelectLocaleCode): string;
@@ -1,16 +1,20 @@
1
1
  //#region src/internal/money.ts
2
- var e = new Intl.NumberFormat("pt-BR", {
3
- style: "currency",
4
- currency: "BRL"
5
- });
6
- function t(e) {
2
+ var e = /* @__PURE__ */ new Map();
3
+ function t(t) {
4
+ let n = e.get(t);
5
+ return n || (n = new Intl.NumberFormat(t === "en" ? "en-US" : "pt-BR", {
6
+ style: "currency",
7
+ currency: "BRL"
8
+ }), e.set(t, n)), n;
9
+ }
10
+ function n(e) {
7
11
  let t = typeof e == "string" ? Number(e) : e;
8
12
  return typeof t == "number" && Number.isFinite(t) ? t : 0;
9
13
  }
10
- function n(n) {
11
- return e.format(t(n) / 100);
14
+ function r(e, r = "pt-BR") {
15
+ return t(r).format(n(e) / 100);
12
16
  }
13
17
  //#endregion
14
- export { n as centsToBRL, t as toNumber };
18
+ export { r as centsToBRL, n as toNumber };
15
19
 
16
20
  //# sourceMappingURL=money.js.map