@viasat/beam-react 2.30.0 → 2.37.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/assets/ActionList.css +1 -1
- package/assets/Avatar.css +1 -1
- package/assets/Badge.css +1 -1
- package/assets/Button.css +1 -1
- package/assets/Checkbox.css +1 -1
- package/assets/Chip.css +1 -1
- package/assets/ChipGroup.css +1 -1
- package/assets/CloseButton.css +1 -1
- package/assets/DateField.css +1 -0
- package/assets/EmptyState.css +1 -1
- package/assets/FloatingUI.css +1 -0
- package/assets/InputChoiceGroup.css +1 -1
- package/assets/Link.css +1 -1
- package/assets/NativeSelect.css +1 -1
- package/assets/Pagination.css +1 -1
- package/assets/ProgressBar.css +1 -1
- package/assets/RadioButton.css +1 -1
- package/assets/Search.css +1 -1
- package/assets/SpinnerWrap.css +1 -1
- package/assets/Switch.css +1 -1
- package/assets/TextArea.css +1 -1
- package/assets/TextField.css +1 -1
- package/assets/card.css +1 -1
- package/assets/combobox.css +1 -1
- package/assets/dialog.css +1 -1
- package/assets/fileUpload.css +1 -1
- package/assets/header.css +1 -1
- package/assets/index.css +1 -1
- package/assets/panel.css +1 -1
- package/assets/segmentedControl.css +1 -1
- package/assets/slider.css +1 -1
- package/assets/stepper.css +1 -1
- package/chunks/DateField.Segment.7oCeBSNo.js +1 -0
- package/chunks/DateField.Segment.DbjGMAPP.js +99 -0
- package/chunks/FloatingUI.arrow.BK0jH2ge.js +1 -0
- package/chunks/FloatingUI.arrow.BXR2atOC.js +28 -0
- package/chunks/dialog.module.Djvqgz-x.js +1 -0
- package/chunks/{dialog.module.TRHzVysh.js → dialog.module.vokt9Lwb.js} +2 -1
- package/chunks/panel.module.BVmRxZHo.js +1 -0
- package/chunks/{panel.module.BblnuBjO.js → panel.module.CnHWv4EZ.js} +1 -3
- package/lib/ActionList/ActionList.Group.d.ts +1 -1
- package/lib/Autocomplete/Autocomplete.cjs.js +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +5 -5
- package/lib/Autocomplete/Autocomplete.es.js +296 -268
- package/lib/Autocomplete/AutocompleteDropdown.cjs.js +1 -1
- package/lib/Autocomplete/AutocompleteDropdown.es.js +15 -12
- package/lib/Breadcrumbs/BreadcrumbsItem.d.ts +1 -1
- package/lib/Dialog/Dialog.Body.cjs.js +1 -1
- package/lib/Dialog/Dialog.Body.es.js +1 -1
- package/lib/Dialog/Dialog.Content.cjs.js +1 -1
- package/lib/Dialog/Dialog.Content.es.js +1 -1
- package/lib/Dialog/Dialog.Footer.cjs.js +1 -1
- package/lib/Dialog/Dialog.Footer.es.js +1 -1
- package/lib/Dialog/Dialog.Header.cjs.js +1 -1
- package/lib/Dialog/Dialog.Header.es.js +1 -1
- package/lib/Dialog/Dialog.cjs.js +1 -1
- package/lib/Dialog/Dialog.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.arrow.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.arrow.es.js +6 -17
- package/lib/FloatingUI/FloatingUI.content.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.content.es.js +31 -32
- package/lib/Search/SearchDropdown.cjs.js +1 -1
- package/lib/Search/SearchDropdown.es.js +1 -1
- package/lib/Select/Select.cjs.js +1 -1
- package/lib/Select/Select.d.ts +3 -2
- package/lib/Select/Select.es.js +208 -195
- package/lib/Select/SelectDropdown.cjs.js +1 -1
- package/lib/Select/SelectDropdown.es.js +15 -12
- package/lib/SideNav/SideNavActionList.es.js +1 -0
- package/lib/SideNav/SideNavActionListItemLabel.d.ts +1 -1
- package/lib/Slider/DualSlider.cjs.js +1 -1
- package/lib/Slider/DualSlider.es.js +28 -27
- package/lib/Slider/SingleSlider.cjs.js +1 -1
- package/lib/Slider/SingleSlider.es.js +1 -1
- package/lib/Slider/Slider.es.js +17 -17
- package/lib/Slider/hooks/useDualSliderLogic.cjs.js +1 -1
- package/lib/Slider/hooks/useDualSliderLogic.es.js +14 -14
- package/lib/Slider/hooks/useSingleSliderLogic.cjs.js +1 -1
- package/lib/Slider/hooks/useSingleSliderLogic.es.js +17 -17
- package/lib/Tabs/Tabs.Group.d.ts +2 -2
- package/lib/Tabs/Tabs.Item.d.ts +2 -2
- package/lib/Tabs/Tabs.Panel.d.ts +2 -2
- package/lib/Text/Text.d.ts +2 -2
- package/lib/Text/Text.es.js +12 -12
- package/lib/_Options/Option.cjs.js +1 -1
- package/lib/_Options/Option.context.cjs.js +1 -1
- package/lib/_Options/Option.context.d.ts +31 -13
- package/lib/_Options/Option.context.es.js +133 -88
- package/lib/_Options/Option.es.js +23 -21
- package/lib/_Options/Option.types.d.ts +23 -0
- package/lib/_Options/OptionGroup.cjs.js +1 -0
- package/lib/_Options/OptionGroup.context.cjs.js +1 -0
- package/lib/_Options/OptionGroup.context.d.ts +6 -0
- package/lib/_Options/OptionGroup.context.es.js +6 -0
- package/lib/_Options/OptionGroup.d.ts +3 -0
- package/lib/_Options/OptionGroup.es.js +22 -0
- package/lib/_Options/getLastVisibleStructureIndex.cjs.js +1 -0
- package/lib/_Options/getLastVisibleStructureIndex.d.ts +15 -0
- package/lib/_Options/getLastVisibleStructureIndex.es.js +14 -0
- package/lib/_Options/index.cjs.js +1 -1
- package/lib/_Options/index.d.ts +4 -0
- package/lib/_Options/index.es.js +13 -4
- package/lib/_Options/useRenderOption.cjs.js +1 -0
- package/lib/_Options/useRenderOption.d.ts +30 -0
- package/lib/_Options/useRenderOption.es.js +43 -0
- package/lib/wip/DateField/DateField.Segment.cjs.js +1 -0
- package/lib/wip/DateField/DateField.Segment.d.ts +2 -0
- package/lib/wip/DateField/DateField.Segment.es.js +8 -0
- package/lib/wip/DateField/DateField.Segments.cjs.js +1 -0
- package/lib/wip/DateField/DateField.Segments.d.ts +17 -0
- package/lib/wip/DateField/DateField.Segments.es.js +61 -0
- package/lib/wip/DateField/DateField.cjs.js +1 -0
- package/lib/wip/DateField/DateField.d.ts +3 -0
- package/lib/wip/DateField/DateField.es.js +191 -0
- package/lib/wip/DateField/DateField.types.cjs.js +1 -0
- package/lib/wip/DateField/DateField.types.d.ts +118 -0
- package/lib/wip/DateField/DateField.types.es.js +1 -0
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -0
- package/lib/wip/DateField/DateField.utils.d.ts +26 -0
- package/lib/wip/DateField/DateField.utils.es.js +45 -0
- package/lib/wip/DateField/DateField.validation.cjs.js +1 -0
- package/lib/wip/DateField/DateField.validation.d.ts +26 -0
- package/lib/wip/DateField/DateField.validation.es.js +24 -0
- package/lib/wip/DateField/index.cjs.js +1 -0
- package/lib/wip/DateField/index.d.ts +2 -0
- package/lib/wip/DateField/index.es.js +4 -0
- package/lib/wip/DateField/useDateFieldFocus.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldFocus.d.ts +23 -0
- package/lib/wip/DateField/useDateFieldFocus.es.js +65 -0
- package/lib/wip/DateField/useDateFieldForm.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldForm.d.ts +32 -0
- package/lib/wip/DateField/useDateFieldForm.es.js +51 -0
- package/lib/wip/DateField/useDateFieldSegments.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldSegments.d.ts +7 -0
- package/lib/wip/DateField/useDateFieldSegments.es.js +13 -0
- package/lib/wip/DateField/useDateFieldValidity.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldValidity.d.ts +23 -0
- package/lib/wip/DateField/useDateFieldValidity.es.js +19 -0
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldValue.d.ts +19 -0
- package/lib/wip/DateField/useDateFieldValue.es.js +62 -0
- package/lib/wip/DateField/useInvalidState.cjs.js +1 -0
- package/lib/wip/DateField/useInvalidState.d.ts +13 -0
- package/lib/wip/DateField/useInvalidState.es.js +8 -0
- package/lib/wip/Panel/Footer/Panel.Footer.Actions.cjs.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.Actions.es.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.cjs.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentAfter.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentAfter.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentBefore.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentBefore.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Description.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Description.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Heading.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Heading.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Row.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Row.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Subheader.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Subheader.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.es.js +1 -1
- package/lib/wip/Panel/Panel.Body.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Body.es.js +1 -1
- package/lib/wip/Panel/Panel.Inline.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Inline.d.ts +3 -1
- package/lib/wip/Panel/Panel.Inline.es.js +44 -40
- package/lib/wip/Panel/Panel.Overlay.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Overlay.d.ts +18 -2
- package/lib/wip/Panel/Panel.Overlay.es.js +110 -84
- package/lib/wip/Panel/Panel.ResizeHandle.cjs.js +1 -1
- package/lib/wip/Panel/Panel.ResizeHandle.es.js +1 -1
- package/lib/wip/Panel/Panel.cjs.js +1 -1
- package/lib/wip/Panel/Panel.d.ts +1 -1
- package/lib/wip/Panel/Panel.es.js +125 -94
- package/lib/wip/Panel/Panel.helpers.cjs.js +1 -1
- package/lib/wip/Panel/Panel.helpers.d.ts +2 -1
- package/lib/wip/Panel/Panel.helpers.es.js +37 -35
- package/lib/wip/Panel/Panel.types.d.ts +64 -10
- package/lib/wip/Panel/Panel.useResize.cjs.js +1 -1
- package/lib/wip/Panel/Panel.useResize.d.ts +3 -1
- package/lib/wip/Panel/Panel.useResize.es.js +34 -30
- package/lib/wip/index.cjs.js +1 -1
- package/lib/wip/index.d.ts +1 -0
- package/lib/wip/index.es.js +4 -2
- package/package.json +6 -6
- package/utils/hooks/index.cjs.js +1 -1
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/index.es.js +12 -10
- package/utils/hooks/useElementResize.cjs.js +1 -1
- package/utils/hooks/useElementResize.d.ts +1 -1
- package/utils/hooks/useElementResize.es.js +33 -33
- package/utils/hooks/usePrevious.cjs.js +1 -0
- package/utils/hooks/usePrevious.d.ts +5 -0
- package/utils/hooks/usePrevious.es.js +10 -0
- package/assets/floatingui.css +0 -1
- package/chunks/dialog.module.C_6Qrg4w.js +0 -1
- package/chunks/floatingui.module.BcBFebz0.js +0 -10
- package/chunks/floatingui.module.D3Aw_aYe.js +0 -1
- package/chunks/panel.module.CVyUzyCZ.js +0 -1
|
@@ -0,0 +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.7oCeBSNo.js"),_e=require("../../../chunks/constants.hwjHOsvT.js"),be=require("../../../chunks/form.context.hesWPMlU.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;
|
|
@@ -0,0 +1,191 @@
|
|
|
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.DbjGMAPP.js";
|
|
5
|
+
import { t as ve } from "../../../chunks/constants.CKKGf1-i.js";
|
|
6
|
+
import { H as Fe } from "../../../chunks/form.context.D7b4066_.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(
|
|
19
|
+
function({
|
|
20
|
+
value: y,
|
|
21
|
+
defaultValue: S,
|
|
22
|
+
onChange: R,
|
|
23
|
+
label: d = null,
|
|
24
|
+
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,
|
|
34
|
+
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) {
|
|
43
|
+
const {
|
|
44
|
+
disabled: e,
|
|
45
|
+
readOnly: m,
|
|
46
|
+
required: f,
|
|
47
|
+
invalid: W,
|
|
48
|
+
errorMessageProvided: c,
|
|
49
|
+
defaultValue: A,
|
|
50
|
+
errorId: p,
|
|
51
|
+
helperTextId: U,
|
|
52
|
+
validationErrorsId: _,
|
|
53
|
+
labelId: b,
|
|
54
|
+
ariaDescribedBy: k,
|
|
55
|
+
ariaLabelledBy: z,
|
|
56
|
+
showErrors: G
|
|
57
|
+
} = Re({
|
|
58
|
+
name: u,
|
|
59
|
+
disabled: C,
|
|
60
|
+
readOnly: O,
|
|
61
|
+
required: T,
|
|
62
|
+
defaultValue: S,
|
|
63
|
+
error: o,
|
|
64
|
+
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
|
|
81
|
+
}), {
|
|
82
|
+
focusedSegment: F,
|
|
83
|
+
fieldTabIndex: le,
|
|
84
|
+
handleSegmentFocus: D,
|
|
85
|
+
handleFieldFocus: ie,
|
|
86
|
+
handleFieldBlur: se,
|
|
87
|
+
handleFieldMouseDown: de,
|
|
88
|
+
focusNext: te
|
|
89
|
+
} = Se({
|
|
90
|
+
disabled: e,
|
|
91
|
+
fieldRef: K,
|
|
92
|
+
segmentRefs: Q,
|
|
93
|
+
partsOrder: I,
|
|
94
|
+
onSegmentFocusChange: ae,
|
|
95
|
+
onFieldBlur: re
|
|
96
|
+
}), { isInvalid: oe } = Ve({
|
|
97
|
+
segments: g,
|
|
98
|
+
currentValue: v,
|
|
99
|
+
wasTouched: Z,
|
|
100
|
+
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) => {
|
|
108
|
+
if (e) return;
|
|
109
|
+
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`],
|
|
116
|
+
e && a[`${s}disabled`],
|
|
117
|
+
m && a[`${s}read-only`],
|
|
118
|
+
P
|
|
119
|
+
);
|
|
120
|
+
return /* @__PURE__ */ h(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: me,
|
|
124
|
+
style: { ...q, maxWidth: w },
|
|
125
|
+
onMouseDownCapture: ue,
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ l(
|
|
128
|
+
De,
|
|
129
|
+
{
|
|
130
|
+
ctxId: b,
|
|
131
|
+
ctxDisabled: e,
|
|
132
|
+
ctxRequired: f && !N,
|
|
133
|
+
children: d
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ l(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
...$,
|
|
140
|
+
ref: J,
|
|
141
|
+
id: M,
|
|
142
|
+
role: "group",
|
|
143
|
+
"aria-label": E,
|
|
144
|
+
"aria-labelledby": z,
|
|
145
|
+
"aria-disabled": e || void 0,
|
|
146
|
+
"aria-required": f || void 0,
|
|
147
|
+
"aria-invalid": x || void 0,
|
|
148
|
+
"aria-describedby": k,
|
|
149
|
+
"aria-errormessage": c ? p : void 0,
|
|
150
|
+
tabIndex: le,
|
|
151
|
+
className: a[ge.field],
|
|
152
|
+
onMouseDown: de,
|
|
153
|
+
onFocus: ie,
|
|
154
|
+
children: /* @__PURE__ */ l(
|
|
155
|
+
Ie,
|
|
156
|
+
{
|
|
157
|
+
segmentText: Y,
|
|
158
|
+
segmentValues: g,
|
|
159
|
+
focusedSegment: F,
|
|
160
|
+
disabled: e,
|
|
161
|
+
readOnly: m,
|
|
162
|
+
onSegmentFocus: D,
|
|
163
|
+
onSegmentBlur: se,
|
|
164
|
+
onSegmentInput: ne,
|
|
165
|
+
registerSegmentRef: X
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ l(
|
|
171
|
+
"input",
|
|
172
|
+
{
|
|
173
|
+
type: "hidden",
|
|
174
|
+
name: u,
|
|
175
|
+
value: ye(v),
|
|
176
|
+
disabled: e
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ h(xe, { ctxId: U, ctxDisabled: e, children: [
|
|
180
|
+
t,
|
|
181
|
+
c && /* @__PURE__ */ l(Fe, { id: p, appearance: "negative", children: o })
|
|
182
|
+
] }),
|
|
183
|
+
G(_)
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
export {
|
|
190
|
+
Je as DateField
|
|
191
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactElement, FocusEvent } from 'react';
|
|
2
|
+
import { Nullable } from '@viasat/beam-shared/utils/types';
|
|
3
|
+
import { ThemeTypes } from '@viasat/beam-shared/utils/constants';
|
|
4
|
+
import { FormValidator } from '@viasat/beam-shared/components/form';
|
|
5
|
+
type DateFieldInputAttributes = Omit<ComponentPropsWithRef<'input'>, 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'type' | 'size' | 'ref' | 'form' | 'autoComplete' | 'inputMode'>;
|
|
6
|
+
export type SegmentType = 'day' | 'month' | 'year';
|
|
7
|
+
export type FocusTarget = SegmentType | 'all' | null;
|
|
8
|
+
/** Per-segment values. Month is 1-12 (NOT 0-11). */
|
|
9
|
+
export interface SegmentValues {
|
|
10
|
+
day: number | null;
|
|
11
|
+
month: number | null;
|
|
12
|
+
year: number | null;
|
|
13
|
+
}
|
|
14
|
+
/** Per-segment raw input strings — the single source of truth. '' = empty. */
|
|
15
|
+
export type SegmentText = Record<SegmentType, string>;
|
|
16
|
+
export interface AppendDigitResult {
|
|
17
|
+
/** True when the segment completed and focus should auto-advance. */
|
|
18
|
+
advanced: boolean;
|
|
19
|
+
/** True when the digit was refused (invalid char, out-of-range, or full). */
|
|
20
|
+
rejected: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Shape mirrors `Intl.DateTimeFormatPart` so DF-8 can swap in locale-derived parts directly. */
|
|
23
|
+
export type DateFieldPart = {
|
|
24
|
+
type: SegmentType | 'literal';
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
export interface DateFieldProps extends DateFieldInputAttributes {
|
|
28
|
+
/**
|
|
29
|
+
* Specify HelperText for DateField
|
|
30
|
+
*/
|
|
31
|
+
helperText?: Nullable<ReactElement>;
|
|
32
|
+
/**
|
|
33
|
+
* Specify if DateField is a required input
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
required?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Specify if the DateField displays with an asterisk
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
hideRequiredMarker?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specify Label for DateField
|
|
44
|
+
*/
|
|
45
|
+
label?: Nullable<ReactElement>;
|
|
46
|
+
/**
|
|
47
|
+
* Specify error text and display error state of a DateField
|
|
48
|
+
*/
|
|
49
|
+
error?: boolean | string;
|
|
50
|
+
/**
|
|
51
|
+
* Specify if DateField displays in a read-only state
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
readOnly?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Specify if DateField displays in a disabled state
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Specify if DateField is fluid
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
fluid?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Specify the width of DateField
|
|
67
|
+
*/
|
|
68
|
+
width?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Specify the theme of the DateField. By default it inherits the theme from the parent
|
|
71
|
+
*/
|
|
72
|
+
theme?: ThemeTypes;
|
|
73
|
+
/**
|
|
74
|
+
* Specify form validation rules for DateField
|
|
75
|
+
*/
|
|
76
|
+
validationRules?: Array<FormValidator>;
|
|
77
|
+
/**
|
|
78
|
+
* Controlled date value. Pass `null` to clear.
|
|
79
|
+
*/
|
|
80
|
+
value?: Nullable<Date>;
|
|
81
|
+
/**
|
|
82
|
+
* Uncontrolled initial date value. Ignored when `value` is provided.
|
|
83
|
+
*/
|
|
84
|
+
defaultValue?: Nullable<Date>;
|
|
85
|
+
/**
|
|
86
|
+
* Fires when the derived `Date | null` value transitions.
|
|
87
|
+
* In DF-1, user-input handlers don't exist yet — wired up in DF-2.
|
|
88
|
+
*/
|
|
89
|
+
onChange?: (value: Nullable<Date>) => void;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Internal props for the segment subcomponent. Not part of the public API.
|
|
93
|
+
* `displayValue` / `isPlaceholder` are pre-computed from the segment string so
|
|
94
|
+
* the segment is pure render; `value` is the parsed number for `aria-valuenow`.
|
|
95
|
+
*/
|
|
96
|
+
export interface DateFieldSegmentProps {
|
|
97
|
+
type: SegmentType;
|
|
98
|
+
/** Numeric segment value — used for `aria-valuenow`. `null` when the segment has no committed value. */
|
|
99
|
+
value: Nullable<number>;
|
|
100
|
+
/** Pre-computed text to render inside the segment (buffer, formatted value, or placeholder). */
|
|
101
|
+
displayValue: string;
|
|
102
|
+
/** True when `displayValue` IS the placeholder (drives `data-placeholder` CSS hook). */
|
|
103
|
+
isPlaceholder: boolean;
|
|
104
|
+
isActive: boolean;
|
|
105
|
+
disabled: boolean;
|
|
106
|
+
readOnly: boolean;
|
|
107
|
+
onFocus: () => void;
|
|
108
|
+
onBlur: (event: FocusEvent<HTMLSpanElement>) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Single-character input callback. DF-2 single-digit typing path. The
|
|
111
|
+
* orchestrator routes this into `appendDigit` and (on advance) `focusNext`.
|
|
112
|
+
* Multi-character input (paste, IME composition commit) is ignored here —
|
|
113
|
+
* DF-13 will add a paste-aware branch for whole-value parsing.
|
|
114
|
+
*/
|
|
115
|
+
onInput: (type: SegmentType, char: string) => void;
|
|
116
|
+
segmentRef: (element: HTMLSpanElement | null) => void;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./DateField.validation.cjs.js"),u={day:"",month:"",year:""},o=e=>e instanceof Date&&!Number.isNaN(e.getTime()),s=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},g=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.getTime()===t.getTime(),m=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}`},d=e=>e.filter(t=>t.type!=="literal").map(t=>t.type),c=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")}:u,l=(e,t)=>{if(t===""||e==="year"&&t.length<i.SEGMENT_MAX_LENGTH.year)return null;const n=parseInt(t,10);return Number.isNaN(n)||n===0?null:n},S=e=>s({day:l("day",e.day),month:l("month",e.month),year:l("year",e.year)}),y=(e,t)=>t===""?"":t.padStart(i.SEGMENT_MAX_LENGTH[e],"0"),T=(e,t,n)=>t===""?{displayValue:n,isPlaceholder:!0}:{displayValue:t.padStart(i.SEGMENT_MAX_LENGTH[e],"0"),isPlaceholder:!1},p=e=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)};exports.deriveValue=s;exports.deriveValueFromText=S;exports.getSegmentDisplay=T;exports.getSegmentOrder=d;exports.isSameDateValue=g;exports.normalizeSegmentText=y;exports.segmentNumber=l;exports.segmentTextFromValue=c;exports.selectElementContents=p;exports.toISODateString=m;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Nullable } from '@viasat/beam-shared/utils/types';
|
|
2
|
+
import { DateFieldPart, SegmentText, SegmentType, SegmentValues } from './DateField.types';
|
|
3
|
+
export declare const deriveValue: (segments: SegmentValues) => Nullable<Date>;
|
|
4
|
+
export declare const isSameDateValue: (a: Nullable<Date>, b: Nullable<Date>) => boolean;
|
|
5
|
+
export declare const toISODateString: (value: Nullable<Date>) => string;
|
|
6
|
+
/** Ordered segment types from a parts array (literals stripped). */
|
|
7
|
+
export declare const getSegmentOrder: (parts: ReadonlyArray<DateFieldPart>) => ReadonlyArray<SegmentType>;
|
|
8
|
+
/** Per-segment zero-padded strings from a Date. All-empty for null/invalid. */
|
|
9
|
+
export declare const segmentTextFromValue: (value: Nullable<Date>) => SegmentText;
|
|
10
|
+
/** The number a segment string contributes to the date / `aria-valuenow`, or
|
|
11
|
+
* null when it shouldn't yet: empty, a parsed 0, or a year under 4 digits. */
|
|
12
|
+
export declare const segmentNumber: (type: SegmentType, text: string) => Nullable<number>;
|
|
13
|
+
/** Derives a Date from the per-segment strings (single source of truth). */
|
|
14
|
+
export declare const deriveValueFromText: (text: SegmentText) => Nullable<Date>;
|
|
15
|
+
/** Zero-pads a segment to its full width on blur (day/month → 2, year → 4),
|
|
16
|
+
* e.g. "1" → "01" / "0001". No year minimum, so a lone "1" settles as year 1. */
|
|
17
|
+
export declare const normalizeSegmentText: (type: SegmentType, text: string) => string;
|
|
18
|
+
export interface SegmentDisplay {
|
|
19
|
+
displayValue: string;
|
|
20
|
+
isPlaceholder: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Placeholder when empty, else the digits zero-padded to the segment width
|
|
23
|
+
* ("1" → "01" / "0001"). Display-only — the raw query drives append + value. */
|
|
24
|
+
export declare const getSegmentDisplay: (type: SegmentType, text: string, placeholder: string) => SegmentDisplay;
|
|
25
|
+
/** Selects an element's entire textContent (whole-segment highlight). */
|
|
26
|
+
export declare const selectElementContents: (element: HTMLElement) => void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SEGMENT_MAX_LENGTH as o } from "./DateField.validation.es.js";
|
|
2
|
+
const s = { day: "", month: "", year: "" }, i = (e) => e instanceof Date && !Number.isNaN(e.getTime()), u = (e) => {
|
|
3
|
+
const { day: t, month: n, year: r } = e;
|
|
4
|
+
if (t == null || n == null || r == null) return null;
|
|
5
|
+
const a = new Date(r, n - 1, t);
|
|
6
|
+
return a.setFullYear(r), Number.isNaN(a.getTime()) || a.getFullYear() !== r || a.getMonth() !== n - 1 || a.getDate() !== t ? null : a;
|
|
7
|
+
}, m = (e, t) => e == null && t == null ? !0 : e == null || t == null ? !1 : e.getTime() === t.getTime(), d = (e) => {
|
|
8
|
+
if (!i(e)) return "";
|
|
9
|
+
const t = String(e.getFullYear()).padStart(4, "0"), n = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
|
|
10
|
+
return `${t}-${n}-${r}`;
|
|
11
|
+
}, c = (e) => e.filter(
|
|
12
|
+
(t) => t.type !== "literal"
|
|
13
|
+
).map((t) => t.type), y = (e) => i(e) ? {
|
|
14
|
+
day: String(e.getDate()).padStart(2, "0"),
|
|
15
|
+
month: String(e.getMonth() + 1).padStart(2, "0"),
|
|
16
|
+
year: String(e.getFullYear()).padStart(4, "0")
|
|
17
|
+
} : s, l = (e, t) => {
|
|
18
|
+
if (t === "" || e === "year" && t.length < o.year) return null;
|
|
19
|
+
const n = parseInt(t, 10);
|
|
20
|
+
return Number.isNaN(n) || n === 0 ? null : n;
|
|
21
|
+
}, S = (e) => u({
|
|
22
|
+
day: l("day", e.day),
|
|
23
|
+
month: l("month", e.month),
|
|
24
|
+
year: l("year", e.year)
|
|
25
|
+
}), p = (e, t) => t === "" ? "" : t.padStart(o[e], "0"), f = (e, t, n) => t === "" ? { displayValue: n, isPlaceholder: !0 } : {
|
|
26
|
+
displayValue: t.padStart(o[e], "0"),
|
|
27
|
+
isPlaceholder: !1
|
|
28
|
+
}, N = (e) => {
|
|
29
|
+
const t = window.getSelection();
|
|
30
|
+
if (!t) return;
|
|
31
|
+
const n = document.createRange();
|
|
32
|
+
n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
u as deriveValue,
|
|
36
|
+
S as deriveValueFromText,
|
|
37
|
+
f as getSegmentDisplay,
|
|
38
|
+
c as getSegmentOrder,
|
|
39
|
+
m as isSameDateValue,
|
|
40
|
+
p as normalizeSegmentText,
|
|
41
|
+
l as segmentNumber,
|
|
42
|
+
y as segmentTextFromValue,
|
|
43
|
+
N as selectElementContents,
|
|
44
|
+
d as toISODateString
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={day:2,month:2,year:4},c=/^[0-9]$/,a=(r,e,n)=>{if(!c.test(n))return{newBuffer:e,shouldAdvance:!1,rejected:!0};const u=s[r];if(e.length>=u)return{newBuffer:e,shouldAdvance:!1,rejected:!0};if(r==="year"){const t=e+n;return{newBuffer:t,shouldAdvance:t.length===u,rejected:!1}}return r==="month"?l(e,n):d(e,n)},l=(r,e)=>r===""?e==="0"||e==="1"?{newBuffer:e,shouldAdvance:!1,rejected:!1}:{newBuffer:`0${e}`,shouldAdvance:!0,rejected:!1}:r==="0"?e==="0"?{newBuffer:r,shouldAdvance:!1,rejected:!0}:{newBuffer:`0${e}`,shouldAdvance:!0,rejected:!1}:r==="1"?e==="0"||e==="1"||e==="2"?{newBuffer:`1${e}`,shouldAdvance:!0,rejected:!1}:{newBuffer:r,shouldAdvance:!1,rejected:!0}:{newBuffer:r,shouldAdvance:!1,rejected:!0},d=(r,e)=>r===""?e==="0"||e==="1"||e==="2"||e==="3"?{newBuffer:e,shouldAdvance:!1,rejected:!1}:{newBuffer:`0${e}`,shouldAdvance:!0,rejected:!1}:r==="0"?e==="0"?{newBuffer:r,shouldAdvance:!1,rejected:!0}:{newBuffer:`0${e}`,shouldAdvance:!0,rejected:!1}:r==="1"||r==="2"?{newBuffer:`${r}${e}`,shouldAdvance:!0,rejected:!1}:r==="3"?e==="0"||e==="1"?{newBuffer:`3${e}`,shouldAdvance:!0,rejected:!1}:{newBuffer:r,shouldAdvance:!1,rejected:!0}:{newBuffer:r,shouldAdvance:!1,rejected:!0},f=s;exports.SEGMENT_MAX_LENGTH=f;exports.tryAppendDigit=a;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SegmentType } from './DateField.types';
|
|
2
|
+
export interface TryAppendDigitResult {
|
|
3
|
+
/** Buffer state after the append. Unchanged when `rejected` is true. */
|
|
4
|
+
newBuffer: string;
|
|
5
|
+
/** True when the segment completed and focus should auto-advance. */
|
|
6
|
+
shouldAdvance: boolean;
|
|
7
|
+
/** True when the digit was refused (invalid char, out-of-range, buffer full). */
|
|
8
|
+
rejected: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Per-segment input validation with intermediate-state awareness. Decides
|
|
12
|
+
* whether a typed digit is accepted (buffer grows), accepted-with-pad (e.g.
|
|
13
|
+
* "5" in empty month → "05"), or rejected ("13" for month).
|
|
14
|
+
*
|
|
15
|
+
* Pure; entirely driven by the (type, buffer, digit) tuple. Cross-segment
|
|
16
|
+
* validity (Feb 30) is NOT checked here — that's `deriveValue`'s job.
|
|
17
|
+
*
|
|
18
|
+
* - Day uses a fixed max of 31; month-dependent day max is intentionally
|
|
19
|
+
* deferred — invalid combinations surface as cross-segment errors.
|
|
20
|
+
* - Year accepts any 4-digit value 0000-9999; min/max range tightening lands
|
|
21
|
+
* in DF-10 via dedicated `minDate` / `maxDate` props.
|
|
22
|
+
*/
|
|
23
|
+
export declare const tryAppendDigit: (type: SegmentType, buffer: string, digit: string) => TryAppendDigitResult;
|
|
24
|
+
/** Re-export so `formatSegment` and `tryAppendDigit` share the same max-length
|
|
25
|
+
* constants without a circular dep. */
|
|
26
|
+
export declare const SEGMENT_MAX_LENGTH: Record<SegmentType, number>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const s = {
|
|
2
|
+
day: 2,
|
|
3
|
+
month: 2,
|
|
4
|
+
year: 4
|
|
5
|
+
}, c = /^[0-9]$/, f = (r, e, n) => {
|
|
6
|
+
if (!c.test(n))
|
|
7
|
+
return { newBuffer: e, shouldAdvance: !1, rejected: !0 };
|
|
8
|
+
const u = s[r];
|
|
9
|
+
if (e.length >= u)
|
|
10
|
+
return { newBuffer: e, shouldAdvance: !1, rejected: !0 };
|
|
11
|
+
if (r === "year") {
|
|
12
|
+
const t = e + n;
|
|
13
|
+
return {
|
|
14
|
+
newBuffer: t,
|
|
15
|
+
shouldAdvance: t.length === u,
|
|
16
|
+
rejected: !1
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return r === "month" ? a(e, n) : l(e, n);
|
|
20
|
+
}, a = (r, e) => r === "" ? e === "0" || e === "1" ? { newBuffer: e, shouldAdvance: !1, rejected: !1 } : { newBuffer: `0${e}`, shouldAdvance: !0, rejected: !1 } : r === "0" ? e === "0" ? { newBuffer: r, shouldAdvance: !1, rejected: !0 } : { newBuffer: `0${e}`, shouldAdvance: !0, rejected: !1 } : r === "1" ? e === "0" || e === "1" || e === "2" ? { newBuffer: `1${e}`, shouldAdvance: !0, rejected: !1 } : { newBuffer: r, shouldAdvance: !1, rejected: !0 } : { newBuffer: r, shouldAdvance: !1, rejected: !0 }, l = (r, e) => r === "" ? e === "0" || e === "1" || e === "2" || e === "3" ? { newBuffer: e, shouldAdvance: !1, rejected: !1 } : { newBuffer: `0${e}`, shouldAdvance: !0, rejected: !1 } : r === "0" ? e === "0" ? { newBuffer: r, shouldAdvance: !1, rejected: !0 } : { newBuffer: `0${e}`, shouldAdvance: !0, rejected: !1 } : r === "1" || r === "2" ? { newBuffer: `${r}${e}`, shouldAdvance: !0, rejected: !1 } : r === "3" ? e === "0" || e === "1" ? { newBuffer: `3${e}`, shouldAdvance: !0, rejected: !1 } : { newBuffer: r, shouldAdvance: !1, rejected: !0 } : { newBuffer: r, shouldAdvance: !1, rejected: !0 }, d = s;
|
|
21
|
+
export {
|
|
22
|
+
d as SEGMENT_MAX_LENGTH,
|
|
23
|
+
f as tryAppendDigit
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./DateField.cjs.js");exports.DateField=e.DateField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react");function M({disabled:n,fieldRef:i,segmentRefs:T,partsOrder:f,onSegmentFocusChange:x,onFieldBlur:k}){const[l,a]=c.useState(null),s=f[0],r=c.useRef(x),o=c.useRef(k);c.useEffect(()=>{r.current=x,o.current=k},[x,k]),c.useEffect(()=>{if(l===null||l==="all")return;const t=T.current.get(l);t&&document.activeElement!==t&&t.focus()},[l,T]);const b=c.useCallback(t=>{var u;n||(a(t),(u=r.current)==null||u.call(r,t))},[n]),y=c.useCallback(t=>{var u;n||t.target===i.current&&(a(s),(u=r.current)==null||u.call(r,s))},[n,i,s]),E=c.useCallback(t=>{var u,e;(u=i.current)!=null&&u.contains(t.relatedTarget)||(a(null),(e=o.current)==null||e.call(o))},[i]),v=c.useCallback(t=>{var e;if(n)return;t.target.closest("[data-segment]")||(t.preventDefault(),a(s),(e=r.current)==null||e.call(r,s))},[n,s]),I=c.useCallback(t=>{var D;const u=f.indexOf(t);if(u===-1)return;const e=f[u+1];e!=null&&(a(e),(D=r.current)==null||D.call(r,e))},[f]);return{focusedSegment:l,fieldTabIndex:n?-1:l===null?0:-1,handleSegmentFocus:b,handleFieldFocus:y,handleFieldBlur:E,handleFieldMouseDown:v,focusNext:I}}exports.useDateFieldFocus=M;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FocusEvent, MouseEvent, MutableRefObject } from 'react';
|
|
2
|
+
import { FocusTarget, SegmentType } from './DateField.types';
|
|
3
|
+
export interface UseDateFieldFocusArgs {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
fieldRef: MutableRefObject<HTMLDivElement | null>;
|
|
6
|
+
segmentRefs: MutableRefObject<Map<SegmentType, HTMLSpanElement>>;
|
|
7
|
+
/** Ordered segment types (literals stripped). En-US hardcoded; DF-8 derives from locale. */
|
|
8
|
+
partsOrder: ReadonlyArray<SegmentType>;
|
|
9
|
+
/** Called when focus enters a segment (any path). */
|
|
10
|
+
onSegmentFocusChange?: (segment: SegmentType) => void;
|
|
11
|
+
/** Called when focus leaves the field entirely (intra-field hops ignored). */
|
|
12
|
+
onFieldBlur?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface UseDateFieldFocusReturn {
|
|
15
|
+
focusedSegment: FocusTarget;
|
|
16
|
+
fieldTabIndex: number;
|
|
17
|
+
handleSegmentFocus: (segment: SegmentType) => void;
|
|
18
|
+
handleFieldFocus: (event: FocusEvent<HTMLDivElement>) => void;
|
|
19
|
+
handleFieldBlur: (event: FocusEvent<HTMLElement>) => void;
|
|
20
|
+
handleFieldMouseDown: (event: MouseEvent<HTMLDivElement>) => void;
|
|
21
|
+
focusNext: (currentType: SegmentType) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function useDateFieldFocus({ disabled, fieldRef, segmentRefs, partsOrder, onSegmentFocusChange, onFieldBlur, }: UseDateFieldFocusArgs): UseDateFieldFocusReturn;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useState as N, useRef as I, useEffect as k, useCallback as s } from "react";
|
|
2
|
+
function z({
|
|
3
|
+
disabled: n,
|
|
4
|
+
fieldRef: f,
|
|
5
|
+
segmentRefs: D,
|
|
6
|
+
partsOrder: o,
|
|
7
|
+
onSegmentFocusChange: a,
|
|
8
|
+
onFieldBlur: T
|
|
9
|
+
}) {
|
|
10
|
+
const [e, i] = N(null), l = o[0], r = I(a), x = I(T);
|
|
11
|
+
k(() => {
|
|
12
|
+
r.current = a, x.current = T;
|
|
13
|
+
}, [a, T]), k(() => {
|
|
14
|
+
if (e === null || e === "all") return;
|
|
15
|
+
const t = D.current.get(e);
|
|
16
|
+
t && document.activeElement !== t && t.focus();
|
|
17
|
+
}, [e, D]);
|
|
18
|
+
const p = s(
|
|
19
|
+
(t) => {
|
|
20
|
+
var u;
|
|
21
|
+
n || (i(t), (u = r.current) == null || u.call(r, t));
|
|
22
|
+
},
|
|
23
|
+
[n]
|
|
24
|
+
), v = s(
|
|
25
|
+
(t) => {
|
|
26
|
+
var u;
|
|
27
|
+
n || t.target === f.current && (i(l), (u = r.current) == null || u.call(r, l));
|
|
28
|
+
},
|
|
29
|
+
[n, f, l]
|
|
30
|
+
), w = s(
|
|
31
|
+
(t) => {
|
|
32
|
+
var u, c;
|
|
33
|
+
(u = f.current) != null && u.contains(t.relatedTarget) || (i(null), (c = x.current) == null || c.call(x));
|
|
34
|
+
},
|
|
35
|
+
[f]
|
|
36
|
+
), y = s(
|
|
37
|
+
(t) => {
|
|
38
|
+
var c;
|
|
39
|
+
if (n) return;
|
|
40
|
+
t.target.closest("[data-segment]") || (t.preventDefault(), i(l), (c = r.current) == null || c.call(r, l));
|
|
41
|
+
},
|
|
42
|
+
[n, l]
|
|
43
|
+
), M = s(
|
|
44
|
+
(t) => {
|
|
45
|
+
var E;
|
|
46
|
+
const u = o.indexOf(t);
|
|
47
|
+
if (u === -1) return;
|
|
48
|
+
const c = o[u + 1];
|
|
49
|
+
c != null && (i(c), (E = r.current) == null || E.call(r, c));
|
|
50
|
+
},
|
|
51
|
+
[o]
|
|
52
|
+
);
|
|
53
|
+
return {
|
|
54
|
+
focusedSegment: e,
|
|
55
|
+
fieldTabIndex: n ? -1 : e === null ? 0 : -1,
|
|
56
|
+
handleSegmentFocus: p,
|
|
57
|
+
handleFieldFocus: v,
|
|
58
|
+
handleFieldBlur: w,
|
|
59
|
+
handleFieldMouseDown: y,
|
|
60
|
+
focusNext: M
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
z as useDateFieldFocus
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("clsx"),T=require("react"),u=require("../../../chunks/form.context.hesWPMlU.js");require("../../Form/contexts/label.context.cjs.js");require("../../Form/contexts/helperText.context.cjs.js");const s=require("../../Form/hooks/useAccessibleId.hook.cjs.js");require("react/jsx-runtime");function L({name:i,disabled:b=!1,readOnly:y=!1,required:I=!1,defaultValue:q,error:e,hasHelperText:p,hasLabel:h,validationRules:F=[],ariaDescribedBy:f,ariaLabelledBy:m}){const{showErrors:v,isInvalid:x,errorShown:g,disabled:B,readOnly:_,required:A}=u.useFormField({name:i,validationRules:F,disabledProp:b,readOnlyProp:y,requiredProp:I}),{ctxInitialValues:D}=T.useContext(u.FormContext),{id:r}=s.useAccessibleId(),{id:d}=s.useAccessibleId(),{id:l}=s.useAccessibleId(),{id:o}=s.useAccessibleId(),t=!!(e!=null&&e.length),P=!!e||x,O=q??D[i],a=n(p&&d,t&&r,g&&l,f),c=n(h&&o,m);return{disabled:B,readOnly:_,required:A,invalid:P,errorMessageProvided:t,defaultValue:O,errorId:r,helperTextId:d,validationErrorsId:l,labelId:o,ariaDescribedBy:a.length>0?a:void 0,ariaLabelledBy:c.length>0?c:void 0,showErrors:v}}exports.useDateFieldForm=L;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FormValidator } from '@viasat/beam-shared/components/form';
|
|
2
|
+
import { Nullable } from '@viasat/beam-shared/utils/types';
|
|
3
|
+
import { useFormField } from '../../Form/contexts';
|
|
4
|
+
export interface UseDateFieldFormArgs {
|
|
5
|
+
name?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
defaultValue?: Nullable<Date>;
|
|
10
|
+
error?: boolean | string;
|
|
11
|
+
hasHelperText: boolean;
|
|
12
|
+
validationRules?: Array<FormValidator>;
|
|
13
|
+
ariaDescribedBy?: string;
|
|
14
|
+
ariaLabelledBy?: string;
|
|
15
|
+
hasLabel: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface UseDateFieldFormReturn {
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
readOnly: boolean;
|
|
20
|
+
required: boolean;
|
|
21
|
+
invalid: boolean;
|
|
22
|
+
errorMessageProvided: boolean;
|
|
23
|
+
defaultValue: Nullable<Date>;
|
|
24
|
+
errorId: string;
|
|
25
|
+
helperTextId: string;
|
|
26
|
+
validationErrorsId: string;
|
|
27
|
+
labelId: string;
|
|
28
|
+
ariaDescribedBy: string | undefined;
|
|
29
|
+
ariaLabelledBy: string | undefined;
|
|
30
|
+
showErrors: ReturnType<typeof useFormField>['showErrors'];
|
|
31
|
+
}
|
|
32
|
+
export declare function useDateFieldForm({ name, disabled: _disabled, readOnly: _readOnly, required: _required, defaultValue: _defaultValue, error, hasHelperText, hasLabel, validationRules, ariaDescribedBy: _ariaDescribedBy, ariaLabelledBy: _ariaLabelledBy, }: UseDateFieldFormArgs): UseDateFieldFormReturn;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import c from "clsx";
|
|
2
|
+
import { useContext as V } from "react";
|
|
3
|
+
import { b as w, F as C } from "../../../chunks/form.context.D7b4066_.js";
|
|
4
|
+
import "../../Form/contexts/label.context.es.js";
|
|
5
|
+
import "../../Form/contexts/helperText.context.es.js";
|
|
6
|
+
import { useAccessibleId as o } from "../../Form/hooks/useAccessibleId.hook.es.js";
|
|
7
|
+
import "react/jsx-runtime";
|
|
8
|
+
function z({
|
|
9
|
+
name: d,
|
|
10
|
+
disabled: m = !1,
|
|
11
|
+
readOnly: p = !1,
|
|
12
|
+
required: u = !1,
|
|
13
|
+
defaultValue: b,
|
|
14
|
+
error: e,
|
|
15
|
+
hasHelperText: f,
|
|
16
|
+
hasLabel: y,
|
|
17
|
+
validationRules: I = [],
|
|
18
|
+
ariaDescribedBy: h,
|
|
19
|
+
ariaLabelledBy: v
|
|
20
|
+
}) {
|
|
21
|
+
const { showErrors: x, isInvalid: B, errorShown: F, disabled: g, readOnly: D, required: P } = w({
|
|
22
|
+
name: d,
|
|
23
|
+
validationRules: I,
|
|
24
|
+
disabledProp: m,
|
|
25
|
+
readOnlyProp: p,
|
|
26
|
+
requiredProp: u
|
|
27
|
+
}), { ctxInitialValues: q } = V(C), { id: i } = o(), { id: r } = o(), { id: s } = o(), { id: t } = o(), a = !!(e != null && e.length), L = !!e || B, O = b ?? q[d], l = c(
|
|
28
|
+
f && r,
|
|
29
|
+
a && i,
|
|
30
|
+
F && s,
|
|
31
|
+
h
|
|
32
|
+
), n = c(y && t, v);
|
|
33
|
+
return {
|
|
34
|
+
disabled: g,
|
|
35
|
+
readOnly: D,
|
|
36
|
+
required: P,
|
|
37
|
+
invalid: L,
|
|
38
|
+
errorMessageProvided: a,
|
|
39
|
+
defaultValue: O,
|
|
40
|
+
errorId: i,
|
|
41
|
+
helperTextId: r,
|
|
42
|
+
validationErrorsId: s,
|
|
43
|
+
labelId: t,
|
|
44
|
+
ariaDescribedBy: l.length > 0 ? l : void 0,
|
|
45
|
+
ariaLabelledBy: n.length > 0 ? n : void 0,
|
|
46
|
+
showErrors: x
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
z as useDateFieldForm
|
|
51
|
+
};
|