@lettuceai/crisp 1.6.4 → 1.6.5
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/components/NumberInput.d.ts +2 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ export interface NumberInputProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* A number field with real steppers. Arrow keys step, Shift+Arrow steps by ten,
|
|
17
|
-
*
|
|
17
|
+
* typing keeps the text as typed (only an in-range number reaches onChange) and the
|
|
18
|
+
* value is clamped on blur or Enter, so a half-typed number never snaps to the minimum.
|
|
18
19
|
*/
|
|
19
20
|
export declare function NumberInput({ value, onChange, min, max, step, precision, suffix, disabled, id, className, }: NumberInputProps): import("react").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -5488,15 +5488,25 @@ function Ui({ title: e, detail: t, items: n, onPauseAll: r, onResumeAll: i, onCa
|
|
|
5488
5488
|
//#endregion
|
|
5489
5489
|
//#region src/components/NumberInput.tsx
|
|
5490
5490
|
function Wi({ value: e, onChange: t, min: n = -Infinity, max: r = Infinity, step: i = 1, precision: a, suffix: o, disabled: s, id: c, className: l }) {
|
|
5491
|
-
let { strings: u } = G(), d = q(), f = p(null), m = a ?? String(i).split(".")[1]?.length ?? 0,
|
|
5492
|
-
Number.isNaN(e) || t(Number(
|
|
5491
|
+
let { strings: u } = G(), d = q(), f = p(null), [h, g] = m(null), _ = a ?? String(i).split(".")[1]?.length ?? 0, v = (e) => Math.min(r, Math.max(n, e)), y = (e) => {
|
|
5492
|
+
Number.isNaN(e) || t(Number(v(e).toFixed(_)));
|
|
5493
|
+
}, b = (e) => Number(e.replace(",", ".")), x = (e) => {
|
|
5494
|
+
g(e);
|
|
5495
|
+
let i = b(e);
|
|
5496
|
+
e.trim() !== "" && !Number.isNaN(i) && i >= n && i <= r && t(Number(i.toFixed(_)));
|
|
5497
|
+
}, S = () => {
|
|
5498
|
+
if (h === null) return;
|
|
5499
|
+
let e = b(h);
|
|
5500
|
+
g(null), h.trim() !== "" && !Number.isNaN(e) && y(e);
|
|
5493
5501
|
};
|
|
5494
5502
|
return /* @__PURE__ */ H("div", {
|
|
5495
5503
|
className: U(J, "control-md flex items-center gap-1 px-1", s && "opacity-40", l),
|
|
5496
5504
|
children: [
|
|
5497
5505
|
/* @__PURE__ */ V("button", {
|
|
5498
5506
|
type: "button",
|
|
5499
|
-
onClick: () =>
|
|
5507
|
+
onClick: () => {
|
|
5508
|
+
g(null), y(e - i);
|
|
5509
|
+
},
|
|
5500
5510
|
disabled: s || e <= n,
|
|
5501
5511
|
"aria-label": u.numberInputDecrease,
|
|
5502
5512
|
className: "touch-target flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-fg-3 transition-colors hover:bg-fill-2 hover:text-fg disabled:pointer-events-none disabled:opacity-30",
|
|
@@ -5507,13 +5517,18 @@ function Wi({ value: e, onChange: t, min: n = -Infinity, max: r = Infinity, step
|
|
|
5507
5517
|
id: c ?? d?.id,
|
|
5508
5518
|
type: "text",
|
|
5509
5519
|
inputMode: "decimal",
|
|
5510
|
-
value: e.toFixed(
|
|
5520
|
+
value: h ?? e.toFixed(_),
|
|
5511
5521
|
disabled: s,
|
|
5512
5522
|
"aria-describedby": d?.describedBy,
|
|
5513
|
-
onChange: (e) =>
|
|
5523
|
+
onChange: (e) => x(e.target.value),
|
|
5524
|
+
onBlur: S,
|
|
5514
5525
|
onKeyDown: (t) => {
|
|
5526
|
+
if (t.key === "Enter") {
|
|
5527
|
+
S();
|
|
5528
|
+
return;
|
|
5529
|
+
}
|
|
5515
5530
|
let n = t.key === "ArrowUp" ? 1 : t.key === "ArrowDown" ? -1 : 0;
|
|
5516
|
-
n && (t.preventDefault(), g(e + n * i * (t.shiftKey ? 10 : 1)));
|
|
5531
|
+
n && (t.preventDefault(), g(null), y(e + n * i * (t.shiftKey ? 10 : 1)));
|
|
5517
5532
|
},
|
|
5518
5533
|
className: "min-w-0 flex-1 bg-transparent text-center text-base tabular-nums text-fg outline-none"
|
|
5519
5534
|
}),
|
|
@@ -5523,7 +5538,9 @@ function Wi({ value: e, onChange: t, min: n = -Infinity, max: r = Infinity, step
|
|
|
5523
5538
|
}),
|
|
5524
5539
|
/* @__PURE__ */ V("button", {
|
|
5525
5540
|
type: "button",
|
|
5526
|
-
onClick: () =>
|
|
5541
|
+
onClick: () => {
|
|
5542
|
+
g(null), y(e + i);
|
|
5543
|
+
},
|
|
5527
5544
|
disabled: s || e >= r,
|
|
5528
5545
|
"aria-label": u.numberInputIncrease,
|
|
5529
5546
|
className: "touch-target flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-fg-3 transition-colors hover:bg-fill-2 hover:text-fg disabled:pointer-events-none disabled:opacity-30",
|