@viasat/beam-react 2.67.1 → 2.69.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/assets/DateField.css +1 -1
  3. package/chunks/DateField.Segment.BP4uMe6e.js +1 -0
  4. package/chunks/{DateField.Segment.BMXzpxgl.js → DateField.Segment.Dtgriddw.js} +56 -51
  5. package/index.cjs.js +1 -1
  6. package/index.es.js +28 -26
  7. package/lib/DateField/DateField.Segment.cjs.js +1 -0
  8. package/lib/{wip/DateField → DateField}/DateField.Segment.d.ts +1 -1
  9. package/lib/DateField/DateField.Segment.es.js +9 -0
  10. package/lib/DateField/DateField.Segments.cjs.js +1 -0
  11. package/lib/{wip/DateField → DateField}/DateField.Segments.d.ts +3 -1
  12. package/lib/DateField/DateField.Segments.es.js +74 -0
  13. package/lib/DateField/DateField.cjs.js +1 -0
  14. package/lib/DateField/DateField.es.js +274 -0
  15. package/lib/{wip/DateField → DateField}/DateField.types.d.ts +37 -46
  16. package/lib/DateField/DateField.utils.cjs.js +1 -0
  17. package/lib/{wip/DateField → DateField}/DateField.utils.d.ts +10 -22
  18. package/lib/{wip/DateField → DateField}/DateField.utils.es.js +3 -5
  19. package/lib/{wip/DateField → DateField}/DateField.validation.d.ts +2 -2
  20. package/lib/DateField/useDateFieldFocus.cjs.js +1 -0
  21. package/lib/{wip/DateField → DateField}/useDateFieldFocus.es.js +17 -14
  22. package/lib/DateField/useDateFieldForm.cjs.js +1 -0
  23. package/lib/{wip/DateField → DateField}/useDateFieldForm.d.ts +1 -1
  24. package/lib/{wip/DateField → DateField}/useDateFieldForm.es.js +5 -5
  25. package/lib/{wip/DateField → DateField}/useDateFieldKeyboard.d.ts +2 -5
  26. package/lib/{wip/DateField → DateField}/useDateFieldValue.cjs.js +1 -1
  27. package/lib/DateField/useDateFieldValue.d.ts +44 -0
  28. package/lib/{wip/DateField → DateField}/useInvalidState.d.ts +5 -4
  29. package/lib/index.cjs.js +1 -1
  30. package/lib/index.d.ts +1 -0
  31. package/lib/index.es.js +20 -18
  32. package/lib/wip/index.cjs.js +1 -1
  33. package/lib/wip/index.d.ts +0 -2
  34. package/lib/wip/index.es.js +15 -19
  35. package/package.json +7 -7
  36. package/chunks/DateField.Segment.BqMaeKLk.js +0 -1
  37. package/lib/wip/DateField/DateField.Segment.cjs.js +0 -1
  38. package/lib/wip/DateField/DateField.Segment.es.js +0 -9
  39. package/lib/wip/DateField/DateField.Segments.cjs.js +0 -1
  40. package/lib/wip/DateField/DateField.Segments.es.js +0 -71
  41. package/lib/wip/DateField/DateField.cjs.js +0 -1
  42. package/lib/wip/DateField/DateField.es.js +0 -271
  43. package/lib/wip/DateField/DateField.utils.cjs.js +0 -1
  44. package/lib/wip/DateField/useDateFieldFocus.cjs.js +0 -1
  45. package/lib/wip/DateField/useDateFieldForm.cjs.js +0 -1
  46. package/lib/wip/DateField/useDateFieldValue.d.ts +0 -80
  47. /package/lib/{wip/DateField → DateField}/DateField.d.ts +0 -0
  48. /package/lib/{wip/DateField → DateField}/DateField.devWarnings.cjs.js +0 -0
  49. /package/lib/{wip/DateField → DateField}/DateField.devWarnings.d.ts +0 -0
  50. /package/lib/{wip/DateField → DateField}/DateField.devWarnings.es.js +0 -0
  51. /package/lib/{wip/DateField → DateField}/DateField.types.cjs.js +0 -0
  52. /package/lib/{wip/DateField → DateField}/DateField.types.es.js +0 -0
  53. /package/lib/{wip/DateField → DateField}/DateField.validation.cjs.js +0 -0
  54. /package/lib/{wip/DateField → DateField}/DateField.validation.es.js +0 -0
  55. /package/lib/{wip/DateField → DateField}/index.cjs.js +0 -0
  56. /package/lib/{wip/DateField → DateField}/index.d.ts +0 -0
  57. /package/lib/{wip/DateField → DateField}/index.es.js +0 -0
  58. /package/lib/{wip/DateField → DateField}/useDateFieldFocus.d.ts +0 -0
  59. /package/lib/{wip/DateField → DateField}/useDateFieldKeyboard.cjs.js +0 -0
  60. /package/lib/{wip/DateField → DateField}/useDateFieldKeyboard.es.js +0 -0
  61. /package/lib/{wip/DateField → DateField}/useDateFieldSegments.cjs.js +0 -0
  62. /package/lib/{wip/DateField → DateField}/useDateFieldSegments.d.ts +0 -0
  63. /package/lib/{wip/DateField → DateField}/useDateFieldSegments.es.js +0 -0
  64. /package/lib/{wip/DateField → DateField}/useDateFieldValidity.cjs.js +0 -0
  65. /package/lib/{wip/DateField → DateField}/useDateFieldValidity.d.ts +0 -0
  66. /package/lib/{wip/DateField → DateField}/useDateFieldValidity.es.js +0 -0
  67. /package/lib/{wip/DateField → DateField}/useDateFieldValue.es.js +0 -0
  68. /package/lib/{wip/DateField → DateField}/useInvalidState.cjs.js +0 -0
  69. /package/lib/{wip/DateField → DateField}/useInvalidState.es.js +0 -0
  70. /package/lib/{wip/ErrorBoundary → _ErrorBoundary}/ErrorBoundary.cjs.js +0 -0
  71. /package/lib/{wip/ErrorBoundary → _ErrorBoundary}/ErrorBoundary.d.ts +0 -0
  72. /package/lib/{wip/ErrorBoundary → _ErrorBoundary}/ErrorBoundary.es.js +0 -0
  73. /package/lib/{wip/ErrorBoundary → _ErrorBoundary}/index.cjs.js +0 -0
  74. /package/lib/{wip/ErrorBoundary → _ErrorBoundary}/index.d.ts +0 -0
  75. /package/lib/{wip/ErrorBoundary → _ErrorBoundary}/index.es.js +0 -0
@@ -1,271 +0,0 @@
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(
26
- function({
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) {
54
- const {
55
- disabled: e,
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
80
- });
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
101
- }), {
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({
111
- disabled: e,
112
- fieldRef: l,
113
- segmentRefs: be,
114
- partsOrder: i,
115
- onSegmentFocusChange: xe,
116
- onFieldBlur: ye
117
- }), we = tr({
118
- disabled: e,
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);
134
- },
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) => {
167
- if (e) return;
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
178
- );
179
- return /* @__PURE__ */ Y(
180
- "div",
181
- {
182
- className: Ae,
183
- style: { ...te, maxWidth: J },
184
- onMouseDownCapture: Te,
185
- children: [
186
- /* @__PURE__ */ t(
187
- _e,
188
- {
189
- ctxId: w,
190
- ctxDisabled: e,
191
- ctxRequired: E && !z,
192
- children: S
193
- }
194
- ),
195
- /* @__PURE__ */ t(
196
- "div",
197
- {
198
- ...oe,
199
- ref: Ve,
200
- id: re,
201
- role: "group",
202
- "aria-label": se,
203
- "aria-labelledby": fe,
204
- "aria-disabled": e || void 0,
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,
215
- {
216
- fallback: /* @__PURE__ */ t("span", { className: s[g.segments], children: ir }),
217
- onError: dr,
218
- children: /* @__PURE__ */ t(
219
- Ge,
220
- {
221
- parts: m,
222
- segmentText: De,
223
- segmentValues: L,
224
- focusedSegment: A,
225
- disabled: e,
226
- readOnly: n,
227
- invalid: p,
228
- role: Be,
229
- onSegmentFocus: d,
230
- onSegmentBlur: Ee,
231
- onSegmentInput: Le,
232
- onSegmentKeyDown: we,
233
- registerSegmentRef: ge
234
- }
235
- )
236
- }
237
- )
238
- }
239
- ),
240
- /* @__PURE__ */ t(
241
- "span",
242
- {
243
- role: "status",
244
- "aria-live": "polite",
245
- "aria-atomic": "true",
246
- className: s[g.srStatus],
247
- children: Ie
248
- }
249
- ),
250
- /* @__PURE__ */ t(
251
- "input",
252
- {
253
- type: "hidden",
254
- name: M,
255
- value: er(B),
256
- disabled: e
257
- }
258
- ),
259
- /* @__PURE__ */ Y($e, { ctxId: ce, ctxDisabled: e, children: [
260
- x,
261
- N && /* @__PURE__ */ t(Ye, { id: O, appearance: "negative", children: y })
262
- ] }),
263
- pe(ue)
264
- ]
265
- }
266
- );
267
- }
268
- );
269
- export {
270
- Br as DateField
271
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../chunks/constants.CgMu0_1M.js");const A=require("../../../chunks/helpers.BIckGIbP.js"),d=require("./DateField.validation.cjs.js"),l="en-US",N=new Intl.DateTimeFormat("en-US",{month:"long"}),w=e=>N.format(new Date(2e3,e-1,1)),u=31,i=12,m=1,f=9999,M=(e,t,n)=>Math.min(n,Math.max(t,e)),T=(e,t)=>((e-1)%t+t)%t+1,F=2024,P=(e,t)=>t==null?31:new Date(e??F,t,0).getDate(),R=()=>{const e=new Date;return{day:e.getDate(),month:e.getMonth()+1,year:e.getFullYear()}},o=e=>e instanceof Date&&!Number.isNaN(e.getTime()),I=(e,t,n,r)=>{if(n==="min")return e==="year"?null:1;if(n==="max")return e==="year"?null:e==="day"?r.daysInMonth:i;if(t==null){if(e==="year")return r.today.year;const E=e==="day"?u:i;return n>0?1:E}if(e==="year")return M(t+n,m,f);const a=e==="day"?u:i;return T(t+n,a)},L={day:"",month:"",year:""},h=e=>{const{day:t,month:n,year:r}=e;if(t==null||n==null||r==null)return null;const a=new Date(r,n-1,t);return a.setFullYear(r),Number.isNaN(a.getTime())||a.getFullYear()!==r||a.getMonth()!==n-1||a.getDate()!==t?null:a},Y=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.getTime()===t.getTime(),s=A.dateToDayKey,O=e=>o(e)?s(e):null,V=(e,t,n)=>{const r=s(e);return!(o(t)&&r<s(t)||o(n)&&r>s(n))},_=(e,t)=>o(e)&&o(t)&&s(e)>s(t),C=(e,t,n)=>{if(_(t,n))return e;const r=s(e);return o(t)&&r<s(t)?new Date(t.getFullYear(),t.getMonth(),t.getDate()):o(n)&&r>s(n)?new Date(n.getFullYear(),n.getMonth(),n.getDate()):e},X=e=>{if(!o(e))return"";const t=String(e.getFullYear()).padStart(4,"0"),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},p=e=>e.type==="literal",D=e=>e.filter(t=>!p(t)).map(t=>t.type),b=new Date(2020,0,2),G=new Set([8206,8207,8234,8235,8236,8237,8238,8294,8295,8296,8297]),H=e=>[...e].filter(t=>!G.has(t.codePointAt(0)??-1)).join(""),K=new Set(["day","month","year","literal"]),y=3,S=e=>{try{const t=new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit",calendar:"gregory"}).formatToParts(b).filter(r=>K.has(r.type)).map(r=>({type:r.type,value:r.type==="literal"?H(r.value):""})),n=D(t);return n.length===y&&new Set(n).size===y?t:null}catch{return null}},g=new Map,$=e=>{try{return new Intl.Locale(e).toString()}catch{return e.toLowerCase()}},k=e=>{try{return Intl.DateTimeFormat.supportedLocalesOf([e]).length>0}catch{return!1}},U=e=>{const t=$(e),n=g.get(t);if(n)return n;const r=k(e);!r&&process.env.NODE_ENV!=="production"&&console.warn(`DateField: locale "${e}" is not supported; falling back to ${l}.`);const a=(r?S(e):null)??S(l);if(!a)throw new Error(`DateField: Intl cannot resolve ${l} date parts`);return g.set(t,a),a},j=()=>g.clear(),q=e=>o(e)?{day:String(e.getDate()).padStart(2,"0"),month:String(e.getMonth()+1).padStart(2,"0"),year:String(e.getFullYear()).padStart(4,"0")}:L,c=(e,t)=>{if(t===""||e==="year"&&t.length<d.SEGMENT_MAX_LENGTH.year)return null;const n=parseInt(t,10);return Number.isNaN(n)||n===0?null:n},v=e=>h({day:c("day",e.day),month:c("month",e.month),year:c("year",e.year)}),z=(e,t)=>t===""?"":t.padStart(d.SEGMENT_MAX_LENGTH[e],"0"),B=(e,t,n)=>t===""?{displayValue:n,isPlaceholder:!0}:{displayValue:t.padStart(d.SEGMENT_MAX_LENGTH[e],"0"),isPlaceholder:!1},W=e=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)},J=e=>{var n;if(!e)return;const t=(n=window.getSelection)==null?void 0:n.call(window);t&&t.rangeCount>0&&e.contains(t.anchorNode)&&t.removeAllRanges()};exports.DAY_SPIN_MAX=u;exports.DEFAULT_LOCALE=l;exports.MONTH_MAX=i;exports.YEAR_MAX=f;exports.YEAR_MIN=m;exports.__clearDatePartsCache=j;exports.adjustSegmentValue=I;exports.clamp=M;exports.clampDateToRange=C;exports.clearSelectionWithin=J;exports.dateKeyOrNull=O;exports.deriveValue=h;exports.deriveValueFromText=v;exports.getDateParts=U;exports.getDaysInMonth=P;exports.getMonthName=w;exports.getSegmentDisplay=B;exports.getSegmentOrder=D;exports.isDateInRange=V;exports.isLiteralPart=p;exports.isMinMaxMisconfigured=_;exports.isSameDateValue=Y;exports.isValidDate=o;exports.normalizeSegmentText=z;exports.segmentNumber=c;exports.segmentTextFromValue=q;exports.selectElementContents=W;exports.toISODateString=X;exports.todayParts=R;exports.wrapInRange=T;
@@ -1 +0,0 @@
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;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("clsx"),T=require("react"),u=require("../../../chunks/form.context.CkC0TwMb.js");require("../../Form/contexts/label.context.cjs.js");require("../../Form/contexts/helperText.context.cjs.js");const s=require("../../Form/hooks/useAccessibleId.hook.cjs.js");require("../../../chunks/constants.CgMu0_1M.js");require("react/jsx-runtime");function L({name:i,disabled:b=!1,readOnly:q=!1,required:y=!1,defaultValue:I,error:e,hasHelperText:p,hasLabel:h,validationRules:F=[],ariaDescribedBy:f,ariaLabelledBy:m}){const{showErrors:v,isInvalid:x,errorShown:g,disabled:B,readOnly:_,required:A}=u.useFormField({name:i,validationRules:F,disabledProp:b,readOnlyProp:q,requiredProp:y}),{ctxInitialValues:D}=T.useContext(u.FormContext),{id:r}=s.useAccessibleId(),{id:d}=s.useAccessibleId(),{id:l}=s.useAccessibleId(),{id:o}=s.useAccessibleId(),t=!!(e!=null&&e.length),P=!!e||x,O=I??D[i],a=n(p&&d,t&&r,g&&l,f),c=n(h&&o,m);return{disabled:B,readOnly:_,required:A,invalid:P,errorMessageProvided:t,defaultValue:O,errorId:r,helperTextId:d,validationErrorsId:l,labelId:o,ariaDescribedBy:a.length>0?a:void 0,ariaLabelledBy:c.length>0?c:void 0,showErrors:v}}exports.useDateFieldForm=L;
@@ -1,80 +0,0 @@
1
- import { Nullable } from '@viasat/beam-shared/utils/types';
2
- import { AppendDigitResult, SegmentAdjustment, SegmentText, SegmentType, SegmentValues } from './DateField.types';
3
- export interface UseDateFieldValueArgs {
4
- value?: Nullable<Date>;
5
- defaultValue?: Nullable<Date>;
6
- /** Fires on user-driven value transitions only, never on controlled `value` changes. */
7
- onChange?: (value: Nullable<Date>) => void;
8
- /**
9
- * Earliest allowed date (inclusive, compared by calendar day). Springs a
10
- * touched value to this bound on blur (see `commitOnBlur`) — does not bound
11
- * the year segment's spin/Home/End, which is free (see `adjustSegment`).
12
- */
13
- minDate?: Nullable<Date>;
14
- /**
15
- * Latest allowed date (inclusive, compared by calendar day). Springs a
16
- * touched value to this bound on blur (see `commitOnBlur`) — does not bound
17
- * the year segment's spin/Home/End, which is free (see `adjustSegment`).
18
- */
19
- maxDate?: Nullable<Date>;
20
- /**
21
- * Called when a touched value springs to a bound on blur; returns a localized
22
- * message set on the polite live region. Omit → no announcement.
23
- */
24
- getClampAnnouncement?: (clampedDate: Date) => string;
25
- }
26
- export interface UseDateFieldValueReturn {
27
- segmentText: SegmentText;
28
- segmentValues: SegmentValues;
29
- currentValue: Nullable<Date>;
30
- isControlled: boolean;
31
- wasTouched: boolean;
32
- appendDigit: (type: SegmentType, digit: string) => AppendDigitResult;
33
- /**
34
- * Increments, decrements, or jumps a segment to its min/max boundary.
35
- *
36
- * - Numeric `amount` (e.g. ±1, ±5): day/month wrap modularly; year clamps
37
- * to `[YEAR_MIN, YEAR_MAX]` (free-spinning, independent of `minDate`/
38
- * `maxDate` — see `DateField.utils.adjustSegmentValue`). An empty day/month
39
- * segment seeds to a direction-based first/last valid value; an empty year
40
- * seeds to the current year.
41
- * - `'min'` / `'max'`: jump to the lower/upper bound. No-op on year (Home/End
42
- * don't bound the year to `minDate`/`maxDate`).
43
- *
44
- * Follows the `appendDigit` mutation pattern: writes zero-padded `segmentText`,
45
- * sets `wasTouched`, calls `emitIfChanged`, and marks the segment in
46
- * `replaceNextRef` so a digit typed immediately after replaces rather than
47
- * appends.
48
- *
49
- * @returns `true` if the segment was adjusted, `false` on a no-op (year
50
- * `'min'`/`'max'`). The keyboard dispatcher uses this to decide whether to
51
- * `preventDefault` — a no-op leaves the key to native (e.g. page scroll).
52
- */
53
- adjustSegment: (type: SegmentType, amount: SegmentAdjustment) => boolean;
54
- /**
55
- * Clears the entire segment buffer to `''` — the shared Backspace and
56
- * Delete behaviour.
57
- *
58
- * Returns `{ wasEmpty: true }` when the buffer was already empty, without
59
- * mutating, so the caller (keyboard handler) knows Backspace should move
60
- * focus to the previous segment instead of clearing. Otherwise focus stays
61
- * on the current segment. Fires `onChange(null)` via `emitIfChanged` when
62
- * the cleared segment was part of a complete date. Clears `replaceNextRef`
63
- * for the segment so the next digit appends.
64
- */
65
- clearSegment: (type: SegmentType) => {
66
- wasEmpty: boolean;
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;
75
- beginSegmentEdit: (type: SegmentType) => void;
76
- commitOnBlur: () => void;
77
- /** Polite live-region message set when the blur clamp springs a value to a bound. */
78
- clampAnnouncement: string;
79
- }
80
- export declare function useDateFieldValue({ value, defaultValue, onChange, minDate, maxDate, getClampAnnouncement, }: UseDateFieldValueArgs): UseDateFieldValueReturn;
File without changes
File without changes
File without changes
File without changes