@selectwin/kit 0.1.249 → 0.1.251
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/SelectNumberField.d.ts +1 -1
- package/dist/SelectNumberField.js +12 -12
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export interface SelectNumberFieldProps {
|
|
|
6
6
|
min?: number;
|
|
7
7
|
max?: number;
|
|
8
8
|
step?: number;
|
|
9
|
-
/** Allow decimal entry
|
|
9
|
+
/** Allow decimal entry, shown with the pt-BR comma (a typed dot also works). Default false = integers. */
|
|
10
10
|
decimal?: boolean;
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
hint?: ReactNode;
|
|
@@ -6,14 +6,14 @@ import { forwardRef as r, useId as i, useState as a } from "react";
|
|
|
6
6
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
7
|
//#region src/SelectNumberField.tsx
|
|
8
8
|
var c = r(function({ label: r, value: c, onChange: l, min: u, max: d, step: f = 1, decimal: p = !1, disabled: m = !1, hint: h, error: g, onBlur: _, placeholder: v, size: y = "md", ariaLabel: b, className: x, ...S }, C) {
|
|
9
|
-
let w = i(), T = g ? `${w}-err` : h ? `${w}-hint` : void 0, E = (e) => Math.min(d ?? Infinity, Math.max(u ?? -Infinity, e)), D = (e) => Math.round(e * 1e6) / 1e6, O = c ?? 0, k = u != null && O <= u, A = d != null && O >= d, [j, M] = a(!1), [N, P] = a(""), F = p && j ? N : c == null ? "" :
|
|
10
|
-
let t = p ? e.replace(/[^\d.,-]/g, "").replace("
|
|
11
|
-
if (p && P(t),
|
|
12
|
-
let
|
|
13
|
-
Number.isFinite(
|
|
14
|
-
},
|
|
9
|
+
let w = i(), T = g ? `${w}-err` : h ? `${w}-hint` : void 0, E = (e) => Math.min(d ?? Infinity, Math.max(u ?? -Infinity, e)), D = (e) => Math.round(e * 1e6) / 1e6, O = c ?? 0, k = u != null && O <= u, A = d != null && O >= d, [j, M] = a(!1), [N, P] = a(""), F = (e) => p ? String(e).replace(".", ",") : String(e), I = p && j ? N : c == null ? "" : F(c), L = (e) => {
|
|
10
|
+
let t = p ? e.replace(/[^\d.,-]/g, "").replace(".", ",") : e.replace(/[^\d-]/g, ""), n = p ? t.replace(",", ".") : t;
|
|
11
|
+
if (p && P(t), n === "" || n === "-" || n === ".") return l(null);
|
|
12
|
+
let r = Number(n);
|
|
13
|
+
Number.isFinite(r) && l(E(r));
|
|
14
|
+
}, R = (e) => {
|
|
15
15
|
let t = E(D(O + e));
|
|
16
|
-
p && P(
|
|
16
|
+
p && P(F(t)), l(t);
|
|
17
17
|
};
|
|
18
18
|
return /* @__PURE__ */ s("div", {
|
|
19
19
|
ref: C,
|
|
@@ -37,7 +37,7 @@ var c = r(function({ label: r, value: c, onChange: l, min: u, max: d, step: f =
|
|
|
37
37
|
}),
|
|
38
38
|
label: "Diminuir",
|
|
39
39
|
disabled: m || k,
|
|
40
|
-
onClick: () =>
|
|
40
|
+
onClick: () => R(-f)
|
|
41
41
|
}),
|
|
42
42
|
/* @__PURE__ */ o("input", {
|
|
43
43
|
id: w,
|
|
@@ -47,10 +47,10 @@ var c = r(function({ label: r, value: c, onChange: l, min: u, max: d, step: f =
|
|
|
47
47
|
autoComplete: "off",
|
|
48
48
|
disabled: m,
|
|
49
49
|
placeholder: v,
|
|
50
|
-
value:
|
|
51
|
-
onChange: (e) =>
|
|
50
|
+
value: I,
|
|
51
|
+
onChange: (e) => L(e.target.value),
|
|
52
52
|
onFocus: () => {
|
|
53
|
-
M(!0), P(c == null ? "" :
|
|
53
|
+
M(!0), P(c == null ? "" : F(c));
|
|
54
54
|
},
|
|
55
55
|
onBlur: () => {
|
|
56
56
|
M(!1), _ == null || _();
|
|
@@ -65,7 +65,7 @@ var c = r(function({ label: r, value: c, onChange: l, min: u, max: d, step: f =
|
|
|
65
65
|
icon: /* @__PURE__ */ o(e, {}),
|
|
66
66
|
label: "Aumentar",
|
|
67
67
|
disabled: m || A,
|
|
68
|
-
onClick: () =>
|
|
68
|
+
onClick: () => R(f)
|
|
69
69
|
})
|
|
70
70
|
]
|
|
71
71
|
}),
|