@viasat/beam-react 2.56.0 → 2.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/chunks/{DateField.Segment.CwhRnhtq.js → DateField.Segment.BMXzpxgl.js} +27 -26
- package/chunks/DateField.Segment.BqMaeKLk.js +1 -0
- package/chunks/use-isomorphic-layout-effect.browser.esm.CkGv31zs.js +1 -0
- package/chunks/use-isomorphic-layout-effect.browser.esm.DERp5kr6.js +5 -0
- package/lib/wip/DataTable/DataTable.columns.cjs.js +1 -0
- package/lib/wip/DataTable/DataTable.columns.d.ts +26 -0
- package/lib/wip/DataTable/DataTable.columns.es.js +10 -0
- package/lib/wip/DataTable/index.cjs.js +1 -1
- package/lib/wip/DataTable/index.d.ts +2 -0
- package/lib/wip/DataTable/index.es.js +13 -11
- package/lib/wip/DateField/DateField.Segment.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segment.es.js +3 -2
- package/lib/wip/DateField/DateField.Segments.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segments.es.js +1 -1
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.devWarnings.cjs.js +1 -0
- package/lib/wip/DateField/DateField.devWarnings.d.ts +15 -0
- package/lib/wip/DateField/DateField.devWarnings.es.js +22 -0
- package/lib/wip/DateField/DateField.es.js +186 -177
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +7 -5
- package/lib/wip/DateField/DateField.utils.es.js +84 -70
- package/lib/wip/ErrorBoundary/ErrorBoundary.cjs.js +1 -0
- package/lib/wip/ErrorBoundary/ErrorBoundary.d.ts +28 -0
- package/lib/wip/ErrorBoundary/ErrorBoundary.es.js +19 -0
- package/lib/wip/ErrorBoundary/index.cjs.js +1 -0
- package/lib/wip/ErrorBoundary/index.d.ts +2 -0
- package/lib/wip/ErrorBoundary/index.es.js +4 -0
- package/lib/wip/index.cjs.js +1 -1
- package/lib/wip/index.d.ts +1 -0
- package/lib/wip/index.es.js +17 -13
- package/package.json +7 -7
- package/utils/hooks/useId.cjs.js +1 -1
- package/utils/hooks/useId.es.js +7 -8
- package/chunks/DateField.Segment.CqFLhMYA.js +0 -1
|
@@ -1,236 +1,245 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { s as
|
|
5
|
-
import { t as
|
|
6
|
-
import { i as
|
|
7
|
-
import { H as
|
|
8
|
-
import { LabelProvider as
|
|
9
|
-
import { HelperTextProvider as
|
|
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
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
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:
|
|
24
|
-
defaultValue:
|
|
25
|
-
onChange:
|
|
26
|
-
minDate:
|
|
27
|
-
maxDate:
|
|
28
|
-
getClampAnnouncement:
|
|
29
|
-
locale:
|
|
30
|
-
label:
|
|
31
|
-
helperText:
|
|
32
|
-
error:
|
|
33
|
-
hideRequiredMarker:
|
|
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:
|
|
36
|
-
theme:
|
|
37
|
-
fluid:
|
|
38
|
-
disabled:
|
|
39
|
-
readOnly:
|
|
40
|
-
required:
|
|
41
|
-
name:
|
|
42
|
-
id:
|
|
43
|
-
className:
|
|
44
|
-
style:
|
|
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:
|
|
53
|
-
required:
|
|
58
|
+
readOnly: t,
|
|
59
|
+
required: h,
|
|
54
60
|
invalid: X,
|
|
55
|
-
errorMessageProvided:
|
|
56
|
-
defaultValue:
|
|
57
|
-
errorId:
|
|
58
|
-
helperTextId:
|
|
59
|
-
validationErrorsId:
|
|
60
|
-
labelId:
|
|
61
|
-
ariaDescribedBy:
|
|
62
|
-
ariaLabelledBy:
|
|
63
|
-
showErrors:
|
|
64
|
-
} =
|
|
65
|
-
name:
|
|
66
|
-
disabled:
|
|
67
|
-
readOnly:
|
|
68
|
-
required:
|
|
69
|
-
defaultValue:
|
|
70
|
-
error:
|
|
71
|
-
hasHelperText: !!
|
|
72
|
-
hasLabel: !!
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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:
|
|
102
|
-
fieldTabIndex:
|
|
103
|
-
handleSegmentFocus:
|
|
104
|
-
handleFieldFocus:
|
|
105
|
-
handleFieldBlur:
|
|
106
|
-
handleFieldMouseDown:
|
|
107
|
-
focusNext:
|
|
108
|
-
focusPrevious:
|
|
109
|
-
} =
|
|
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:
|
|
112
|
-
segmentRefs:
|
|
113
|
-
partsOrder:
|
|
114
|
-
onSegmentFocusChange:
|
|
115
|
-
onFieldBlur:
|
|
116
|
-
}),
|
|
113
|
+
fieldRef: I,
|
|
114
|
+
segmentRefs: te,
|
|
115
|
+
partsOrder: N,
|
|
116
|
+
onSegmentFocusChange: fe,
|
|
117
|
+
onFieldBlur: pe
|
|
118
|
+
}), Se = Ge({
|
|
117
119
|
disabled: e,
|
|
118
|
-
readOnly:
|
|
119
|
-
fieldRef:
|
|
120
|
-
focusNext:
|
|
121
|
-
focusPrevious:
|
|
122
|
-
adjustSegment:
|
|
123
|
-
clearSegment:
|
|
124
|
-
}), { isInvalid:
|
|
125
|
-
segments:
|
|
126
|
-
currentValue:
|
|
127
|
-
wasTouched:
|
|
128
|
-
isFocused:
|
|
129
|
-
}),
|
|
130
|
-
(s,
|
|
131
|
-
const { advanced:
|
|
132
|
-
|
|
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
|
-
[
|
|
135
|
-
),
|
|
136
|
+
[C, n]
|
|
137
|
+
), d = Ze({
|
|
136
138
|
formInvalid: X,
|
|
137
|
-
valueInvalid:
|
|
138
|
-
}),
|
|
139
|
+
valueInvalid: xe
|
|
140
|
+
}), Ie = M && Ve() ? "textbox" : "spinbutton", Me = (s) => {
|
|
139
141
|
if (e) return;
|
|
140
|
-
const
|
|
141
|
-
!
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
e &&
|
|
148
|
-
|
|
149
|
-
|
|
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__ */
|
|
153
|
+
return /* @__PURE__ */ B(
|
|
152
154
|
"div",
|
|
153
155
|
{
|
|
154
|
-
className:
|
|
155
|
-
style: { ...
|
|
156
|
-
onMouseDownCapture:
|
|
156
|
+
className: Ne,
|
|
157
|
+
style: { ...k, maxWidth: K },
|
|
158
|
+
onMouseDownCapture: Me,
|
|
157
159
|
children: [
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
|
|
160
|
+
/* @__PURE__ */ a(
|
|
161
|
+
Ae,
|
|
160
162
|
{
|
|
161
|
-
ctxId:
|
|
163
|
+
ctxId: y,
|
|
162
164
|
ctxDisabled: e,
|
|
163
|
-
ctxRequired:
|
|
164
|
-
children:
|
|
165
|
+
ctxRequired: h && !P,
|
|
166
|
+
children: g
|
|
165
167
|
}
|
|
166
168
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
169
|
+
/* @__PURE__ */ a(
|
|
168
170
|
"div",
|
|
169
171
|
{
|
|
170
172
|
...J,
|
|
171
|
-
ref:
|
|
172
|
-
id:
|
|
173
|
+
ref: ie,
|
|
174
|
+
id: $,
|
|
173
175
|
role: "group",
|
|
174
|
-
"aria-label":
|
|
175
|
-
"aria-labelledby":
|
|
176
|
+
"aria-label": U,
|
|
177
|
+
"aria-labelledby": se,
|
|
176
178
|
"aria-disabled": e || void 0,
|
|
177
|
-
"aria-required":
|
|
178
|
-
"aria-invalid":
|
|
179
|
-
"aria-describedby":
|
|
180
|
-
"aria-errormessage":
|
|
181
|
-
tabIndex:
|
|
182
|
-
className:
|
|
183
|
-
onMouseDown:
|
|
184
|
-
onFocus:
|
|
185
|
-
children: /* @__PURE__ */
|
|
186
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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__ */
|
|
214
|
+
/* @__PURE__ */ a(
|
|
206
215
|
"span",
|
|
207
216
|
{
|
|
208
217
|
role: "status",
|
|
209
218
|
"aria-live": "polite",
|
|
210
219
|
"aria-atomic": "true",
|
|
211
|
-
className:
|
|
212
|
-
children:
|
|
220
|
+
className: r[m.srStatus],
|
|
221
|
+
children: ge
|
|
213
222
|
}
|
|
214
223
|
),
|
|
215
|
-
/* @__PURE__ */
|
|
224
|
+
/* @__PURE__ */ a(
|
|
216
225
|
"input",
|
|
217
226
|
{
|
|
218
227
|
type: "hidden",
|
|
219
|
-
name:
|
|
220
|
-
value:
|
|
228
|
+
name: F,
|
|
229
|
+
value: ke(R),
|
|
221
230
|
disabled: e
|
|
222
231
|
}
|
|
223
232
|
),
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
237
|
+
oe(ae)
|
|
229
238
|
]
|
|
230
239
|
}
|
|
231
240
|
);
|
|
232
241
|
}
|
|
233
242
|
);
|
|
234
243
|
export {
|
|
235
|
-
|
|
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
|
|
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
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
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. */
|