@viasat/beam-react 2.39.3 → 2.41.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/chunks/{DateField.Segment.BVKky9IE.js → DateField.Segment.C2qoaY0Z.js} +33 -34
- package/chunks/DateField.Segment.CY0jg03_.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.d.ts +7 -2
- package/lib/wip/DateField/DateField.Segments.es.js +50 -44
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.es.js +141 -130
- package/lib/wip/DateField/DateField.types.d.ts +20 -1
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +89 -1
- package/lib/wip/DateField/DateField.utils.es.js +67 -38
- package/lib/wip/DateField/useDateFieldFocus.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldFocus.d.ts +3 -2
- package/lib/wip/DateField/useDateFieldFocus.es.js +56 -44
- package/lib/wip/DateField/useDateFieldKeyboard.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldKeyboard.d.ts +44 -0
- package/lib/wip/DateField/useDateFieldKeyboard.es.js +45 -0
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldValue.d.ts +20 -1
- package/lib/wip/DateField/useDateFieldValue.es.js +66 -50
- package/package.json +6 -6
- package/chunks/DateField.Segment.BBcn6sug.js +0 -1
|
@@ -1,62 +1,78 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { segmentTextFromValue as v, segmentNumber as
|
|
3
|
-
import { tryAppendDigit as
|
|
4
|
-
function
|
|
5
|
-
value:
|
|
6
|
-
defaultValue:
|
|
7
|
-
onChange:
|
|
1
|
+
import { useRef as u, useState as M, useEffect as N, useCallback as i } from "react";
|
|
2
|
+
import { segmentTextFromValue as v, segmentNumber as a, deriveValue as C, isSameDateValue as w, deriveValueFromText as F, getDaysInMonth as H, adjustSegmentValue as L, todayParts as O, normalizeSegmentText as E } 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: c,
|
|
6
|
+
defaultValue: I,
|
|
7
|
+
onChange: h
|
|
8
8
|
}) {
|
|
9
|
-
const
|
|
10
|
-
() => v(
|
|
11
|
-
), [B,
|
|
12
|
-
day:
|
|
13
|
-
month:
|
|
14
|
-
year:
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
if (!
|
|
22
|
-
b.current =
|
|
23
|
-
const e = v(
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
const
|
|
27
|
-
var
|
|
28
|
-
const t =
|
|
29
|
-
w(t,
|
|
30
|
-
}, []),
|
|
9
|
+
const D = u(c !== void 0), S = D.current, [d, f] = M(
|
|
10
|
+
() => v(S ? c ?? null : I ?? null)
|
|
11
|
+
), [B, T] = M(!1), r = u(d), l = u(/* @__PURE__ */ new Set()), x = u(!1), R = {
|
|
12
|
+
day: a("day", d.day),
|
|
13
|
+
month: a("month", d.month),
|
|
14
|
+
year: a("year", d.year)
|
|
15
|
+
}, j = C(R), y = u(j), b = u(
|
|
16
|
+
S ? c ?? null : null
|
|
17
|
+
), g = u(h);
|
|
18
|
+
N(() => {
|
|
19
|
+
g.current = h;
|
|
20
|
+
}, [h]), N(() => {
|
|
21
|
+
if (!D.current || x.current || w(c ?? null, b.current)) return;
|
|
22
|
+
b.current = c ?? null;
|
|
23
|
+
const e = v(c ?? null);
|
|
24
|
+
r.current = e, f(e), y.current = F(e);
|
|
25
|
+
}, [c]);
|
|
26
|
+
const s = i((e) => {
|
|
27
|
+
var n;
|
|
28
|
+
const t = F(e);
|
|
29
|
+
w(t, y.current) || (y.current = t, (n = g.current) == null || n.call(g, t));
|
|
30
|
+
}, []), G = i(
|
|
31
31
|
(e, t) => {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
return
|
|
32
|
+
const n = l.current.has(e) ? "" : r.current[e], o = P(e, n, t);
|
|
33
|
+
if (o.rejected) return { advanced: !1, rejected: !0 };
|
|
34
|
+
const m = { ...r.current, [e]: o.newBuffer };
|
|
35
|
+
return r.current = m, f(m), T(!0), s(m), o.shouldAdvance ? l.current.add(e) : l.current.delete(e), { advanced: o.shouldAdvance, rejected: !1 };
|
|
36
36
|
},
|
|
37
|
-
[
|
|
37
|
+
[s]
|
|
38
|
+
), _ = i(
|
|
39
|
+
(e, t) => {
|
|
40
|
+
const n = r.current, o = a(e, n[e]), m = H(
|
|
41
|
+
a("year", n.year),
|
|
42
|
+
a("month", n.month)
|
|
43
|
+
), A = L(e, o, t, {
|
|
44
|
+
daysInMonth: m,
|
|
45
|
+
today: O()
|
|
46
|
+
});
|
|
47
|
+
if (A == null) return !1;
|
|
48
|
+
x.current = !0;
|
|
49
|
+
const z = String(A).padStart(W[e], "0"), V = { ...n, [e]: z };
|
|
50
|
+
return r.current = V, f(V), T(!0), s(V), l.current.add(e), !0;
|
|
51
|
+
},
|
|
52
|
+
[s]
|
|
38
53
|
), k = i((e) => {
|
|
39
|
-
|
|
40
|
-
}, []),
|
|
41
|
-
|
|
42
|
-
const e =
|
|
43
|
-
day:
|
|
44
|
-
month:
|
|
45
|
-
year:
|
|
54
|
+
x.current = !0, l.current.add(e);
|
|
55
|
+
}, []), p = i(() => {
|
|
56
|
+
x.current = !1;
|
|
57
|
+
const e = r.current, t = {
|
|
58
|
+
day: E("day", e.day),
|
|
59
|
+
month: E("month", e.month),
|
|
60
|
+
year: E("year", e.year)
|
|
46
61
|
};
|
|
47
|
-
|
|
48
|
-
}, [
|
|
62
|
+
r.current = t, f(t), T(!0), s(t);
|
|
63
|
+
}, [s]);
|
|
49
64
|
return {
|
|
50
|
-
segmentText:
|
|
51
|
-
segmentValues:
|
|
52
|
-
currentValue:
|
|
53
|
-
isControlled:
|
|
65
|
+
segmentText: d,
|
|
66
|
+
segmentValues: R,
|
|
67
|
+
currentValue: j,
|
|
68
|
+
isControlled: S,
|
|
54
69
|
wasTouched: B,
|
|
55
|
-
appendDigit:
|
|
70
|
+
appendDigit: G,
|
|
71
|
+
adjustSegment: _,
|
|
56
72
|
beginSegmentEdit: k,
|
|
57
|
-
commitOnBlur:
|
|
73
|
+
commitOnBlur: p
|
|
58
74
|
};
|
|
59
75
|
}
|
|
60
76
|
export {
|
|
61
|
-
|
|
77
|
+
K as useDateFieldValue
|
|
62
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.0",
|
|
4
4
|
"description": "React component library for the Beam design system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Viasat",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"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.
|
|
62
|
+
"@viasat/beam-fonts": "2.41.0",
|
|
63
|
+
"@viasat/beam-shared": "2.41.0",
|
|
64
|
+
"@viasat/beam-styles": "2.41.0",
|
|
65
|
+
"@viasat/beam-tokens": "2.41.0",
|
|
66
|
+
"@viasat/beam-icons": "2.41.0",
|
|
67
67
|
"clsx": "^1.2.1",
|
|
68
68
|
"@floating-ui/react": "^0.26.18",
|
|
69
69
|
"@stepperize/react": "^5.1.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var y=require("../assets/DateField.css");const v=require("react/jsx-runtime"),N=require("clsx"),d=require("react"),M=require("./classNames.DC8Ra4sw.js"),D=require("../lib/wip/DateField/DateField.utils.cjs.js"),F="date-field",{baseClassNamePrefix:R,classModifierPrefix:q,subElementClassPrefix:r}=M.getBEMClassNames(F),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:31,month:12,year:9999},P={day:"day",month:"month",year:"year"},k=({type:n,value:_,displayValue:t,isPlaceholder:g,isActive:a,disabled:l,readOnly:o,onFocus:C,onBlur:p,onInput:x,segmentRef:m})=>{const s=!l&&!o,f=d.useRef(null),E=d.useCallback(e=>{f.current=e,m(e)},[m]),h=e=>{if(!s)return;const b=e.currentTarget,i=e.nativeEvent.data;i!=null&&i.length===1&&x(n,i),b.textContent!==t&&(b.textContent=t)};return d.useLayoutEffect(()=>{if(!a||!s)return;const e=f.current;e&&D.selectElementContents(e)},[t,a,s]),v.jsx("span",{ref:E,role:"spinbutton","aria-label":P[n],"aria-valuenow":_??void 0,"aria-valuemin":1,"aria-valuemax":I[n],"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":g,onFocus:C,onBlur:p,onInput:h,onMouseUp:e=>e.preventDefault(),className:N(u[c.segment]),children:t})};exports.DateFieldSegment=k;exports.baseClassNamePrefix=R;exports.classModifierPrefix=q;exports.staticDateFieldClassNames=c;exports.styles=u;
|