@viasat/beam-react 2.64.0 → 2.66.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/assets/dataTable.css +1 -1
- package/chunks/{dataTable.B_4qCCp1.js → dataTable.B2F2FRDV.js} +5 -3
- package/chunks/dataTable.I3f-w2wt.js +1 -0
- package/lib/wip/DataTable/DataTable.Body.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Body.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Cell.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Cell.es.js +1 -1
- package/lib/wip/DataTable/DataTable.ColumnHeader.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.ColumnHeader.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Footer.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Footer.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Head.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Head.es.js +27 -10
- package/lib/wip/DataTable/DataTable.Header.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Header.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Row.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Row.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Toolbar.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Toolbar.es.js +1 -1
- package/lib/wip/DataTable/DataTable.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.columns.d.ts +3 -3
- package/lib/wip/DataTable/DataTable.es.js +1 -1
- package/lib/wip/DataTable/DataTable.types.d.ts +11 -3
- 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/chunks/dataTable.B2EH91vH.js +0 -1
|
@@ -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
|
};
|