@viasat/beam-react 2.47.0 → 2.48.0
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 +20 -0
- package/assets/DateField.css +1 -1
- package/chunks/{DateField.Segment.C2qoaY0Z.js → DateField.Segment.BVe6TzWY.js} +48 -45
- package/chunks/DateField.Segment.CnDrSK1L.js +1 -0
- package/lib/wip/DateField/DateField.Segment.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segment.d.ts +1 -1
- package/lib/wip/DateField/DateField.Segment.es.js +1 -1
- package/lib/wip/DateField/DateField.Segments.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segments.es.js +36 -31
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.es.js +185 -164
- package/lib/wip/DateField/DateField.types.d.ts +22 -3
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +49 -21
- package/lib/wip/DateField/DateField.utils.es.js +78 -66
- package/lib/wip/DateField/useDateFieldFocus.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldFocus.es.js +56 -49
- 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/useDateFieldValidity.d.ts +5 -3
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldValue.d.ts +38 -22
- package/lib/wip/DateField/useDateFieldValue.es.js +92 -85
- package/package.json +7 -7
- package/chunks/DateField.Segment.CY0jg03_.js +0 -1
|
@@ -1,96 +1,103 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { segmentTextFromValue as
|
|
3
|
-
import { tryAppendDigit as
|
|
4
|
-
function
|
|
5
|
-
value:
|
|
6
|
-
defaultValue:
|
|
7
|
-
onChange:
|
|
1
|
+
import { useRef as c, useState as w, useEffect as N, useCallback as a } from "react";
|
|
2
|
+
import { segmentTextFromValue as b, segmentNumber as i, deriveValue as Q, isSameDateValue as v, deriveValueFromText as D, getDaysInMonth as U, adjustSegmentValue as Y, todayParts as Z, normalizeSegmentText as I, isDateInRange as $, clampDateToRange as C, dateKeyOrNull as k } from "./DateField.utils.es.js";
|
|
3
|
+
import { tryAppendDigit as ee, SEGMENT_MAX_LENGTH as te } from "./DateField.validation.es.js";
|
|
4
|
+
function ue({
|
|
5
|
+
value: s,
|
|
6
|
+
defaultValue: q,
|
|
7
|
+
onChange: T,
|
|
8
|
+
minDate: E,
|
|
9
|
+
maxDate: R,
|
|
10
|
+
getClampAnnouncement: V
|
|
8
11
|
}) {
|
|
9
|
-
const
|
|
10
|
-
() =>
|
|
11
|
-
), [F,
|
|
12
|
-
day:
|
|
13
|
-
month:
|
|
14
|
-
year:
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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) => {
|
|
27
|
-
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(
|
|
31
|
-
(e, t, { replace: r }) => {
|
|
32
|
-
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);
|
|
12
|
+
const M = c(s !== void 0), p = M.current, [m, A] = w(
|
|
13
|
+
() => b(p ? s ?? null : q ?? null)
|
|
14
|
+
), [F, z] = w(!1), [H, K] = w(""), u = c(m), g = c(/* @__PURE__ */ new Set()), f = c(!1), o = c(null), B = {
|
|
15
|
+
day: i("day", m.day),
|
|
16
|
+
month: i("month", m.month),
|
|
17
|
+
year: i("year", m.year)
|
|
18
|
+
}, G = Q(B), j = c(G), O = c(p ? s ?? null : null), h = c(T), x = c(V);
|
|
19
|
+
N(() => {
|
|
20
|
+
h.current = T, x.current = V;
|
|
21
|
+
}, [T, V]), N(
|
|
22
|
+
() => () => {
|
|
23
|
+
o.current != null && cancelAnimationFrame(o.current);
|
|
34
24
|
},
|
|
35
|
-
[
|
|
36
|
-
),
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
[]
|
|
26
|
+
), N(() => {
|
|
27
|
+
if (!M.current || f.current || v(s ?? null, O.current)) return;
|
|
28
|
+
O.current = s ?? null;
|
|
29
|
+
const e = b(s ?? null);
|
|
30
|
+
u.current = e, A(e), j.current = D(e);
|
|
31
|
+
}, [s]);
|
|
32
|
+
const y = a((e) => {
|
|
33
|
+
var t;
|
|
34
|
+
const n = D(e);
|
|
35
|
+
v(n, j.current) || (j.current = n, (t = h.current) == null || t.call(h, n));
|
|
36
|
+
}, []), l = a(
|
|
37
|
+
(e, n, { replace: t }) => {
|
|
38
|
+
const r = { ...u.current, [e]: n };
|
|
39
|
+
u.current = r, A(r), z(!0), y(r), t ? g.current.add(e) : g.current.delete(e);
|
|
40
40
|
},
|
|
41
|
-
[
|
|
42
|
-
),
|
|
43
|
-
(e,
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
d("month", r.month)
|
|
47
|
-
), j = O(e, n, t, {
|
|
48
|
-
daysInMonth: z,
|
|
49
|
-
today: P()
|
|
50
|
-
});
|
|
51
|
-
return j == null ? !1 : (l.current = !0, u(
|
|
52
|
-
e,
|
|
53
|
-
String(j).padStart(X[e], "0"),
|
|
54
|
-
{ replace: !0 }
|
|
55
|
-
), !0);
|
|
56
|
-
},
|
|
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 });
|
|
41
|
+
[y]
|
|
42
|
+
), L = a(
|
|
43
|
+
(e, n) => {
|
|
44
|
+
const t = g.current.has(e) ? "" : u.current[e], r = ee(e, t, n);
|
|
45
|
+
return r.rejected ? { advanced: !1, rejected: !0 } : (l(e, r.newBuffer, { replace: r.shouldAdvance }), { advanced: r.shouldAdvance, rejected: !1 });
|
|
62
46
|
},
|
|
63
|
-
[
|
|
64
|
-
),
|
|
65
|
-
(e) => {
|
|
66
|
-
|
|
47
|
+
[l]
|
|
48
|
+
), P = a(
|
|
49
|
+
(e, n) => {
|
|
50
|
+
const t = u.current, r = i(e, t[e]), S = U(
|
|
51
|
+
i("year", t.year),
|
|
52
|
+
i("month", t.month)
|
|
53
|
+
), d = Y(e, r, n, {
|
|
54
|
+
daysInMonth: S,
|
|
55
|
+
today: Z()
|
|
56
|
+
});
|
|
57
|
+
return d == null ? !1 : (f.current = !0, l(e, String(d).padStart(te[e], "0"), {
|
|
58
|
+
replace: !0
|
|
59
|
+
}), !0);
|
|
67
60
|
},
|
|
68
|
-
[
|
|
69
|
-
),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
[l]
|
|
62
|
+
), W = a(
|
|
63
|
+
(e) => u.current[e] === "" ? { wasEmpty: !0 } : (f.current = !0, l(e, "", { replace: !1 }), { wasEmpty: !1 }),
|
|
64
|
+
[l]
|
|
65
|
+
), X = a((e) => {
|
|
66
|
+
f.current = !0, g.current.add(e);
|
|
67
|
+
}, []), J = a(() => {
|
|
68
|
+
var S;
|
|
69
|
+
f.current = !1;
|
|
70
|
+
const e = u.current, n = {
|
|
71
|
+
day: I("day", e.day),
|
|
72
|
+
month: I("month", e.month),
|
|
73
|
+
year: I("year", e.year)
|
|
74
|
+
}, t = D(n);
|
|
75
|
+
let r = n;
|
|
76
|
+
if (t != null && F && !$(t, E, R)) {
|
|
77
|
+
const d = C(t, E, R);
|
|
78
|
+
if (r = b(d), !v(d, t)) {
|
|
79
|
+
const _ = ((S = x.current) == null ? void 0 : S.call(x, d)) ?? "";
|
|
80
|
+
_ && (o.current != null && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
|
|
81
|
+
o.current = null, K(_);
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
u.current = r, A(r), z(!0), y(r);
|
|
86
|
+
}, [y, F, k(E), k(R)]);
|
|
80
87
|
return {
|
|
81
|
-
segmentText:
|
|
82
|
-
segmentValues:
|
|
83
|
-
currentValue:
|
|
84
|
-
isControlled:
|
|
88
|
+
segmentText: m,
|
|
89
|
+
segmentValues: B,
|
|
90
|
+
currentValue: G,
|
|
91
|
+
isControlled: p,
|
|
85
92
|
wasTouched: F,
|
|
86
|
-
appendDigit:
|
|
87
|
-
adjustSegment:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
appendDigit: L,
|
|
94
|
+
adjustSegment: P,
|
|
95
|
+
clearSegment: W,
|
|
96
|
+
beginSegmentEdit: X,
|
|
97
|
+
commitOnBlur: J,
|
|
98
|
+
clampAnnouncement: H
|
|
92
99
|
};
|
|
93
100
|
}
|
|
94
101
|
export {
|
|
95
|
-
|
|
102
|
+
ue as useDateFieldValue
|
|
96
103
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.48.0",
|
|
4
4
|
"description": "React component library for the Beam design system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Viasat",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@viasat/beam-fonts": "2.
|
|
64
|
-
"@viasat/beam-shared": "2.
|
|
65
|
-
"@viasat/beam-styles": "2.
|
|
66
|
-
"@viasat/beam-tokens": "2.
|
|
67
|
-
"@viasat/beam-icons": "2.
|
|
68
|
-
"@viasat/beam-react-claude-plugin": "2.
|
|
63
|
+
"@viasat/beam-fonts": "2.48.0",
|
|
64
|
+
"@viasat/beam-shared": "2.48.0",
|
|
65
|
+
"@viasat/beam-styles": "2.48.0",
|
|
66
|
+
"@viasat/beam-tokens": "2.48.0",
|
|
67
|
+
"@viasat/beam-icons": "2.48.0",
|
|
68
|
+
"@viasat/beam-react-claude-plugin": "2.48.0",
|
|
69
69
|
"clsx": "^1.2.1",
|
|
70
70
|
"@floating-ui/react": "^0.26.18",
|
|
71
71
|
"@stepperize/react": "^5.1.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var w=require("../assets/DateField.css");const N=require("react/jsx-runtime"),F=require("clsx"),d=require("react"),M=require("./classNames.DC8Ra4sw.js"),q=require("../lib/wip/DateField/DateField.utils.cjs.js"),P="date-field",{baseClassNamePrefix:R,classModifierPrefix:k,subElementClassPrefix:r}=M.getBEMClassNames(P),c={field:`${r}field`,segments:`${r}segments`,segment:`${r}segment`,separator:`${r}separator`},u={"bm-light":"bm-light","bm-dark":"bm-dark","bm-inverse":"bm-inverse","bm-enterprise":"bm-enterprise","bm-consumer":"bm-consumer","bm-date-field":"bm-date-field","bm-date-field--disabled":"bm-date-field--disabled","bm-date-field--error":"bm-date-field--error","bm-date-field__field":"bm-date-field__field","bm-date-field__segment":"bm-date-field__segment","bm-date-field--read-only":"bm-date-field--read-only","bm-date-field--fluid":"bm-date-field--fluid","bm-date-field__segments":"bm-date-field__segments","bm-date-field__separator":"bm-date-field__separator"},I={day:"day",month:"month",year:"year"},$=({type:n,value:_,valueMax:g,displayValue:t,isPlaceholder:C,isActive:a,disabled:l,readOnly:o,onFocus:p,onBlur:x,onInput:E,onKeyDown:h,segmentRef:m})=>{const s=!l&&!o,f=d.useRef(null),v=d.useCallback(e=>{f.current=e,m(e)},[m]),D=e=>{if(!s)return;const b=e.currentTarget,i=e.nativeEvent.data;i!=null&&i.length===1&&E(n,i),b.textContent!==t&&(b.textContent=t)};return d.useLayoutEffect(()=>{if(!a||!s)return;const e=f.current;e&&q.selectElementContents(e)},[t,a,s]),N.jsx("span",{ref:v,role:"spinbutton","aria-label":I[n],"aria-valuenow":_??void 0,"aria-valuemin":1,"aria-valuemax":g,"aria-valuetext":t,"aria-disabled":l||void 0,"aria-readonly":o||void 0,contentEditable:s&&a,suppressContentEditableWarning:!0,tabIndex:a?0:-1,inputMode:s?"numeric":void 0,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off","data-segment":n,"data-active":a,"data-placeholder":C,onFocus:p,onBlur:x,onInput:D,onKeyDown:e=>h(n,e),onMouseUp:e=>e.preventDefault(),className:F(u[c.segment]),children:t})};exports.DateFieldSegment=$;exports.baseClassNamePrefix=R;exports.classModifierPrefix=k;exports.staticDateFieldClassNames=c;exports.styles=u;
|