@viasat/beam-react 2.64.0 → 2.66.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/dataTable.css +1 -1
- package/chunks/{dataTable.B_4qCCp1.js → dataTable.B2F2FRDV.js} +5 -3
- package/chunks/dataTable.I3f-w2wt.js +1 -0
- package/lib/wip/DataTable/DataTable.Body.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Body.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Cell.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Cell.es.js +1 -1
- package/lib/wip/DataTable/DataTable.ColumnHeader.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.ColumnHeader.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Footer.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Footer.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Head.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Head.es.js +27 -10
- package/lib/wip/DataTable/DataTable.Header.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Header.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Row.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Row.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Toolbar.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Toolbar.es.js +1 -1
- package/lib/wip/DataTable/DataTable.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.columns.d.ts +3 -3
- package/lib/wip/DataTable/DataTable.es.js +1 -1
- package/lib/wip/DataTable/DataTable.types.d.ts +11 -3
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.d.ts +2 -2
- package/lib/wip/DateField/DateField.es.js +220 -194
- package/lib/wip/DateField/DateField.types.d.ts +17 -0
- package/lib/wip/DateField/index.d.ts +1 -1
- package/lib/wip/DateField/useDateFieldFocus.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldFocus.d.ts +1 -1
- package/lib/wip/DateField/useDateFieldFocus.es.js +52 -53
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldValue.d.ts +7 -0
- package/lib/wip/DateField/useDateFieldValue.es.js +79 -75
- package/package.json +7 -7
- package/chunks/dataTable.B2EH91vH.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),t=require("./DateField.utils.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),t=require("./DateField.utils.cjs.js"),A=require("./DateField.validation.cjs.js");function K({value:a,defaultValue:j,onChange:R,minDate:V,maxDate:y,getClampAnnouncement:F}){const k=r.useRef(a!==void 0),h=k.current,[d,S]=r.useState(()=>t.segmentTextFromValue(h?a??null:j??null)),[D,E]=r.useState(!1),[C,M]=r.useState(""),s=r.useRef(d),f=r.useRef(new Set),g=r.useRef(!1),l=r.useRef(null),v={day:t.segmentNumber("day",d.day),month:t.segmentNumber("month",d.month),year:t.segmentNumber("year",d.year)},p=t.deriveValue(v),N=r.useRef(p),_=r.useRef(h?a??null:null),b=r.useRef(R),x=r.useRef(F);r.useEffect(()=>{b.current=R,x.current=F},[R,F]),r.useEffect(()=>()=>{l.current!=null&&cancelAnimationFrame(l.current)},[]),r.useEffect(()=>{if(!k.current||g.current||t.isSameDateValue(a??null,_.current))return;_.current=a??null;const e=t.segmentTextFromValue(a??null);s.current=e,S(e),N.current=t.deriveValueFromText(e)},[a]);const o=r.useCallback(e=>{var n;const c=t.deriveValueFromText(e);t.isSameDateValue(c,N.current)||(N.current=c,(n=b.current)==null||n.call(b,c))},[]),i=r.useCallback((e,c,{replace:n})=>{const u={...s.current,[e]:c};s.current=u,S(u),E(!0),o(u),n?f.current.add(e):f.current.delete(e)},[o]),q=r.useCallback((e,c)=>{const n=f.current.has(e)?"":s.current[e],u=A.tryAppendDigit(e,n,c);return u.rejected?{advanced:!1,rejected:!0}:(i(e,u.newBuffer,{replace:u.shouldAdvance}),{advanced:u.shouldAdvance,rejected:!1})},[i]),z=r.useCallback((e,c)=>{const n=s.current,u=t.segmentNumber(e,n[e]),T=t.getDaysInMonth(t.segmentNumber("year",n.year),t.segmentNumber("month",n.month)),m=t.adjustSegmentValue(e,u,c,{daysInMonth:T,today:t.todayParts()});return m==null?!1:(g.current=!0,i(e,String(m).padStart(A.SEGMENT_MAX_LENGTH[e],"0"),{replace:!0}),!0)},[i]),I=r.useCallback(e=>s.current[e]===""?{wasEmpty:!0}:(g.current=!0,i(e,"",{replace:!1}),{wasEmpty:!1}),[i]),O=r.useCallback(()=>{const e=t.segmentTextFromValue(null);s.current=e,S(e),E(!0),f.current.clear(),_.current=null,o(e)},[o]),B=r.useCallback(e=>{g.current=!0,f.current.add(e)},[]),G=r.useCallback(()=>{var T;g.current=!1;const e=s.current,c={day:t.normalizeSegmentText("day",e.day),month:t.normalizeSegmentText("month",e.month),year:t.normalizeSegmentText("year",e.year)},n=t.deriveValueFromText(c);let u=c;if(n!=null&&D&&!t.isDateInRange(n,V,y)){const m=t.clampDateToRange(n,V,y);if(u=t.segmentTextFromValue(m),!t.isSameDateValue(m,n)){const w=((T=x.current)==null?void 0:T.call(x,m))??"";w&&(l.current!=null&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{l.current=null,M(w)}))}}s.current=u,S(u),E(!0),o(u)},[o,D,t.dateKeyOrNull(V),t.dateKeyOrNull(y)]);return{segmentText:d,segmentValues:v,currentValue:p,isControlled:h,wasTouched:D,appendDigit:q,adjustSegment:z,clearSegment:I,clearAll:O,beginSegmentEdit:B,commitOnBlur:G,clampAnnouncement:C}}exports.useDateFieldValue=K;
|
|
@@ -65,6 +65,13 @@ export interface UseDateFieldValueReturn {
|
|
|
65
65
|
clearSegment: (type: SegmentType) => {
|
|
66
66
|
wasEmpty: boolean;
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Clears all three segments at once and fires `onChange(null)` (via
|
|
70
|
+
* `emitIfChanged`, so only when a value was present). Backs the imperative
|
|
71
|
+
* `ref.current.clear()` (DF-16); unlike `clearSegment`, it isn't tied to a
|
|
72
|
+
* focused segment.
|
|
73
|
+
*/
|
|
74
|
+
clearAll: () => void;
|
|
68
75
|
beginSegmentEdit: (type: SegmentType) => void;
|
|
69
76
|
commitOnBlur: () => void;
|
|
70
77
|
/** Polite live-region message set when the blur clamp springs a value to a bound. */
|
|
@@ -1,103 +1,107 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { segmentTextFromValue as
|
|
3
|
-
import { tryAppendDigit as
|
|
4
|
-
function
|
|
5
|
-
value:
|
|
1
|
+
import { useRef as u, useState as v, useEffect as D, useCallback as s } from "react";
|
|
2
|
+
import { segmentTextFromValue as E, segmentNumber as m, deriveValue as U, isSameDateValue as I, deriveValueFromText as M, getDaysInMonth as Y, adjustSegmentValue as Z, todayParts as $, normalizeSegmentText as z, isDateInRange as C, clampDateToRange as ee, dateKeyOrNull as k } from "./DateField.utils.es.js";
|
|
3
|
+
import { tryAppendDigit as te, SEGMENT_MAX_LENGTH as re } from "./DateField.validation.es.js";
|
|
4
|
+
function se({
|
|
5
|
+
value: a,
|
|
6
6
|
defaultValue: q,
|
|
7
|
-
onChange:
|
|
8
|
-
minDate:
|
|
9
|
-
maxDate:
|
|
10
|
-
getClampAnnouncement:
|
|
7
|
+
onChange: R,
|
|
8
|
+
minDate: V,
|
|
9
|
+
maxDate: p,
|
|
10
|
+
getClampAnnouncement: A
|
|
11
11
|
}) {
|
|
12
|
-
const
|
|
13
|
-
() =>
|
|
14
|
-
), [
|
|
15
|
-
day:
|
|
16
|
-
month:
|
|
17
|
-
year:
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, [
|
|
12
|
+
const B = u(a !== void 0), F = B.current, [f, h] = v(
|
|
13
|
+
() => E(F ? a ?? null : q ?? null)
|
|
14
|
+
), [j, w] = v(!1), [H, K] = v(""), c = u(f), g = u(/* @__PURE__ */ new Set()), x = u(!1), l = u(null), G = {
|
|
15
|
+
day: m("day", f.day),
|
|
16
|
+
month: m("month", f.month),
|
|
17
|
+
year: m("year", f.year)
|
|
18
|
+
}, O = U(G), N = u(O), b = u(F ? a ?? null : null), y = u(R), S = u(A);
|
|
19
|
+
D(() => {
|
|
20
|
+
y.current = R, S.current = A;
|
|
21
|
+
}, [R, A]), D(
|
|
22
22
|
() => () => {
|
|
23
|
-
|
|
23
|
+
l.current != null && cancelAnimationFrame(l.current);
|
|
24
24
|
},
|
|
25
25
|
[]
|
|
26
|
-
),
|
|
27
|
-
if (!
|
|
28
|
-
|
|
29
|
-
const e =
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
const
|
|
26
|
+
), D(() => {
|
|
27
|
+
if (!B.current || x.current || I(a ?? null, b.current)) return;
|
|
28
|
+
b.current = a ?? null;
|
|
29
|
+
const e = E(a ?? null);
|
|
30
|
+
c.current = e, h(e), N.current = M(e);
|
|
31
|
+
}, [a]);
|
|
32
|
+
const o = s((e) => {
|
|
33
33
|
var t;
|
|
34
|
-
const n =
|
|
35
|
-
|
|
36
|
-
}, []),
|
|
34
|
+
const n = M(e);
|
|
35
|
+
I(n, N.current) || (N.current = n, (t = y.current) == null || t.call(y, n));
|
|
36
|
+
}, []), d = s(
|
|
37
37
|
(e, n, { replace: t }) => {
|
|
38
|
-
const r = { ...
|
|
39
|
-
|
|
38
|
+
const r = { ...c.current, [e]: n };
|
|
39
|
+
c.current = r, h(r), w(!0), o(r), t ? g.current.add(e) : g.current.delete(e);
|
|
40
40
|
},
|
|
41
|
-
[
|
|
42
|
-
), L =
|
|
41
|
+
[o]
|
|
42
|
+
), L = s(
|
|
43
43
|
(e, n) => {
|
|
44
|
-
const t = g.current.has(e) ? "" :
|
|
45
|
-
return r.rejected ? { advanced: !1, rejected: !0 } : (
|
|
44
|
+
const t = g.current.has(e) ? "" : c.current[e], r = te(e, t, n);
|
|
45
|
+
return r.rejected ? { advanced: !1, rejected: !0 } : (d(e, r.newBuffer, { replace: r.shouldAdvance }), { advanced: r.shouldAdvance, rejected: !1 });
|
|
46
46
|
},
|
|
47
|
-
[
|
|
48
|
-
), P =
|
|
47
|
+
[d]
|
|
48
|
+
), P = s(
|
|
49
49
|
(e, n) => {
|
|
50
|
-
const t =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
),
|
|
54
|
-
daysInMonth:
|
|
55
|
-
today:
|
|
50
|
+
const t = c.current, r = m(e, t[e]), T = Y(
|
|
51
|
+
m("year", t.year),
|
|
52
|
+
m("month", t.month)
|
|
53
|
+
), i = Z(e, r, n, {
|
|
54
|
+
daysInMonth: T,
|
|
55
|
+
today: $()
|
|
56
56
|
});
|
|
57
|
-
return
|
|
57
|
+
return i == null ? !1 : (x.current = !0, d(e, String(i).padStart(re[e], "0"), {
|
|
58
58
|
replace: !0
|
|
59
59
|
}), !0);
|
|
60
60
|
},
|
|
61
|
-
[
|
|
62
|
-
), W =
|
|
63
|
-
(e) =>
|
|
64
|
-
[
|
|
65
|
-
), X =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
[d]
|
|
62
|
+
), W = s(
|
|
63
|
+
(e) => c.current[e] === "" ? { wasEmpty: !0 } : (x.current = !0, d(e, "", { replace: !1 }), { wasEmpty: !1 }),
|
|
64
|
+
[d]
|
|
65
|
+
), X = s(() => {
|
|
66
|
+
const e = E(null);
|
|
67
|
+
c.current = e, h(e), w(!0), g.current.clear(), b.current = null, o(e);
|
|
68
|
+
}, [o]), J = s((e) => {
|
|
69
|
+
x.current = !0, g.current.add(e);
|
|
70
|
+
}, []), Q = s(() => {
|
|
71
|
+
var T;
|
|
72
|
+
x.current = !1;
|
|
73
|
+
const e = c.current, n = {
|
|
74
|
+
day: z("day", e.day),
|
|
75
|
+
month: z("month", e.month),
|
|
76
|
+
year: z("year", e.year)
|
|
77
|
+
}, t = M(n);
|
|
75
78
|
let r = n;
|
|
76
|
-
if (t != null &&
|
|
77
|
-
const
|
|
78
|
-
if (r =
|
|
79
|
-
const _ = ((
|
|
80
|
-
_ && (
|
|
81
|
-
|
|
79
|
+
if (t != null && j && !C(t, V, p)) {
|
|
80
|
+
const i = ee(t, V, p);
|
|
81
|
+
if (r = E(i), !I(i, t)) {
|
|
82
|
+
const _ = ((T = S.current) == null ? void 0 : T.call(S, i)) ?? "";
|
|
83
|
+
_ && (l.current != null && cancelAnimationFrame(l.current), l.current = requestAnimationFrame(() => {
|
|
84
|
+
l.current = null, K(_);
|
|
82
85
|
}));
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
}, [
|
|
88
|
+
c.current = r, h(r), w(!0), o(r);
|
|
89
|
+
}, [o, j, k(V), k(p)]);
|
|
87
90
|
return {
|
|
88
|
-
segmentText:
|
|
89
|
-
segmentValues:
|
|
90
|
-
currentValue:
|
|
91
|
-
isControlled:
|
|
92
|
-
wasTouched:
|
|
91
|
+
segmentText: f,
|
|
92
|
+
segmentValues: G,
|
|
93
|
+
currentValue: O,
|
|
94
|
+
isControlled: F,
|
|
95
|
+
wasTouched: j,
|
|
93
96
|
appendDigit: L,
|
|
94
97
|
adjustSegment: P,
|
|
95
98
|
clearSegment: W,
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
clearAll: X,
|
|
100
|
+
beginSegmentEdit: J,
|
|
101
|
+
commitOnBlur: Q,
|
|
98
102
|
clampAnnouncement: H
|
|
99
103
|
};
|
|
100
104
|
}
|
|
101
105
|
export {
|
|
102
|
-
|
|
106
|
+
se as useDateFieldValue
|
|
103
107
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.66.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.66.0",
|
|
64
|
+
"@viasat/beam-shared": "2.66.0",
|
|
65
|
+
"@viasat/beam-styles": "2.66.0",
|
|
66
|
+
"@viasat/beam-tokens": "2.66.0",
|
|
67
|
+
"@viasat/beam-icons": "2.66.0",
|
|
68
|
+
"@viasat/beam-react-claude-plugin": "2.66.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 s=require("../assets/dataTable.css");const t=require("./classNames.BFQUGnCN.js"),b=require("./constants.CgMu0_1M.js"),l={"bm-light":"bm-light","bm-dark":"bm-dark","bm-inverse":"bm-inverse","bm-enterprise":"bm-enterprise","bm-consumer":"bm-consumer","bm-data-table-container":"bm-data-table-container","bm-data-table-container--bordered":"bm-data-table-container--bordered","bm-data-table-container--rounded":"bm-data-table-container--rounded","bm-data-table__toolbar":"bm-data-table__toolbar","bm-data-table":"bm-data-table","bm-data-table__header":"bm-data-table__header","bm-data-table__head":"bm-data-table__head","bm-data-table__column-header":"bm-data-table__column-header","bm-data-table__body":"bm-data-table__body","bm-data-table__row":"bm-data-table__row","bm-data-table__cell":"bm-data-table__cell","bm-data-table__footer":"bm-data-table__footer","bm-data-table--sm":"bm-data-table--sm","bm-data-table--md":"bm-data-table--md","bm-data-table--lg":"bm-data-table--lg"},d="data-table",{baseClassNamePrefix:e,classModifierPrefix:m,subElementClassPrefix:a}=t.getBEMClassNames(d),r=b.allSizes.md,o={container:`${e}-container`,toolbar:`${a}toolbar`,header:`${a}header`,head:`${a}head`,columnHeader:`${a}column-header`,body:`${a}body`,row:`${a}row`,cell:`${a}cell`,footer:`${a}footer`};exports.DEFAULT_DATATABLE_DENSITY=r;exports.baseClassNamePrefix=e;exports.classModifierPrefix=m;exports.staticDataTableClassNames=o;exports.styles=l;
|