@viasat/beam-react 2.63.0 → 2.65.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 CHANGED
@@ -1,3 +1,23 @@
1
+ ## 2.65.0 (2026-09-03)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **DateField:** Imperative ref API ([#1422](https://git.viasat.com/vega/Beam/pull/1422))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Roman-Ionita, Alin
10
+
11
+ ## 2.64.0 (2026-09-01)
12
+
13
+ ### 🚀 Features
14
+
15
+ - **web-components:** real-browser test lane (WTR) + FormField name reflection fix so beam's inputs work with none beam forms ([#1425](https://git.viasat.com/vega/Beam/pull/1425))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - Evans, Joel
20
+
1
21
  ## 2.63.0 (2026-09-01)
2
22
 
3
23
  ### 🚀 Features
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Ie=require("clsx"),u=require("react"),e=require("../../../chunks/DateField.Segment.BqMaeKLk.js"),Me=require("../../../chunks/constants.CgMu0_1M.js"),Ee=require("../../../chunks/helpers.BIckGIbP.js"),Ne=require("../../../chunks/form.context.CkC0TwMb.js"),Re=require("../../Form/contexts/label.context.cjs.js"),Ce=require("../../Form/contexts/helperText.context.cjs.js"),je=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),Le=require("../../../utils/hooks/useIsMounted.cjs.js"),Oe=require("../ErrorBoundary/ErrorBoundary.cjs.js"),Be=require("./DateField.Segments.cjs.js"),C=require("./DateField.devWarnings.cjs.js"),l=require("./DateField.utils.cjs.js"),Te=require("./useDateFieldFocus.cjs.js"),Ve=require("./useDateFieldForm.cjs.js"),Pe=require("./useDateFieldKeyboard.cjs.js"),Ae=require("./useDateFieldSegments.cjs.js"),ke=require("./useDateFieldValidity.cjs.js"),Ke=require("./useDateFieldValue.cjs.js"),He=require("./useInvalidState.cjs.js"),We="MM/DD/YYYY",Ue=()=>{process.env.NODE_ENV!=="production"&&console.warn("DateField: segments failed to render; showing a static fallback.")},Ye=u.forwardRef(function({value:c,defaultValue:_,onChange:j,minDate:F,maxDate:b,getClampAnnouncement:L,locale:O,label:D=null,helperText:m=null,error:f,hideRequiredMarker:B=!1,validationRules:T,width:V,theme:g,fluid:P=!1,disabled:A=!1,readOnly:k=!1,required:K=!1,name:p,id:H,className:W,style:U,"aria-label":Y,"aria-describedby":$,"aria-labelledby":z,...G},J){const{disabled:a,readOnly:r,required:x,invalid:Q,errorMessageProvided:v,defaultValue:X,errorId:y,helperTextId:Z,validationErrorsId:ee,labelId:h,ariaDescribedBy:se,ariaLabelledBy:ae,showErrors:ie}=Ve.useDateFieldForm({name:p,disabled:A,readOnly:k,required:K,defaultValue:_,error:f,hasHelperText:!!m,hasLabel:!!D,validationRules:T,ariaDescribedBy:$,ariaLabelledBy:z});C.useDevMinMaxWarning(F,b),C.useDevInvalidValueWarning(c,_);const{refFn:le,ref:S}=je.useUniversalRef(J),{segmentRefs:te,registerSegmentRef:re}=Ae.useDateFieldSegments(),ne=O??l.DEFAULT_LOCALE,q=Le.useIsMounted(),n=l.getDateParts(q?ne:l.DEFAULT_LOCALE),w=u.useMemo(()=>l.getSegmentOrder(n),[n]),{segmentText:de,segmentValues:I,currentValue:M,wasTouched:oe,appendDigit:E,adjustSegment:ue,clearSegment:ce,beginSegmentEdit:_e,commitOnBlur:Fe,clampAnnouncement:be}=Ke.useDateFieldValue({value:c,defaultValue:X,onChange:j,minDate:F,maxDate:b,getClampAnnouncement:L}),{focusedSegment:N,fieldTabIndex:De,handleSegmentFocus:R,handleFieldFocus:me,handleFieldBlur:fe,handleFieldMouseDown:ge,focusNext:d,focusPrevious:pe}=Te.useDateFieldFocus({disabled:a,fieldRef:S,segmentRefs:te,partsOrder:w,onSegmentFocusChange:_e,onFieldBlur:Fe}),xe=Pe.useDateFieldKeyboard({disabled:a,readOnly:r,fieldRef:S,focusNext:d,focusPrevious:pe,adjustSegment:ue,clearSegment:ce}),{isInvalid:ve}=ke.useDateFieldValidity({segments:I,currentValue:M,wasTouched:oe,isFocused:N!==null}),ye=u.useCallback((i,t)=>{const{advanced:we}=E(i,t);we&&d(i)},[E,d]),o=He.useInvalidState({formInvalid:Q,valueInvalid:ve}),he=q&&Ee.isIOS()?"textbox":"spinbutton",Se=i=>{if(a)return;const t=i.target.closest("label");!t||t.id!==h||(i.preventDefault(),R(w[0]))},qe=Ie(e.styles[e.baseClassNamePrefix],g&&Me.themeClassName(g),P&&e.styles[`${e.classModifierPrefix}fluid`],o&&e.styles[`${e.classModifierPrefix}error`],a&&e.styles[`${e.classModifierPrefix}disabled`],r&&e.styles[`${e.classModifierPrefix}read-only`],W);return s.jsxs("div",{className:qe,style:{...U,maxWidth:V},onMouseDownCapture:Se,children:[s.jsx(Re.LabelProvider,{ctxId:h,ctxDisabled:a,ctxRequired:x&&!B,children:D}),s.jsx("div",{...G,ref:le,id:H,role:"group","aria-label":Y,"aria-labelledby":ae,"aria-disabled":a||void 0,"aria-required":x||void 0,"aria-invalid":o||void 0,"aria-describedby":se,"aria-errormessage":v?y:void 0,tabIndex:De,className:e.styles[e.staticDateFieldClassNames.field],onMouseDown:ge,onFocus:me,children:s.jsx(Oe.ErrorBoundary,{fallback:s.jsx("span",{className:e.styles[e.staticDateFieldClassNames.segments],children:We}),onError:Ue,children:s.jsx(Be.DateFieldSegments,{parts:n,segmentText:de,segmentValues:I,focusedSegment:N,disabled:a,readOnly:r,invalid:o,role:he,onSegmentFocus:R,onSegmentBlur:fe,onSegmentInput:ye,onSegmentKeyDown:xe,registerSegmentRef:re})})}),s.jsx("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:e.styles[e.staticDateFieldClassNames.srStatus],children:be}),s.jsx("input",{type:"hidden",name:p,value:l.toISODateString(M),disabled:a}),s.jsxs(Ce.HelperTextProvider,{ctxId:Z,ctxDisabled:a,children:[m,v&&s.jsx(Ne.HelperText,{id:y,appearance:"negative",children:f})]}),ie(ee)]})});exports.DateField=Ye;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),Le=require("clsx"),a=require("react"),e=require("../../../chunks/DateField.Segment.BqMaeKLk.js"),Oe=require("../../../chunks/constants.CgMu0_1M.js"),Te=require("../../../chunks/helpers.BIckGIbP.js"),Be=require("../../../chunks/form.context.CkC0TwMb.js"),Ve=require("../../Form/contexts/label.context.cjs.js"),Pe=require("../../Form/contexts/helperText.context.cjs.js"),Ae=require("../../../utils/hooks/useIsMounted.cjs.js"),ke=require("../../../utils/functions.cjs.js"),He=require("../ErrorBoundary/ErrorBoundary.cjs.js"),Ke=require("./DateField.Segments.cjs.js"),k=require("./DateField.devWarnings.cjs.js"),o=require("./DateField.utils.cjs.js"),We=require("./useDateFieldFocus.cjs.js"),Ye=require("./useDateFieldForm.cjs.js"),$e=require("./useDateFieldKeyboard.cjs.js"),Ue=require("./useDateFieldSegments.cjs.js"),ze=require("./useDateFieldValidity.cjs.js"),Ge=require("./useDateFieldValue.cjs.js"),Je=require("./useInvalidState.cjs.js"),Qe="MM/DD/YYYY",Xe=()=>{process.env.NODE_ENV!=="production"&&console.warn("DateField: segments failed to render; showing a static fallback.")},Ze=a.forwardRef(function({value:F,defaultValue:D,onChange:H,minDate:m,maxDate:g,getClampAnnouncement:K,locale:W,label:p=null,helperText:x=null,error:v,hideRequiredMarker:Y=!1,validationRules:$,width:U,theme:y,fluid:z=!1,disabled:G=!1,readOnly:J=!1,required:Q=!1,name:S,id:X,className:Z,style:ee,"aria-label":se,"aria-describedby":te,"aria-labelledby":ae,...le},h){const{disabled:s,readOnly:i,required:q,invalid:re,errorMessageProvided:w,defaultValue:ie,errorId:I,helperTextId:ne,validationErrorsId:oe,labelId:M,ariaDescribedBy:de,ariaLabelledBy:ue,showErrors:ce}=Ye.useDateFieldForm({name:S,disabled:G,readOnly:J,required:Q,defaultValue:D,error:v,hasHelperText:!!x,hasLabel:!!p,validationRules:$,ariaDescribedBy:te,ariaLabelledBy:ae});k.useDevMinMaxWarning(m,g),k.useDevInvalidValueWarning(F,D);const n=a.useRef(null),{segmentRefs:be,registerSegmentRef:fe}=Ue.useDateFieldSegments(),_e=W??o.DEFAULT_LOCALE,R=Ae.useIsMounted(),c=o.getDateParts(R?_e:o.DEFAULT_LOCALE),d=a.useMemo(()=>o.getSegmentOrder(c),[c]),{segmentText:Fe,segmentValues:C,currentValue:E,wasTouched:De,appendDigit:N,adjustSegment:me,clearSegment:ge,clearAll:j,beginSegmentEdit:pe,commitOnBlur:xe,clampAnnouncement:ve}=Ge.useDateFieldValue({value:F,defaultValue:ie,onChange:H,minDate:m,maxDate:g,getClampAnnouncement:K}),{focusedSegment:L,fieldTabIndex:ye,handleSegmentFocus:u,handleFieldFocus:Se,handleFieldBlur:he,handleFieldMouseDown:qe,focusNext:b,focusPrevious:we}=We.useDateFieldFocus({disabled:s,fieldRef:n,segmentRefs:be,partsOrder:d,onSegmentFocusChange:pe,onFieldBlur:xe}),Ie=$e.useDateFieldKeyboard({disabled:s,readOnly:i,fieldRef:n,focusNext:b,focusPrevious:we,adjustSegment:me,clearSegment:ge}),{isInvalid:Me}=ze.useDateFieldValidity({segments:C,currentValue:E,wasTouched:De,isFocused:L!==null}),Re=a.useCallback((t,r)=>{const{advanced:_}=N(t,r);_&&b(t)},[N,b]),f=Je.useInvalidState({formInvalid:re,valueInvalid:Me}),Ce=R&&Te.isIOS()?"textbox":"spinbutton",O=a.useCallback(t=>{s||u(d[0],t)},[s,u,d]),T=a.useCallback(()=>{var r;if(s)return;const t=document.activeElement;t instanceof HTMLElement&&t!==n.current&&((r=n.current)!=null&&r.contains(t))&&t.blur()},[s]),B=a.useCallback(()=>{s||i||j()},[s,i,j]),V=a.useRef(O),P=a.useRef(T),A=a.useRef(B);V.current=O,P.current=T,A.current=B;const Ee=a.useCallback(t=>{const r=t?Object.assign(t,{focus:_=>V.current(_),blur:()=>P.current(),clear:()=>A.current()}):null;ke.mergeRefs(n,h)(r)},[h]),Ne=t=>{if(s)return;const r=t.target.closest("label");!r||r.id!==M||(t.preventDefault(),u(d[0]))},je=Le(e.styles[e.baseClassNamePrefix],y&&Oe.themeClassName(y),z&&e.styles[`${e.classModifierPrefix}fluid`],f&&e.styles[`${e.classModifierPrefix}error`],s&&e.styles[`${e.classModifierPrefix}disabled`],i&&e.styles[`${e.classModifierPrefix}read-only`],Z);return l.jsxs("div",{className:je,style:{...ee,maxWidth:U},onMouseDownCapture:Ne,children:[l.jsx(Ve.LabelProvider,{ctxId:M,ctxDisabled:s,ctxRequired:q&&!Y,children:p}),l.jsx("div",{...le,ref:Ee,id:X,role:"group","aria-label":se,"aria-labelledby":ue,"aria-disabled":s||void 0,"aria-required":q||void 0,"aria-invalid":f||void 0,"aria-describedby":de,"aria-errormessage":w?I:void 0,tabIndex:ye,className:e.styles[e.staticDateFieldClassNames.field],onMouseDown:qe,onFocus:Se,children:l.jsx(He.ErrorBoundary,{fallback:l.jsx("span",{className:e.styles[e.staticDateFieldClassNames.segments],children:Qe}),onError:Xe,children:l.jsx(Ke.DateFieldSegments,{parts:c,segmentText:Fe,segmentValues:C,focusedSegment:L,disabled:s,readOnly:i,invalid:f,role:Ce,onSegmentFocus:u,onSegmentBlur:he,onSegmentInput:Re,onSegmentKeyDown:Ie,registerSegmentRef:fe})})}),l.jsx("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:e.styles[e.staticDateFieldClassNames.srStatus],children:ve}),l.jsx("input",{type:"hidden",name:S,value:o.toISODateString(E),disabled:s}),l.jsxs(Pe.HelperTextProvider,{ctxId:ne,ctxDisabled:s,children:[x,w&&l.jsx(Be.HelperText,{id:I,appearance:"negative",children:v})]}),ce(oe)]})});exports.DateField=Ze;
@@ -1,3 +1,3 @@
1
- import { DateFieldProps } from './DateField.types';
1
+ import { DateFieldHandle, DateFieldProps } from './DateField.types';
2
2
  /** Segmented date input. */
3
- export declare const DateField: import('react').ForwardRefExoticComponent<DateFieldProps & import('react').RefAttributes<HTMLDivElement>>;
3
+ export declare const DateField: import('react').ForwardRefExoticComponent<DateFieldProps & import('react').RefAttributes<DateFieldHandle>>;
@@ -1,245 +1,271 @@
1
- import { jsxs as B, jsx as a } from "react/jsx-runtime";
2
- import Re from "clsx";
3
- import { forwardRef as Ce, useMemo as Ee, useCallback as Oe } from "react";
4
- import { s as r, b as Be, c as i, a as m } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
5
- import { t as Le } from "../../../chunks/constants.Cruz2A1w.js";
6
- import { i as Ve } from "../../../chunks/helpers.CiQfGwdc.js";
7
- import { H as Te } from "../../../chunks/form.context.BDYA2JQs.js";
8
- import { LabelProvider as Ae } from "../../Form/contexts/label.context.es.js";
9
- import { HelperTextProvider as Pe } from "../../Form/contexts/helperText.context.es.js";
10
- import { useUniversalRef as qe } from "../../Form/hooks/useUniversalRef.hook.es.js";
11
- import { useIsMounted as Ke } from "../../../utils/hooks/useIsMounted.es.js";
12
- import { ErrorBoundary as He } from "../ErrorBoundary/ErrorBoundary.es.js";
13
- import { DateFieldSegments as We } from "./DateField.Segments.es.js";
14
- import { useDevMinMaxWarning as Ye, useDevInvalidValueWarning as _e } from "./DateField.devWarnings.es.js";
15
- import { getDateParts as $e, getSegmentOrder as je, toISODateString as ke, DEFAULT_LOCALE as L } from "./DateField.utils.es.js";
16
- import { useDateFieldFocus as Ue } from "./useDateFieldFocus.es.js";
17
- import { useDateFieldForm as ze } from "./useDateFieldForm.es.js";
18
- import { useDateFieldKeyboard as Ge } from "./useDateFieldKeyboard.es.js";
19
- import { useDateFieldSegments as Je } from "./useDateFieldSegments.es.js";
20
- import { useDateFieldValidity as Qe } from "./useDateFieldValidity.es.js";
21
- import { useDateFieldValue as Xe } from "./useDateFieldValue.es.js";
22
- import { useInvalidState as Ze } from "./useInvalidState.es.js";
23
- const ea = "MM/DD/YYYY", aa = () => {
24
- process.env.NODE_ENV !== "production" && console.warn(
25
- "DateField: segments failed to render; showing a static fallback."
26
- );
27
- }, Ma = Ce(
1
+ import { jsxs as Y, jsx as t } from "react/jsx-runtime";
2
+ import Pe from "clsx";
3
+ import { forwardRef as qe, useRef as c, useMemo as He, useCallback as o } from "react";
4
+ import { s, b as Ke, c as u, a as g } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
5
+ import { t as je } from "../../../chunks/constants.Cruz2A1w.js";
6
+ import { i as We } from "../../../chunks/helpers.CiQfGwdc.js";
7
+ import { H as Ye } from "../../../chunks/form.context.BDYA2JQs.js";
8
+ import { LabelProvider as _e } from "../../Form/contexts/label.context.es.js";
9
+ import { HelperTextProvider as $e } from "../../Form/contexts/helperText.context.es.js";
10
+ import { useIsMounted as ke } from "../../../utils/hooks/useIsMounted.es.js";
11
+ import { mergeRefs as Ue } from "../../../utils/functions.es.js";
12
+ import { ErrorBoundary as ze } from "../ErrorBoundary/ErrorBoundary.es.js";
13
+ import { DateFieldSegments as Ge } from "./DateField.Segments.es.js";
14
+ import { useDevMinMaxWarning as Je, useDevInvalidValueWarning as Qe } from "./DateField.devWarnings.es.js";
15
+ import { getDateParts as Xe, getSegmentOrder as Ze, toISODateString as er, DEFAULT_LOCALE as _ } from "./DateField.utils.es.js";
16
+ import { useDateFieldFocus as rr } from "./useDateFieldFocus.es.js";
17
+ import { useDateFieldForm as ar } from "./useDateFieldForm.es.js";
18
+ import { useDateFieldKeyboard as tr } from "./useDateFieldKeyboard.es.js";
19
+ import { useDateFieldSegments as sr } from "./useDateFieldSegments.es.js";
20
+ import { useDateFieldValidity as nr } from "./useDateFieldValidity.es.js";
21
+ import { useDateFieldValue as lr } from "./useDateFieldValue.es.js";
22
+ import { useInvalidState as or } from "./useInvalidState.es.js";
23
+ const ir = "MM/DD/YYYY", dr = () => {
24
+ process.env.NODE_ENV !== "production" && console.warn("DateField: segments failed to render; showing a static fallback.");
25
+ }, Br = qe(
28
26
  function({
29
- value: u,
30
- defaultValue: c,
31
- onChange: V,
32
- minDate: f,
33
- maxDate: p,
34
- getClampAnnouncement: T,
35
- locale: A,
36
- label: g = null,
37
- helperText: b = null,
38
- error: v,
39
- hideRequiredMarker: P = !1,
40
- validationRules: q,
41
- width: K,
42
- theme: D,
43
- fluid: H = !1,
44
- disabled: W = !1,
45
- readOnly: Y = !1,
46
- required: _ = !1,
47
- name: F,
48
- id: $,
49
- className: j,
50
- style: k,
51
- "aria-label": U,
52
- "aria-describedby": z,
53
- "aria-labelledby": G,
54
- ...J
55
- }, Q) {
27
+ value: v,
28
+ defaultValue: D,
29
+ onChange: $,
30
+ minDate: F,
31
+ maxDate: h,
32
+ getClampAnnouncement: k,
33
+ locale: U,
34
+ label: S = null,
35
+ helperText: x = null,
36
+ error: y,
37
+ hideRequiredMarker: z = !1,
38
+ validationRules: G,
39
+ width: J,
40
+ theme: I,
41
+ fluid: Q = !1,
42
+ disabled: X = !1,
43
+ readOnly: Z = !1,
44
+ required: ee = !1,
45
+ name: M,
46
+ id: re,
47
+ className: ae,
48
+ style: te,
49
+ "aria-label": se,
50
+ "aria-describedby": ne,
51
+ "aria-labelledby": le,
52
+ ...oe
53
+ }, R) {
56
54
  const {
57
55
  disabled: e,
58
- readOnly: t,
59
- required: h,
60
- invalid: X,
61
- errorMessageProvided: S,
62
- defaultValue: Z,
63
- errorId: x,
64
- helperTextId: ee,
65
- validationErrorsId: ae,
66
- labelId: y,
67
- ariaDescribedBy: re,
68
- ariaLabelledBy: se,
69
- showErrors: oe
70
- } = ze({
71
- name: F,
72
- disabled: W,
73
- readOnly: Y,
74
- required: _,
75
- defaultValue: c,
76
- error: v,
77
- hasHelperText: !!b,
78
- hasLabel: !!g,
79
- validationRules: q,
80
- ariaDescribedBy: z,
81
- ariaLabelledBy: G
56
+ readOnly: n,
57
+ required: E,
58
+ invalid: ie,
59
+ errorMessageProvided: N,
60
+ defaultValue: de,
61
+ errorId: O,
62
+ helperTextId: ce,
63
+ validationErrorsId: ue,
64
+ labelId: w,
65
+ ariaDescribedBy: me,
66
+ ariaLabelledBy: fe,
67
+ showErrors: pe
68
+ } = ar({
69
+ name: M,
70
+ disabled: X,
71
+ readOnly: Z,
72
+ required: ee,
73
+ defaultValue: D,
74
+ error: y,
75
+ hasHelperText: !!x,
76
+ hasLabel: !!S,
77
+ validationRules: G,
78
+ ariaDescribedBy: ne,
79
+ ariaLabelledBy: le
82
80
  });
83
- Ye(f, p), _e(u, c);
84
- const { refFn: ie, ref: I } = qe(Q), { segmentRefs: te, registerSegmentRef: le } = Je(), ne = A ?? L, M = Ke(), l = $e(M ? ne : L), N = Ee(() => je(l), [l]), {
85
- segmentText: de,
86
- segmentValues: w,
87
- currentValue: R,
88
- wasTouched: me,
89
- appendDigit: C,
90
- adjustSegment: ue,
91
- clearSegment: ce,
92
- beginSegmentEdit: fe,
93
- commitOnBlur: pe,
94
- clampAnnouncement: ge
95
- } = Xe({
96
- value: u,
97
- defaultValue: Z,
98
- onChange: V,
99
- minDate: f,
100
- maxDate: p,
101
- getClampAnnouncement: T
81
+ Je(F, h), Qe(v, D);
82
+ const l = c(null), { segmentRefs: be, registerSegmentRef: ge } = sr(), ve = U ?? _, C = ke(), m = Xe(C ? ve : _), i = He(() => Ze(m), [m]), {
83
+ segmentText: De,
84
+ segmentValues: L,
85
+ currentValue: B,
86
+ wasTouched: Fe,
87
+ appendDigit: V,
88
+ adjustSegment: he,
89
+ clearSegment: Se,
90
+ clearAll: T,
91
+ beginSegmentEdit: xe,
92
+ commitOnBlur: ye,
93
+ clampAnnouncement: Ie
94
+ } = lr({
95
+ value: v,
96
+ defaultValue: de,
97
+ onChange: $,
98
+ minDate: F,
99
+ maxDate: h,
100
+ getClampAnnouncement: k
102
101
  }), {
103
- focusedSegment: E,
104
- fieldTabIndex: be,
105
- handleSegmentFocus: O,
106
- handleFieldFocus: ve,
107
- handleFieldBlur: De,
108
- handleFieldMouseDown: Fe,
109
- focusNext: n,
110
- focusPrevious: he
111
- } = Ue({
102
+ focusedSegment: A,
103
+ fieldTabIndex: Me,
104
+ handleSegmentFocus: d,
105
+ handleFieldFocus: Re,
106
+ handleFieldBlur: Ee,
107
+ handleFieldMouseDown: Ne,
108
+ focusNext: f,
109
+ focusPrevious: Oe
110
+ } = rr({
112
111
  disabled: e,
113
- fieldRef: I,
114
- segmentRefs: te,
115
- partsOrder: N,
116
- onSegmentFocusChange: fe,
117
- onFieldBlur: pe
118
- }), Se = Ge({
112
+ fieldRef: l,
113
+ segmentRefs: be,
114
+ partsOrder: i,
115
+ onSegmentFocusChange: xe,
116
+ onFieldBlur: ye
117
+ }), we = tr({
119
118
  disabled: e,
120
- readOnly: t,
121
- fieldRef: I,
122
- focusNext: n,
123
- focusPrevious: he,
124
- adjustSegment: ue,
125
- clearSegment: ce
126
- }), { isInvalid: xe } = Qe({
127
- segments: w,
128
- currentValue: R,
129
- wasTouched: me,
130
- isFocused: E !== null
131
- }), ye = Oe(
132
- (s, o) => {
133
- const { advanced: we } = C(s, o);
134
- we && n(s);
119
+ readOnly: n,
120
+ fieldRef: l,
121
+ focusNext: f,
122
+ focusPrevious: Oe,
123
+ adjustSegment: he,
124
+ clearSegment: Se
125
+ }), { isInvalid: Ce } = nr({
126
+ segments: L,
127
+ currentValue: B,
128
+ wasTouched: Fe,
129
+ isFocused: A !== null
130
+ }), Le = o(
131
+ (r, a) => {
132
+ const { advanced: b } = V(r, a);
133
+ b && f(r);
135
134
  },
136
- [C, n]
137
- ), d = Ze({
138
- formInvalid: X,
139
- valueInvalid: xe
140
- }), Ie = M && Ve() ? "textbox" : "spinbutton", Me = (s) => {
135
+ [V, f]
136
+ ), p = or({
137
+ formInvalid: ie,
138
+ valueInvalid: Ce
139
+ }), Be = C && We() ? "textbox" : "spinbutton", P = o(
140
+ (r) => {
141
+ e || d(i[0], r);
142
+ },
143
+ [e, d, i]
144
+ ), q = o(() => {
145
+ var a;
146
+ if (e) return;
147
+ const r = document.activeElement;
148
+ r instanceof HTMLElement && r !== l.current && ((a = l.current) != null && a.contains(r)) && r.blur();
149
+ }, [e]), H = o(() => {
150
+ e || n || T();
151
+ }, [e, n, T]), K = c(P), j = c(q), W = c(H);
152
+ K.current = P, j.current = q, W.current = H;
153
+ const Ve = o(
154
+ (r) => {
155
+ const a = r ? Object.assign(r, {
156
+ focus: (b) => K.current(b),
157
+ blur: () => j.current(),
158
+ clear: () => W.current()
159
+ }) : null;
160
+ Ue(
161
+ l,
162
+ R
163
+ )(a);
164
+ },
165
+ [R]
166
+ ), Te = (r) => {
141
167
  if (e) return;
142
- const o = s.target.closest("label");
143
- !o || o.id !== y || (s.preventDefault(), O(N[0]));
144
- }, Ne = Re(
145
- r[Be],
146
- D && Le(D),
147
- H && r[`${i}fluid`],
148
- d && r[`${i}error`],
149
- e && r[`${i}disabled`],
150
- t && r[`${i}read-only`],
151
- j
168
+ const a = r.target.closest("label");
169
+ !a || a.id !== w || (r.preventDefault(), d(i[0]));
170
+ }, Ae = Pe(
171
+ s[Ke],
172
+ I && je(I),
173
+ Q && s[`${u}fluid`],
174
+ p && s[`${u}error`],
175
+ e && s[`${u}disabled`],
176
+ n && s[`${u}read-only`],
177
+ ae
152
178
  );
153
- return /* @__PURE__ */ B(
179
+ return /* @__PURE__ */ Y(
154
180
  "div",
155
181
  {
156
- className: Ne,
157
- style: { ...k, maxWidth: K },
158
- onMouseDownCapture: Me,
182
+ className: Ae,
183
+ style: { ...te, maxWidth: J },
184
+ onMouseDownCapture: Te,
159
185
  children: [
160
- /* @__PURE__ */ a(
161
- Ae,
186
+ /* @__PURE__ */ t(
187
+ _e,
162
188
  {
163
- ctxId: y,
189
+ ctxId: w,
164
190
  ctxDisabled: e,
165
- ctxRequired: h && !P,
166
- children: g
191
+ ctxRequired: E && !z,
192
+ children: S
167
193
  }
168
194
  ),
169
- /* @__PURE__ */ a(
195
+ /* @__PURE__ */ t(
170
196
  "div",
171
197
  {
172
- ...J,
173
- ref: ie,
174
- id: $,
198
+ ...oe,
199
+ ref: Ve,
200
+ id: re,
175
201
  role: "group",
176
- "aria-label": U,
177
- "aria-labelledby": se,
202
+ "aria-label": se,
203
+ "aria-labelledby": fe,
178
204
  "aria-disabled": e || void 0,
179
- "aria-required": h || void 0,
180
- "aria-invalid": d || void 0,
181
- "aria-describedby": re,
182
- "aria-errormessage": S ? x : void 0,
183
- tabIndex: be,
184
- className: r[m.field],
185
- onMouseDown: Fe,
186
- onFocus: ve,
187
- children: /* @__PURE__ */ a(
188
- He,
205
+ "aria-required": E || void 0,
206
+ "aria-invalid": p || void 0,
207
+ "aria-describedby": me,
208
+ "aria-errormessage": N ? O : void 0,
209
+ tabIndex: Me,
210
+ className: s[g.field],
211
+ onMouseDown: Ne,
212
+ onFocus: Re,
213
+ children: /* @__PURE__ */ t(
214
+ ze,
189
215
  {
190
- fallback: /* @__PURE__ */ a("span", { className: r[m.segments], children: ea }),
191
- onError: aa,
192
- children: /* @__PURE__ */ a(
193
- We,
216
+ fallback: /* @__PURE__ */ t("span", { className: s[g.segments], children: ir }),
217
+ onError: dr,
218
+ children: /* @__PURE__ */ t(
219
+ Ge,
194
220
  {
195
- parts: l,
196
- segmentText: de,
197
- segmentValues: w,
198
- focusedSegment: E,
221
+ parts: m,
222
+ segmentText: De,
223
+ segmentValues: L,
224
+ focusedSegment: A,
199
225
  disabled: e,
200
- readOnly: t,
201
- invalid: d,
202
- role: Ie,
203
- onSegmentFocus: O,
204
- onSegmentBlur: De,
205
- onSegmentInput: ye,
206
- onSegmentKeyDown: Se,
207
- registerSegmentRef: le
226
+ readOnly: n,
227
+ invalid: p,
228
+ role: Be,
229
+ onSegmentFocus: d,
230
+ onSegmentBlur: Ee,
231
+ onSegmentInput: Le,
232
+ onSegmentKeyDown: we,
233
+ registerSegmentRef: ge
208
234
  }
209
235
  )
210
236
  }
211
237
  )
212
238
  }
213
239
  ),
214
- /* @__PURE__ */ a(
240
+ /* @__PURE__ */ t(
215
241
  "span",
216
242
  {
217
243
  role: "status",
218
244
  "aria-live": "polite",
219
245
  "aria-atomic": "true",
220
- className: r[m.srStatus],
221
- children: ge
246
+ className: s[g.srStatus],
247
+ children: Ie
222
248
  }
223
249
  ),
224
- /* @__PURE__ */ a(
250
+ /* @__PURE__ */ t(
225
251
  "input",
226
252
  {
227
253
  type: "hidden",
228
- name: F,
229
- value: ke(R),
254
+ name: M,
255
+ value: er(B),
230
256
  disabled: e
231
257
  }
232
258
  ),
233
- /* @__PURE__ */ B(Pe, { ctxId: ee, ctxDisabled: e, children: [
234
- b,
235
- S && /* @__PURE__ */ a(Te, { id: x, appearance: "negative", children: v })
259
+ /* @__PURE__ */ Y($e, { ctxId: ce, ctxDisabled: e, children: [
260
+ x,
261
+ N && /* @__PURE__ */ t(Ye, { id: O, appearance: "negative", children: y })
236
262
  ] }),
237
- oe(ae)
263
+ pe(ue)
238
264
  ]
239
265
  }
240
266
  );
241
267
  }
242
268
  );
243
269
  export {
244
- Ma as DateField
270
+ Br as DateField
245
271
  };
@@ -31,6 +31,23 @@ export type DateFieldPart = {
31
31
  type: SegmentType | 'literal';
32
32
  value: string;
33
33
  };
34
+ /**
35
+ * The DateField `ref` value (DF-16): the field's **root DOM element**
36
+ * (`role="group"`) augmented with a `clear()` method. Keeping the ref a real
37
+ * element (not a separate handle object) means it works anywhere a DOM node is
38
+ * expected — a `Popover` / `FloatingUI` trigger, measuring, `scrollIntoView` —
39
+ * while also carrying the field's imperative API.
40
+ *
41
+ * `focus()` and `blur()` are field-aware overrides of the native element methods:
42
+ * `focus()` moves to the first segment; `blur()` exits the field (running the
43
+ * same commit / normalize / clamp as a user blur). Both no-op when the field is
44
+ * disabled. `clear()` empties every segment and fires `onChange(null)` (only
45
+ * when a value was present), and no-ops when disabled or read-only.
46
+ * (`selectAll()` is reserved for DF-13.)
47
+ */
48
+ export type DateFieldHandle = HTMLDivElement & {
49
+ clear(): void;
50
+ };
34
51
  export interface DateFieldProps extends DateFieldInputAttributes {
35
52
  /**
36
53
  * Specify HelperText for DateField
@@ -1,2 +1,2 @@
1
1
  export { DateField } from './DateField';
2
- export type { DateFieldProps } from './DateField.types';
2
+ export type { DateFieldHandle, DateFieldProps } from './DateField.types';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),P=require("./DateField.utils.cjs.js");function j({disabled:l,fieldRef:i,segmentRefs:T,partsOrder:b,onSegmentFocusChange:d,onFieldBlur:x}){const[c,o]=r.useState(null),a=b[0],y=r.useRef(c);y.current=c;const e=r.useRef(d),k=r.useRef(x);r.useEffect(()=>{e.current=d,k.current=x},[d,x]),r.useEffect(()=>{if(c===null||c==="all")return;const t=T.current.get(c);t&&document.activeElement!==t&&t.focus()},[c,T]);const E=r.useCallback(t=>{var u;l||(o(t),(u=e.current)==null||u.call(e,t))},[l]),q=r.useCallback(t=>{var u;l||t.target===i.current&&(o(a),(u=e.current)==null||u.call(e,a))},[l,i,a]),v=r.useCallback(t=>{var n,s,f,_;if((n=i.current)!=null&&n.contains(t.relatedTarget))return;const u=(f=(s=t.target)==null?void 0:s.getAttribute)==null?void 0:f.call(s,"data-segment");u&&u!==y.current||(o(null),(_=k.current)==null||_.call(k),P.clearSelectionWithin(i.current))},[i]),w=r.useCallback(t=>{var n;if(l)return;t.target.closest("[data-segment]")||(t.preventDefault(),o(a),(n=e.current)==null||n.call(e,a))},[l,a]),D=r.useCallback((t,u)=>{var f;const n=b.indexOf(t);if(n===-1)return;const s=b[n+u];s!=null&&(o(s),(f=e.current)==null||f.call(e,s))},[b]),I=r.useCallback(t=>{D(t,1)},[D]),M=r.useCallback(t=>{D(t,-1)},[D]);return{focusedSegment:c,fieldTabIndex:l?-1:c===null?0:-1,handleSegmentFocus:E,handleFieldFocus:q,handleFieldBlur:v,handleFieldMouseDown:w,focusNext:I,focusPrevious:M}}exports.useDateFieldFocus=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),P=require("./DateField.utils.cjs.js");function j({disabled:l,fieldRef:a,segmentRefs:v,partsOrder:b,onSegmentFocusChange:D,onFieldBlur:x}){const[n,o]=e.useState(null),i=b[0],y=e.useRef(n);y.current=n;const r=e.useRef(D),d=e.useRef(x);e.useEffect(()=>{r.current=D,d.current=x},[D,x]);const T=e.useRef(void 0);e.useEffect(()=>{if(n===null||n==="all")return;const t=v.current.get(n);t&&(document.activeElement!==t&&t.focus(T.current),T.current=void 0)},[n,v]);const p=e.useCallback((t,c)=>{var u;l||(T.current=c,o(t),(u=r.current)==null||u.call(r,t))},[l]),E=e.useCallback(t=>{var c;l||t.target===a.current&&(o(i),(c=r.current)==null||c.call(r,i))},[l,a,i]),q=e.useCallback(t=>{var u,s,f,_;if((u=a.current)!=null&&u.contains(t.relatedTarget))return;const c=(f=(s=t.target)==null?void 0:s.getAttribute)==null?void 0:f.call(s,"data-segment");c&&c!==y.current||(o(null),(_=d.current)==null||_.call(d),P.clearSelectionWithin(a.current))},[a]),w=e.useCallback(t=>{var u;if(l)return;t.target.closest("[data-segment]")||(t.preventDefault(),o(i),(u=r.current)==null||u.call(r,i))},[l,i]),k=e.useCallback((t,c)=>{var f;const u=b.indexOf(t);if(u===-1)return;const s=b[u+c];s!=null&&(o(s),(f=r.current)==null||f.call(r,s))},[b]),I=e.useCallback(t=>{k(t,1)},[k]),M=e.useCallback(t=>{k(t,-1)},[k]);return{focusedSegment:n,fieldTabIndex:l?-1:n===null?0:-1,handleSegmentFocus:p,handleFieldFocus:E,handleFieldBlur:q,handleFieldMouseDown:w,focusNext:I,focusPrevious:M}}exports.useDateFieldFocus=j;
@@ -14,7 +14,7 @@ export interface UseDateFieldFocusArgs {
14
14
  export interface UseDateFieldFocusReturn {
15
15
  focusedSegment: FocusTarget;
16
16
  fieldTabIndex: number;
17
- handleSegmentFocus: (segment: SegmentType) => void;
17
+ handleSegmentFocus: (segment: SegmentType, options?: FocusOptions) => void;
18
18
  handleFieldFocus: (event: FocusEvent<HTMLDivElement>) => void;
19
19
  handleFieldBlur: (event: FocusEvent<HTMLElement>) => void;
20
20
  handleFieldMouseDown: (event: MouseEvent<HTMLDivElement>) => void;
@@ -1,76 +1,75 @@
1
- import { useState as d, useRef as y, useEffect as v, useCallback as o } from "react";
2
- import { clearSelectionWithin as j } from "./DateField.utils.es.js";
3
- function H({
4
- disabled: s,
5
- fieldRef: l,
6
- segmentRefs: E,
1
+ import { useState as j, useRef as d, useEffect as k, useCallback as s } from "react";
2
+ import { clearSelectionWithin as q } from "./DateField.utils.es.js";
3
+ function J({
4
+ disabled: o,
5
+ fieldRef: f,
6
+ segmentRefs: y,
7
7
  partsOrder: x,
8
- onSegmentFocusChange: m,
9
- onFieldBlur: p
8
+ onSegmentFocusChange: v,
9
+ onFieldBlur: D
10
10
  }) {
11
- const [u, f] = d(null), i = x[0], I = y(u);
12
- I.current = u;
13
- const r = y(m), T = y(p);
14
- v(() => {
15
- r.current = m, T.current = p;
16
- }, [m, p]), v(() => {
11
+ const [u, l] = j(null), i = x[0], E = d(u);
12
+ E.current = u;
13
+ const r = d(v), p = d(D);
14
+ k(() => {
15
+ r.current = v, p.current = D;
16
+ }, [v, D]);
17
+ const m = d(void 0);
18
+ k(() => {
17
19
  if (u === null || u === "all") return;
18
- const t = E.current.get(u);
19
- t && document.activeElement !== t && t.focus();
20
- }, [u, E]);
21
- const w = o(
22
- (t) => {
20
+ const t = y.current.get(u);
21
+ t && (document.activeElement !== t && t.focus(m.current), m.current = void 0);
22
+ }, [u, y]);
23
+ const w = s(
24
+ (t, n) => {
23
25
  var c;
24
- s || (f(t), (c = r.current) == null || c.call(r, t));
26
+ o || (m.current = n, l(t), (c = r.current) == null || c.call(r, t));
25
27
  },
26
- [s]
27
- ), A = o(
28
+ [o]
29
+ ), A = s(
28
30
  (t) => {
29
- var c;
30
- s || t.target === l.current && (f(i), (c = r.current) == null || c.call(r, i));
31
+ var n;
32
+ o || t.target === f.current && (l(i), (n = r.current) == null || n.call(r, i));
31
33
  },
32
- [s, l, i]
33
- ), M = o(
34
+ [o, f, i]
35
+ ), M = s(
34
36
  (t) => {
35
- var n, e, a, k;
36
- if ((n = l.current) != null && n.contains(t.relatedTarget)) return;
37
- const c = (a = (e = t.target) == null ? void 0 : e.getAttribute) == null ? void 0 : a.call(
38
- e,
39
- "data-segment"
40
- );
41
- c && c !== I.current || (f(null), (k = T.current) == null || k.call(T), j(l.current));
37
+ var c, e, a, I;
38
+ if ((c = f.current) != null && c.contains(t.relatedTarget)) return;
39
+ const n = (a = (e = t.target) == null ? void 0 : e.getAttribute) == null ? void 0 : a.call(e, "data-segment");
40
+ n && n !== E.current || (l(null), (I = p.current) == null || I.call(p), q(f.current));
42
41
  },
43
- [l]
44
- ), N = o(
42
+ [f]
43
+ ), N = s(
45
44
  (t) => {
46
- var n;
47
- if (s) return;
48
- t.target.closest("[data-segment]") || (t.preventDefault(), f(i), (n = r.current) == null || n.call(r, i));
45
+ var c;
46
+ if (o) return;
47
+ t.target.closest("[data-segment]") || (t.preventDefault(), l(i), (c = r.current) == null || c.call(r, i));
49
48
  },
50
- [s, i]
51
- ), D = o(
52
- (t, c) => {
49
+ [o, i]
50
+ ), T = s(
51
+ (t, n) => {
53
52
  var a;
54
- const n = x.indexOf(t);
55
- if (n === -1) return;
56
- const e = x[n + c];
57
- e != null && (f(e), (a = r.current) == null || a.call(r, e));
53
+ const c = x.indexOf(t);
54
+ if (c === -1) return;
55
+ const e = x[c + n];
56
+ e != null && (l(e), (a = r.current) == null || a.call(r, e));
58
57
  },
59
58
  [x]
60
- ), P = o(
59
+ ), P = s(
61
60
  (t) => {
62
- D(t, 1);
61
+ T(t, 1);
63
62
  },
64
- [D]
65
- ), W = o(
63
+ [T]
64
+ ), W = s(
66
65
  (t) => {
67
- D(t, -1);
66
+ T(t, -1);
68
67
  },
69
- [D]
68
+ [T]
70
69
  );
71
70
  return {
72
71
  focusedSegment: u,
73
- fieldTabIndex: s ? -1 : u === null ? 0 : -1,
72
+ fieldTabIndex: o ? -1 : u === null ? 0 : -1,
74
73
  handleSegmentFocus: w,
75
74
  handleFieldFocus: A,
76
75
  handleFieldBlur: M,
@@ -80,5 +79,5 @@ function H({
80
79
  };
81
80
  }
82
81
  export {
83
- H as useDateFieldFocus
82
+ J as useDateFieldFocus
84
83
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),t=require("./DateField.utils.cjs.js"),j=require("./DateField.validation.cjs.js");function G({value:a,defaultValue:A,onChange:x,minDate:R,maxDate:y,getClampAnnouncement:V}){const N=r.useRef(a!==void 0),F=N.current,[m,h]=r.useState(()=>t.segmentTextFromValue(F?a??null:A??null)),[D,_]=r.useState(!1),[C,M]=r.useState(""),c=r.useRef(m),f=r.useRef(new Set),d=r.useRef(!1),l=r.useRef(null),v={day:t.segmentNumber("day",m.day),month:t.segmentNumber("month",m.month),year:t.segmentNumber("year",m.year)},k=t.deriveValue(v),E=r.useRef(k),p=r.useRef(F?a??null:null),g=r.useRef(x),S=r.useRef(V);r.useEffect(()=>{g.current=x,S.current=V},[x,V]),r.useEffect(()=>()=>{l.current!=null&&cancelAnimationFrame(l.current)},[]),r.useEffect(()=>{if(!N.current||d.current||t.isSameDateValue(a??null,p.current))return;p.current=a??null;const e=t.segmentTextFromValue(a??null);c.current=e,h(e),E.current=t.deriveValueFromText(e)},[a]);const b=r.useCallback(e=>{var n;const s=t.deriveValueFromText(e);t.isSameDateValue(s,E.current)||(E.current=s,(n=g.current)==null||n.call(g,s))},[]),o=r.useCallback((e,s,{replace:n})=>{const u={...c.current,[e]:s};c.current=u,h(u),_(!0),b(u),n?f.current.add(e):f.current.delete(e)},[b]),q=r.useCallback((e,s)=>{const n=f.current.has(e)?"":c.current[e],u=j.tryAppendDigit(e,n,s);return u.rejected?{advanced:!1,rejected:!0}:(o(e,u.newBuffer,{replace:u.shouldAdvance}),{advanced:u.shouldAdvance,rejected:!1})},[o]),z=r.useCallback((e,s)=>{const n=c.current,u=t.segmentNumber(e,n[e]),T=t.getDaysInMonth(t.segmentNumber("year",n.year),t.segmentNumber("month",n.month)),i=t.adjustSegmentValue(e,u,s,{daysInMonth:T,today:t.todayParts()});return i==null?!1:(d.current=!0,o(e,String(i).padStart(j.SEGMENT_MAX_LENGTH[e],"0"),{replace:!0}),!0)},[o]),I=r.useCallback(e=>c.current[e]===""?{wasEmpty:!0}:(d.current=!0,o(e,"",{replace:!1}),{wasEmpty:!1}),[o]),O=r.useCallback(e=>{d.current=!0,f.current.add(e)},[]),B=r.useCallback(()=>{var T;d.current=!1;const e=c.current,s={day:t.normalizeSegmentText("day",e.day),month:t.normalizeSegmentText("month",e.month),year:t.normalizeSegmentText("year",e.year)},n=t.deriveValueFromText(s);let u=s;if(n!=null&&D&&!t.isDateInRange(n,R,y)){const i=t.clampDateToRange(n,R,y);if(u=t.segmentTextFromValue(i),!t.isSameDateValue(i,n)){const w=((T=S.current)==null?void 0:T.call(S,i))??"";w&&(l.current!=null&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{l.current=null,M(w)}))}}c.current=u,h(u),_(!0),b(u)},[b,D,t.dateKeyOrNull(R),t.dateKeyOrNull(y)]);return{segmentText:m,segmentValues:v,currentValue:k,isControlled:F,wasTouched:D,appendDigit:q,adjustSegment:z,clearSegment:I,beginSegmentEdit:O,commitOnBlur:B,clampAnnouncement:C}}exports.useDateFieldValue=G;
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 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,
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: T,
8
- minDate: E,
9
- maxDate: R,
10
- getClampAnnouncement: V
7
+ onChange: R,
8
+ minDate: V,
9
+ maxDate: p,
10
+ getClampAnnouncement: A
11
11
  }) {
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(
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
- o.current != null && cancelAnimationFrame(o.current);
23
+ l.current != null && cancelAnimationFrame(l.current);
24
24
  },
25
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) => {
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 = D(e);
35
- v(n, j.current) || (j.current = n, (t = h.current) == null || t.call(h, n));
36
- }, []), l = a(
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 = { ...u.current, [e]: n };
39
- u.current = r, A(r), z(!0), y(r), t ? g.current.add(e) : g.current.delete(e);
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
- [y]
42
- ), L = a(
41
+ [o]
42
+ ), L = s(
43
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 });
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
- [l]
48
- ), P = a(
47
+ [d]
48
+ ), P = s(
49
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()
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 d == null ? !1 : (f.current = !0, l(e, String(d).padStart(te[e], "0"), {
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
- [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);
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 && 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(_);
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
- u.current = r, A(r), z(!0), y(r);
86
- }, [y, F, k(E), k(R)]);
88
+ c.current = r, h(r), w(!0), o(r);
89
+ }, [o, j, k(V), k(p)]);
87
90
  return {
88
- segmentText: m,
89
- segmentValues: B,
90
- currentValue: G,
91
- isControlled: p,
92
- wasTouched: F,
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
- beginSegmentEdit: X,
97
- commitOnBlur: J,
99
+ clearAll: X,
100
+ beginSegmentEdit: J,
101
+ commitOnBlur: Q,
98
102
  clampAnnouncement: H
99
103
  };
100
104
  }
101
105
  export {
102
- ue as useDateFieldValue
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.63.0",
3
+ "version": "2.65.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.63.0",
64
- "@viasat/beam-shared": "2.63.0",
65
- "@viasat/beam-styles": "2.63.0",
66
- "@viasat/beam-tokens": "2.63.0",
67
- "@viasat/beam-icons": "2.63.0",
68
- "@viasat/beam-react-claude-plugin": "2.63.0",
63
+ "@viasat/beam-fonts": "2.65.0",
64
+ "@viasat/beam-shared": "2.65.0",
65
+ "@viasat/beam-styles": "2.65.0",
66
+ "@viasat/beam-tokens": "2.65.0",
67
+ "@viasat/beam-icons": "2.65.0",
68
+ "@viasat/beam-react-claude-plugin": "2.65.0",
69
69
  "clsx": "^1.2.1",
70
70
  "@floating-ui/react": "^0.26.18",
71
71
  "@stepperize/react": "^5.1.5",