@viasat/beam-react 2.46.0 → 2.47.1

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.
@@ -17,7 +17,9 @@ export interface UseDateFieldValueReturn {
17
17
  * Increments, decrements, or jumps a segment to its min/max boundary.
18
18
  *
19
19
  * - Numeric `amount` (e.g. ±1, ±5): day/month wrap modularly; year clamps
20
- * to [1, 9999]. An empty segment seeds to today's value on the first press.
20
+ * to [1, 9999]. An empty day/month segment seeds to a fixed first/last
21
+ * valid value based on direction; an empty year seeds to the current
22
+ * year.
21
23
  * - `'min'` / `'max'`: jump to the lower/upper bound. No-op on year (no
22
24
  * meaningful bound until DF-10 adds minDate/maxDate).
23
25
  *
@@ -33,24 +35,19 @@ export interface UseDateFieldValueReturn {
33
35
  */
34
36
  adjustSegment: (type: SegmentType, amount: SegmentAdjustment) => boolean;
35
37
  /**
36
- * Removes the last raw digit from the segment buffer (Backspace behaviour).
38
+ * Clears the entire segment buffer to `''` — the shared Backspace and
39
+ * Delete behaviour.
37
40
  *
38
- * Returns `{ wasEmpty: true }` when the buffer was already empty so the
39
- * caller (keyboard handler) knows to move focus to the previous segment.
40
- * Clears `replaceNextRef` for the segment so a digit typed immediately after
41
- * appends rather than replaces.
41
+ * Returns `{ wasEmpty: true }` when the buffer was already empty, without
42
+ * mutating, so the caller (keyboard handler) knows Backspace should move
43
+ * focus to the previous segment instead of clearing. Otherwise focus stays
44
+ * on the current segment. Fires `onChange(null)` via `emitIfChanged` when
45
+ * the cleared segment was part of a complete date. Clears `replaceNextRef`
46
+ * for the segment so the next digit appends.
42
47
  */
43
- deleteLastDigit: (type: SegmentType) => {
48
+ clearSegment: (type: SegmentType) => {
44
49
  wasEmpty: boolean;
45
50
  };
46
- /**
47
- * Clears the entire segment buffer to `''` (Delete behaviour).
48
- *
49
- * Focus stays on the current segment. Fires `onChange(null)` via
50
- * `emitIfChanged` when the cleared segment was part of a complete date.
51
- * Clears `replaceNextRef` for the segment so the next digit appends.
52
- */
53
- clearSegment: (type: SegmentType) => void;
54
51
  beginSegmentEdit: (type: SegmentType) => void;
55
52
  commitOnBlur: () => void;
56
53
  }
@@ -1,75 +1,63 @@
1
- import { useRef as o, useState as w, useEffect as b, useCallback as s } from "react";
2
- import { segmentTextFromValue as v, segmentNumber as d, deriveValue as C, isSameDateValue as A, deriveValueFromText as M, getDaysInMonth as H, adjustSegmentValue as O, todayParts as P, normalizeSegmentText as T } from "./DateField.utils.es.js";
3
- import { tryAppendDigit as W, SEGMENT_MAX_LENGTH as X } from "./DateField.validation.es.js";
4
- function Q({
5
- value: a,
6
- defaultValue: N,
1
+ import { useRef as s, useState as w, useEffect as b, useCallback as o } from "react";
2
+ import { segmentTextFromValue as A, segmentNumber as l, deriveValue as C, isSameDateValue as M, deriveValueFromText as N, getDaysInMonth as H, adjustSegmentValue as L, todayParts as O, normalizeSegmentText as T } from "./DateField.utils.es.js";
3
+ import { tryAppendDigit as P, SEGMENT_MAX_LENGTH as W } from "./DateField.validation.es.js";
4
+ function K({
5
+ value: u,
6
+ defaultValue: v,
7
7
  onChange: x
8
8
  }) {
9
- const E = o(a !== void 0), h = E.current, [i, S] = w(
10
- () => v(h ? a ?? null : N ?? null)
11
- ), [F, V] = w(!1), c = o(i), m = o(/* @__PURE__ */ new Set()), l = o(!1), p = {
12
- day: d("day", i.day),
13
- month: d("month", i.month),
14
- year: d("year", i.year)
15
- }, D = C(p), y = o(D), R = o(
16
- h ? a ?? null : null
17
- ), f = o(x);
9
+ const E = s(u !== void 0), h = E.current, [d, S] = w(
10
+ () => A(h ? u ?? null : v ?? null)
11
+ ), [F, V] = w(!1), c = s(d), i = s(/* @__PURE__ */ new Set()), m = s(!1), p = {
12
+ day: l("day", d.day),
13
+ month: l("month", d.month),
14
+ year: l("year", d.year)
15
+ }, D = C(p), y = s(D), R = s(h ? u ?? null : null), f = s(x);
18
16
  b(() => {
19
17
  f.current = x;
20
18
  }, [x]), b(() => {
21
- if (!E.current || l.current || A(a ?? null, R.current)) return;
22
- R.current = a ?? null;
23
- const e = v(a ?? null);
24
- c.current = e, S(e), y.current = M(e);
25
- }, [a]);
26
- const g = s((e) => {
19
+ if (!E.current || m.current || M(u ?? null, R.current)) return;
20
+ R.current = u ?? null;
21
+ const e = A(u ?? null);
22
+ c.current = e, S(e), y.current = N(e);
23
+ }, [u]);
24
+ const g = o((e) => {
27
25
  var r;
28
- const t = M(e);
29
- A(t, y.current) || (y.current = t, (r = f.current) == null || r.call(f, t));
30
- }, []), u = s(
26
+ const t = N(e);
27
+ M(t, y.current) || (y.current = t, (r = f.current) == null || r.call(f, t));
28
+ }, []), a = o(
31
29
  (e, t, { replace: r }) => {
32
30
  const n = { ...c.current, [e]: t };
33
- c.current = n, S(n), V(!0), g(n), r ? m.current.add(e) : m.current.delete(e);
31
+ c.current = n, S(n), V(!0), g(n), r ? i.current.add(e) : i.current.delete(e);
34
32
  },
35
33
  [g]
36
- ), I = s(
34
+ ), I = o(
37
35
  (e, t) => {
38
- const r = m.current.has(e) ? "" : c.current[e], n = W(e, r, t);
39
- return n.rejected ? { advanced: !1, rejected: !0 } : (u(e, n.newBuffer, { replace: n.shouldAdvance }), { advanced: n.shouldAdvance, rejected: !1 });
36
+ const r = i.current.has(e) ? "" : c.current[e], n = P(e, r, t);
37
+ return n.rejected ? { advanced: !1, rejected: !0 } : (a(e, n.newBuffer, { replace: n.shouldAdvance }), { advanced: n.shouldAdvance, rejected: !1 });
40
38
  },
41
- [u]
42
- ), B = s(
39
+ [a]
40
+ ), B = o(
43
41
  (e, t) => {
44
- const r = c.current, n = d(e, r[e]), z = H(
45
- d("year", r.year),
46
- d("month", r.month)
47
- ), j = O(e, n, t, {
42
+ const r = c.current, n = l(e, r[e]), z = H(
43
+ l("year", r.year),
44
+ l("month", r.month)
45
+ ), j = L(e, n, t, {
48
46
  daysInMonth: z,
49
- today: P()
47
+ today: O()
50
48
  });
51
- return j == null ? !1 : (l.current = !0, u(
52
- e,
53
- String(j).padStart(X[e], "0"),
54
- { replace: !0 }
55
- ), !0);
49
+ return j == null ? !1 : (m.current = !0, a(e, String(j).padStart(W[e], "0"), {
50
+ replace: !0
51
+ }), !0);
56
52
  },
57
- [u]
58
- ), G = s(
59
- (e) => {
60
- const t = c.current[e];
61
- return t === "" ? { wasEmpty: !0 } : (l.current = !0, u(e, t.slice(0, -1), { replace: !1 }), { wasEmpty: !1 });
62
- },
63
- [u]
64
- ), L = s(
65
- (e) => {
66
- c.current[e] !== "" && (l.current = !0, u(e, "", { replace: !1 }));
67
- },
68
- [u]
69
- ), _ = s((e) => {
70
- l.current = !0, m.current.add(e);
71
- }, []), k = s(() => {
72
- l.current = !1;
53
+ [a]
54
+ ), G = o(
55
+ (e) => c.current[e] === "" ? { wasEmpty: !0 } : (m.current = !0, a(e, "", { replace: !1 }), { wasEmpty: !1 }),
56
+ [a]
57
+ ), _ = o((e) => {
58
+ m.current = !0, i.current.add(e);
59
+ }, []), k = o(() => {
60
+ m.current = !1;
73
61
  const e = c.current, t = {
74
62
  day: T("day", e.day),
75
63
  month: T("month", e.month),
@@ -78,19 +66,18 @@ function Q({
78
66
  c.current = t, S(t), V(!0), g(t);
79
67
  }, [g]);
80
68
  return {
81
- segmentText: i,
69
+ segmentText: d,
82
70
  segmentValues: p,
83
71
  currentValue: D,
84
72
  isControlled: h,
85
73
  wasTouched: F,
86
74
  appendDigit: I,
87
75
  adjustSegment: B,
88
- deleteLastDigit: G,
89
- clearSegment: L,
76
+ clearSegment: G,
90
77
  beginSegmentEdit: _,
91
78
  commitOnBlur: k
92
79
  };
93
80
  }
94
81
  export {
95
- Q as useDateFieldValue
82
+ K as useDateFieldValue
96
83
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viasat/beam-react",
3
- "version": "2.46.0",
3
+ "version": "2.47.1",
4
4
  "description": "React component library for the Beam design system",
5
5
  "license": "MIT",
6
6
  "author": "Viasat",
@@ -44,6 +44,7 @@
44
44
  "custom-properties.d.cjs.js",
45
45
  "custom-properties.d.es.js",
46
46
  "README.md",
47
+ "CHANGELOG.md",
47
48
  "lib/",
48
49
  "assets/",
49
50
  "chunks/",
@@ -59,11 +60,12 @@
59
60
  "access": "public"
60
61
  },
61
62
  "dependencies": {
62
- "@viasat/beam-fonts": "2.46.0",
63
- "@viasat/beam-shared": "2.46.0",
64
- "@viasat/beam-styles": "2.46.0",
65
- "@viasat/beam-tokens": "2.46.0",
66
- "@viasat/beam-icons": "2.46.0",
63
+ "@viasat/beam-fonts": "2.47.1",
64
+ "@viasat/beam-shared": "2.47.1",
65
+ "@viasat/beam-styles": "2.47.1",
66
+ "@viasat/beam-tokens": "2.47.1",
67
+ "@viasat/beam-icons": "2.47.1",
68
+ "@viasat/beam-react-claude-plugin": "2.47.1",
67
69
  "clsx": "^1.2.1",
68
70
  "@floating-ui/react": "^0.26.18",
69
71
  "@stepperize/react": "^5.1.5",