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