@viasat/beam-react 2.39.3 → 2.41.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/chunks/{DateField.Segment.BVKky9IE.js → DateField.Segment.C2qoaY0Z.js} +33 -34
- package/chunks/DateField.Segment.CY0jg03_.js +1 -0
- package/lib/wip/DateField/DateField.Segment.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segment.d.ts +1 -1
- package/lib/wip/DateField/DateField.Segment.es.js +1 -1
- package/lib/wip/DateField/DateField.Segments.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segments.d.ts +7 -2
- package/lib/wip/DateField/DateField.Segments.es.js +50 -44
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.es.js +141 -130
- package/lib/wip/DateField/DateField.types.d.ts +20 -1
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +89 -1
- package/lib/wip/DateField/DateField.utils.es.js +67 -38
- package/lib/wip/DateField/useDateFieldFocus.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldFocus.d.ts +3 -2
- package/lib/wip/DateField/useDateFieldFocus.es.js +56 -44
- package/lib/wip/DateField/useDateFieldKeyboard.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldKeyboard.d.ts +44 -0
- package/lib/wip/DateField/useDateFieldKeyboard.es.js +45 -0
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -1
- package/lib/wip/DateField/useDateFieldValue.d.ts +20 -1
- package/lib/wip/DateField/useDateFieldValue.es.js +66 -50
- package/package.json +6 -6
- package/chunks/DateField.Segment.BBcn6sug.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "../assets/DateField.css";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { g as
|
|
2
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import v from "clsx";
|
|
4
|
+
import { useRef as D, useCallback as M, useLayoutEffect as N } from "react";
|
|
5
|
+
import { g as k } from "./classNames.ZWNk1hey.js";
|
|
6
6
|
import { selectElementContents as I } from "../lib/wip/DateField/DateField.utils.es.js";
|
|
7
|
-
const
|
|
7
|
+
const $ = "date-field", { baseClassNamePrefix: j, classModifierPrefix: z, subElementClassPrefix: s } = k($), B = {
|
|
8
8
|
field: `${s}field`,
|
|
9
9
|
segments: `${s}segments`,
|
|
10
10
|
segment: `${s}segment`,
|
|
11
11
|
separator: `${s}separator`
|
|
12
|
-
},
|
|
12
|
+
}, L = {
|
|
13
13
|
"bm-light": "bm-light",
|
|
14
14
|
"bm-dark": "bm-dark",
|
|
15
15
|
"bm-inverse": "bm-inverse",
|
|
@@ -24,50 +24,48 @@ const k = "date-field", { baseClassNamePrefix: F, classModifierPrefix: G, subEle
|
|
|
24
24
|
"bm-date-field--fluid": "bm-date-field--fluid",
|
|
25
25
|
"bm-date-field__segments": "bm-date-field__segments",
|
|
26
26
|
"bm-date-field__separator": "bm-date-field__separator"
|
|
27
|
-
},
|
|
28
|
-
day: 31,
|
|
29
|
-
month: 12,
|
|
30
|
-
year: 9999
|
|
31
|
-
}, y = {
|
|
27
|
+
}, P = {
|
|
32
28
|
day: "day",
|
|
33
29
|
month: "month",
|
|
34
30
|
year: "year"
|
|
35
|
-
},
|
|
31
|
+
}, G = ({
|
|
36
32
|
type: r,
|
|
37
33
|
value: b,
|
|
34
|
+
valueMax: c,
|
|
38
35
|
displayValue: t,
|
|
39
|
-
isPlaceholder:
|
|
36
|
+
isPlaceholder: u,
|
|
40
37
|
isActive: a,
|
|
41
38
|
disabled: o,
|
|
42
39
|
readOnly: i,
|
|
43
|
-
onFocus:
|
|
44
|
-
onBlur:
|
|
45
|
-
onInput:
|
|
40
|
+
onFocus: p,
|
|
41
|
+
onBlur: g,
|
|
42
|
+
onInput: _,
|
|
43
|
+
onKeyDown: C,
|
|
46
44
|
segmentRef: m
|
|
47
45
|
}) => {
|
|
48
|
-
const n = !o && !i, l =
|
|
46
|
+
const n = !o && !i, l = D(null), x = M(
|
|
49
47
|
(e) => {
|
|
50
48
|
l.current = e, m(e);
|
|
51
49
|
},
|
|
52
50
|
[m]
|
|
53
|
-
),
|
|
51
|
+
), E = (e) => {
|
|
54
52
|
if (!n) return;
|
|
55
53
|
const f = e.currentTarget, d = e.nativeEvent.data;
|
|
56
|
-
d != null && d.length === 1 &&
|
|
54
|
+
d != null && d.length === 1 && _(r, d), f.textContent !== t && (f.textContent = t);
|
|
57
55
|
};
|
|
58
|
-
return
|
|
56
|
+
return N(() => {
|
|
59
57
|
if (!a || !n) return;
|
|
60
58
|
const e = l.current;
|
|
61
59
|
e && I(e);
|
|
62
|
-
}, [t, a, n]), /* @__PURE__ */
|
|
60
|
+
}, [t, a, n]), /* @__PURE__ */ h(
|
|
63
61
|
"span",
|
|
64
62
|
{
|
|
65
|
-
ref:
|
|
63
|
+
ref: x,
|
|
66
64
|
role: "spinbutton",
|
|
67
|
-
"aria-label":
|
|
65
|
+
"aria-label": P[r],
|
|
68
66
|
"aria-valuenow": b ?? void 0,
|
|
69
67
|
"aria-valuemin": 1,
|
|
70
|
-
"aria-valuemax":
|
|
68
|
+
"aria-valuemax": c,
|
|
71
69
|
"aria-valuetext": t,
|
|
72
70
|
"aria-disabled": o || void 0,
|
|
73
71
|
"aria-readonly": i || void 0,
|
|
@@ -80,20 +78,21 @@ const k = "date-field", { baseClassNamePrefix: F, classModifierPrefix: G, subEle
|
|
|
80
78
|
autoCapitalize: "off",
|
|
81
79
|
"data-segment": r,
|
|
82
80
|
"data-active": a,
|
|
83
|
-
"data-placeholder":
|
|
84
|
-
onFocus:
|
|
85
|
-
onBlur:
|
|
86
|
-
onInput:
|
|
81
|
+
"data-placeholder": u,
|
|
82
|
+
onFocus: p,
|
|
83
|
+
onBlur: g,
|
|
84
|
+
onInput: E,
|
|
85
|
+
onKeyDown: (e) => C(r, e),
|
|
87
86
|
onMouseUp: (e) => e.preventDefault(),
|
|
88
|
-
className:
|
|
87
|
+
className: v(L[B.segment]),
|
|
89
88
|
children: t
|
|
90
89
|
}
|
|
91
90
|
);
|
|
92
91
|
};
|
|
93
92
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
G as D,
|
|
94
|
+
B as a,
|
|
95
|
+
j as b,
|
|
96
|
+
z as c,
|
|
97
|
+
L as s
|
|
99
98
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=require("../assets/DateField.css");const N=require("react/jsx-runtime"),F=require("clsx"),d=require("react"),M=require("./classNames.DC8Ra4sw.js"),q=require("../lib/wip/DateField/DateField.utils.cjs.js"),P="date-field",{baseClassNamePrefix:R,classModifierPrefix:k,subElementClassPrefix:r}=M.getBEMClassNames(P),c={field:`${r}field`,segments:`${r}segments`,segment:`${r}segment`,separator:`${r}separator`},u={"bm-light":"bm-light","bm-dark":"bm-dark","bm-inverse":"bm-inverse","bm-enterprise":"bm-enterprise","bm-consumer":"bm-consumer","bm-date-field":"bm-date-field","bm-date-field--disabled":"bm-date-field--disabled","bm-date-field--error":"bm-date-field--error","bm-date-field__field":"bm-date-field__field","bm-date-field__segment":"bm-date-field__segment","bm-date-field--read-only":"bm-date-field--read-only","bm-date-field--fluid":"bm-date-field--fluid","bm-date-field__segments":"bm-date-field__segments","bm-date-field__separator":"bm-date-field__separator"},I={day:"day",month:"month",year:"year"},$=({type:n,value:_,valueMax:g,displayValue:t,isPlaceholder:C,isActive:a,disabled:l,readOnly:o,onFocus:p,onBlur:x,onInput:E,onKeyDown:h,segmentRef:m})=>{const s=!l&&!o,f=d.useRef(null),v=d.useCallback(e=>{f.current=e,m(e)},[m]),D=e=>{if(!s)return;const b=e.currentTarget,i=e.nativeEvent.data;i!=null&&i.length===1&&E(n,i),b.textContent!==t&&(b.textContent=t)};return d.useLayoutEffect(()=>{if(!a||!s)return;const e=f.current;e&&q.selectElementContents(e)},[t,a,s]),N.jsx("span",{ref:v,role:"spinbutton","aria-label":I[n],"aria-valuenow":_??void 0,"aria-valuemin":1,"aria-valuemax":g,"aria-valuetext":t,"aria-disabled":l||void 0,"aria-readonly":o||void 0,contentEditable:s&&a,suppressContentEditableWarning:!0,tabIndex:a?0:-1,inputMode:s?"numeric":void 0,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off","data-segment":n,"data-active":a,"data-placeholder":C,onFocus:p,onBlur:x,onInput:D,onKeyDown:e=>h(n,e),onMouseUp:e=>e.preventDefault(),className:F(u[c.segment]),children:t})};exports.DateFieldSegment=$;exports.baseClassNamePrefix=R;exports.classModifierPrefix=k;exports.staticDateFieldClassNames=c;exports.styles=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");const e=require("../../../chunks/DateField.Segment.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");const e=require("../../../chunks/DateField.Segment.CY0jg03_.js");require("./DateField.utils.cjs.js");exports.DateFieldSegment=e.DateFieldSegment;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DateFieldSegmentProps } from './DateField.types';
|
|
2
|
-
export declare const DateFieldSegment: ({ type, value, displayValue, isPlaceholder, isActive, disabled, readOnly, onFocus, onBlur, onInput, segmentRef, }: DateFieldSegmentProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DateFieldSegment: ({ type, value, valueMax, displayValue, isPlaceholder, isActive, disabled, readOnly, onFocus, onBlur, onInput, onKeyDown, segmentRef, }: DateFieldSegmentProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "clsx";
|
|
3
3
|
import "react";
|
|
4
|
-
import { D as p } from "../../../chunks/DateField.Segment.
|
|
4
|
+
import { D as p } from "../../../chunks/DateField.Segment.C2qoaY0Z.js";
|
|
5
5
|
import "./DateField.utils.es.js";
|
|
6
6
|
export {
|
|
7
7
|
p as DateFieldSegment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),t=require("../../../chunks/DateField.Segment.CY0jg03_.js"),a=require("./DateField.utils.cjs.js"),i=[{type:"month",value:""},{type:"literal",value:"/"},{type:"day",value:""},{type:"literal",value:"/"},{type:"year",value:""}],h={month:"MM",day:"DD",year:"YYYY"},A=a.getSegmentOrder(i),M=({segmentText:r,segmentValues:s,focusedSegment:o,disabled:c,readOnly:y,onSegmentFocus:d,onSegmentBlur:u,onSegmentInput:p,onSegmentKeyDown:m,registerSegmentRef:D})=>{const S=a.getDaysInMonth(s.year,s.month);return n.jsx("span",{className:t.styles[t.staticDateFieldClassNames.segments],children:i.map((l,_)=>{if(l.type==="literal")return n.jsx("span",{"aria-hidden":"true",className:t.styles[t.staticDateFieldClassNames.separator],children:l.value},`literal-${_}`);const e=l.type,g=h[e],{displayValue:R,isPlaceholder:v}=a.getSegmentDisplay(e,r[e],g),F=e==="day"?S:a.SEGMENT_ARIA_MAX[e];return n.jsx(t.DateFieldSegment,{type:e,value:s[e],valueMax:F,displayValue:R,isPlaceholder:v,isActive:o===e,disabled:c,readOnly:y,onFocus:()=>d(e),onBlur:u,onInput:p,onKeyDown:m,segmentRef:D(e)},e)})})};exports.DateFieldSegments=M;exports.PARTS_ORDER=A;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FocusEvent } from 'react';
|
|
1
|
+
import { FocusEvent, KeyboardEvent } from 'react';
|
|
2
2
|
import { FocusTarget, SegmentText, SegmentType, SegmentValues } from './DateField.types';
|
|
3
3
|
export declare const PARTS_ORDER: ReadonlyArray<SegmentType>;
|
|
4
4
|
export interface DateFieldSegmentsProps {
|
|
@@ -9,9 +9,14 @@ export interface DateFieldSegmentsProps {
|
|
|
9
9
|
focusedSegment: FocusTarget;
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
readOnly: boolean;
|
|
12
|
+
/** Forwarded to each segment's focus handler. */
|
|
12
13
|
onSegmentFocus: (segment: SegmentType) => void;
|
|
14
|
+
/** Forwarded to each segment's blur handler. */
|
|
13
15
|
onSegmentBlur: (event: FocusEvent<HTMLSpanElement>) => void;
|
|
16
|
+
/** Forwarded to each segment's single-digit input handler. */
|
|
14
17
|
onSegmentInput: (segment: SegmentType, char: string) => void;
|
|
18
|
+
/** Keyboard handler from `useDateFieldKeyboard`, forwarded to each segment. */
|
|
19
|
+
onSegmentKeyDown: (segment: SegmentType, event: KeyboardEvent<HTMLSpanElement>) => void;
|
|
15
20
|
registerSegmentRef: (segment: SegmentType) => (element: HTMLSpanElement | null) => void;
|
|
16
21
|
}
|
|
17
|
-
export declare const DateFieldSegments: ({ segmentText, segmentValues, focusedSegment, disabled, readOnly, onSegmentFocus, onSegmentBlur, onSegmentInput, registerSegmentRef, }: DateFieldSegmentsProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const DateFieldSegments: ({ segmentText, segmentValues, focusedSegment, disabled, readOnly, onSegmentFocus, onSegmentBlur, onSegmentInput, onSegmentKeyDown, registerSegmentRef, }: DateFieldSegmentsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,61 +1,67 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { s, a as l, D as
|
|
3
|
-
import { getSegmentOrder as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { s as n, a as l, D as R } from "../../../chunks/DateField.Segment.C2qoaY0Z.js";
|
|
3
|
+
import { getSegmentOrder as E, getDaysInMonth as f, getSegmentDisplay as N, SEGMENT_ARIA_MAX as _ } from "./DateField.utils.es.js";
|
|
4
|
+
const o = [
|
|
5
5
|
{ type: "month", value: "" },
|
|
6
6
|
{ type: "literal", value: "/" },
|
|
7
7
|
{ type: "day", value: "" },
|
|
8
8
|
{ type: "literal", value: "/" },
|
|
9
9
|
{ type: "year", value: "" }
|
|
10
|
-
],
|
|
10
|
+
], x = {
|
|
11
11
|
month: "MM",
|
|
12
12
|
day: "DD",
|
|
13
13
|
year: "YYYY"
|
|
14
|
-
},
|
|
14
|
+
}, Y = E(o), I = ({
|
|
15
15
|
segmentText: r,
|
|
16
|
-
segmentValues:
|
|
16
|
+
segmentValues: t,
|
|
17
17
|
focusedSegment: i,
|
|
18
|
-
disabled:
|
|
18
|
+
disabled: y,
|
|
19
19
|
readOnly: p,
|
|
20
20
|
onSegmentFocus: c,
|
|
21
|
-
onSegmentBlur:
|
|
22
|
-
onSegmentInput:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
onSegmentBlur: m,
|
|
22
|
+
onSegmentInput: d,
|
|
23
|
+
onSegmentKeyDown: u,
|
|
24
|
+
registerSegmentRef: D
|
|
25
|
+
}) => {
|
|
26
|
+
const h = f(t.year, t.month);
|
|
27
|
+
return /* @__PURE__ */ s("span", { className: n[l.segments], children: o.map((a, v) => {
|
|
28
|
+
if (a.type === "literal")
|
|
29
|
+
return /* @__PURE__ */ s(
|
|
30
|
+
"span",
|
|
31
|
+
{
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
className: n[l.separator],
|
|
34
|
+
children: a.value
|
|
35
|
+
},
|
|
36
|
+
`literal-${v}`
|
|
37
|
+
);
|
|
38
|
+
const e = a.type, S = x[e], { displayValue: g, isPlaceholder: A } = N(
|
|
39
|
+
e,
|
|
40
|
+
r[e],
|
|
41
|
+
S
|
|
42
|
+
), M = e === "day" ? h : _[e];
|
|
43
|
+
return /* @__PURE__ */ s(
|
|
44
|
+
R,
|
|
28
45
|
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
type: e,
|
|
47
|
+
value: t[e],
|
|
48
|
+
valueMax: M,
|
|
49
|
+
displayValue: g,
|
|
50
|
+
isPlaceholder: A,
|
|
51
|
+
isActive: i === e,
|
|
52
|
+
disabled: y,
|
|
53
|
+
readOnly: p,
|
|
54
|
+
onFocus: () => c(e),
|
|
55
|
+
onBlur: m,
|
|
56
|
+
onInput: d,
|
|
57
|
+
onKeyDown: u,
|
|
58
|
+
segmentRef: D(e)
|
|
32
59
|
},
|
|
33
|
-
|
|
60
|
+
e
|
|
34
61
|
);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
r[e],
|
|
38
|
-
D
|
|
39
|
-
);
|
|
40
|
-
return /* @__PURE__ */ a(
|
|
41
|
-
h,
|
|
42
|
-
{
|
|
43
|
-
type: e,
|
|
44
|
-
value: o[e],
|
|
45
|
-
displayValue: v,
|
|
46
|
-
isPlaceholder: S,
|
|
47
|
-
isActive: i === e,
|
|
48
|
-
disabled: m,
|
|
49
|
-
readOnly: p,
|
|
50
|
-
onFocus: () => c(e),
|
|
51
|
-
onBlur: y,
|
|
52
|
-
onInput: u,
|
|
53
|
-
segmentRef: d(e)
|
|
54
|
-
},
|
|
55
|
-
e
|
|
56
|
-
);
|
|
57
|
-
}) });
|
|
62
|
+
}) });
|
|
63
|
+
};
|
|
58
64
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
I as DateFieldSegments,
|
|
66
|
+
Y as PARTS_ORDER
|
|
61
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),be=require("clsx"),De=require("react"),e=require("../../../chunks/DateField.Segment.CY0jg03_.js"),fe=require("../../../chunks/constants.CgMu0_1M.js"),me=require("../../../chunks/form.context.D5XrYvpI.js"),pe=require("../../Form/contexts/label.context.cjs.js"),xe=require("../../Form/contexts/helperText.context.cjs.js"),ge=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),r=require("./DateField.Segments.cjs.js"),ve=require("./DateField.utils.cjs.js"),ye=require("./useDateFieldFocus.cjs.js"),Se=require("./useDateFieldForm.cjs.js"),qe=require("./useDateFieldKeyboard.cjs.js"),he=require("./useDateFieldSegments.cjs.js"),we=require("./useDateFieldValidity.cjs.js"),Ie=require("./useDateFieldValue.cjs.js"),Re=require("./useInvalidState.cjs.js"),Pe=De.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}=Se.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}=ge.useUniversalRef(K),{segmentRefs:J,registerSegmentRef:Q}=he.useDateFieldSegments(),{segmentText:X,segmentValues:m,currentValue:p,wasTouched:Y,appendDigit:Z,adjustSegment:ee,beginSegmentEdit:ie,commitOnBlur:ae}=Ie.useDateFieldValue({value:S,defaultValue:$,onChange:h}),{focusedSegment:x,fieldTabIndex:le,handleSegmentFocus:g,handleFieldFocus:se,handleFieldBlur:te,handleFieldMouseDown:re,focusNext:v,focusPrevious:de}=ye.useDateFieldFocus({disabled:i,fieldRef:f,segmentRefs:J,partsOrder:r.PARTS_ORDER,onSegmentFocusChange:ie,onFieldBlur:ae}),ne=qe.useDateFieldKeyboard({disabled:i,readOnly:t,fieldRef:f,focusNext:v,focusPrevious:de,adjustSegment:ee}),{isInvalid:oe}=we.useDateFieldValidity({segments:m,currentValue:p,wasTouched:Y,isFocused:x!==null}),ue=(l,s)=>{const{advanced:_e}=Z(l,s);_e&&v(l)},y=Re.useInvalidState({formInvalid:L,valueInvalid:oe}),ce=l=>{if(i)return;const s=l.target.closest("label");!s||s.id!==D||(l.preventDefault(),g(r.PARTS_ORDER[0]))},Fe=be(e.styles[e.baseClassNamePrefix],u&&fe.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:Fe,style:{...O,maxWidth:R},onMouseDownCapture:ce,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:le,className:e.styles[e.staticDateFieldClassNames.field],onMouseDown:re,onFocus:se,children:a.jsx(r.DateFieldSegments,{segmentText:X,segmentValues:m,focusedSegment:x,disabled:i,readOnly:t,onSegmentFocus:g,onSegmentBlur:te,onSegmentInput:ue,onSegmentKeyDown:ne,registerSegmentRef:Q})}),a.jsx("input",{type:"hidden",name:c,value:ve.toISODateString(p),disabled:i}),a.jsxs(xe.HelperTextProvider,{ctxId:k,ctxDisabled:i,children:[n,_&&a.jsx(me.HelperText,{id:b,appearance:"negative",children:o})]}),z(A)]})});exports.DateField=Pe;
|
|
@@ -1,168 +1,179 @@
|
|
|
1
|
-
import { jsxs as
|
|
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 {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
1
|
+
import { jsxs as S, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import ge from "clsx";
|
|
3
|
+
import { forwardRef as ve } from "react";
|
|
4
|
+
import { s as a, b as De, c as s, a as Fe } from "../../../chunks/DateField.Segment.C2qoaY0Z.js";
|
|
5
|
+
import { t as he } from "../../../chunks/constants.Cruz2A1w.js";
|
|
6
|
+
import { H as xe } from "../../../chunks/form.context.cEuTL68U.js";
|
|
7
|
+
import { LabelProvider as ye } from "../../Form/contexts/label.context.es.js";
|
|
8
|
+
import { HelperTextProvider as Se } from "../../Form/contexts/helperText.context.es.js";
|
|
9
|
+
import { useUniversalRef as Ie } from "../../Form/hooks/useUniversalRef.hook.es.js";
|
|
10
|
+
import { DateFieldSegments as we, PARTS_ORDER as I } from "./DateField.Segments.es.js";
|
|
11
|
+
import { toISODateString as Re } from "./DateField.utils.es.js";
|
|
12
|
+
import { useDateFieldFocus as Ne } from "./useDateFieldFocus.es.js";
|
|
13
|
+
import { useDateFieldForm as Ve } from "./useDateFieldForm.es.js";
|
|
14
|
+
import { useDateFieldKeyboard as Be } from "./useDateFieldKeyboard.es.js";
|
|
15
|
+
import { useDateFieldSegments as Ce } from "./useDateFieldSegments.es.js";
|
|
16
|
+
import { useDateFieldValidity as Oe } from "./useDateFieldValidity.es.js";
|
|
17
|
+
import { useDateFieldValue as Pe } from "./useDateFieldValue.es.js";
|
|
18
|
+
import { useInvalidState as Te } from "./useInvalidState.es.js";
|
|
19
|
+
const Ze = ve(
|
|
19
20
|
function({
|
|
20
|
-
value:
|
|
21
|
-
defaultValue:
|
|
22
|
-
onChange:
|
|
23
|
-
label:
|
|
21
|
+
value: w,
|
|
22
|
+
defaultValue: R,
|
|
23
|
+
onChange: N,
|
|
24
|
+
label: o = null,
|
|
24
25
|
helperText: t = null,
|
|
25
|
-
error:
|
|
26
|
-
hideRequiredMarker:
|
|
27
|
-
validationRules:
|
|
28
|
-
width:
|
|
29
|
-
theme:
|
|
30
|
-
fluid:
|
|
31
|
-
disabled:
|
|
32
|
-
readOnly:
|
|
33
|
-
required:
|
|
26
|
+
error: n,
|
|
27
|
+
hideRequiredMarker: V = !1,
|
|
28
|
+
validationRules: B,
|
|
29
|
+
width: C,
|
|
30
|
+
theme: m,
|
|
31
|
+
fluid: O = !1,
|
|
32
|
+
disabled: P = !1,
|
|
33
|
+
readOnly: T = !1,
|
|
34
|
+
required: M = !1,
|
|
34
35
|
name: u,
|
|
35
|
-
id:
|
|
36
|
-
className:
|
|
37
|
-
style:
|
|
38
|
-
"aria-label":
|
|
39
|
-
"aria-describedby":
|
|
40
|
-
"aria-labelledby":
|
|
41
|
-
|
|
42
|
-
},
|
|
36
|
+
id: q,
|
|
37
|
+
className: E,
|
|
38
|
+
style: H,
|
|
39
|
+
"aria-label": L,
|
|
40
|
+
"aria-describedby": $,
|
|
41
|
+
"aria-labelledby": j,
|
|
42
|
+
...K
|
|
43
|
+
}, W) {
|
|
43
44
|
const {
|
|
44
45
|
disabled: e,
|
|
45
|
-
readOnly:
|
|
46
|
+
readOnly: d,
|
|
46
47
|
required: f,
|
|
47
|
-
invalid:
|
|
48
|
+
invalid: A,
|
|
48
49
|
errorMessageProvided: c,
|
|
49
|
-
defaultValue:
|
|
50
|
+
defaultValue: U,
|
|
50
51
|
errorId: p,
|
|
51
|
-
helperTextId:
|
|
52
|
-
validationErrorsId:
|
|
52
|
+
helperTextId: _,
|
|
53
|
+
validationErrorsId: k,
|
|
53
54
|
labelId: b,
|
|
54
|
-
ariaDescribedBy:
|
|
55
|
-
ariaLabelledBy:
|
|
56
|
-
showErrors:
|
|
57
|
-
} =
|
|
55
|
+
ariaDescribedBy: z,
|
|
56
|
+
ariaLabelledBy: G,
|
|
57
|
+
showErrors: J
|
|
58
|
+
} = Ve({
|
|
58
59
|
name: u,
|
|
59
|
-
disabled:
|
|
60
|
-
readOnly:
|
|
61
|
-
required:
|
|
62
|
-
defaultValue:
|
|
63
|
-
error:
|
|
60
|
+
disabled: P,
|
|
61
|
+
readOnly: T,
|
|
62
|
+
required: M,
|
|
63
|
+
defaultValue: R,
|
|
64
|
+
error: n,
|
|
64
65
|
hasHelperText: !!t,
|
|
65
|
-
hasLabel: !!
|
|
66
|
-
validationRules:
|
|
67
|
-
ariaDescribedBy:
|
|
68
|
-
ariaLabelledBy:
|
|
69
|
-
}), { refFn:
|
|
70
|
-
segmentText:
|
|
71
|
-
segmentValues:
|
|
72
|
-
currentValue:
|
|
73
|
-
wasTouched:
|
|
74
|
-
appendDigit:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
hasLabel: !!o,
|
|
67
|
+
validationRules: B,
|
|
68
|
+
ariaDescribedBy: $,
|
|
69
|
+
ariaLabelledBy: j
|
|
70
|
+
}), { refFn: Q, ref: g } = Ie(W), { segmentRefs: X, registerSegmentRef: Y } = Ce(), {
|
|
71
|
+
segmentText: Z,
|
|
72
|
+
segmentValues: v,
|
|
73
|
+
currentValue: D,
|
|
74
|
+
wasTouched: ee,
|
|
75
|
+
appendDigit: ae,
|
|
76
|
+
adjustSegment: re,
|
|
77
|
+
beginSegmentEdit: le,
|
|
78
|
+
commitOnBlur: ie
|
|
79
|
+
} = Pe({
|
|
80
|
+
value: w,
|
|
81
|
+
defaultValue: U,
|
|
82
|
+
onChange: N
|
|
81
83
|
}), {
|
|
82
84
|
focusedSegment: F,
|
|
83
|
-
fieldTabIndex:
|
|
84
|
-
handleSegmentFocus:
|
|
85
|
-
handleFieldFocus:
|
|
86
|
-
handleFieldBlur:
|
|
87
|
-
handleFieldMouseDown:
|
|
88
|
-
focusNext:
|
|
89
|
-
|
|
85
|
+
fieldTabIndex: se,
|
|
86
|
+
handleSegmentFocus: h,
|
|
87
|
+
handleFieldFocus: de,
|
|
88
|
+
handleFieldBlur: oe,
|
|
89
|
+
handleFieldMouseDown: te,
|
|
90
|
+
focusNext: x,
|
|
91
|
+
focusPrevious: ne
|
|
92
|
+
} = Ne({
|
|
90
93
|
disabled: e,
|
|
91
|
-
fieldRef:
|
|
92
|
-
segmentRefs:
|
|
94
|
+
fieldRef: g,
|
|
95
|
+
segmentRefs: X,
|
|
93
96
|
partsOrder: I,
|
|
94
|
-
onSegmentFocusChange:
|
|
95
|
-
onFieldBlur:
|
|
96
|
-
}),
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
onSegmentFocusChange: le,
|
|
98
|
+
onFieldBlur: ie
|
|
99
|
+
}), me = Be({
|
|
100
|
+
disabled: e,
|
|
101
|
+
readOnly: d,
|
|
102
|
+
fieldRef: g,
|
|
103
|
+
focusNext: x,
|
|
104
|
+
focusPrevious: ne,
|
|
105
|
+
adjustSegment: re
|
|
106
|
+
}), { isInvalid: ue } = Oe({
|
|
107
|
+
segments: v,
|
|
108
|
+
currentValue: D,
|
|
109
|
+
wasTouched: ee,
|
|
100
110
|
isFocused: F !== null
|
|
101
|
-
}),
|
|
102
|
-
const { advanced:
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
formInvalid:
|
|
106
|
-
valueInvalid:
|
|
107
|
-
}),
|
|
111
|
+
}), fe = (r, i) => {
|
|
112
|
+
const { advanced: be } = ae(r, i);
|
|
113
|
+
be && x(r);
|
|
114
|
+
}, y = Te({
|
|
115
|
+
formInvalid: A,
|
|
116
|
+
valueInvalid: ue
|
|
117
|
+
}), ce = (r) => {
|
|
108
118
|
if (e) return;
|
|
109
119
|
const i = r.target.closest("label");
|
|
110
|
-
!i || i.id !== b || (r.preventDefault(),
|
|
111
|
-
},
|
|
112
|
-
a[
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
!i || i.id !== b || (r.preventDefault(), h(I[0]));
|
|
121
|
+
}, pe = ge(
|
|
122
|
+
a[De],
|
|
123
|
+
m && he(m),
|
|
124
|
+
O && a[`${s}fluid`],
|
|
125
|
+
y && a[`${s}error`],
|
|
116
126
|
e && a[`${s}disabled`],
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
d && a[`${s}read-only`],
|
|
128
|
+
E
|
|
119
129
|
);
|
|
120
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ S(
|
|
121
131
|
"div",
|
|
122
132
|
{
|
|
123
|
-
className:
|
|
124
|
-
style: { ...
|
|
125
|
-
onMouseDownCapture:
|
|
133
|
+
className: pe,
|
|
134
|
+
style: { ...H, maxWidth: C },
|
|
135
|
+
onMouseDownCapture: ce,
|
|
126
136
|
children: [
|
|
127
137
|
/* @__PURE__ */ l(
|
|
128
|
-
|
|
138
|
+
ye,
|
|
129
139
|
{
|
|
130
140
|
ctxId: b,
|
|
131
141
|
ctxDisabled: e,
|
|
132
|
-
ctxRequired: f && !
|
|
133
|
-
children:
|
|
142
|
+
ctxRequired: f && !V,
|
|
143
|
+
children: o
|
|
134
144
|
}
|
|
135
145
|
),
|
|
136
146
|
/* @__PURE__ */ l(
|
|
137
147
|
"div",
|
|
138
148
|
{
|
|
139
|
-
|
|
140
|
-
ref:
|
|
141
|
-
id:
|
|
149
|
+
...K,
|
|
150
|
+
ref: Q,
|
|
151
|
+
id: q,
|
|
142
152
|
role: "group",
|
|
143
|
-
"aria-label":
|
|
144
|
-
"aria-labelledby":
|
|
153
|
+
"aria-label": L,
|
|
154
|
+
"aria-labelledby": G,
|
|
145
155
|
"aria-disabled": e || void 0,
|
|
146
156
|
"aria-required": f || void 0,
|
|
147
|
-
"aria-invalid":
|
|
148
|
-
"aria-describedby":
|
|
157
|
+
"aria-invalid": y || void 0,
|
|
158
|
+
"aria-describedby": z,
|
|
149
159
|
"aria-errormessage": c ? p : void 0,
|
|
150
|
-
tabIndex:
|
|
151
|
-
className: a[
|
|
152
|
-
onMouseDown:
|
|
153
|
-
onFocus:
|
|
160
|
+
tabIndex: se,
|
|
161
|
+
className: a[Fe.field],
|
|
162
|
+
onMouseDown: te,
|
|
163
|
+
onFocus: de,
|
|
154
164
|
children: /* @__PURE__ */ l(
|
|
155
|
-
|
|
165
|
+
we,
|
|
156
166
|
{
|
|
157
|
-
segmentText:
|
|
158
|
-
segmentValues:
|
|
167
|
+
segmentText: Z,
|
|
168
|
+
segmentValues: v,
|
|
159
169
|
focusedSegment: F,
|
|
160
170
|
disabled: e,
|
|
161
|
-
readOnly:
|
|
162
|
-
onSegmentFocus:
|
|
163
|
-
onSegmentBlur:
|
|
164
|
-
onSegmentInput:
|
|
165
|
-
|
|
171
|
+
readOnly: d,
|
|
172
|
+
onSegmentFocus: h,
|
|
173
|
+
onSegmentBlur: oe,
|
|
174
|
+
onSegmentInput: fe,
|
|
175
|
+
onSegmentKeyDown: me,
|
|
176
|
+
registerSegmentRef: Y
|
|
166
177
|
}
|
|
167
178
|
)
|
|
168
179
|
}
|
|
@@ -172,20 +183,20 @@ const Je = pe(
|
|
|
172
183
|
{
|
|
173
184
|
type: "hidden",
|
|
174
185
|
name: u,
|
|
175
|
-
value:
|
|
186
|
+
value: Re(D),
|
|
176
187
|
disabled: e
|
|
177
188
|
}
|
|
178
189
|
),
|
|
179
|
-
/* @__PURE__ */
|
|
190
|
+
/* @__PURE__ */ S(Se, { ctxId: _, ctxDisabled: e, children: [
|
|
180
191
|
t,
|
|
181
|
-
c && /* @__PURE__ */ l(
|
|
192
|
+
c && /* @__PURE__ */ l(xe, { id: p, appearance: "negative", children: n })
|
|
182
193
|
] }),
|
|
183
|
-
|
|
194
|
+
J(k)
|
|
184
195
|
]
|
|
185
196
|
}
|
|
186
197
|
);
|
|
187
198
|
}
|
|
188
199
|
);
|
|
189
200
|
export {
|
|
190
|
-
|
|
201
|
+
Ze as DateField
|
|
191
202
|
};
|