@lettuceai/crisp 1.6.3 → 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.
@@ -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
- * and the value is clamped on commit rather than silently accepting nonsense.
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
@@ -3552,7 +3552,7 @@ function jr({ open: e, onClose: t, title: n, description: r, leftAction: i, righ
3552
3552
  })
3553
3553
  }),
3554
3554
  /* @__PURE__ */ H("div", {
3555
- className: U("flex items-center gap-2 px-4", I ? "pb-3 pt-1.5" : "py-4"),
3555
+ className: U("flex items-center gap-2 px-4", I ? "pb-3 pt-1.5" : "py-4 [@media(pointer:coarse)]:py-2"),
3556
3556
  children: [
3557
3557
  i && /* @__PURE__ */ V("div", {
3558
3558
  className: "shrink-0",
@@ -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, h = (e) => Math.min(r, Math.max(n, e)), g = (e) => {
5492
- Number.isNaN(e) || t(Number(h(e).toFixed(m)));
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: () => g(e - i),
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(m),
5520
+ value: h ?? e.toFixed(_),
5511
5521
  disabled: s,
5512
5522
  "aria-describedby": d?.describedBy,
5513
- onChange: (e) => g(Number(e.target.value.replace(",", "."))),
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: () => g(e + i),
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",
@@ -7430,6 +7447,12 @@ function uo({ position: e = "bottom-center", bottomInset: t = 0 } = {}) {
7430
7447
  left: 16,
7431
7448
  right: 16
7432
7449
  },
7450
+ mobileOffset: {
7451
+ bottom: `calc(env(safe-area-inset-bottom) + ${16 + t}px)`,
7452
+ top: "calc(env(safe-area-inset-top) + 16px)",
7453
+ left: 16,
7454
+ right: 16
7455
+ },
7433
7456
  toastOptions: {
7434
7457
  unstyled: !0,
7435
7458
  classNames: { toast: "w-full" }