@viasat/beam-react 2.56.0 → 2.58.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 (36) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/chunks/{DateField.Segment.CwhRnhtq.js → DateField.Segment.BMXzpxgl.js} +27 -26
  3. package/chunks/DateField.Segment.BqMaeKLk.js +1 -0
  4. package/chunks/use-isomorphic-layout-effect.browser.esm.CkGv31zs.js +1 -0
  5. package/chunks/use-isomorphic-layout-effect.browser.esm.DERp5kr6.js +5 -0
  6. package/lib/wip/DataTable/DataTable.columns.cjs.js +1 -0
  7. package/lib/wip/DataTable/DataTable.columns.d.ts +26 -0
  8. package/lib/wip/DataTable/DataTable.columns.es.js +10 -0
  9. package/lib/wip/DataTable/index.cjs.js +1 -1
  10. package/lib/wip/DataTable/index.d.ts +2 -0
  11. package/lib/wip/DataTable/index.es.js +13 -11
  12. package/lib/wip/DateField/DateField.Segment.cjs.js +1 -1
  13. package/lib/wip/DateField/DateField.Segment.es.js +3 -2
  14. package/lib/wip/DateField/DateField.Segments.cjs.js +1 -1
  15. package/lib/wip/DateField/DateField.Segments.es.js +1 -1
  16. package/lib/wip/DateField/DateField.cjs.js +1 -1
  17. package/lib/wip/DateField/DateField.devWarnings.cjs.js +1 -0
  18. package/lib/wip/DateField/DateField.devWarnings.d.ts +15 -0
  19. package/lib/wip/DateField/DateField.devWarnings.es.js +22 -0
  20. package/lib/wip/DateField/DateField.es.js +186 -177
  21. package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
  22. package/lib/wip/DateField/DateField.utils.d.ts +7 -5
  23. package/lib/wip/DateField/DateField.utils.es.js +84 -70
  24. package/lib/wip/ErrorBoundary/ErrorBoundary.cjs.js +1 -0
  25. package/lib/wip/ErrorBoundary/ErrorBoundary.d.ts +28 -0
  26. package/lib/wip/ErrorBoundary/ErrorBoundary.es.js +19 -0
  27. package/lib/wip/ErrorBoundary/index.cjs.js +1 -0
  28. package/lib/wip/ErrorBoundary/index.d.ts +2 -0
  29. package/lib/wip/ErrorBoundary/index.es.js +4 -0
  30. package/lib/wip/index.cjs.js +1 -1
  31. package/lib/wip/index.d.ts +1 -0
  32. package/lib/wip/index.es.js +17 -13
  33. package/package.json +7 -7
  34. package/utils/hooks/useId.cjs.js +1 -1
  35. package/utils/hooks/useId.es.js +7 -8
  36. package/chunks/DateField.Segment.CqFLhMYA.js +0 -1
@@ -1,236 +1,245 @@
1
- import { jsxs as O, jsx as r } from "react/jsx-runtime";
2
- import Ne from "clsx";
3
- import { forwardRef as we, useEffect as Oe, useMemo as Ve, useCallback as Ce } from "react";
4
- import { s as a, b as Be, c as i, a as V } from "../../../chunks/DateField.Segment.CwhRnhtq.js";
5
- import { t as Re } from "../../../chunks/constants.Cruz2A1w.js";
6
- import { i as Pe } from "../../../chunks/helpers.CiQfGwdc.js";
7
- import { H as Ee } from "../../../chunks/form.context.BDYA2JQs.js";
8
- import { LabelProvider as Le } from "../../Form/contexts/label.context.es.js";
9
- import { HelperTextProvider as Te } from "../../Form/contexts/helperText.context.es.js";
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
10
  import { useUniversalRef as qe } from "../../Form/hooks/useUniversalRef.hook.es.js";
11
- import { useIsMounted as He } from "../../../utils/hooks/useIsMounted.es.js";
12
- import { DateFieldSegments as Ke } from "./DateField.Segments.es.js";
13
- import { isMinMaxMisconfigured as $e, dateKeyOrNull as C, getDateParts as je, getSegmentOrder as Ue, toISODateString as We } from "./DateField.utils.es.js";
14
- import { useDateFieldFocus as ke } from "./useDateFieldFocus.es.js";
15
- import { useDateFieldForm as Ae } from "./useDateFieldForm.es.js";
16
- import { useDateFieldKeyboard as _e } from "./useDateFieldKeyboard.es.js";
17
- import { useDateFieldSegments as ze } from "./useDateFieldSegments.es.js";
18
- import { useDateFieldValidity as Ge } from "./useDateFieldValidity.es.js";
19
- import { useDateFieldValue as Je } from "./useDateFieldValue.es.js";
20
- import { useInvalidState as Qe } from "./useInvalidState.es.js";
21
- const ha = we(
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(
22
28
  function({
23
- value: B,
24
- defaultValue: R,
25
- onChange: P,
26
- minDate: l,
27
- maxDate: o,
28
- getClampAnnouncement: E,
29
- locale: L,
30
- label: c = null,
31
- helperText: f = null,
32
- error: p,
33
- hideRequiredMarker: T = !1,
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,
34
40
  validationRules: q,
35
- width: H,
36
- theme: b,
37
- fluid: K = !1,
38
- disabled: $ = !1,
39
- readOnly: j = !1,
40
- required: U = !1,
41
- name: g,
42
- id: W,
43
- className: k,
44
- style: A,
45
- "aria-label": _,
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,
46
52
  "aria-describedby": z,
47
53
  "aria-labelledby": G,
48
54
  ...J
49
55
  }, Q) {
50
56
  const {
51
57
  disabled: e,
52
- readOnly: d,
53
- required: v,
58
+ readOnly: t,
59
+ required: h,
54
60
  invalid: X,
55
- errorMessageProvided: F,
56
- defaultValue: Y,
57
- errorId: D,
58
- helperTextId: Z,
59
- validationErrorsId: ee,
60
- labelId: h,
61
- ariaDescribedBy: ae,
62
- ariaLabelledBy: re,
63
- showErrors: se
64
- } = Ae({
65
- name: g,
66
- disabled: $,
67
- readOnly: j,
68
- required: U,
69
- defaultValue: R,
70
- error: p,
71
- hasHelperText: !!f,
72
- hasLabel: !!c,
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,
73
79
  validationRules: q,
74
80
  ariaDescribedBy: z,
75
81
  ariaLabelledBy: G
76
82
  });
77
- Oe(() => {
78
- process.env.NODE_ENV !== "production" && $e(l, o) && console.warn(
79
- "DateField: `minDate` is after `maxDate` — no date satisfies both, so the blur clamp is disabled and values are left as typed."
80
- );
81
- }, [C(l), C(o)]);
82
- const { refFn: te, ref: S } = qe(Q), { segmentRefs: ie, registerSegmentRef: le } = ze(), n = je(L ?? "en-US"), x = Ve(() => Ue(n), [n]), {
83
- segmentText: oe,
84
- segmentValues: y,
85
- currentValue: I,
86
- wasTouched: de,
87
- appendDigit: M,
88
- adjustSegment: ne,
89
- clearSegment: ue,
90
- beginSegmentEdit: me,
91
- commitOnBlur: ce,
92
- clampAnnouncement: fe
93
- } = Je({
94
- value: B,
95
- defaultValue: Y,
96
- onChange: P,
97
- minDate: l,
98
- maxDate: o,
99
- getClampAnnouncement: E
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
100
102
  }), {
101
- focusedSegment: N,
102
- fieldTabIndex: pe,
103
- handleSegmentFocus: w,
104
- handleFieldFocus: be,
105
- handleFieldBlur: ge,
106
- handleFieldMouseDown: ve,
107
- focusNext: u,
108
- focusPrevious: Fe
109
- } = ke({
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({
110
112
  disabled: e,
111
- fieldRef: S,
112
- segmentRefs: ie,
113
- partsOrder: x,
114
- onSegmentFocusChange: me,
115
- onFieldBlur: ce
116
- }), De = _e({
113
+ fieldRef: I,
114
+ segmentRefs: te,
115
+ partsOrder: N,
116
+ onSegmentFocusChange: fe,
117
+ onFieldBlur: pe
118
+ }), Se = Ge({
117
119
  disabled: e,
118
- readOnly: d,
119
- fieldRef: S,
120
- focusNext: u,
121
- focusPrevious: Fe,
122
- adjustSegment: ne,
123
- clearSegment: ue
124
- }), { isInvalid: he } = Ge({
125
- segments: y,
126
- currentValue: I,
127
- wasTouched: de,
128
- isFocused: N !== null
129
- }), Se = Ce(
130
- (s, t) => {
131
- const { advanced: Me } = M(s, t);
132
- Me && u(s);
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);
133
135
  },
134
- [M, u]
135
- ), m = Qe({
136
+ [C, n]
137
+ ), d = Ze({
136
138
  formInvalid: X,
137
- valueInvalid: he
138
- }), xe = He() && Pe() ? "textbox" : "spinbutton", ye = (s) => {
139
+ valueInvalid: xe
140
+ }), Ie = M && Ve() ? "textbox" : "spinbutton", Me = (s) => {
139
141
  if (e) return;
140
- const t = s.target.closest("label");
141
- !t || t.id !== h || (s.preventDefault(), w(x[0]));
142
- }, Ie = Ne(
143
- a[Be],
144
- b && Re(b),
145
- K && a[`${i}fluid`],
146
- m && a[`${i}error`],
147
- e && a[`${i}disabled`],
148
- d && a[`${i}read-only`],
149
- k
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
150
152
  );
151
- return /* @__PURE__ */ O(
153
+ return /* @__PURE__ */ B(
152
154
  "div",
153
155
  {
154
- className: Ie,
155
- style: { ...A, maxWidth: H },
156
- onMouseDownCapture: ye,
156
+ className: Ne,
157
+ style: { ...k, maxWidth: K },
158
+ onMouseDownCapture: Me,
157
159
  children: [
158
- /* @__PURE__ */ r(
159
- Le,
160
+ /* @__PURE__ */ a(
161
+ Ae,
160
162
  {
161
- ctxId: h,
163
+ ctxId: y,
162
164
  ctxDisabled: e,
163
- ctxRequired: v && !T,
164
- children: c
165
+ ctxRequired: h && !P,
166
+ children: g
165
167
  }
166
168
  ),
167
- /* @__PURE__ */ r(
169
+ /* @__PURE__ */ a(
168
170
  "div",
169
171
  {
170
172
  ...J,
171
- ref: te,
172
- id: W,
173
+ ref: ie,
174
+ id: $,
173
175
  role: "group",
174
- "aria-label": _,
175
- "aria-labelledby": re,
176
+ "aria-label": U,
177
+ "aria-labelledby": se,
176
178
  "aria-disabled": e || void 0,
177
- "aria-required": v || void 0,
178
- "aria-invalid": m || void 0,
179
- "aria-describedby": ae,
180
- "aria-errormessage": F ? D : void 0,
181
- tabIndex: pe,
182
- className: a[V.field],
183
- onMouseDown: ve,
184
- onFocus: be,
185
- children: /* @__PURE__ */ r(
186
- Ke,
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,
187
189
  {
188
- parts: n,
189
- segmentText: oe,
190
- segmentValues: y,
191
- focusedSegment: N,
192
- disabled: e,
193
- readOnly: d,
194
- invalid: m,
195
- role: xe,
196
- onSegmentFocus: w,
197
- onSegmentBlur: ge,
198
- onSegmentInput: Se,
199
- onSegmentKeyDown: De,
200
- registerSegmentRef: le
190
+ fallback: /* @__PURE__ */ a("span", { className: r[m.segments], children: ea }),
191
+ onError: aa,
192
+ children: /* @__PURE__ */ a(
193
+ We,
194
+ {
195
+ parts: l,
196
+ segmentText: de,
197
+ segmentValues: w,
198
+ focusedSegment: E,
199
+ 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
208
+ }
209
+ )
201
210
  }
202
211
  )
203
212
  }
204
213
  ),
205
- /* @__PURE__ */ r(
214
+ /* @__PURE__ */ a(
206
215
  "span",
207
216
  {
208
217
  role: "status",
209
218
  "aria-live": "polite",
210
219
  "aria-atomic": "true",
211
- className: a[V.srStatus],
212
- children: fe
220
+ className: r[m.srStatus],
221
+ children: ge
213
222
  }
214
223
  ),
215
- /* @__PURE__ */ r(
224
+ /* @__PURE__ */ a(
216
225
  "input",
217
226
  {
218
227
  type: "hidden",
219
- name: g,
220
- value: We(I),
228
+ name: F,
229
+ value: ke(R),
221
230
  disabled: e
222
231
  }
223
232
  ),
224
- /* @__PURE__ */ O(Te, { ctxId: Z, ctxDisabled: e, children: [
225
- f,
226
- F && /* @__PURE__ */ r(Ee, { id: D, appearance: "negative", children: p })
233
+ /* @__PURE__ */ B(Pe, { ctxId: ee, ctxDisabled: e, children: [
234
+ b,
235
+ S && /* @__PURE__ */ a(Te, { id: x, appearance: "negative", children: v })
227
236
  ] }),
228
- se(ee)
237
+ oe(ae)
229
238
  ]
230
239
  }
231
240
  );
232
241
  }
233
242
  );
234
243
  export {
235
- ha as DateField
244
+ Ma as DateField
236
245
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../chunks/constants.CgMu0_1M.js");const D=require("../../../chunks/helpers.BIckGIbP.js"),g=require("./DateField.validation.cjs.js"),E=new Intl.DateTimeFormat("en-US",{month:"long"}),p=e=>E.format(new Date(2e3,e-1,1)),c=31,l=12,S=1,m=9999,M=(e,t,n)=>Math.min(n,Math.max(t,e)),T=(e,t)=>((e-1)%t+t)%t+1,w=2024,P=(e,t)=>t==null?31:new Date(e??w,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:l;if(t==null){if(e==="year")return r.today.year;const A=e==="day"?c:l;return n>0?1:A}if(e==="year")return M(t+n,S,m);const s=e==="day"?c:l;return T(t+n,s)},F={day:"",month:"",year:""},f=e=>{const{day:t,month:n,year:r}=e;if(t==null||n==null||r==null)return null;const s=new Date(r,n-1,t);return s.setFullYear(r),Number.isNaN(s.getTime())||s.getFullYear()!==r||s.getMonth()!==n-1||s.getDate()!==t?null:s},Y=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.getTime()===t.getTime(),a=D.dateToDayKey,V=e=>o(e)?a(e):null,O=(e,t,n)=>{const r=a(e);return!(o(t)&&r<a(t)||o(n)&&r>a(n))},h=(e,t)=>o(e)&&o(t)&&a(e)>a(t),C=(e,t,n)=>{if(h(t,n))return e;const r=a(e);return o(t)&&r<a(t)?new Date(t.getFullYear(),t.getMonth(),t.getDate()):o(n)&&r>a(n)?new Date(n.getFullYear(),n.getMonth(),n.getDate()):e},L=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}`},_=e=>e.type==="literal",N=e=>e.filter(t=>!_(t)).map(t=>t.type),X=new Date(2020,0,2),b=new Set([8206,8207,8234,8235,8236,8237,8238,8294,8295,8296,8297]),G=e=>[...e].filter(t=>!b.has(t.codePointAt(0)??-1)).join(""),H=new Set(["day","month","year","literal"]),d=3,y=e=>{try{const t=new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit",calendar:"gregory"}).formatToParts(X).filter(r=>H.has(r.type)).map(r=>({type:r.type,value:r.type==="literal"?G(r.value):""})),n=N(t);return n.length===d&&new Set(n).size===d?t:null}catch{return null}},u=new Map,K=e=>{let t=e;try{t=new Intl.Locale(e).toString()}catch{t=e.toLowerCase()}const n=u.get(t);if(n)return n;const r=y(e)??y("en-US");if(!r)throw new Error("DateField: Intl cannot resolve en-US date parts");return u.set(t,r),r},j=()=>u.clear(),k=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")}:F,i=(e,t)=>{if(t===""||e==="year"&&t.length<g.SEGMENT_MAX_LENGTH.year)return null;const n=parseInt(t,10);return Number.isNaN(n)||n===0?null:n},U=e=>f({day:i("day",e.day),month:i("month",e.month),year:i("year",e.year)}),q=(e,t)=>t===""?"":t.padStart(g.SEGMENT_MAX_LENGTH[e],"0"),z=(e,t,n)=>t===""?{displayValue:n,isPlaceholder:!0}:{displayValue:t.padStart(g.SEGMENT_MAX_LENGTH[e],"0"),isPlaceholder:!1},B=e=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)},$=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=c;exports.MONTH_MAX=l;exports.YEAR_MAX=m;exports.YEAR_MIN=S;exports.__clearDatePartsCache=j;exports.adjustSegmentValue=I;exports.clamp=M;exports.clampDateToRange=C;exports.clearSelectionWithin=$;exports.dateKeyOrNull=V;exports.deriveValue=f;exports.deriveValueFromText=U;exports.getDateParts=K;exports.getDaysInMonth=P;exports.getMonthName=p;exports.getSegmentDisplay=z;exports.getSegmentOrder=N;exports.isDateInRange=O;exports.isLiteralPart=_;exports.isMinMaxMisconfigured=h;exports.isSameDateValue=Y;exports.normalizeSegmentText=q;exports.segmentNumber=i;exports.segmentTextFromValue=k;exports.selectElementContents=B;exports.toISODateString=L;exports.todayParts=R;exports.wrapInRange=T;
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,5 +1,6 @@
1
1
  import { Nullable } from '@viasat/beam-shared/utils/types';
2
2
  import { DateFieldPart, SegmentAdjustment, SegmentText, SegmentType, SegmentValues } from './DateField.types';
3
+ export declare const DEFAULT_LOCALE = "en-US";
3
4
  /** Returns the locale month name for a 1-based month (1 = January). */
4
5
  export declare const getMonthName: (month: number) => string;
5
6
  /**
@@ -48,6 +49,8 @@ export declare const todayParts: () => {
48
49
  month: number;
49
50
  year: number;
50
51
  };
52
+ /** True for a `Date` instance that isn't `Invalid Date`. */
53
+ export declare const isValidDate: (value: unknown) => value is Date;
51
54
  /** Context passed into {@link adjustSegmentValue} — kept pure by the caller. */
52
55
  export interface AdjustSegmentContext {
53
56
  /** Days in the current month (use {@link getDaysInMonth} to compute). */
@@ -124,11 +127,10 @@ export declare const isLiteralPart: (part: DateFieldPart) => part is DateFieldPa
124
127
  export declare const getSegmentOrder: (parts: ReadonlyArray<DateFieldPart>) => ReadonlyArray<SegmentType>;
125
128
  /**
126
129
  * Locale-derived segment order + separators (DF-8), memoized per locale. Falls
127
- * back to en-US for any locale Intl can't resolve to the three date segments —
128
- * en-US being the ECMAScript-guaranteed baseline (Intl's own ultimate fallback).
129
- * Resolved lazily on first use, so a broken Intl (which can't render the field
130
- * anyway — `getMonthName` needs it too) surfaces at render, catchable by an
131
- * error boundary, instead of crashing the bundle at import.
130
+ * back to {@link DEFAULT_LOCALE} for any locale Intl can't resolve to the three
131
+ * date segments. Resolved lazily on first use, so a broken Intl (which can't
132
+ * render the field anyway — `getMonthName` needs it too) surfaces at render,
133
+ * catchable by an error boundary, instead of crashing the bundle at import.
132
134
  */
133
135
  export declare const getDateParts: (locale: string) => ReadonlyArray<DateFieldPart>;
134
136
  /** @internal — test-only. Clears the per-locale parts cache for Intl isolation. */