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