@viasat/beam-react 2.29.1 → 2.36.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 → FloatingUI.css} +1 -1
- 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/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.DFhYQv_F.js +1 -0
- package/chunks/FloatingUI.arrow.tN5_IctZ.js +27 -0
- package/chunks/panel.module.BVmRxZHo.js +1 -0
- package/chunks/{panel.module.BblnuBjO.js → panel.module.CnHWv4EZ.js} +1 -3
- package/index.cjs.js +1 -1
- package/index.es.js +35 -33
- 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/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 +17 -18
- 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/_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/index.cjs.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.es.js +27 -25
- 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 +5 -1
- package/lib/wip/Panel/Panel.Inline.es.js +54 -47
- package/lib/wip/Panel/Panel.Overlay.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Overlay.d.ts +20 -2
- package/lib/wip/Panel/Panel.Overlay.es.js +117 -80
- 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 +139 -100
- 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/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/chunks/floatingui.module.BcBFebz0.js +0 -10
- package/chunks/floatingui.module.D3Aw_aYe.js +0 -1
- package/chunks/panel.module.CVyUzyCZ.js +0 -1
package/lib/index.es.js
CHANGED
|
@@ -4,19 +4,19 @@ import { Alert as m } from "./Alert/Alert.es.js";
|
|
|
4
4
|
import { Autocomplete as f } from "./Autocomplete/Autocomplete.es.js";
|
|
5
5
|
import { Avatar as d } from "./Avatar/index.es.js";
|
|
6
6
|
import { CloseButton as s } from "./CloseButton/CloseButton.es.js";
|
|
7
|
-
import { Button as
|
|
7
|
+
import { Button as l, ButtonIconWrap as A } from "./Button/Button.es.js";
|
|
8
8
|
import { Dialog as S } from "./Dialog/Dialog.es.js";
|
|
9
9
|
import { Breadcrumb as v } from "./Breadcrumbs/Breadcrumbs.es.js";
|
|
10
10
|
import { B as C } from "../chunks/BreadcrumbsItem.6c7NEqgi.js";
|
|
11
11
|
import { EmptyState as P } from "./EmptyState/EmptyState.es.js";
|
|
12
12
|
import { Badge as g } from "./Badge/Badge.es.js";
|
|
13
13
|
import { BadgeDot as _ } from "./BadgeDot/BadgeDot.es.js";
|
|
14
|
-
import { Box as
|
|
14
|
+
import { Box as O } from "./Box/Box.es.js";
|
|
15
15
|
import { Checkbox as I } from "./Checkbox/Checkbox.es.js";
|
|
16
16
|
import { Chip as E } from "./Chips/Chip.es.js";
|
|
17
17
|
import { ChipGroup as b } from "./Chips/ChipGroup.es.js";
|
|
18
18
|
import { Divider as y } from "./Divider/Divider.es.js";
|
|
19
|
-
import { default as
|
|
19
|
+
import { default as M } from "./FileUpload/FileUpload.es.js";
|
|
20
20
|
import { Flag as Y } from "./Flag/Flag.es.js";
|
|
21
21
|
import { Form as w } from "./Form/Form.es.js";
|
|
22
22
|
import { H as V } from "../chunks/form.context.D7b4066_.js";
|
|
@@ -30,14 +30,14 @@ import { List as xo } from "./List/List.es.js";
|
|
|
30
30
|
import { ActionList as ao } from "./ActionList/ActionList.es.js";
|
|
31
31
|
import { Logo as io } from "./Logo/Logo.es.js";
|
|
32
32
|
import { Menu as so } from "./Menu/Menu.es.js";
|
|
33
|
-
import { useMenuContext as
|
|
33
|
+
import { useMenuContext as lo } from "./Menu/Menu.context.es.js";
|
|
34
34
|
import { NativeSelect as co } from "./NativeSelect/NativeSelect.es.js";
|
|
35
35
|
import { Pagination as To } from "./Pagination/Pagination.es.js";
|
|
36
36
|
import { ProgressBar as Bo } from "./ProgressBar/ProgressBar.es.js";
|
|
37
37
|
import { RadioButton as Lo } from "./RadioButton/RadioButton.es.js";
|
|
38
|
-
import { DRAWER_LAYOUT as No, HIDDEN_LAYOUT as go, LOCAL_STORAGE_SIDE_NAV_WIDTH_VAR_NAME as Ro, NO_LAYOUT as _o, OPAQUE_BACKDROP as
|
|
39
|
-
import { SideNavProvider as yo, useSideNavContext as
|
|
40
|
-
import { SegmentedControl as
|
|
38
|
+
import { DRAWER_LAYOUT as No, HIDDEN_LAYOUT as go, LOCAL_STORAGE_SIDE_NAV_WIDTH_VAR_NAME as Ro, NO_LAYOUT as _o, OPAQUE_BACKDROP as Do, RAIL_LAYOUT as Oo, Root as Ho, SideNav as Io, SideNavBackdrops as ho, SideNavClosedLayouts as Eo, SideNavOpenLayouts as Go, TRANSPARENT_BACKDROP as bo } from "./SideNav/SideNav.es.js";
|
|
39
|
+
import { SideNavProvider as yo, useSideNavContext as Fo } from "./SideNav/SideNavContext.es.js";
|
|
40
|
+
import { SegmentedControl as ko } from "./SegmentedControl/SegmentedControl.es.js";
|
|
41
41
|
import { Select as Wo } from "./Select/Select.es.js";
|
|
42
42
|
import { Spinner as Ko } from "./Spinner/Spinner.es.js";
|
|
43
43
|
import { StateLayer as Qo } from "./StateLayer/StateLayer.es.js";
|
|
@@ -50,22 +50,23 @@ import { TextArea as xr } from "./TextArea/TextArea.es.js";
|
|
|
50
50
|
import { TextField as ar } from "./TextField/TextField.es.js";
|
|
51
51
|
import { Toast as ir } from "./Toasts/Toast.es.js";
|
|
52
52
|
import { T as nr, u as sr } from "../chunks/ToastContext.CYGy7l7R.js";
|
|
53
|
-
import { ToastContainer as
|
|
53
|
+
import { ToastContainer as lr } from "./Toasts/ToastContainer.es.js";
|
|
54
54
|
import { Tooltip as cr, TooltipIconTrigger as Sr } from "./Tooltip/Tooltip.es.js";
|
|
55
55
|
import { Header as vr, InternalHeader as Br } from "./Header/Header.es.js";
|
|
56
56
|
import { HeaderMasthead as Lr } from "./Header/HeaderMasthead.es.js";
|
|
57
57
|
import { HeaderActionGroup as Nr } from "./Header/HeaderActionGroup.es.js";
|
|
58
58
|
import { HeaderNavigation as Rr } from "./Header/HeaderNavigation.es.js";
|
|
59
|
-
import { PortalContext as
|
|
59
|
+
import { PortalContext as Dr, usePortal as Or } from "./PortalProvider/PortalContext.es.js";
|
|
60
60
|
import { PortalProvider as Ir } from "./PortalProvider/PortalProvider.es.js";
|
|
61
61
|
import { Popover as Er } from "./Popover/Popover.es.js";
|
|
62
62
|
import { PageHeader as br } from "./PageHeader/PageHeader.es.js";
|
|
63
63
|
import { PageLayout as yr } from "./PageLayout/PageLayout.es.js";
|
|
64
|
-
import { Slider as
|
|
64
|
+
import { Slider as Mr } from "./Slider/Slider.es.js";
|
|
65
65
|
import { Card as Yr } from "./Card/Card.es.js";
|
|
66
66
|
import { CardGroup as wr } from "./Card/CardGroup.es.js";
|
|
67
67
|
import { Search as Vr } from "./Search/Search.es.js";
|
|
68
|
-
import {
|
|
68
|
+
import { DateField as jr } from "./wip/DateField/DateField.es.js";
|
|
69
|
+
import { v as zr } from "../chunks/useFormValidator.hook.CSmddwEt.js";
|
|
69
70
|
export {
|
|
70
71
|
e as Accordion,
|
|
71
72
|
p as AccordionGroup,
|
|
@@ -75,11 +76,11 @@ export {
|
|
|
75
76
|
d as Avatar,
|
|
76
77
|
g as Badge,
|
|
77
78
|
_ as BadgeDot,
|
|
78
|
-
|
|
79
|
+
O as Box,
|
|
79
80
|
v as Breadcrumb,
|
|
80
81
|
C as BreadcrumbItem,
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
l as Button,
|
|
83
|
+
A as ButtonIconWrap,
|
|
83
84
|
Yr as Card,
|
|
84
85
|
wr as CardGroup,
|
|
85
86
|
I as Checkbox,
|
|
@@ -88,10 +89,11 @@ export {
|
|
|
88
89
|
b as ChipGroup,
|
|
89
90
|
s as CloseButton,
|
|
90
91
|
No as DRAWER_LAYOUT,
|
|
92
|
+
jr as DateField,
|
|
91
93
|
S as Dialog,
|
|
92
94
|
y as Divider,
|
|
93
95
|
P as EmptyState,
|
|
94
|
-
|
|
96
|
+
M as FileUpload,
|
|
95
97
|
Y as Flag,
|
|
96
98
|
w as Form,
|
|
97
99
|
go as HIDDEN_LAYOUT,
|
|
@@ -110,27 +112,27 @@ export {
|
|
|
110
112
|
so as Menu,
|
|
111
113
|
_o as NO_LAYOUT,
|
|
112
114
|
co as NativeSelect,
|
|
113
|
-
|
|
115
|
+
Do as OPAQUE_BACKDROP,
|
|
114
116
|
br as PageHeader,
|
|
115
117
|
yr as PageLayout,
|
|
116
118
|
To as Pagination,
|
|
117
119
|
Er as Popover,
|
|
118
|
-
|
|
120
|
+
Dr as PortalContext,
|
|
119
121
|
Ir as PortalProvider,
|
|
120
122
|
Bo as ProgressBar,
|
|
121
|
-
|
|
123
|
+
Oo as RAIL_LAYOUT,
|
|
122
124
|
Lo as RadioButton,
|
|
123
125
|
$ as RadioButtonGroup,
|
|
124
126
|
Ho as Root,
|
|
125
127
|
Vr as Search,
|
|
126
|
-
|
|
128
|
+
ko as SegmentedControl,
|
|
127
129
|
Wo as Select,
|
|
128
130
|
Io as SideNav,
|
|
129
131
|
ho as SideNavBackdrops,
|
|
130
132
|
Eo as SideNavClosedLayouts,
|
|
131
133
|
Go as SideNavOpenLayouts,
|
|
132
134
|
yo as SideNavProvider,
|
|
133
|
-
|
|
135
|
+
Mr as Slider,
|
|
134
136
|
Ko as Spinner,
|
|
135
137
|
Qo as StateLayer,
|
|
136
138
|
qo as Stepper,
|
|
@@ -142,15 +144,15 @@ export {
|
|
|
142
144
|
xr as TextArea,
|
|
143
145
|
ar as TextField,
|
|
144
146
|
ir as Toast,
|
|
145
|
-
|
|
147
|
+
lr as ToastContainer,
|
|
146
148
|
nr as ToastProvider,
|
|
147
149
|
cr as Tooltip,
|
|
148
150
|
Sr as TooltipIconTrigger,
|
|
149
151
|
Jo as processMetadata,
|
|
150
152
|
Xo as useBeamStepper,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
lo as useMenuContext,
|
|
154
|
+
Or as usePortal,
|
|
155
|
+
Fo as useSideNavContext,
|
|
154
156
|
sr as useToast,
|
|
155
|
-
|
|
157
|
+
zr as validators
|
|
156
158
|
};
|
|
@@ -0,0 +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.7oCeBSNo.js");require("./DateField.utils.cjs.js");exports.DateFieldSegment=e.DateFieldSegment;
|
|
@@ -0,0 +1,2 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),t=require("../../../chunks/DateField.Segment.7oCeBSNo.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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FocusEvent } from 'react';
|
|
2
|
+
import { FocusTarget, SegmentText, SegmentType, SegmentValues } from './DateField.types';
|
|
3
|
+
export declare const PARTS_ORDER: ReadonlyArray<SegmentType>;
|
|
4
|
+
export interface DateFieldSegmentsProps {
|
|
5
|
+
/** Per-segment raw strings — the single source of truth for display. */
|
|
6
|
+
segmentText: SegmentText;
|
|
7
|
+
/** Derived per-segment numbers for `aria-valuenow`. */
|
|
8
|
+
segmentValues: SegmentValues;
|
|
9
|
+
focusedSegment: FocusTarget;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
readOnly: boolean;
|
|
12
|
+
onSegmentFocus: (segment: SegmentType) => void;
|
|
13
|
+
onSegmentBlur: (event: FocusEvent<HTMLSpanElement>) => void;
|
|
14
|
+
onSegmentInput: (segment: SegmentType, char: string) => void;
|
|
15
|
+
registerSegmentRef: (segment: SegmentType) => (element: HTMLSpanElement | null) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const DateFieldSegments: ({ segmentText, segmentValues, focusedSegment, disabled, readOnly, onSegmentFocus, onSegmentBlur, onSegmentInput, registerSegmentRef, }: DateFieldSegmentsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { s, a as l, D as h } from "../../../chunks/DateField.Segment.DbjGMAPP.js";
|
|
3
|
+
import { getSegmentOrder as R, getSegmentDisplay as f } from "./DateField.utils.es.js";
|
|
4
|
+
const n = [
|
|
5
|
+
{ type: "month", value: "" },
|
|
6
|
+
{ type: "literal", value: "/" },
|
|
7
|
+
{ type: "day", value: "" },
|
|
8
|
+
{ type: "literal", value: "/" },
|
|
9
|
+
{ type: "year", value: "" }
|
|
10
|
+
], A = {
|
|
11
|
+
month: "MM",
|
|
12
|
+
day: "DD",
|
|
13
|
+
year: "YYYY"
|
|
14
|
+
}, P = R(n), Y = ({
|
|
15
|
+
segmentText: r,
|
|
16
|
+
segmentValues: o,
|
|
17
|
+
focusedSegment: i,
|
|
18
|
+
disabled: m,
|
|
19
|
+
readOnly: p,
|
|
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",
|
|
28
|
+
{
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
className: s[l.separator],
|
|
31
|
+
children: t.value
|
|
32
|
+
},
|
|
33
|
+
`literal-${g}`
|
|
34
|
+
);
|
|
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
|
+
}) });
|
|
58
|
+
export {
|
|
59
|
+
Y as DateFieldSegments,
|
|
60
|
+
P as PARTS_ORDER
|
|
61
|
+
};
|
|
@@ -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
|
+
};
|