@viasat/beam-react 2.47.0 → 2.47.1
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.es.js +66 -68
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +9 -3
- package/lib/wip/DateField/DateField.utils.es.js +68 -64
- package/lib/wip/DateField/useDateFieldKeyboard.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldKeyboard.d.ts +6 -10
- package/lib/wip/DateField/useDateFieldKeyboard.es.js +39 -41
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldValue.d.ts +12 -15
- package/lib/wip/DateField/useDateFieldValue.es.js +47 -60
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 2.47.1 (2026-07-27)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **DateField:** predictable empty-seed + simpler Backspace/Delete (EPTOOLS-2766) ([#1377](https://git.viasat.com/vega/Beam/pull/1377))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Roman-Ionita, Alin
|
|
10
|
+
|
|
1
11
|
## 2.47.0 (2026-07-23)
|
|
2
12
|
|
|
3
13
|
### 🚀 Features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),De=require("clsx"),fe=require("react"),e=require("../../../chunks/DateField.Segment.CY0jg03_.js"),me=require("../../../chunks/constants.CgMu0_1M.js"),ge=require("../../../chunks/form.context.D5XrYvpI.js"),pe=require("../../Form/contexts/label.context.cjs.js"),xe=require("../../Form/contexts/helperText.context.cjs.js"),ve=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),r=require("./DateField.Segments.cjs.js"),ye=require("./DateField.utils.cjs.js"),Se=require("./useDateFieldFocus.cjs.js"),qe=require("./useDateFieldForm.cjs.js"),he=require("./useDateFieldKeyboard.cjs.js"),we=require("./useDateFieldSegments.cjs.js"),Ie=require("./useDateFieldValidity.cjs.js"),Re=require("./useDateFieldValue.cjs.js"),Pe=require("./useInvalidState.cjs.js"),Te=fe.forwardRef(function({value:S,defaultValue:q,onChange:h,label:d=null,helperText:n=null,error:o,hideRequiredMarker:w=!1,validationRules:I,width:R,theme:u,fluid:P=!1,disabled:T=!1,readOnly:V=!1,required:j=!1,name:c,id:M,className:N,style:O,"aria-label":B,"aria-describedby":C,"aria-labelledby":E,...H},K){const{disabled:i,readOnly:t,required:F,invalid:L,errorMessageProvided:_,defaultValue:$,errorId:b,helperTextId:k,validationErrorsId:A,labelId:D,ariaDescribedBy:U,ariaLabelledBy:W,showErrors:z}=qe.useDateFieldForm({name:c,disabled:T,readOnly:V,required:j,defaultValue:q,error:o,hasHelperText:!!n,hasLabel:!!d,validationRules:I,ariaDescribedBy:C,ariaLabelledBy:E}),{refFn:G,ref:f}=ve.useUniversalRef(K),{segmentRefs:J,registerSegmentRef:Q}=we.useDateFieldSegments(),{segmentText:X,segmentValues:m,currentValue:g,wasTouched:Y,appendDigit:Z,adjustSegment:ee,clearSegment:ie,beginSegmentEdit:ae,commitOnBlur:le}=Re.useDateFieldValue({value:S,defaultValue:$,onChange:h}),{focusedSegment:p,fieldTabIndex:se,handleSegmentFocus:x,handleFieldFocus:te,handleFieldBlur:re,handleFieldMouseDown:de,focusNext:v,focusPrevious:ne}=Se.useDateFieldFocus({disabled:i,fieldRef:f,segmentRefs:J,partsOrder:r.PARTS_ORDER,onSegmentFocusChange:ae,onFieldBlur:le}),oe=he.useDateFieldKeyboard({disabled:i,readOnly:t,fieldRef:f,focusNext:v,focusPrevious:ne,adjustSegment:ee,clearSegment:ie}),{isInvalid:ue}=Ie.useDateFieldValidity({segments:m,currentValue:g,wasTouched:Y,isFocused:p!==null}),ce=(l,s)=>{const{advanced:be}=Z(l,s);be&&v(l)},y=Pe.useInvalidState({formInvalid:L,valueInvalid:ue}),Fe=l=>{if(i)return;const s=l.target.closest("label");!s||s.id!==D||(l.preventDefault(),x(r.PARTS_ORDER[0]))},_e=De(e.styles[e.baseClassNamePrefix],u&&me.themeClassName(u),P&&e.styles[`${e.classModifierPrefix}fluid`],y&&e.styles[`${e.classModifierPrefix}error`],i&&e.styles[`${e.classModifierPrefix}disabled`],t&&e.styles[`${e.classModifierPrefix}read-only`],N);return a.jsxs("div",{className:_e,style:{...O,maxWidth:R},onMouseDownCapture:Fe,children:[a.jsx(pe.LabelProvider,{ctxId:D,ctxDisabled:i,ctxRequired:F&&!w,children:d}),a.jsx("div",{...H,ref:G,id:M,role:"group","aria-label":B,"aria-labelledby":W,"aria-disabled":i||void 0,"aria-required":F||void 0,"aria-invalid":y||void 0,"aria-describedby":U,"aria-errormessage":_?b:void 0,tabIndex:se,className:e.styles[e.staticDateFieldClassNames.field],onMouseDown:de,onFocus:te,children:a.jsx(r.DateFieldSegments,{segmentText:X,segmentValues:m,focusedSegment:p,disabled:i,readOnly:t,onSegmentFocus:x,onSegmentBlur:re,onSegmentInput:ce,onSegmentKeyDown:oe,registerSegmentRef:Q})}),a.jsx("input",{type:"hidden",name:c,value:ye.toISODateString(g),disabled:i}),a.jsxs(xe.HelperTextProvider,{ctxId:k,ctxDisabled:i,children:[n,_&&a.jsx(ge.HelperText,{id:b,appearance:"negative",children:o})]}),z(A)]})});exports.DateField=Te;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsxs as S, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { s as a, b as
|
|
5
|
-
import { t as
|
|
6
|
-
import { H as
|
|
7
|
-
import { LabelProvider as
|
|
8
|
-
import { HelperTextProvider as
|
|
9
|
-
import { useUniversalRef as
|
|
10
|
-
import { DateFieldSegments as
|
|
11
|
-
import { toISODateString as
|
|
12
|
-
import { useDateFieldFocus as
|
|
13
|
-
import { useDateFieldForm as
|
|
14
|
-
import { useDateFieldKeyboard as
|
|
15
|
-
import { useDateFieldSegments as
|
|
16
|
-
import { useDateFieldValidity as
|
|
17
|
-
import { useDateFieldValue as
|
|
18
|
-
import { useInvalidState as
|
|
19
|
-
const
|
|
2
|
+
import ve from "clsx";
|
|
3
|
+
import { forwardRef as De } from "react";
|
|
4
|
+
import { s as a, b as Fe, c as s, a as he } from "../../../chunks/DateField.Segment.C2qoaY0Z.js";
|
|
5
|
+
import { t as xe } from "../../../chunks/constants.Cruz2A1w.js";
|
|
6
|
+
import { H as ye } from "../../../chunks/form.context.cEuTL68U.js";
|
|
7
|
+
import { LabelProvider as Se } from "../../Form/contexts/label.context.es.js";
|
|
8
|
+
import { HelperTextProvider as Ie } from "../../Form/contexts/helperText.context.es.js";
|
|
9
|
+
import { useUniversalRef as we } from "../../Form/hooks/useUniversalRef.hook.es.js";
|
|
10
|
+
import { DateFieldSegments as Re, PARTS_ORDER as I } from "./DateField.Segments.es.js";
|
|
11
|
+
import { toISODateString as Ne } from "./DateField.utils.es.js";
|
|
12
|
+
import { useDateFieldFocus as Ve } from "./useDateFieldFocus.es.js";
|
|
13
|
+
import { useDateFieldForm as Be } from "./useDateFieldForm.es.js";
|
|
14
|
+
import { useDateFieldKeyboard as Ce } from "./useDateFieldKeyboard.es.js";
|
|
15
|
+
import { useDateFieldSegments as Oe } from "./useDateFieldSegments.es.js";
|
|
16
|
+
import { useDateFieldValidity as Pe } from "./useDateFieldValidity.es.js";
|
|
17
|
+
import { useDateFieldValue as Te } from "./useDateFieldValue.es.js";
|
|
18
|
+
import { useInvalidState as Me } from "./useInvalidState.es.js";
|
|
19
|
+
const ea = De(
|
|
20
20
|
function({
|
|
21
21
|
value: w,
|
|
22
22
|
defaultValue: R,
|
|
@@ -34,9 +34,9 @@ const aa = Fe(
|
|
|
34
34
|
required: M = !1,
|
|
35
35
|
name: u,
|
|
36
36
|
id: q,
|
|
37
|
-
className:
|
|
38
|
-
style:
|
|
39
|
-
"aria-label":
|
|
37
|
+
className: E,
|
|
38
|
+
style: H,
|
|
39
|
+
"aria-label": L,
|
|
40
40
|
"aria-describedby": $,
|
|
41
41
|
"aria-labelledby": j,
|
|
42
42
|
...K
|
|
@@ -55,7 +55,7 @@ const aa = Fe(
|
|
|
55
55
|
ariaDescribedBy: z,
|
|
56
56
|
ariaLabelledBy: G,
|
|
57
57
|
showErrors: J
|
|
58
|
-
} =
|
|
58
|
+
} = Be({
|
|
59
59
|
name: u,
|
|
60
60
|
disabled: P,
|
|
61
61
|
readOnly: T,
|
|
@@ -67,79 +67,77 @@ const aa = Fe(
|
|
|
67
67
|
validationRules: B,
|
|
68
68
|
ariaDescribedBy: $,
|
|
69
69
|
ariaLabelledBy: j
|
|
70
|
-
}), { refFn: Q, ref: g } =
|
|
70
|
+
}), { refFn: Q, ref: g } = we(W), { segmentRefs: X, registerSegmentRef: Y } = Oe(), {
|
|
71
71
|
segmentText: Z,
|
|
72
72
|
segmentValues: v,
|
|
73
73
|
currentValue: D,
|
|
74
74
|
wasTouched: ee,
|
|
75
75
|
appendDigit: ae,
|
|
76
76
|
adjustSegment: re,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} = Me({
|
|
77
|
+
clearSegment: le,
|
|
78
|
+
beginSegmentEdit: ie,
|
|
79
|
+
commitOnBlur: se
|
|
80
|
+
} = Te({
|
|
82
81
|
value: w,
|
|
83
82
|
defaultValue: U,
|
|
84
83
|
onChange: N
|
|
85
84
|
}), {
|
|
86
85
|
focusedSegment: F,
|
|
87
|
-
fieldTabIndex:
|
|
86
|
+
fieldTabIndex: de,
|
|
88
87
|
handleSegmentFocus: h,
|
|
89
|
-
handleFieldFocus:
|
|
90
|
-
handleFieldBlur:
|
|
91
|
-
handleFieldMouseDown:
|
|
88
|
+
handleFieldFocus: te,
|
|
89
|
+
handleFieldBlur: oe,
|
|
90
|
+
handleFieldMouseDown: ne,
|
|
92
91
|
focusNext: x,
|
|
93
|
-
focusPrevious:
|
|
94
|
-
} =
|
|
92
|
+
focusPrevious: me
|
|
93
|
+
} = Ve({
|
|
95
94
|
disabled: e,
|
|
96
95
|
fieldRef: g,
|
|
97
96
|
segmentRefs: X,
|
|
98
97
|
partsOrder: I,
|
|
99
|
-
onSegmentFocusChange:
|
|
100
|
-
onFieldBlur:
|
|
101
|
-
}),
|
|
98
|
+
onSegmentFocusChange: ie,
|
|
99
|
+
onFieldBlur: se
|
|
100
|
+
}), ue = Ce({
|
|
102
101
|
disabled: e,
|
|
103
102
|
readOnly: d,
|
|
104
103
|
fieldRef: g,
|
|
105
104
|
focusNext: x,
|
|
106
|
-
focusPrevious:
|
|
105
|
+
focusPrevious: me,
|
|
107
106
|
adjustSegment: re,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}), { isInvalid: ce } = Te({
|
|
107
|
+
clearSegment: le
|
|
108
|
+
}), { isInvalid: fe } = Pe({
|
|
111
109
|
segments: v,
|
|
112
110
|
currentValue: D,
|
|
113
111
|
wasTouched: ee,
|
|
114
112
|
isFocused: F !== null
|
|
115
|
-
}),
|
|
116
|
-
const { advanced:
|
|
117
|
-
|
|
118
|
-
}, y =
|
|
113
|
+
}), ce = (r, i) => {
|
|
114
|
+
const { advanced: ge } = ae(r, i);
|
|
115
|
+
ge && x(r);
|
|
116
|
+
}, y = Me({
|
|
119
117
|
formInvalid: A,
|
|
120
|
-
valueInvalid:
|
|
121
|
-
}),
|
|
118
|
+
valueInvalid: fe
|
|
119
|
+
}), pe = (r) => {
|
|
122
120
|
if (e) return;
|
|
123
121
|
const i = r.target.closest("label");
|
|
124
122
|
!i || i.id !== b || (r.preventDefault(), h(I[0]));
|
|
125
|
-
},
|
|
126
|
-
a[
|
|
127
|
-
m &&
|
|
123
|
+
}, be = ve(
|
|
124
|
+
a[Fe],
|
|
125
|
+
m && xe(m),
|
|
128
126
|
O && a[`${s}fluid`],
|
|
129
127
|
y && a[`${s}error`],
|
|
130
128
|
e && a[`${s}disabled`],
|
|
131
129
|
d && a[`${s}read-only`],
|
|
132
|
-
|
|
130
|
+
E
|
|
133
131
|
);
|
|
134
132
|
return /* @__PURE__ */ S(
|
|
135
133
|
"div",
|
|
136
134
|
{
|
|
137
|
-
className:
|
|
138
|
-
style: { ...
|
|
139
|
-
onMouseDownCapture:
|
|
135
|
+
className: be,
|
|
136
|
+
style: { ...H, maxWidth: C },
|
|
137
|
+
onMouseDownCapture: pe,
|
|
140
138
|
children: [
|
|
141
139
|
/* @__PURE__ */ l(
|
|
142
|
-
|
|
140
|
+
Se,
|
|
143
141
|
{
|
|
144
142
|
ctxId: b,
|
|
145
143
|
ctxDisabled: e,
|
|
@@ -154,19 +152,19 @@ const aa = Fe(
|
|
|
154
152
|
ref: Q,
|
|
155
153
|
id: q,
|
|
156
154
|
role: "group",
|
|
157
|
-
"aria-label":
|
|
155
|
+
"aria-label": L,
|
|
158
156
|
"aria-labelledby": G,
|
|
159
157
|
"aria-disabled": e || void 0,
|
|
160
158
|
"aria-required": f || void 0,
|
|
161
159
|
"aria-invalid": y || void 0,
|
|
162
160
|
"aria-describedby": z,
|
|
163
161
|
"aria-errormessage": c ? p : void 0,
|
|
164
|
-
tabIndex:
|
|
165
|
-
className: a[
|
|
166
|
-
onMouseDown:
|
|
167
|
-
onFocus:
|
|
162
|
+
tabIndex: de,
|
|
163
|
+
className: a[he.field],
|
|
164
|
+
onMouseDown: ne,
|
|
165
|
+
onFocus: te,
|
|
168
166
|
children: /* @__PURE__ */ l(
|
|
169
|
-
|
|
167
|
+
Re,
|
|
170
168
|
{
|
|
171
169
|
segmentText: Z,
|
|
172
170
|
segmentValues: v,
|
|
@@ -174,9 +172,9 @@ const aa = Fe(
|
|
|
174
172
|
disabled: e,
|
|
175
173
|
readOnly: d,
|
|
176
174
|
onSegmentFocus: h,
|
|
177
|
-
onSegmentBlur:
|
|
178
|
-
onSegmentInput:
|
|
179
|
-
onSegmentKeyDown:
|
|
175
|
+
onSegmentBlur: oe,
|
|
176
|
+
onSegmentInput: ce,
|
|
177
|
+
onSegmentKeyDown: ue,
|
|
180
178
|
registerSegmentRef: Y
|
|
181
179
|
}
|
|
182
180
|
)
|
|
@@ -187,13 +185,13 @@ const aa = Fe(
|
|
|
187
185
|
{
|
|
188
186
|
type: "hidden",
|
|
189
187
|
name: u,
|
|
190
|
-
value:
|
|
188
|
+
value: Ne(D),
|
|
191
189
|
disabled: e
|
|
192
190
|
}
|
|
193
191
|
),
|
|
194
|
-
/* @__PURE__ */ S(
|
|
192
|
+
/* @__PURE__ */ S(Ie, { ctxId: _, ctxDisabled: e, children: [
|
|
195
193
|
o,
|
|
196
|
-
c && /* @__PURE__ */ l(
|
|
194
|
+
c && /* @__PURE__ */ l(ye, { id: p, appearance: "negative", children: n })
|
|
197
195
|
] }),
|
|
198
196
|
J(k)
|
|
199
197
|
]
|
|
@@ -202,5 +200,5 @@ const aa = Fe(
|
|
|
202
200
|
}
|
|
203
201
|
);
|
|
204
202
|
export {
|
|
205
|
-
|
|
203
|
+
ea as DateField
|
|
206
204
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./DateField.validation.cjs.js"),i=31,l=12,S={day:i,month:l,year:9999},u=(e,t,n)=>Math.min(n,Math.max(t,e)),g=(e,t)=>((e-1)%t+t)%t+1,y=2024,M=(e,t)=>t==null?31:new Date(e??y,t,0).getDate(),N=()=>{const e=new Date;return{day:e.getDate(),month:e.getMonth()+1,year:e.getFullYear()}},f=(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 m=e==="day"?i:l;return n>0?1:m}if(e==="year")return u(t+n,1,9999);const a=e==="day"?i:l;return g(t+n,a)},T={day:"",month:"",year:""},c=e=>e instanceof Date&&!Number.isNaN(e.getTime()),d=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},_=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.getTime()===t.getTime(),h=e=>{if(!c(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}`},D=e=>e.filter(t=>t.type!=="literal").map(t=>t.type),A=e=>c(e)?{day:String(e.getDate()).padStart(2,"0"),month:String(e.getMonth()+1).padStart(2,"0"),year:String(e.getFullYear()).padStart(4,"0")}:T,o=(e,t)=>{if(t===""||e==="year"&&t.length<s.SEGMENT_MAX_LENGTH.year)return null;const n=parseInt(t,10);return Number.isNaN(n)||n===0?null:n},E=e=>d({day:o("day",e.day),month:o("month",e.month),year:o("year",e.year)}),p=(e,t)=>t===""?"":t.padStart(s.SEGMENT_MAX_LENGTH[e],"0"),V=(e,t,n)=>t===""?{displayValue:n,isPlaceholder:!0}:{displayValue:t.padStart(s.SEGMENT_MAX_LENGTH[e],"0"),isPlaceholder:!1},F=e=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)},I=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=i;exports.MONTH_MAX=l;exports.SEGMENT_ARIA_MAX=S;exports.adjustSegmentValue=f;exports.clamp=u;exports.clearSelectionWithin=I;exports.deriveValue=d;exports.deriveValueFromText=E;exports.getDaysInMonth=M;exports.getSegmentDisplay=V;exports.getSegmentOrder=D;exports.isSameDateValue=_;exports.normalizeSegmentText=p;exports.segmentNumber=o;exports.segmentTextFromValue=A;exports.selectElementContents=F;exports.toISODateString=h;exports.todayParts=N;exports.wrapInRange=g;
|
|
@@ -49,7 +49,11 @@ export declare const todayParts: () => {
|
|
|
49
49
|
export interface AdjustSegmentContext {
|
|
50
50
|
/** Days in the current month (use {@link getDaysInMonth} to compute). */
|
|
51
51
|
daysInMonth: number;
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Today's local-date values. Only `year` is read now — it seeds an empty
|
|
54
|
+
* year segment on the first press. Day/month seed to a fixed first/last
|
|
55
|
+
* valid value instead, so `day`/`month` here go unused.
|
|
56
|
+
*/
|
|
53
57
|
today: {
|
|
54
58
|
day: number;
|
|
55
59
|
month: number;
|
|
@@ -71,8 +75,10 @@ export interface AdjustSegmentContext {
|
|
|
71
75
|
* currently selected month (month-aware).
|
|
72
76
|
* - **month**: modular wrap within `[1, MONTH_MAX]`.
|
|
73
77
|
* - **year**: clamp to `[1, 9999]`; no wrap.
|
|
74
|
-
* - **Empty segment + numeric delta**:
|
|
75
|
-
*
|
|
78
|
+
* - **Empty segment + numeric delta**: direction-based first/last valid value
|
|
79
|
+
* for day/month — positive amount → `1`, negative amount → `DAY_SPIN_MAX`/
|
|
80
|
+
* `MONTH_MAX`. Year has no natural bound, so it seeds to `ctx.today.year`
|
|
81
|
+
* regardless of direction.
|
|
76
82
|
* - **`'min'`**: returns 1 for day/month, null for year.
|
|
77
83
|
* - **`'max'`**: returns `ctx.daysInMonth` for day (End → month-aware last
|
|
78
84
|
* valid day), MONTH_MAX for month, null for year.
|
|
@@ -1,74 +1,78 @@
|
|
|
1
|
-
import { SEGMENT_MAX_LENGTH as
|
|
2
|
-
const
|
|
3
|
-
day:
|
|
4
|
-
month:
|
|
1
|
+
import { SEGMENT_MAX_LENGTH as i } from "./DateField.validation.es.js";
|
|
2
|
+
const s = 31, l = 12, h = {
|
|
3
|
+
day: s,
|
|
4
|
+
month: l,
|
|
5
5
|
year: 9999
|
|
6
|
-
},
|
|
7
|
-
const
|
|
8
|
-
return { day:
|
|
9
|
-
},
|
|
10
|
-
if (n === "min") return
|
|
6
|
+
}, g = (e, t, n) => Math.min(n, Math.max(t, e)), d = (e, t) => ((e - 1) % t + t) % t + 1, m = 2024, N = (e, t) => t == null ? 31 : new Date(e ?? m, t, 0).getDate(), M = () => {
|
|
7
|
+
const e = /* @__PURE__ */ new Date();
|
|
8
|
+
return { day: e.getDate(), month: e.getMonth() + 1, year: e.getFullYear() };
|
|
9
|
+
}, D = (e, t, n, r) => {
|
|
10
|
+
if (n === "min") return e === "year" ? null : 1;
|
|
11
11
|
if (n === "max")
|
|
12
|
-
return
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
}, T = (t) => t.
|
|
27
|
-
(e)
|
|
28
|
-
).
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
12
|
+
return e === "year" ? null : e === "day" ? r.daysInMonth : l;
|
|
13
|
+
if (t == null) {
|
|
14
|
+
if (e === "year") return r.today.year;
|
|
15
|
+
const c = e === "day" ? s : l;
|
|
16
|
+
return n > 0 ? 1 : c;
|
|
17
|
+
}
|
|
18
|
+
if (e === "year") return g(t + n, 1, 9999);
|
|
19
|
+
const a = e === "day" ? s : l;
|
|
20
|
+
return d(t + n, a);
|
|
21
|
+
}, y = { day: "", month: "", year: "" }, u = (e) => e instanceof Date && !Number.isNaN(e.getTime()), S = (e) => {
|
|
22
|
+
const { day: t, month: n, year: r } = e;
|
|
23
|
+
if (t == null || n == null || r == null) return null;
|
|
24
|
+
const a = new Date(r, n - 1, t);
|
|
25
|
+
return a.setFullYear(r), Number.isNaN(a.getTime()) || a.getFullYear() !== r || a.getMonth() !== n - 1 || a.getDate() !== t ? null : a;
|
|
26
|
+
}, T = (e, t) => e == null && t == null ? !0 : e == null || t == null ? !1 : e.getTime() === t.getTime(), p = (e) => {
|
|
27
|
+
if (!u(e)) return "";
|
|
28
|
+
const t = String(e.getFullYear()).padStart(4, "0"), n = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
|
|
29
|
+
return `${t}-${n}-${r}`;
|
|
30
|
+
}, A = (e) => e.filter(
|
|
31
|
+
(t) => t.type !== "literal"
|
|
32
|
+
).map((t) => t.type), E = (e) => u(e) ? {
|
|
33
|
+
day: String(e.getDate()).padStart(2, "0"),
|
|
34
|
+
month: String(e.getMonth() + 1).padStart(2, "0"),
|
|
35
|
+
year: String(e.getFullYear()).padStart(4, "0")
|
|
36
|
+
} : y, o = (e, t) => {
|
|
37
|
+
if (t === "" || e === "year" && t.length < i.year) return null;
|
|
38
|
+
const n = parseInt(t, 10);
|
|
35
39
|
return Number.isNaN(n) || n === 0 ? null : n;
|
|
36
|
-
},
|
|
37
|
-
day:
|
|
38
|
-
month:
|
|
39
|
-
year:
|
|
40
|
-
}),
|
|
41
|
-
displayValue:
|
|
40
|
+
}, _ = (e) => S({
|
|
41
|
+
day: o("day", e.day),
|
|
42
|
+
month: o("month", e.month),
|
|
43
|
+
year: o("year", e.year)
|
|
44
|
+
}), w = (e, t) => t === "" ? "" : t.padStart(i[e], "0"), F = (e, t, n) => t === "" ? { displayValue: n, isPlaceholder: !0 } : {
|
|
45
|
+
displayValue: t.padStart(i[e], "0"),
|
|
42
46
|
isPlaceholder: !1
|
|
43
|
-
},
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
47
|
+
}, V = (e) => {
|
|
48
|
+
const t = window.getSelection();
|
|
49
|
+
if (!t) return;
|
|
46
50
|
const n = document.createRange();
|
|
47
|
-
n.selectNodeContents(
|
|
48
|
-
},
|
|
51
|
+
n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
|
|
52
|
+
}, Y = (e) => {
|
|
49
53
|
var n;
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
52
|
-
|
|
54
|
+
if (!e) return;
|
|
55
|
+
const t = (n = window.getSelection) == null ? void 0 : n.call(window);
|
|
56
|
+
t && t.rangeCount > 0 && e.contains(t.anchorNode) && t.removeAllRanges();
|
|
53
57
|
};
|
|
54
58
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
s as DAY_SPIN_MAX,
|
|
60
|
+
l as MONTH_MAX,
|
|
61
|
+
h as SEGMENT_ARIA_MAX,
|
|
62
|
+
D as adjustSegmentValue,
|
|
63
|
+
g as clamp,
|
|
64
|
+
Y as clearSelectionWithin,
|
|
65
|
+
S as deriveValue,
|
|
66
|
+
_ as deriveValueFromText,
|
|
67
|
+
N as getDaysInMonth,
|
|
68
|
+
F as getSegmentDisplay,
|
|
69
|
+
A as getSegmentOrder,
|
|
70
|
+
T as isSameDateValue,
|
|
71
|
+
w as normalizeSegmentText,
|
|
72
|
+
o as segmentNumber,
|
|
73
|
+
E as segmentTextFromValue,
|
|
74
|
+
V as selectElementContents,
|
|
71
75
|
p as toISODateString,
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
M as todayParts,
|
|
77
|
+
d as wrapInRange
|
|
74
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react");function d({disabled:a,readOnly:c,fieldRef:y,focusNext:o,focusPrevious:e,adjustSegment:t,clearSegment:l}){const p=w.useMemo(()=>{const n={ArrowRight:({segment:r,isRTL:i})=>((i?e:o)(r),!0),ArrowLeft:({segment:r,isRTL:i})=>((i?o:e)(r),!0)};return c?n:{...n,ArrowUp:({segment:r})=>t(r,1),ArrowDown:({segment:r})=>t(r,-1),PageUp:({segment:r})=>t(r,5),PageDown:({segment:r})=>t(r,-5),Home:({segment:r})=>t(r,"min"),End:({segment:r})=>t(r,"max"),Backspace:({segment:r})=>(l(r).wasEmpty&&e(r),!0),Delete:({segment:r})=>(l(r),!0)}},[t,l,o,e,c]);return w.useCallback((n,r)=>{if(a||r.altKey||r.ctrlKey||r.metaKey||r.shiftKey)return;const i=p[r.key];if(!i)return;const u=y.current,b=!!u&&(getComputedStyle(u).direction==="rtl"||!!u.closest('[dir="rtl"]'));i({segment:n,event:r,isRTL:b})&&r.preventDefault()},[a,p,y])}exports.useDateFieldKeyboard=d;
|
|
@@ -41,18 +41,14 @@ export interface UseDateFieldKeyboardArgs {
|
|
|
41
41
|
*/
|
|
42
42
|
adjustSegment: (type: SegmentType, amount: SegmentAdjustment) => boolean;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* Returns `{ wasEmpty: true }` when the buffer was already
|
|
46
|
-
*
|
|
44
|
+
* Clears the entire segment buffer to `''` — shared by Backspace and Delete.
|
|
45
|
+
* Returns `{ wasEmpty: true }` when the buffer was already
|
|
46
|
+
* empty, signalling Backspace to move focus to the previous segment instead;
|
|
47
|
+
* Delete ignores the result and leaves focus on the current segment.
|
|
47
48
|
* Provided by `useDateFieldValue`.
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
|
+
clearSegment: (type: SegmentType) => {
|
|
50
51
|
wasEmpty: boolean;
|
|
51
52
|
};
|
|
52
|
-
/**
|
|
53
|
-
* Clears the entire segment buffer to `''` (Delete). Focus stays on the
|
|
54
|
-
* current segment. Provided by `useDateFieldValue`.
|
|
55
|
-
*/
|
|
56
|
-
clearSegment: (type: SegmentType) => void;
|
|
57
53
|
}
|
|
58
|
-
export declare function useDateFieldKeyboard({ disabled, readOnly, fieldRef, focusNext, focusPrevious, adjustSegment,
|
|
54
|
+
export declare function useDateFieldKeyboard({ disabled, readOnly, fieldRef, focusNext, focusPrevious, adjustSegment, clearSegment, }: UseDateFieldKeyboardArgs): (segment: SegmentType, event: KeyboardEvent<HTMLSpanElement>) => void;
|
|
@@ -1,49 +1,47 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
function
|
|
3
|
-
disabled:
|
|
4
|
-
readOnly:
|
|
5
|
-
fieldRef:
|
|
1
|
+
import { useMemo as D, useCallback as K } from "react";
|
|
2
|
+
function A({
|
|
3
|
+
disabled: e,
|
|
4
|
+
readOnly: u,
|
|
5
|
+
fieldRef: w,
|
|
6
6
|
focusNext: l,
|
|
7
|
-
focusPrevious:
|
|
8
|
-
adjustSegment:
|
|
9
|
-
|
|
10
|
-
clearSegment: y
|
|
7
|
+
focusPrevious: n,
|
|
8
|
+
adjustSegment: t,
|
|
9
|
+
clearSegment: p
|
|
11
10
|
}) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return h(
|
|
11
|
+
const y = D(() => {
|
|
12
|
+
const o = {
|
|
13
|
+
// Nav keys always own the event (arrows are contentEditable caret keys we
|
|
14
|
+
// suppress even at the first/last segment), so they always report handled.
|
|
15
|
+
ArrowRight: ({ segment: r, isRTL: i }) => ((i ? n : l)(r), !0),
|
|
16
|
+
ArrowLeft: ({ segment: r, isRTL: i }) => ((i ? l : n)(r), !0)
|
|
17
|
+
};
|
|
18
|
+
return u ? o : {
|
|
19
|
+
...o,
|
|
20
|
+
ArrowUp: ({ segment: r }) => t(r, 1),
|
|
21
|
+
ArrowDown: ({ segment: r }) => t(r, -1),
|
|
22
|
+
PageUp: ({ segment: r }) => t(r, 5),
|
|
23
|
+
PageDown: ({ segment: r }) => t(r, -5),
|
|
24
|
+
Home: ({ segment: r }) => t(r, "min"),
|
|
25
|
+
End: ({ segment: r }) => t(r, "max"),
|
|
26
|
+
// Backspace and Delete both clear the whole segment to
|
|
27
|
+
// placeholder. Backspace on an already-empty segment moves focus to the
|
|
28
|
+
// previous segment instead (MUI parity); Delete just clears.
|
|
29
|
+
// Both always own the key (clear or focus-hop), so they report handled.
|
|
30
|
+
Backspace: ({ segment: r }) => (p(r).wasEmpty && n(r), !0),
|
|
31
|
+
Delete: ({ segment: r }) => (p(r), !0)
|
|
32
|
+
};
|
|
33
|
+
}, [t, p, l, n, u]);
|
|
34
|
+
return K(
|
|
37
35
|
(o, r) => {
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
const c =
|
|
42
|
-
|
|
36
|
+
if (e || r.altKey || r.ctrlKey || r.metaKey || r.shiftKey) return;
|
|
37
|
+
const i = y[r.key];
|
|
38
|
+
if (!i) return;
|
|
39
|
+
const c = w.current, a = !!c && (getComputedStyle(c).direction === "rtl" || !!c.closest('[dir="rtl"]'));
|
|
40
|
+
i({ segment: o, event: r, isRTL: a }) && r.preventDefault();
|
|
43
41
|
},
|
|
44
|
-
[
|
|
42
|
+
[e, y, w]
|
|
45
43
|
);
|
|
46
44
|
}
|
|
47
45
|
export {
|
|
48
|
-
|
|
46
|
+
A as useDateFieldKeyboard
|
|
49
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),t=require("./DateField.utils.cjs.js"),E=require("./DateField.validation.cjs.js");function p({value:c,defaultValue:F,onChange:g}){const T=r.useRef(c!==void 0),b=T.current,[o,S]=r.useState(()=>t.segmentTextFromValue(b?c??null:F??null)),[_,y]=r.useState(!1),a=r.useRef(o),d=r.useRef(new Set),i=r.useRef(!1),h={day:t.segmentNumber("day",o.day),month:t.segmentNumber("month",o.month),year:t.segmentNumber("year",o.year)},R=t.deriveValue(h),x=r.useRef(R),V=r.useRef(b?c??null:null),m=r.useRef(g);r.useEffect(()=>{m.current=g},[g]),r.useEffect(()=>{if(!T.current||i.current||t.isSameDateValue(c??null,V.current))return;V.current=c??null;const e=t.segmentTextFromValue(c??null);a.current=e,S(e),x.current=t.deriveValueFromText(e)},[c]);const f=r.useCallback(e=>{var u;const n=t.deriveValueFromText(e);t.isSameDateValue(n,x.current)||(x.current=n,(u=m.current)==null||u.call(m,n))},[]),l=r.useCallback((e,n,{replace:u})=>{const s={...a.current,[e]:n};a.current=s,S(s),y(!0),f(s),u?d.current.add(e):d.current.delete(e)},[f]),N=r.useCallback((e,n)=>{const u=d.current.has(e)?"":a.current[e],s=E.tryAppendDigit(e,u,n);return s.rejected?{advanced:!1,rejected:!0}:(l(e,s.newBuffer,{replace:s.shouldAdvance}),{advanced:s.shouldAdvance,rejected:!1})},[l]),k=r.useCallback((e,n)=>{const u=a.current,s=t.segmentNumber(e,u[e]),v=t.getDaysInMonth(t.segmentNumber("year",u.year),t.segmentNumber("month",u.month)),D=t.adjustSegmentValue(e,s,n,{daysInMonth:v,today:t.todayParts()});return D==null?!1:(i.current=!0,l(e,String(D).padStart(E.SEGMENT_MAX_LENGTH[e],"0"),{replace:!0}),!0)},[l]),w=r.useCallback(e=>a.current[e]===""?{wasEmpty:!0}:(i.current=!0,l(e,"",{replace:!1}),{wasEmpty:!1}),[l]),C=r.useCallback(e=>{i.current=!0,d.current.add(e)},[]),j=r.useCallback(()=>{i.current=!1;const e=a.current,n={day:t.normalizeSegmentText("day",e.day),month:t.normalizeSegmentText("month",e.month),year:t.normalizeSegmentText("year",e.year)};a.current=n,S(n),y(!0),f(n)},[f]);return{segmentText:o,segmentValues:h,currentValue:R,isControlled:b,wasTouched:_,appendDigit:N,adjustSegment:k,clearSegment:w,beginSegmentEdit:C,commitOnBlur:j}}exports.useDateFieldValue=p;
|
|
@@ -17,7 +17,9 @@ export interface UseDateFieldValueReturn {
|
|
|
17
17
|
* Increments, decrements, or jumps a segment to its min/max boundary.
|
|
18
18
|
*
|
|
19
19
|
* - Numeric `amount` (e.g. ±1, ±5): day/month wrap modularly; year clamps
|
|
20
|
-
* to [1, 9999]. An empty segment seeds to
|
|
20
|
+
* to [1, 9999]. An empty day/month segment seeds to a fixed first/last
|
|
21
|
+
* valid value based on direction; an empty year seeds to the current
|
|
22
|
+
* year.
|
|
21
23
|
* - `'min'` / `'max'`: jump to the lower/upper bound. No-op on year (no
|
|
22
24
|
* meaningful bound until DF-10 adds minDate/maxDate).
|
|
23
25
|
*
|
|
@@ -33,24 +35,19 @@ export interface UseDateFieldValueReturn {
|
|
|
33
35
|
*/
|
|
34
36
|
adjustSegment: (type: SegmentType, amount: SegmentAdjustment) => boolean;
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* Clears the entire segment buffer to `''` — the shared Backspace and
|
|
39
|
+
* Delete behaviour.
|
|
37
40
|
*
|
|
38
|
-
* Returns `{ wasEmpty: true }` when the buffer was already empty
|
|
39
|
-
* caller (keyboard handler) knows
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* Returns `{ wasEmpty: true }` when the buffer was already empty, without
|
|
42
|
+
* mutating, so the caller (keyboard handler) knows Backspace should move
|
|
43
|
+
* focus to the previous segment instead of clearing. Otherwise focus stays
|
|
44
|
+
* on the current segment. Fires `onChange(null)` via `emitIfChanged` when
|
|
45
|
+
* the cleared segment was part of a complete date. Clears `replaceNextRef`
|
|
46
|
+
* for the segment so the next digit appends.
|
|
42
47
|
*/
|
|
43
|
-
|
|
48
|
+
clearSegment: (type: SegmentType) => {
|
|
44
49
|
wasEmpty: boolean;
|
|
45
50
|
};
|
|
46
|
-
/**
|
|
47
|
-
* Clears the entire segment buffer to `''` (Delete behaviour).
|
|
48
|
-
*
|
|
49
|
-
* Focus stays on the current segment. Fires `onChange(null)` via
|
|
50
|
-
* `emitIfChanged` when the cleared segment was part of a complete date.
|
|
51
|
-
* Clears `replaceNextRef` for the segment so the next digit appends.
|
|
52
|
-
*/
|
|
53
|
-
clearSegment: (type: SegmentType) => void;
|
|
54
51
|
beginSegmentEdit: (type: SegmentType) => void;
|
|
55
52
|
commitOnBlur: () => void;
|
|
56
53
|
}
|
|
@@ -1,75 +1,63 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { segmentTextFromValue as
|
|
3
|
-
import { tryAppendDigit as
|
|
4
|
-
function
|
|
5
|
-
value:
|
|
6
|
-
defaultValue:
|
|
1
|
+
import { useRef as s, useState as w, useEffect as b, useCallback as o } from "react";
|
|
2
|
+
import { segmentTextFromValue as A, segmentNumber as l, deriveValue as C, isSameDateValue as M, deriveValueFromText as N, getDaysInMonth as H, adjustSegmentValue as L, todayParts as O, normalizeSegmentText as T } from "./DateField.utils.es.js";
|
|
3
|
+
import { tryAppendDigit as P, SEGMENT_MAX_LENGTH as W } from "./DateField.validation.es.js";
|
|
4
|
+
function K({
|
|
5
|
+
value: u,
|
|
6
|
+
defaultValue: v,
|
|
7
7
|
onChange: x
|
|
8
8
|
}) {
|
|
9
|
-
const E =
|
|
10
|
-
() =>
|
|
11
|
-
), [F, V] = w(!1), c =
|
|
12
|
-
day:
|
|
13
|
-
month:
|
|
14
|
-
year:
|
|
15
|
-
}, D = C(p), y =
|
|
16
|
-
h ? a ?? null : null
|
|
17
|
-
), f = o(x);
|
|
9
|
+
const E = s(u !== void 0), h = E.current, [d, S] = w(
|
|
10
|
+
() => A(h ? u ?? null : v ?? null)
|
|
11
|
+
), [F, V] = w(!1), c = s(d), i = s(/* @__PURE__ */ new Set()), m = s(!1), p = {
|
|
12
|
+
day: l("day", d.day),
|
|
13
|
+
month: l("month", d.month),
|
|
14
|
+
year: l("year", d.year)
|
|
15
|
+
}, D = C(p), y = s(D), R = s(h ? u ?? null : null), f = s(x);
|
|
18
16
|
b(() => {
|
|
19
17
|
f.current = x;
|
|
20
18
|
}, [x]), b(() => {
|
|
21
|
-
if (!E.current ||
|
|
22
|
-
R.current =
|
|
23
|
-
const e =
|
|
24
|
-
c.current = e, S(e), y.current =
|
|
25
|
-
}, [
|
|
26
|
-
const g =
|
|
19
|
+
if (!E.current || m.current || M(u ?? null, R.current)) return;
|
|
20
|
+
R.current = u ?? null;
|
|
21
|
+
const e = A(u ?? null);
|
|
22
|
+
c.current = e, S(e), y.current = N(e);
|
|
23
|
+
}, [u]);
|
|
24
|
+
const g = o((e) => {
|
|
27
25
|
var r;
|
|
28
|
-
const t =
|
|
29
|
-
|
|
30
|
-
}, []),
|
|
26
|
+
const t = N(e);
|
|
27
|
+
M(t, y.current) || (y.current = t, (r = f.current) == null || r.call(f, t));
|
|
28
|
+
}, []), a = o(
|
|
31
29
|
(e, t, { replace: r }) => {
|
|
32
30
|
const n = { ...c.current, [e]: t };
|
|
33
|
-
c.current = n, S(n), V(!0), g(n), r ?
|
|
31
|
+
c.current = n, S(n), V(!0), g(n), r ? i.current.add(e) : i.current.delete(e);
|
|
34
32
|
},
|
|
35
33
|
[g]
|
|
36
|
-
), I =
|
|
34
|
+
), I = o(
|
|
37
35
|
(e, t) => {
|
|
38
|
-
const r =
|
|
39
|
-
return n.rejected ? { advanced: !1, rejected: !0 } : (
|
|
36
|
+
const r = i.current.has(e) ? "" : c.current[e], n = P(e, r, t);
|
|
37
|
+
return n.rejected ? { advanced: !1, rejected: !0 } : (a(e, n.newBuffer, { replace: n.shouldAdvance }), { advanced: n.shouldAdvance, rejected: !1 });
|
|
40
38
|
},
|
|
41
|
-
[
|
|
42
|
-
), B =
|
|
39
|
+
[a]
|
|
40
|
+
), B = o(
|
|
43
41
|
(e, t) => {
|
|
44
|
-
const r = c.current, n =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
), j =
|
|
42
|
+
const r = c.current, n = l(e, r[e]), z = H(
|
|
43
|
+
l("year", r.year),
|
|
44
|
+
l("month", r.month)
|
|
45
|
+
), j = L(e, n, t, {
|
|
48
46
|
daysInMonth: z,
|
|
49
|
-
today:
|
|
47
|
+
today: O()
|
|
50
48
|
});
|
|
51
|
-
return j == null ? !1 : (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{ replace: !0 }
|
|
55
|
-
), !0);
|
|
49
|
+
return j == null ? !1 : (m.current = !0, a(e, String(j).padStart(W[e], "0"), {
|
|
50
|
+
replace: !0
|
|
51
|
+
}), !0);
|
|
56
52
|
},
|
|
57
|
-
[
|
|
58
|
-
), G =
|
|
59
|
-
(e) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(e) => {
|
|
66
|
-
c.current[e] !== "" && (l.current = !0, u(e, "", { replace: !1 }));
|
|
67
|
-
},
|
|
68
|
-
[u]
|
|
69
|
-
), _ = s((e) => {
|
|
70
|
-
l.current = !0, m.current.add(e);
|
|
71
|
-
}, []), k = s(() => {
|
|
72
|
-
l.current = !1;
|
|
53
|
+
[a]
|
|
54
|
+
), G = o(
|
|
55
|
+
(e) => c.current[e] === "" ? { wasEmpty: !0 } : (m.current = !0, a(e, "", { replace: !1 }), { wasEmpty: !1 }),
|
|
56
|
+
[a]
|
|
57
|
+
), _ = o((e) => {
|
|
58
|
+
m.current = !0, i.current.add(e);
|
|
59
|
+
}, []), k = o(() => {
|
|
60
|
+
m.current = !1;
|
|
73
61
|
const e = c.current, t = {
|
|
74
62
|
day: T("day", e.day),
|
|
75
63
|
month: T("month", e.month),
|
|
@@ -78,19 +66,18 @@ function Q({
|
|
|
78
66
|
c.current = t, S(t), V(!0), g(t);
|
|
79
67
|
}, [g]);
|
|
80
68
|
return {
|
|
81
|
-
segmentText:
|
|
69
|
+
segmentText: d,
|
|
82
70
|
segmentValues: p,
|
|
83
71
|
currentValue: D,
|
|
84
72
|
isControlled: h,
|
|
85
73
|
wasTouched: F,
|
|
86
74
|
appendDigit: I,
|
|
87
75
|
adjustSegment: B,
|
|
88
|
-
|
|
89
|
-
clearSegment: L,
|
|
76
|
+
clearSegment: G,
|
|
90
77
|
beginSegmentEdit: _,
|
|
91
78
|
commitOnBlur: k
|
|
92
79
|
};
|
|
93
80
|
}
|
|
94
81
|
export {
|
|
95
|
-
|
|
82
|
+
K as useDateFieldValue
|
|
96
83
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.47.
|
|
3
|
+
"version": "2.47.1",
|
|
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.47.
|
|
64
|
-
"@viasat/beam-shared": "2.47.
|
|
65
|
-
"@viasat/beam-styles": "2.47.
|
|
66
|
-
"@viasat/beam-tokens": "2.47.
|
|
67
|
-
"@viasat/beam-icons": "2.47.
|
|
68
|
-
"@viasat/beam-react-claude-plugin": "2.47.
|
|
63
|
+
"@viasat/beam-fonts": "2.47.1",
|
|
64
|
+
"@viasat/beam-shared": "2.47.1",
|
|
65
|
+
"@viasat/beam-styles": "2.47.1",
|
|
66
|
+
"@viasat/beam-tokens": "2.47.1",
|
|
67
|
+
"@viasat/beam-icons": "2.47.1",
|
|
68
|
+
"@viasat/beam-react-claude-plugin": "2.47.1",
|
|
69
69
|
"clsx": "^1.2.1",
|
|
70
70
|
"@floating-ui/react": "^0.26.18",
|
|
71
71
|
"@stepperize/react": "^5.1.5",
|