@viasat/beam-react 2.56.0 → 2.57.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 (30) hide show
  1. package/CHANGELOG.md +10 -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/DateField/DateField.Segment.cjs.js +1 -1
  7. package/lib/wip/DateField/DateField.Segment.es.js +3 -2
  8. package/lib/wip/DateField/DateField.Segments.cjs.js +1 -1
  9. package/lib/wip/DateField/DateField.Segments.es.js +1 -1
  10. package/lib/wip/DateField/DateField.cjs.js +1 -1
  11. package/lib/wip/DateField/DateField.devWarnings.cjs.js +1 -0
  12. package/lib/wip/DateField/DateField.devWarnings.d.ts +15 -0
  13. package/lib/wip/DateField/DateField.devWarnings.es.js +22 -0
  14. package/lib/wip/DateField/DateField.es.js +186 -177
  15. package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
  16. package/lib/wip/DateField/DateField.utils.d.ts +7 -5
  17. package/lib/wip/DateField/DateField.utils.es.js +84 -70
  18. package/lib/wip/ErrorBoundary/ErrorBoundary.cjs.js +1 -0
  19. package/lib/wip/ErrorBoundary/ErrorBoundary.d.ts +28 -0
  20. package/lib/wip/ErrorBoundary/ErrorBoundary.es.js +19 -0
  21. package/lib/wip/ErrorBoundary/index.cjs.js +1 -0
  22. package/lib/wip/ErrorBoundary/index.d.ts +2 -0
  23. package/lib/wip/ErrorBoundary/index.es.js +4 -0
  24. package/lib/wip/index.cjs.js +1 -1
  25. package/lib/wip/index.d.ts +1 -0
  26. package/lib/wip/index.es.js +17 -15
  27. package/package.json +7 -7
  28. package/utils/hooks/useId.cjs.js +1 -1
  29. package/utils/hooks/useId.es.js +7 -8
  30. package/chunks/DateField.Segment.CqFLhMYA.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 2.57.0 (2026-08-20)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **DateField:** SSR safety and error boundary ([#1399](https://git.viasat.com/vega/Beam/pull/1399))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Roman-Ionita, Alin
10
+
1
11
  ## 2.56.0 (2026-08-20)
2
12
 
3
13
  ### 🚀 Features
@@ -1,16 +1,17 @@
1
1
  import "../assets/DateField.css";
2
2
  import { jsx as $ } from "react/jsx-runtime";
3
3
  import k from "clsx";
4
- import { useRef as I, useCallback as y, useLayoutEffect as B } from "react";
5
- import { g as L } from "./classNames.CA_0DokS.js";
6
- import { selectElementContents as P } from "../lib/wip/DateField/DateField.utils.es.js";
7
- const R = "date-field", { baseClassNamePrefix: W, classModifierPrefix: q, subElementClassPrefix: s } = L(R), S = {
4
+ import { useRef as I, useCallback as B } from "react";
5
+ import { i as P } from "./use-isomorphic-layout-effect.browser.esm.DERp5kr6.js";
6
+ import { g as R } from "./classNames.CA_0DokS.js";
7
+ import { selectElementContents as S } from "../lib/wip/DateField/DateField.utils.es.js";
8
+ const w = "date-field", { baseClassNamePrefix: q, classModifierPrefix: A, subElementClassPrefix: s } = R(w), y = {
8
9
  field: `${s}field`,
9
10
  segments: `${s}segments`,
10
11
  segment: `${s}segment`,
11
12
  separator: `${s}separator`,
12
13
  srStatus: `${s}sr-status`
13
- }, w = {
14
+ }, F = {
14
15
  "bm-light": "bm-light",
15
16
  "bm-dark": "bm-dark",
16
17
  "bm-inverse": "bm-inverse",
@@ -26,11 +27,11 @@ const R = "date-field", { baseClassNamePrefix: W, classModifierPrefix: q, subEle
26
27
  "bm-date-field__segments": "bm-date-field__segments",
27
28
  "bm-date-field__separator": "bm-date-field__separator",
28
29
  "bm-date-field__sr-status": "bm-date-field__sr-status"
29
- }, F = {
30
+ }, L = {
30
31
  day: "day",
31
32
  month: "month",
32
33
  year: "year"
33
- }, A = ({
34
+ }, H = ({
34
35
  type: r,
35
36
  value: u,
36
37
  valueMin: c,
@@ -39,32 +40,32 @@ const R = "date-field", { baseClassNamePrefix: W, classModifierPrefix: q, subEle
39
40
  isPlaceholder: p,
40
41
  valueText: g,
41
42
  invalid: C,
42
- role: i,
43
+ role: d,
43
44
  isActive: t,
44
45
  disabled: l,
45
46
  readOnly: m,
46
- onFocus: v,
47
- onBlur: x,
47
+ onFocus: x,
48
+ onBlur: v,
48
49
  onInput: E,
49
50
  onKeyDown: h,
50
51
  segmentRef: o
51
52
  }) => {
52
- const a = !l && !m, f = I(null), D = y(
53
+ const a = !l && !m, f = I(null), D = B(
53
54
  (e) => {
54
55
  f.current = e, o(e);
55
56
  },
56
57
  [o]
57
58
  ), M = (e) => {
58
59
  if (!a) return;
59
- const b = e.currentTarget, d = e.nativeEvent.data;
60
- d != null && d.length === 1 && E(r, d), b.textContent !== n && (b.textContent = n);
60
+ const b = e.currentTarget, i = e.nativeEvent.data;
61
+ i != null && i.length === 1 && E(r, i), b.textContent !== n && (b.textContent = n);
61
62
  };
62
- B(() => {
63
+ P(() => {
63
64
  if (!t || !a) return;
64
65
  const e = f.current;
65
- e && P(e);
66
+ e && S(e);
66
67
  }, [n, t, a]);
67
- const N = i === "spinbutton" ? {
68
+ const N = d === "spinbutton" ? {
68
69
  "aria-valuenow": u ?? void 0,
69
70
  "aria-valuemin": c,
70
71
  "aria-valuemax": _,
@@ -74,8 +75,8 @@ const R = "date-field", { baseClassNamePrefix: W, classModifierPrefix: q, subEle
74
75
  "span",
75
76
  {
76
77
  ref: D,
77
- role: i,
78
- "aria-label": F[r],
78
+ role: d,
79
+ "aria-label": L[r],
79
80
  ...N,
80
81
  "aria-disabled": l || void 0,
81
82
  "aria-readonly": m || void 0,
@@ -90,20 +91,20 @@ const R = "date-field", { baseClassNamePrefix: W, classModifierPrefix: q, subEle
90
91
  "data-segment": r,
91
92
  "data-active": t,
92
93
  "data-placeholder": p,
93
- onFocus: v,
94
- onBlur: x,
94
+ onFocus: x,
95
+ onBlur: v,
95
96
  onInput: M,
96
97
  onKeyDown: (e) => h(r, e),
97
98
  onMouseUp: (e) => e.preventDefault(),
98
- className: k(w[S.segment]),
99
+ className: k(F[y.segment]),
99
100
  children: n
100
101
  }
101
102
  );
102
103
  };
103
104
  export {
104
- A as D,
105
- S as a,
106
- W as b,
107
- q as c,
108
- w as s
105
+ H as D,
106
+ y as a,
107
+ q as b,
108
+ A as c,
109
+ F as s
109
110
  };
@@ -0,0 +1 @@
1
+ var T=require("../assets/DateField.css");const P=require("react/jsx-runtime"),R=require("clsx"),u=require("react"),$=require("./use-isomorphic-layout-effect.browser.esm.CkGv31zs.js"),k=require("./classNames.BFQUGnCN.js"),w=require("../lib/wip/DateField/DateField.utils.cjs.js"),y="date-field",{baseClassNamePrefix:S,classModifierPrefix:B,subElementClassPrefix:s}=k.getBEMClassNames(y),c={field:`${s}field`,segments:`${s}segments`,segment:`${s}segment`,separator:`${s}separator`,srStatus:`${s}sr-status`},_={"bm-light":"bm-light","bm-dark":"bm-dark","bm-inverse":"bm-inverse","bm-enterprise":"bm-enterprise","bm-consumer":"bm-consumer","bm-date-field":"bm-date-field","bm-date-field--disabled":"bm-date-field--disabled","bm-date-field--error":"bm-date-field--error","bm-date-field__field":"bm-date-field__field","bm-date-field__segment":"bm-date-field__segment","bm-date-field--read-only":"bm-date-field--read-only","bm-date-field--fluid":"bm-date-field--fluid","bm-date-field__segments":"bm-date-field__segments","bm-date-field__separator":"bm-date-field__separator","bm-date-field__sr-status":"bm-date-field__sr-status"},L={day:"day",month:"month",year:"year"},j=({type:i,value:g,valueMin:p,valueMax:C,displayValue:r,isPlaceholder:x,valueText:v,invalid:E,role:d,isActive:t,disabled:l,readOnly:o,onFocus:h,onBlur:D,onInput:N,onKeyDown:q,segmentRef:m})=>{const a=!l&&!o,f=u.useRef(null),F=u.useCallback(e=>{f.current=e,m(e)},[m]),M=e=>{if(!a)return;const b=e.currentTarget,n=e.nativeEvent.data;n!=null&&n.length===1&&N(i,n),b.textContent!==r&&(b.textContent=r)};$.index(()=>{if(!t||!a)return;const e=f.current;e&&w.selectElementContents(e)},[r,t,a]);const I=d==="spinbutton"?{"aria-valuenow":g??void 0,"aria-valuemin":p,"aria-valuemax":C,"aria-valuetext":v}:{"aria-multiline":!1};return P.jsx("span",{ref:F,role:d,"aria-label":L[i],...I,"aria-disabled":l||void 0,"aria-readonly":o||void 0,"aria-invalid":E||void 0,contentEditable:a&&t,suppressContentEditableWarning:!0,tabIndex:t?0:-1,inputMode:a?"numeric":void 0,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off","data-segment":i,"data-active":t,"data-placeholder":x,onFocus:h,onBlur:D,onInput:M,onKeyDown:e=>q(i,e),onMouseUp:e=>e.preventDefault(),className:R(_[c.segment]),children:r})};exports.DateFieldSegment=j;exports.baseClassNamePrefix=S;exports.classModifierPrefix=B;exports.staticDateFieldClassNames=c;exports.styles=_;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react");var t=e.useLayoutEffect;exports.index=t;
@@ -0,0 +1,5 @@
1
+ import { useLayoutEffect as e } from "react";
2
+ var r = e;
3
+ export {
4
+ r as i
5
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");const e=require("../../../chunks/DateField.Segment.CqFLhMYA.js");require("./DateField.utils.cjs.js");exports.DateFieldSegment=e.DateFieldSegment;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");require("../../../chunks/use-isomorphic-layout-effect.browser.esm.CkGv31zs.js");const e=require("../../../chunks/DateField.Segment.BqMaeKLk.js");require("./DateField.utils.cjs.js");exports.DateFieldSegment=e.DateFieldSegment;
@@ -1,8 +1,9 @@
1
1
  import "react/jsx-runtime";
2
2
  import "clsx";
3
3
  import "react";
4
- import { D as p } from "../../../chunks/DateField.Segment.CwhRnhtq.js";
4
+ import "../../../chunks/use-isomorphic-layout-effect.browser.esm.DERp5kr6.js";
5
+ import { D as a } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
5
6
  import "./DateField.utils.es.js";
6
7
  export {
7
- p as DateFieldSegment
8
+ a as DateFieldSegment
8
9
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("../../../chunks/DateField.Segment.CqFLhMYA.js"),t=require("./DateField.utils.cjs.js"),Y={month:"MM",day:"DD",year:"YYYY"},j=({parts:o,segmentText:r,segmentValues:a,focusedSegment:m,disabled:c,readOnly:d,invalid:u,role:y,onSegmentFocus:D,onSegmentBlur:h,onSegmentInput:p,onSegmentKeyDown:M,registerSegmentRef:x})=>{const _={day:{min:1,max:t.getDaysInMonth(a.year,a.month)},month:{min:1,max:t.MONTH_MAX},year:{min:t.YEAR_MIN,max:t.YEAR_MAX}};return i.jsx("span",{className:n.styles[n.staticDateFieldClassNames.segments],children:o.map((s,g)=>{if(s.type==="literal")return i.jsx("span",{"aria-hidden":"true",className:n.styles[n.staticDateFieldClassNames.separator],children:s.value},`literal-${g}`);const e=s.type,F=Y[e],{displayValue:l,isPlaceholder:S}=t.getSegmentDisplay(e,r[e],F),{min:v,max:N}=_[e],A=e==="month"&&a.month!=null?t.getMonthName(a.month):l;return i.jsx(n.DateFieldSegment,{type:e,value:a[e],valueMin:v,valueMax:N,displayValue:l,isPlaceholder:S,valueText:A,invalid:u,role:y,isActive:m===e,disabled:c,readOnly:d,onFocus:()=>D(e),onBlur:h,onInput:p,onKeyDown:M,segmentRef:x(e)},e)})})};exports.DateFieldSegments=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("../../../chunks/DateField.Segment.BqMaeKLk.js"),t=require("./DateField.utils.cjs.js"),Y={month:"MM",day:"DD",year:"YYYY"},j=({parts:o,segmentText:r,segmentValues:a,focusedSegment:m,disabled:c,readOnly:d,invalid:u,role:y,onSegmentFocus:D,onSegmentBlur:h,onSegmentInput:p,onSegmentKeyDown:M,registerSegmentRef:x})=>{const _={day:{min:1,max:t.getDaysInMonth(a.year,a.month)},month:{min:1,max:t.MONTH_MAX},year:{min:t.YEAR_MIN,max:t.YEAR_MAX}};return i.jsx("span",{className:n.styles[n.staticDateFieldClassNames.segments],children:o.map((s,g)=>{if(s.type==="literal")return i.jsx("span",{"aria-hidden":"true",className:n.styles[n.staticDateFieldClassNames.separator],children:s.value},`literal-${g}`);const e=s.type,F=Y[e],{displayValue:l,isPlaceholder:S}=t.getSegmentDisplay(e,r[e],F),{min:v,max:N}=_[e],A=e==="month"&&a.month!=null?t.getMonthName(a.month):l;return i.jsx(n.DateFieldSegment,{type:e,value:a[e],valueMin:v,valueMax:N,displayValue:l,isPlaceholder:S,valueText:A,invalid:u,role:y,isActive:m===e,disabled:c,readOnly:d,onFocus:()=>D(e),onBlur:h,onInput:p,onKeyDown:M,segmentRef:x(e)},e)})})};exports.DateFieldSegments=j;
@@ -1,5 +1,5 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { s, a as m, D as F } from "../../../chunks/DateField.Segment.CwhRnhtq.js";
2
+ import { s, a as m, D as F } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
3
3
  import { getDaysInMonth as R, getSegmentDisplay as S, YEAR_MAX as I, YEAR_MIN as T, MONTH_MAX as _, getMonthName as B } from "./DateField.utils.es.js";
4
4
  const C = {
5
5
  month: "MM",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),qe=require("clsx"),r=require("react"),e=require("../../../chunks/DateField.Segment.CqFLhMYA.js"),we=require("../../../chunks/constants.CgMu0_1M.js"),Ie=require("../../../chunks/helpers.BIckGIbP.js"),Me=require("../../../chunks/form.context.CkC0TwMb.js"),Ne=require("../../Form/contexts/label.context.cjs.js"),Oe=require("../../Form/contexts/helperText.context.cjs.js"),Ve=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),je=require("../../../utils/hooks/useIsMounted.cjs.js"),Pe=require("./DateField.Segments.cjs.js"),i=require("./DateField.utils.cjs.js"),Re=require("./useDateFieldFocus.cjs.js"),Ce=require("./useDateFieldForm.cjs.js"),Te=require("./useDateFieldKeyboard.cjs.js"),Be=require("./useDateFieldSegments.cjs.js"),Ee=require("./useDateFieldValidity.cjs.js"),Ke=require("./useDateFieldValue.cjs.js"),He=require("./useInvalidState.cjs.js"),Le=r.forwardRef(function({value:N,defaultValue:O,onChange:V,minDate:d,maxDate:n,getClampAnnouncement:j,locale:P,label:F=null,helperText:f=null,error:_,hideRequiredMarker:R=!1,validationRules:C,width:T,theme:m,fluid:B=!1,disabled:E=!1,readOnly:K=!1,required:H=!1,name:D,id:L,className:k,style:$,"aria-label":U,"aria-describedby":W,"aria-labelledby":A,...z},G){const{disabled:s,readOnly:o,required:p,invalid:J,errorMessageProvided:g,defaultValue:Q,errorId:x,helperTextId:X,validationErrorsId:Y,labelId:v,ariaDescribedBy:Z,ariaLabelledBy:ee,showErrors:se}=Ce.useDateFieldForm({name:D,disabled:E,readOnly:K,required:H,defaultValue:O,error:_,hasHelperText:!!f,hasLabel:!!F,validationRules:C,ariaDescribedBy:W,ariaLabelledBy:A});r.useEffect(()=>{process.env.NODE_ENV!=="production"&&i.isMinMaxMisconfigured(d,n)&&console.warn("DateField: `minDate` is after `maxDate` — no date satisfies both, so the blur clamp is disabled and values are left as typed.")},[i.dateKeyOrNull(d),i.dateKeyOrNull(n)]);const{refFn:ae,ref:y}=Ve.useUniversalRef(G),{segmentRefs:ie,registerSegmentRef:le}=Be.useDateFieldSegments(),te=P??"en-US",u=i.getDateParts(te),S=r.useMemo(()=>i.getSegmentOrder(u),[u]),{segmentText:re,segmentValues:h,currentValue:q,wasTouched:de,appendDigit:w,adjustSegment:ne,clearSegment:oe,beginSegmentEdit:ue,commitOnBlur:ce,clampAnnouncement:be}=Ke.useDateFieldValue({value:N,defaultValue:Q,onChange:V,minDate:d,maxDate:n,getClampAnnouncement:j}),{focusedSegment:I,fieldTabIndex:Fe,handleSegmentFocus:M,handleFieldFocus:fe,handleFieldBlur:_e,handleFieldMouseDown:me,focusNext:c,focusPrevious:De}=Re.useDateFieldFocus({disabled:s,fieldRef:y,segmentRefs:ie,partsOrder:S,onSegmentFocusChange:ue,onFieldBlur:ce}),pe=Te.useDateFieldKeyboard({disabled:s,readOnly:o,fieldRef:y,focusNext:c,focusPrevious:De,adjustSegment:ne,clearSegment:oe}),{isInvalid:ge}=Ee.useDateFieldValidity({segments:h,currentValue:q,wasTouched:de,isFocused:I!==null}),xe=r.useCallback((l,t)=>{const{advanced:he}=w(l,t);he&&c(l)},[w,c]),b=He.useInvalidState({formInvalid:J,valueInvalid:ge}),ve=je.useIsMounted()&&Ie.isIOS()?"textbox":"spinbutton",ye=l=>{if(s)return;const t=l.target.closest("label");!t||t.id!==v||(l.preventDefault(),M(S[0]))},Se=qe(e.styles[e.baseClassNamePrefix],m&&we.themeClassName(m),B&&e.styles[`${e.classModifierPrefix}fluid`],b&&e.styles[`${e.classModifierPrefix}error`],s&&e.styles[`${e.classModifierPrefix}disabled`],o&&e.styles[`${e.classModifierPrefix}read-only`],k);return a.jsxs("div",{className:Se,style:{...$,maxWidth:T},onMouseDownCapture:ye,children:[a.jsx(Ne.LabelProvider,{ctxId:v,ctxDisabled:s,ctxRequired:p&&!R,children:F}),a.jsx("div",{...z,ref:ae,id:L,role:"group","aria-label":U,"aria-labelledby":ee,"aria-disabled":s||void 0,"aria-required":p||void 0,"aria-invalid":b||void 0,"aria-describedby":Z,"aria-errormessage":g?x:void 0,tabIndex:Fe,className:e.styles[e.staticDateFieldClassNames.field],onMouseDown:me,onFocus:fe,children:a.jsx(Pe.DateFieldSegments,{parts:u,segmentText:re,segmentValues:h,focusedSegment:I,disabled:s,readOnly:o,invalid:b,role:ve,onSegmentFocus:M,onSegmentBlur:_e,onSegmentInput:xe,onSegmentKeyDown:pe,registerSegmentRef:le})}),a.jsx("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:e.styles[e.staticDateFieldClassNames.srStatus],children:be}),a.jsx("input",{type:"hidden",name:D,value:i.toISODateString(q),disabled:s}),a.jsxs(Oe.HelperTextProvider,{ctxId:X,ctxDisabled:s,children:[f,g&&a.jsx(Me.HelperText,{id:x,appearance:"negative",children:_})]}),se(Y)]})});exports.DateField=Le;
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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),i=require("./DateField.utils.cjs.js"),l=(e,a)=>{s.useEffect(()=>{process.env.NODE_ENV!=="production"&&i.isMinMaxMisconfigured(e,a)&&console.warn("DateField: `minDate` is after `maxDate` — no date satisfies both, so the blur clamp is disabled and values are left as typed.")},[i.dateKeyOrNull(e),i.dateKeyOrNull(a)])},r=(e,a)=>{const n=e instanceof Date&&!i.isValidDate(e),t=a instanceof Date&&!i.isValidDate(a);s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&console.warn("DateField: `value` is an Invalid Date; rendering with no value."),t&&console.warn("DateField: `defaultValue` is an Invalid Date; rendering with no value."))},[n,t])};exports.useDevInvalidValueWarning=r;exports.useDevMinMaxWarning=l;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Dev-only guard: `minDate` after `maxDate` is a caller misconfig where no date
3
+ * satisfies both, so the blur clamp is disabled (values are left as typed). Warns
4
+ * once per prop change (stripped in production). Deps key on the primitive
5
+ * calendar day, not the `Date` object — an inline `new Date()` bound would
6
+ * otherwise re-run this every render and spam the warning.
7
+ */
8
+ export declare const useDevMinMaxWarning: (minDate: Date | null | undefined, maxDate: Date | null | undefined) => void;
9
+ /**
10
+ * Dev-only guard: an Invalid Date prop renders with no value (segments show
11
+ * placeholders). Warns so the caller notices rather than debugging a silently
12
+ * empty field. Keyed on booleans, not the `Date` objects, so a fresh-but-valid
13
+ * `Date` each render doesn't churn.
14
+ */
15
+ export declare const useDevInvalidValueWarning: (value: Date | null | undefined, defaultValue: Date | null | undefined) => void;
@@ -0,0 +1,22 @@
1
+ import { useEffect as o } from "react";
2
+ import { isMinMaxMisconfigured as l, dateKeyOrNull as t, isValidDate as s } from "./DateField.utils.es.js";
3
+ const c = (e, a) => {
4
+ o(() => {
5
+ process.env.NODE_ENV !== "production" && l(e, a) && console.warn(
6
+ "DateField: `minDate` is after `maxDate` — no date satisfies both, so the blur clamp is disabled and values are left as typed."
7
+ );
8
+ }, [t(e), t(a)]);
9
+ }, u = (e, a) => {
10
+ const n = e instanceof Date && !s(e), i = a instanceof Date && !s(a);
11
+ o(() => {
12
+ process.env.NODE_ENV !== "production" && (n && console.warn(
13
+ "DateField: `value` is an Invalid Date; rendering with no value."
14
+ ), i && console.warn(
15
+ "DateField: `defaultValue` is an Invalid Date; rendering with no value."
16
+ ));
17
+ }, [n, i]);
18
+ };
19
+ export {
20
+ u as useDevInvalidValueWarning,
21
+ c as useDevMinMaxWarning
22
+ };
@@ -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. */
@@ -1,39 +1,39 @@
1
1
  import "../../../chunks/constants.Cruz2A1w.js";
2
2
  import { a as S } from "../../../chunks/helpers.CiQfGwdc.js";
3
- import { SEGMENT_MAX_LENGTH as u } from "./DateField.validation.es.js";
4
- const m = new Intl.DateTimeFormat("en-US", { month: "long" }), L = (t) => m.format(new Date(2e3, t - 1, 1)), g = 31, l = 12, h = 1, T = 9999, M = (t, e, n) => Math.min(n, Math.max(e, t)), p = (t, e) => ((t - 1) % e + e) % e + 1, w = 2024, O = (t, e) => e == null ? 31 : new Date(t ?? w, e, 0).getDate(), K = () => {
3
+ import { SEGMENT_MAX_LENGTH as g } from "./DateField.validation.es.js";
4
+ const l = "en-US", h = new Intl.DateTimeFormat("en-US", { month: "long" }), $ = (t) => h.format(new Date(2e3, t - 1, 1)), d = 31, c = 12, p = 1, T = 9999, M = (t, e, n) => Math.min(n, Math.max(e, t)), A = (t, e) => ((t - 1) % e + e) % e + 1, E = 2024, k = (t, e) => e == null ? 31 : new Date(t ?? E, e, 0).getDate(), X = () => {
5
5
  const t = /* @__PURE__ */ new Date();
6
6
  return { day: t.getDate(), month: t.getMonth() + 1, year: t.getFullYear() };
7
- }, o = (t) => t instanceof Date && !Number.isNaN(t.getTime()), X = (t, e, n, r) => {
7
+ }, s = (t) => t instanceof Date && !Number.isNaN(t.getTime()), b = (t, e, n, r) => {
8
8
  if (n === "min") return t === "year" ? null : 1;
9
9
  if (n === "max")
10
- return t === "year" ? null : t === "day" ? r.daysInMonth : l;
10
+ return t === "year" ? null : t === "day" ? r.daysInMonth : c;
11
11
  if (e == null) {
12
12
  if (t === "year") return r.today.year;
13
- const f = t === "day" ? g : l;
14
- return n > 0 ? 1 : f;
13
+ const m = t === "day" ? d : c;
14
+ return n > 0 ? 1 : m;
15
15
  }
16
- if (t === "year") return M(e + n, h, T);
17
- const s = t === "day" ? g : l;
18
- return p(e + n, s);
19
- }, A = { day: "", month: "", year: "" }, N = (t) => {
16
+ if (t === "year") return M(e + n, p, T);
17
+ const a = t === "day" ? d : c;
18
+ return A(e + n, a);
19
+ }, N = { day: "", month: "", year: "" }, w = (t) => {
20
20
  const { day: e, month: n, year: r } = t;
21
21
  if (e == null || n == null || r == null) return null;
22
- const s = new Date(r, n - 1, e);
23
- return s.setFullYear(r), Number.isNaN(s.getTime()) || s.getFullYear() !== r || s.getMonth() !== n - 1 || s.getDate() !== e ? null : s;
24
- }, k = (t, e) => t == null && e == null ? !0 : t == null || e == null ? !1 : t.getTime() === e.getTime(), a = S, H = (t) => o(t) ? a(t) : null, U = (t, e, n) => {
25
- const r = a(t);
26
- return !(o(e) && r < a(e) || o(n) && r > a(n));
27
- }, _ = (t, e) => o(t) && o(e) && a(t) > a(e), b = (t, e, n) => {
28
- if (_(e, n)) return t;
29
- const r = a(t);
30
- return o(e) && r < a(e) ? new Date(e.getFullYear(), e.getMonth(), e.getDate()) : o(n) && r > a(n) ? new Date(n.getFullYear(), n.getMonth(), n.getDate()) : t;
31
- }, B = (t) => {
32
- if (!o(t)) return "";
22
+ const a = new Date(r, n - 1, e);
23
+ return a.setFullYear(r), Number.isNaN(a.getTime()) || a.getFullYear() !== r || a.getMonth() !== n - 1 || a.getDate() !== e ? null : a;
24
+ }, H = (t, e) => t == null && e == null ? !0 : t == null || e == null ? !1 : t.getTime() === e.getTime(), o = S, U = (t) => s(t) ? o(t) : null, B = (t, e, n) => {
25
+ const r = o(t);
26
+ return !(s(e) && r < o(e) || s(n) && r > o(n));
27
+ }, D = (t, e) => s(t) && s(e) && o(t) > o(e), G = (t, e, n) => {
28
+ if (D(e, n)) return t;
29
+ const r = o(t);
30
+ return s(e) && r < o(e) ? new Date(e.getFullYear(), e.getMonth(), e.getDate()) : s(n) && r > o(n) ? new Date(n.getFullYear(), n.getMonth(), n.getDate()) : t;
31
+ }, j = (t) => {
32
+ if (!s(t)) return "";
33
33
  const e = String(t.getFullYear()).padStart(4, "0"), n = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0");
34
34
  return `${e}-${n}-${r}`;
35
- }, E = (t) => t.type === "literal", D = (t) => t.filter(
36
- (e) => !E(e)
35
+ }, _ = (t) => t.type === "literal", F = (t) => t.filter(
36
+ (e) => !_(e)
37
37
  ).map((e) => e.type), P = new Date(2020, 0, 2), R = /* @__PURE__ */ new Set([
38
38
  8206,
39
39
  8207,
@@ -46,87 +46,101 @@ const m = new Intl.DateTimeFormat("en-US", { month: "long" }), L = (t) => m.form
46
46
  8295,
47
47
  8296,
48
48
  8297
49
- ]), F = (t) => [...t].filter((e) => !R.has(e.codePointAt(0) ?? -1)).join(""), I = /* @__PURE__ */ new Set(["day", "month", "year", "literal"]), d = 3, y = (t) => {
49
+ ]), I = (t) => [...t].filter((e) => !R.has(e.codePointAt(0) ?? -1)).join(""), Y = /* @__PURE__ */ new Set(["day", "month", "year", "literal"]), y = 3, f = (t) => {
50
50
  try {
51
51
  const e = new Intl.DateTimeFormat(t, {
52
52
  year: "numeric",
53
53
  month: "2-digit",
54
54
  day: "2-digit",
55
55
  calendar: "gregory"
56
- }).formatToParts(P).filter((r) => I.has(r.type)).map((r) => ({
56
+ }).formatToParts(P).filter((r) => Y.has(r.type)).map((r) => ({
57
57
  type: r.type,
58
- value: r.type === "literal" ? F(r.value) : ""
59
- })), n = D(e);
60
- return n.length === d && new Set(n).size === d ? e : null;
58
+ value: r.type === "literal" ? I(r.value) : ""
59
+ })), n = F(e);
60
+ return n.length === y && new Set(n).size === y ? e : null;
61
61
  } catch {
62
62
  return null;
63
63
  }
64
- }, c = /* @__PURE__ */ new Map(), G = (t) => {
65
- let e = t;
64
+ }, u = /* @__PURE__ */ new Map(), L = (t) => {
66
65
  try {
67
- e = new Intl.Locale(t).toString();
66
+ return new Intl.Locale(t).toString();
68
67
  } catch {
69
- e = t.toLowerCase();
68
+ return t.toLowerCase();
70
69
  }
71
- const n = c.get(e);
70
+ }, C = (t) => {
71
+ try {
72
+ return Intl.DateTimeFormat.supportedLocalesOf([t]).length > 0;
73
+ } catch {
74
+ return !1;
75
+ }
76
+ }, z = (t) => {
77
+ const e = L(t), n = u.get(e);
72
78
  if (n) return n;
73
- const r = y(t) ?? y("en-US");
74
- if (!r)
75
- throw new Error("DateField: Intl cannot resolve en-US date parts");
76
- return c.set(e, r), r;
77
- }, $ = () => c.clear(), j = (t) => o(t) ? {
79
+ const r = C(t);
80
+ !r && process.env.NODE_ENV !== "production" && console.warn(
81
+ `DateField: locale "${t}" is not supported; falling back to ${l}.`
82
+ );
83
+ const a = (r ? f(t) : null) ?? f(l);
84
+ if (!a)
85
+ throw new Error(
86
+ `DateField: Intl cannot resolve ${l} date parts`
87
+ );
88
+ return u.set(e, a), a;
89
+ }, W = () => u.clear(), q = (t) => s(t) ? {
78
90
  day: String(t.getDate()).padStart(2, "0"),
79
91
  month: String(t.getMonth() + 1).padStart(2, "0"),
80
92
  year: String(t.getFullYear()).padStart(4, "0")
81
- } : A, i = (t, e) => {
82
- if (e === "" || t === "year" && e.length < u.year) return null;
93
+ } : N, i = (t, e) => {
94
+ if (e === "" || t === "year" && e.length < g.year) return null;
83
95
  const n = parseInt(e, 10);
84
96
  return Number.isNaN(n) || n === 0 ? null : n;
85
- }, z = (t) => N({
97
+ }, J = (t) => w({
86
98
  day: i("day", t.day),
87
99
  month: i("month", t.month),
88
100
  year: i("year", t.year)
89
- }), W = (t, e) => e === "" ? "" : e.padStart(u[t], "0"), q = (t, e, n) => e === "" ? { displayValue: n, isPlaceholder: !0 } : {
90
- displayValue: e.padStart(u[t], "0"),
101
+ }), Q = (t, e) => e === "" ? "" : e.padStart(g[t], "0"), Z = (t, e, n) => e === "" ? { displayValue: n, isPlaceholder: !0 } : {
102
+ displayValue: e.padStart(g[t], "0"),
91
103
  isPlaceholder: !1
92
- }, J = (t) => {
104
+ }, v = (t) => {
93
105
  const e = window.getSelection();
94
106
  if (!e) return;
95
107
  const n = document.createRange();
96
108
  n.selectNodeContents(t), e.removeAllRanges(), e.addRange(n);
97
- }, Q = (t) => {
109
+ }, x = (t) => {
98
110
  var n;
99
111
  if (!t) return;
100
112
  const e = (n = window.getSelection) == null ? void 0 : n.call(window);
101
113
  e && e.rangeCount > 0 && t.contains(e.anchorNode) && e.removeAllRanges();
102
114
  };
103
115
  export {
104
- g as DAY_SPIN_MAX,
105
- l as MONTH_MAX,
116
+ d as DAY_SPIN_MAX,
117
+ l as DEFAULT_LOCALE,
118
+ c as MONTH_MAX,
106
119
  T as YEAR_MAX,
107
- h as YEAR_MIN,
108
- $ as __clearDatePartsCache,
109
- X as adjustSegmentValue,
120
+ p as YEAR_MIN,
121
+ W as __clearDatePartsCache,
122
+ b as adjustSegmentValue,
110
123
  M as clamp,
111
- b as clampDateToRange,
112
- Q as clearSelectionWithin,
113
- H as dateKeyOrNull,
114
- N as deriveValue,
115
- z as deriveValueFromText,
116
- G as getDateParts,
117
- O as getDaysInMonth,
118
- L as getMonthName,
119
- q as getSegmentDisplay,
120
- D as getSegmentOrder,
121
- U as isDateInRange,
122
- E as isLiteralPart,
123
- _ as isMinMaxMisconfigured,
124
- k as isSameDateValue,
125
- W as normalizeSegmentText,
124
+ G as clampDateToRange,
125
+ x as clearSelectionWithin,
126
+ U as dateKeyOrNull,
127
+ w as deriveValue,
128
+ J as deriveValueFromText,
129
+ z as getDateParts,
130
+ k as getDaysInMonth,
131
+ $ as getMonthName,
132
+ Z as getSegmentDisplay,
133
+ F as getSegmentOrder,
134
+ B as isDateInRange,
135
+ _ as isLiteralPart,
136
+ D as isMinMaxMisconfigured,
137
+ H as isSameDateValue,
138
+ s as isValidDate,
139
+ Q as normalizeSegmentText,
126
140
  i as segmentNumber,
127
- j as segmentTextFromValue,
128
- J as selectElementContents,
129
- B as toISODateString,
130
- K as todayParts,
131
- p as wrapInRange
141
+ q as segmentTextFromValue,
142
+ v as selectElementContents,
143
+ j as toISODateString,
144
+ X as todayParts,
145
+ A as wrapInRange
132
146
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");class a extends s.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,o){var r,t;(t=(r=this.props).onError)==null||t.call(r,e,o)}render(){return this.state.hasError?this.props.fallback:this.props.children}}exports.ErrorBoundary=a;
@@ -0,0 +1,28 @@
1
+ import { Component, ErrorInfo, ReactNode } from 'react';
2
+ export interface ErrorBoundaryProps {
3
+ /** Rendered normally; a render/commit error anywhere below is caught. */
4
+ children: ReactNode;
5
+ /** Rendered instead of `children` once a descendant throws. */
6
+ fallback: ReactNode;
7
+ /** Called when an error is caught — use for logging/telemetry. */
8
+ onError?: (error: Error, info: ErrorInfo) => void;
9
+ }
10
+ interface ErrorBoundaryState {
11
+ hasError: boolean;
12
+ }
13
+ /**
14
+ * Generic React error boundary: renders `fallback` when a descendant throws
15
+ * during render or commit, instead of letting the error crash the whole tree.
16
+ * Consumers own the fallback UI and any logging via `onError`.
17
+ *
18
+ * Must be a class component — React exposes error boundaries only through the
19
+ * `getDerivedStateFromError` / `componentDidCatch` lifecycle, which has no hook
20
+ * equivalent.
21
+ */
22
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
23
+ state: ErrorBoundaryState;
24
+ static getDerivedStateFromError(): ErrorBoundaryState;
25
+ componentDidCatch(error: Error, info: ErrorInfo): void;
26
+ render(): ReactNode;
27
+ }
28
+ export {};
@@ -0,0 +1,19 @@
1
+ import { Component as e } from "react";
2
+ class p extends e {
3
+ constructor() {
4
+ super(...arguments), this.state = { hasError: !1 };
5
+ }
6
+ static getDerivedStateFromError() {
7
+ return { hasError: !0 };
8
+ }
9
+ componentDidCatch(o, s) {
10
+ var r, t;
11
+ (t = (r = this.props).onError) == null || t.call(r, o, s);
12
+ }
13
+ render() {
14
+ return this.state.hasError ? this.props.fallback : this.props.children;
15
+ }
16
+ }
17
+ export {
18
+ p as ErrorBoundary
19
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./ErrorBoundary.cjs.js");exports.ErrorBoundary=r.ErrorBoundary;
@@ -0,0 +1,2 @@
1
+ export { ErrorBoundary } from './ErrorBoundary';
2
+ export type { ErrorBoundaryProps } from './ErrorBoundary';
@@ -0,0 +1,4 @@
1
+ import { ErrorBoundary as a } from "./ErrorBoundary.es.js";
2
+ export {
3
+ a as ErrorBoundary
4
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./DataTable/DataTable.cjs.js"),l=require("./DataTable/DataTable.Header.cjs.js"),t=require("./DataTable/DataTable.Toolbar.cjs.js"),b=require("./DataTable/DataTable.Head.cjs.js"),T=require("./DataTable/DataTable.ColumnHeader.cjs.js"),D=require("./DataTable/DataTable.Body.cjs.js"),i=require("./DataTable/DataTable.Row.cjs.js"),_=require("./DataTable/DataTable.Cell.cjs.js"),r=require("./DataTable/DataTable.Footer.cjs.js"),a=require("./DataTable/DataTable.context.cjs.js"),o=require("./DataTable/useBeamTable.cjs.js"),u=require("./DateField/DateField.cjs.js");exports.DataTable=e.DataTable;exports.DataTableHeader=l.DataTableHeader;exports.DataTableToolbar=t.DataTableToolbar;exports.DataTableHead=b.DataTableHead;exports.DataTableColumnHeader=T.DataTableColumnHeader;exports.DataTableBody=D.DataTableBody;exports.DataTableRow=i.DataTableRow;exports.DataTableCell=_.DataTableCell;exports.DataTableFooter=r.DataTableFooter;exports.DataTableProvider=a.DataTableProvider;exports.useDataTable=a.useDataTable;exports.useBeamTable=o.useBeamTable;exports.DateField=u.DateField;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./DataTable/DataTable.cjs.js"),l=require("./DataTable/DataTable.Header.cjs.js"),t=require("./DataTable/DataTable.Toolbar.cjs.js"),b=require("./DataTable/DataTable.Head.cjs.js"),r=require("./DataTable/DataTable.ColumnHeader.cjs.js"),T=require("./DataTable/DataTable.Body.cjs.js"),o=require("./DataTable/DataTable.Row.cjs.js"),i=require("./DataTable/DataTable.Cell.cjs.js"),_=require("./DataTable/DataTable.Footer.cjs.js"),a=require("./DataTable/DataTable.context.cjs.js"),D=require("./DataTable/useBeamTable.cjs.js"),u=require("./DateField/DateField.cjs.js"),d=require("./ErrorBoundary/ErrorBoundary.cjs.js");exports.DataTable=e.DataTable;exports.DataTableHeader=l.DataTableHeader;exports.DataTableToolbar=t.DataTableToolbar;exports.DataTableHead=b.DataTableHead;exports.DataTableColumnHeader=r.DataTableColumnHeader;exports.DataTableBody=T.DataTableBody;exports.DataTableRow=o.DataTableRow;exports.DataTableCell=i.DataTableCell;exports.DataTableFooter=_.DataTableFooter;exports.DataTableProvider=a.DataTableProvider;exports.useDataTable=a.useDataTable;exports.useBeamTable=D.useBeamTable;exports.DateField=u.DateField;exports.ErrorBoundary=d.ErrorBoundary;
@@ -1,2 +1,3 @@
1
1
  export * from './DataTable';
2
2
  export * from './DateField';
3
+ export * from './ErrorBoundary';
@@ -1,27 +1,29 @@
1
1
  import { DataTable as o } from "./DataTable/DataTable.es.js";
2
2
  import { DataTableHeader as t } from "./DataTable/DataTable.Header.es.js";
3
3
  import { DataTableToolbar as m } from "./DataTable/DataTable.Toolbar.es.js";
4
- import { DataTableHead as T } from "./DataTable/DataTable.Head.es.js";
5
- import { DataTableColumnHeader as p } from "./DataTable/DataTable.ColumnHeader.es.js";
4
+ import { DataTableHead as f } from "./DataTable/DataTable.Head.es.js";
5
+ import { DataTableColumnHeader as x } from "./DataTable/DataTable.ColumnHeader.es.js";
6
6
  import { DataTableBody as D } from "./DataTable/DataTable.Body.es.js";
7
7
  import { DataTableRow as u } from "./DataTable/DataTable.Row.es.js";
8
- import { DataTableCell as i } from "./DataTable/DataTable.Cell.es.js";
9
- import { DataTableFooter as B } from "./DataTable/DataTable.Footer.es.js";
10
- import { DataTableProvider as F, useDataTable as n } from "./DataTable/DataTable.context.es.js";
11
- import { useBeamTable as w } from "./DataTable/useBeamTable.es.js";
12
- import { DateField as P } from "./DateField/DateField.es.js";
8
+ import { DataTableCell as H } from "./DataTable/DataTable.Cell.es.js";
9
+ import { DataTableFooter as n } from "./DataTable/DataTable.Footer.es.js";
10
+ import { DataTableProvider as y, useDataTable as C } from "./DataTable/DataTable.context.es.js";
11
+ import { useBeamTable as v } from "./DataTable/useBeamTable.es.js";
12
+ import { DateField as E } from "./DateField/DateField.es.js";
13
+ import { ErrorBoundary as R } from "./ErrorBoundary/ErrorBoundary.es.js";
13
14
  export {
14
15
  o as DataTable,
15
16
  D as DataTableBody,
16
- i as DataTableCell,
17
- p as DataTableColumnHeader,
18
- B as DataTableFooter,
19
- T as DataTableHead,
17
+ H as DataTableCell,
18
+ x as DataTableColumnHeader,
19
+ n as DataTableFooter,
20
+ f as DataTableHead,
20
21
  t as DataTableHeader,
21
- F as DataTableProvider,
22
+ y as DataTableProvider,
22
23
  u as DataTableRow,
23
24
  m as DataTableToolbar,
24
- P as DateField,
25
- w as useBeamTable,
26
- n as useDataTable
25
+ E as DateField,
26
+ R as ErrorBoundary,
27
+ v as useBeamTable,
28
+ C as useDataTable
27
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viasat/beam-react",
3
- "version": "2.56.0",
3
+ "version": "2.57.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.56.0",
64
- "@viasat/beam-shared": "2.56.0",
65
- "@viasat/beam-styles": "2.56.0",
66
- "@viasat/beam-tokens": "2.56.0",
67
- "@viasat/beam-icons": "2.56.0",
68
- "@viasat/beam-react-claude-plugin": "2.56.0",
63
+ "@viasat/beam-fonts": "2.57.0",
64
+ "@viasat/beam-shared": "2.57.0",
65
+ "@viasat/beam-styles": "2.57.0",
66
+ "@viasat/beam-tokens": "2.57.0",
67
+ "@viasat/beam-icons": "2.57.0",
68
+ "@viasat/beam-react-claude-plugin": "2.57.0",
69
69
  "clsx": "^1.2.1",
70
70
  "@floating-ui/react": "^0.26.18",
71
71
  "@stepperize/react": "^5.1.5",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),a=require("../safeReact.cjs.js"),i=require("../../chunks/constants.CgMu0_1M.js");function f(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=f(u);var l=u.useLayoutEffect;let c=!1,d=0;const s=()=>`${i.prefix}-${Math.random().toString(36).slice(2,6)}${d++}`;function g(){const[e,t]=r.useState(()=>c?s():void 0);return l(()=>{e==null&&t(s())},[]),r.useEffect(()=>{c=!0},[]),e}const p=a.SafeReact.useId,b=p||g;exports.useId=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),a=require("../../chunks/use-isomorphic-layout-effect.browser.esm.CkGv31zs.js"),i=require("../safeReact.cjs.js"),f=require("../../chunks/constants.CgMu0_1M.js");function l(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=l(u);let s=!1,d=0;const c=()=>`${f.prefix}-${Math.random().toString(36).slice(2,6)}${d++}`;function g(){const[e,t]=r.useState(()=>s?c():void 0);return a.index(()=>{e==null&&t(c())},[]),r.useEffect(()=>{s=!0},[]),e}const p=i.SafeReact.useId,b=p||g;exports.useId=b;
@@ -1,10 +1,9 @@
1
1
  import * as t from "react";
2
- import { useLayoutEffect as f } from "react";
3
- import { SafeReact as n } from "../safeReact.es.js";
2
+ import { i as n } from "../../chunks/use-isomorphic-layout-effect.browser.esm.DERp5kr6.js";
3
+ import { SafeReact as i } from "../safeReact.es.js";
4
4
  import { p as a } from "../../chunks/constants.Cruz2A1w.js";
5
- var i = f;
6
- let o = !1, u = 0;
7
- const r = () => `${a}-${Math.random().toString(36).slice(2, 6)}${u++}`;
5
+ let o = !1, f = 0;
6
+ const r = () => `${a}-${Math.random().toString(36).slice(2, 6)}${f++}`;
8
7
  function c() {
9
8
  const [e, s] = t.useState(
10
9
  () => (
@@ -12,13 +11,13 @@ function c() {
12
11
  o ? r() : void 0
13
12
  )
14
13
  );
15
- return i(() => {
14
+ return n(() => {
16
15
  e == null && s(r());
17
16
  }, []), t.useEffect(() => {
18
17
  o = !0;
19
18
  }, []), e;
20
19
  }
21
- const d = n.useId, I = d || c;
20
+ const d = i.useId, p = d || c;
22
21
  export {
23
- I as useId
22
+ p as useId
24
23
  };
@@ -1 +0,0 @@
1
- var j=require("../assets/DateField.css");const R=require("react/jsx-runtime"),$=require("clsx"),d=require("react"),k=require("./classNames.BFQUGnCN.js"),y=require("../lib/wip/DateField/DateField.utils.cjs.js"),I="date-field",{baseClassNamePrefix:S,classModifierPrefix:w,subElementClassPrefix:s}=k.getBEMClassNames(I),c={field:`${s}field`,segments:`${s}segments`,segment:`${s}segment`,separator:`${s}separator`,srStatus:`${s}sr-status`},_={"bm-light":"bm-light","bm-dark":"bm-dark","bm-inverse":"bm-inverse","bm-enterprise":"bm-enterprise","bm-consumer":"bm-consumer","bm-date-field":"bm-date-field","bm-date-field--disabled":"bm-date-field--disabled","bm-date-field--error":"bm-date-field--error","bm-date-field__field":"bm-date-field__field","bm-date-field__segment":"bm-date-field__segment","bm-date-field--read-only":"bm-date-field--read-only","bm-date-field--fluid":"bm-date-field--fluid","bm-date-field__segments":"bm-date-field__segments","bm-date-field__separator":"bm-date-field__separator","bm-date-field__sr-status":"bm-date-field__sr-status"},B={day:"day",month:"month",year:"year"},L=({type:i,value:g,valueMin:p,valueMax:C,displayValue:n,isPlaceholder:x,valueText:v,invalid:E,role:l,isActive:t,disabled:m,readOnly:o,onFocus:h,onBlur:D,onInput:N,onKeyDown:F,segmentRef:f})=>{const a=!m&&!o,b=d.useRef(null),M=d.useCallback(e=>{b.current=e,f(e)},[f]),q=e=>{if(!a)return;const u=e.currentTarget,r=e.nativeEvent.data;r!=null&&r.length===1&&N(i,r),u.textContent!==n&&(u.textContent=n)};d.useLayoutEffect(()=>{if(!t||!a)return;const e=b.current;e&&y.selectElementContents(e)},[n,t,a]);const P=l==="spinbutton"?{"aria-valuenow":g??void 0,"aria-valuemin":p,"aria-valuemax":C,"aria-valuetext":v}:{"aria-multiline":!1};return R.jsx("span",{ref:M,role:l,"aria-label":B[i],...P,"aria-disabled":m||void 0,"aria-readonly":o||void 0,"aria-invalid":E||void 0,contentEditable:a&&t,suppressContentEditableWarning:!0,tabIndex:t?0:-1,inputMode:a?"numeric":void 0,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off","data-segment":i,"data-active":t,"data-placeholder":x,onFocus:h,onBlur:D,onInput:q,onKeyDown:e=>F(i,e),onMouseUp:e=>e.preventDefault(),className:$(_[c.segment]),children:n})};exports.DateFieldSegment=L;exports.baseClassNamePrefix=S;exports.classModifierPrefix=w;exports.staticDateFieldClassNames=c;exports.styles=_;