@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.
- package/CHANGELOG.md +1887 -0
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.es.js +66 -68
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +9 -3
- package/lib/wip/DateField/DateField.utils.es.js +68 -64
- package/lib/wip/DateField/useDateFieldKeyboard.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldKeyboard.d.ts +6 -10
- package/lib/wip/DateField/useDateFieldKeyboard.es.js +39 -41
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldValue.d.ts +12 -15
- package/lib/wip/DateField/useDateFieldValue.es.js +47 -60
- package/package.json +8 -6
|
@@ -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
|
|
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
|
-
*
|
|
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
|
|
39
|
-
* caller (keyboard handler) knows
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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
|
-
|
|
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
|
|
2
|
-
import { segmentTextFromValue as
|
|
3
|
-
import { tryAppendDigit as
|
|
4
|
-
function
|
|
5
|
-
value:
|
|
6
|
-
defaultValue:
|
|
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 =
|
|
10
|
-
() =>
|
|
11
|
-
), [F, V] = w(!1), c =
|
|
12
|
-
day:
|
|
13
|
-
month:
|
|
14
|
-
year:
|
|
15
|
-
}, D = C(p), y =
|
|
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 ||
|
|
22
|
-
R.current =
|
|
23
|
-
const e =
|
|
24
|
-
c.current = e, S(e), y.current =
|
|
25
|
-
}, [
|
|
26
|
-
const g =
|
|
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 =
|
|
29
|
-
|
|
30
|
-
}, []),
|
|
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 ?
|
|
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 =
|
|
34
|
+
), I = o(
|
|
37
35
|
(e, t) => {
|
|
38
|
-
const r =
|
|
39
|
-
return n.rejected ? { advanced: !1, rejected: !0 } : (
|
|
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
|
-
[
|
|
42
|
-
), B =
|
|
39
|
+
[a]
|
|
40
|
+
), B = o(
|
|
43
41
|
(e, t) => {
|
|
44
|
-
const r = c.current, n =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
), j =
|
|
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:
|
|
47
|
+
today: O()
|
|
50
48
|
});
|
|
51
|
-
return j == null ? !1 : (
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
[
|
|
58
|
-
), G =
|
|
59
|
-
(e) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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:
|
|
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
|
-
|
|
89
|
-
clearSegment: L,
|
|
76
|
+
clearSegment: G,
|
|
90
77
|
beginSegmentEdit: _,
|
|
91
78
|
commitOnBlur: k
|
|
92
79
|
};
|
|
93
80
|
}
|
|
94
81
|
export {
|
|
95
|
-
|
|
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.
|
|
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.
|
|
63
|
-
"@viasat/beam-shared": "2.
|
|
64
|
-
"@viasat/beam-styles": "2.
|
|
65
|
-
"@viasat/beam-tokens": "2.
|
|
66
|
-
"@viasat/beam-icons": "2.
|
|
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",
|