@viasat/beam-react 2.55.2 → 2.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/assets/dataTable.css +1 -1
- package/chunks/{DateField.Segment.CwhRnhtq.js → DateField.Segment.BMXzpxgl.js} +27 -26
- package/chunks/DateField.Segment.BqMaeKLk.js +1 -0
- package/chunks/dataTable.B2EH91vH.js +1 -0
- package/chunks/{dataTable.DQQX95em.js → dataTable.B_4qCCp1.js} +5 -3
- package/chunks/use-isomorphic-layout-effect.browser.esm.CkGv31zs.js +1 -0
- package/chunks/use-isomorphic-layout-effect.browser.esm.DERp5kr6.js +5 -0
- package/lib/wip/DataTable/DataTable.Body.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Body.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Cell.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Cell.es.js +1 -1
- package/lib/wip/DataTable/DataTable.ColumnHeader.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.ColumnHeader.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Footer.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Footer.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Head.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Head.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Header.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Header.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Row.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Row.es.js +1 -1
- package/lib/wip/DataTable/DataTable.Toolbar.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.Toolbar.es.js +1 -1
- package/lib/wip/DataTable/DataTable.cjs.js +1 -1
- package/lib/wip/DataTable/DataTable.context.d.ts +5 -5
- package/lib/wip/DataTable/DataTable.d.ts +22 -11
- package/lib/wip/DataTable/DataTable.es.js +88 -62
- package/lib/wip/DataTable/DataTable.types.d.ts +56 -14
- package/lib/wip/DateField/DateField.Segment.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segment.es.js +3 -2
- package/lib/wip/DateField/DateField.Segments.cjs.js +1 -1
- package/lib/wip/DateField/DateField.Segments.es.js +1 -1
- package/lib/wip/DateField/DateField.cjs.js +1 -1
- package/lib/wip/DateField/DateField.devWarnings.cjs.js +1 -0
- package/lib/wip/DateField/DateField.devWarnings.d.ts +15 -0
- package/lib/wip/DateField/DateField.devWarnings.es.js +22 -0
- package/lib/wip/DateField/DateField.es.js +186 -177
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -1
- package/lib/wip/DateField/DateField.utils.d.ts +7 -5
- package/lib/wip/DateField/DateField.utils.es.js +84 -70
- package/lib/wip/ErrorBoundary/ErrorBoundary.cjs.js +1 -0
- package/lib/wip/ErrorBoundary/ErrorBoundary.d.ts +28 -0
- package/lib/wip/ErrorBoundary/ErrorBoundary.es.js +19 -0
- package/lib/wip/ErrorBoundary/index.cjs.js +1 -0
- package/lib/wip/ErrorBoundary/index.d.ts +2 -0
- package/lib/wip/ErrorBoundary/index.es.js +4 -0
- package/lib/wip/index.cjs.js +1 -1
- package/lib/wip/index.d.ts +1 -0
- package/lib/wip/index.es.js +17 -15
- package/package.json +7 -7
- package/utils/hooks/useId.cjs.js +1 -1
- package/utils/hooks/useId.es.js +7 -8
- package/chunks/DateField.Segment.CqFLhMYA.js +0 -1
- package/chunks/dataTable.BeVtkYp6.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
-
import { ColumnDef, Table } from '@tanstack/react-table';
|
|
2
|
+
import { ColumnDef, RowData, Table } from '@tanstack/react-table';
|
|
3
3
|
import { DataTableDensity } from '@viasat/beam-shared/components/dataTable';
|
|
4
4
|
/**
|
|
5
5
|
* Column definition for a DataTable, aliased from TanStack Table's `ColumnDef`.
|
|
@@ -7,25 +7,22 @@ import { DataTableDensity } from '@viasat/beam-shared/components/dataTable';
|
|
|
7
7
|
* @typeParam TValue - Type of the value held in the column's cell.
|
|
8
8
|
*/
|
|
9
9
|
export type DataTableColumnDef<TData, TValue = unknown> = ColumnDef<TData, TValue>;
|
|
10
|
-
|
|
10
|
+
interface DataTableBaseProps extends ComponentPropsWithRef<'div'> {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
data?: TData[];
|
|
15
|
-
/**
|
|
16
|
-
* Column definitions describing how to render each column.
|
|
12
|
+
* Density of the table's rows.
|
|
13
|
+
* @default 'md'
|
|
17
14
|
*/
|
|
18
|
-
|
|
15
|
+
density?: DataTableDensity;
|
|
19
16
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* Adds a border around the table container.
|
|
18
|
+
* @default true
|
|
22
19
|
*/
|
|
23
|
-
|
|
20
|
+
bordered?: boolean;
|
|
24
21
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @default
|
|
22
|
+
* Rounds the corners of the table container.
|
|
23
|
+
* @default true
|
|
27
24
|
*/
|
|
28
|
-
|
|
25
|
+
rounded?: boolean;
|
|
29
26
|
/**
|
|
30
27
|
* Props forwarded to the inner `<table>` element. The root props on `DataTable`
|
|
31
28
|
* target the wrapper `<div>`, which contains both the toolbar and the table.
|
|
@@ -35,7 +32,51 @@ export interface DataTableProps<TData = unknown> extends ComponentPropsWithoutRe
|
|
|
35
32
|
* DataTable sub-components (Header, Toolbar, Head, ColumnHeader, Body, Row, Cell, Footer).
|
|
36
33
|
*/
|
|
37
34
|
children?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible name for the table. Applied directly to the `<table>` element, unless
|
|
37
|
+
* a `DataTable.Toolbar` is present — then it's applied to the container as a
|
|
38
|
+
* `region` landmark naming the whole widget instead.
|
|
39
|
+
*/
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
/**
|
|
42
|
+
* ID of the element that labels the table. Alternative to `aria-label` — see its
|
|
43
|
+
* description for how the label is routed depending on whether a toolbar is present.
|
|
44
|
+
*/
|
|
45
|
+
'aria-labelledby'?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Layer 1 (ADR-000): the opaque `data`/`columns` path. DataTable builds its TanStack
|
|
49
|
+
* instance internally via `useBeamTable`. Mutually exclusive with `table` — see
|
|
50
|
+
* {@link DataTableInstanceProps}.
|
|
51
|
+
*/
|
|
52
|
+
export interface DataTableDataProps<TData extends RowData = unknown> extends DataTableBaseProps {
|
|
53
|
+
/**
|
|
54
|
+
* Row data rendered by the table.
|
|
55
|
+
*/
|
|
56
|
+
data?: TData[];
|
|
57
|
+
/**
|
|
58
|
+
* Column definitions describing how to render each column.
|
|
59
|
+
*/
|
|
60
|
+
columns?: DataTableColumnDef<TData>[];
|
|
61
|
+
table?: never;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Layer 2/3 (ADR-000): renders a pre-built TanStack `table` instance — from
|
|
65
|
+
* `useBeamTable` or a raw `useReactTable` escape hatch — directly instead of
|
|
66
|
+
* building one internally. Mutually exclusive with `data`/`columns` — see
|
|
67
|
+
* {@link DataTableDataProps}.
|
|
68
|
+
*/
|
|
69
|
+
export interface DataTableInstanceProps<TData extends RowData = unknown> extends DataTableBaseProps {
|
|
70
|
+
data?: never;
|
|
71
|
+
columns?: never;
|
|
72
|
+
/**
|
|
73
|
+
* A pre-built TanStack `Table` instance (e.g. from `useBeamTable` or
|
|
74
|
+
* `useReactTable`). When supplied, DataTable renders it directly instead of
|
|
75
|
+
* building its own. Mutually exclusive with `data`/`columns`.
|
|
76
|
+
*/
|
|
77
|
+
table: Table<TData>;
|
|
38
78
|
}
|
|
79
|
+
export type DataTableProps<TData extends RowData = unknown> = DataTableDataProps<TData> | DataTableInstanceProps<TData>;
|
|
39
80
|
export interface DataTableHeaderProps extends ComponentPropsWithRef<'caption'> {
|
|
40
81
|
children?: ReactNode;
|
|
41
82
|
}
|
|
@@ -64,3 +105,4 @@ export interface DataTableCellProps extends ComponentPropsWithRef<'td'> {
|
|
|
64
105
|
export interface DataTableFooterProps extends ComponentPropsWithRef<'tfoot'> {
|
|
65
106
|
children?: ReactNode;
|
|
66
107
|
}
|
|
108
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");const e=require("../../../chunks/DateField.Segment.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");require("../../../chunks/use-isomorphic-layout-effect.browser.esm.CkGv31zs.js");const e=require("../../../chunks/DateField.Segment.BqMaeKLk.js");require("./DateField.utils.cjs.js");exports.DateFieldSegment=e.DateFieldSegment;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "clsx";
|
|
3
3
|
import "react";
|
|
4
|
-
import
|
|
4
|
+
import "../../../chunks/use-isomorphic-layout-effect.browser.esm.DERp5kr6.js";
|
|
5
|
+
import { D as a } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
|
|
5
6
|
import "./DateField.utils.es.js";
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
+
a as DateFieldSegment
|
|
8
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("../../../chunks/DateField.Segment.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("../../../chunks/DateField.Segment.BqMaeKLk.js"),t=require("./DateField.utils.cjs.js"),Y={month:"MM",day:"DD",year:"YYYY"},j=({parts:o,segmentText:r,segmentValues:a,focusedSegment:m,disabled:c,readOnly:d,invalid:u,role:y,onSegmentFocus:D,onSegmentBlur:h,onSegmentInput:p,onSegmentKeyDown:M,registerSegmentRef:x})=>{const _={day:{min:1,max:t.getDaysInMonth(a.year,a.month)},month:{min:1,max:t.MONTH_MAX},year:{min:t.YEAR_MIN,max:t.YEAR_MAX}};return i.jsx("span",{className:n.styles[n.staticDateFieldClassNames.segments],children:o.map((s,g)=>{if(s.type==="literal")return i.jsx("span",{"aria-hidden":"true",className:n.styles[n.staticDateFieldClassNames.separator],children:s.value},`literal-${g}`);const e=s.type,F=Y[e],{displayValue:l,isPlaceholder:S}=t.getSegmentDisplay(e,r[e],F),{min:v,max:N}=_[e],A=e==="month"&&a.month!=null?t.getMonthName(a.month):l;return i.jsx(n.DateFieldSegment,{type:e,value:a[e],valueMin:v,valueMax:N,displayValue:l,isPlaceholder:S,valueText:A,invalid:u,role:y,isActive:m===e,disabled:c,readOnly:d,onFocus:()=>D(e),onBlur:h,onInput:p,onKeyDown:M,segmentRef:x(e)},e)})})};exports.DateFieldSegments=j;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { s, a as m, D as F } from "../../../chunks/DateField.Segment.
|
|
2
|
+
import { s, a as m, D as F } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
|
|
3
3
|
import { getDaysInMonth as R, getSegmentDisplay as S, YEAR_MAX as I, YEAR_MIN as T, MONTH_MAX as _, getMonthName as B } from "./DateField.utils.es.js";
|
|
4
4
|
const C = {
|
|
5
5
|
month: "MM",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Ie=require("clsx"),u=require("react"),e=require("../../../chunks/DateField.Segment.BqMaeKLk.js"),Me=require("../../../chunks/constants.CgMu0_1M.js"),Ee=require("../../../chunks/helpers.BIckGIbP.js"),Ne=require("../../../chunks/form.context.CkC0TwMb.js"),Re=require("../../Form/contexts/label.context.cjs.js"),Ce=require("../../Form/contexts/helperText.context.cjs.js"),je=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),Le=require("../../../utils/hooks/useIsMounted.cjs.js"),Oe=require("../ErrorBoundary/ErrorBoundary.cjs.js"),Be=require("./DateField.Segments.cjs.js"),C=require("./DateField.devWarnings.cjs.js"),l=require("./DateField.utils.cjs.js"),Te=require("./useDateFieldFocus.cjs.js"),Ve=require("./useDateFieldForm.cjs.js"),Pe=require("./useDateFieldKeyboard.cjs.js"),Ae=require("./useDateFieldSegments.cjs.js"),ke=require("./useDateFieldValidity.cjs.js"),Ke=require("./useDateFieldValue.cjs.js"),He=require("./useInvalidState.cjs.js"),We="MM/DD/YYYY",Ue=()=>{process.env.NODE_ENV!=="production"&&console.warn("DateField: segments failed to render; showing a static fallback.")},Ye=u.forwardRef(function({value:c,defaultValue:_,onChange:j,minDate:F,maxDate:b,getClampAnnouncement:L,locale:O,label:D=null,helperText:m=null,error:f,hideRequiredMarker:B=!1,validationRules:T,width:V,theme:g,fluid:P=!1,disabled:A=!1,readOnly:k=!1,required:K=!1,name:p,id:H,className:W,style:U,"aria-label":Y,"aria-describedby":$,"aria-labelledby":z,...G},J){const{disabled:a,readOnly:r,required:x,invalid:Q,errorMessageProvided:v,defaultValue:X,errorId:y,helperTextId:Z,validationErrorsId:ee,labelId:h,ariaDescribedBy:se,ariaLabelledBy:ae,showErrors:ie}=Ve.useDateFieldForm({name:p,disabled:A,readOnly:k,required:K,defaultValue:_,error:f,hasHelperText:!!m,hasLabel:!!D,validationRules:T,ariaDescribedBy:$,ariaLabelledBy:z});C.useDevMinMaxWarning(F,b),C.useDevInvalidValueWarning(c,_);const{refFn:le,ref:S}=je.useUniversalRef(J),{segmentRefs:te,registerSegmentRef:re}=Ae.useDateFieldSegments(),ne=O??l.DEFAULT_LOCALE,q=Le.useIsMounted(),n=l.getDateParts(q?ne:l.DEFAULT_LOCALE),w=u.useMemo(()=>l.getSegmentOrder(n),[n]),{segmentText:de,segmentValues:I,currentValue:M,wasTouched:oe,appendDigit:E,adjustSegment:ue,clearSegment:ce,beginSegmentEdit:_e,commitOnBlur:Fe,clampAnnouncement:be}=Ke.useDateFieldValue({value:c,defaultValue:X,onChange:j,minDate:F,maxDate:b,getClampAnnouncement:L}),{focusedSegment:N,fieldTabIndex:De,handleSegmentFocus:R,handleFieldFocus:me,handleFieldBlur:fe,handleFieldMouseDown:ge,focusNext:d,focusPrevious:pe}=Te.useDateFieldFocus({disabled:a,fieldRef:S,segmentRefs:te,partsOrder:w,onSegmentFocusChange:_e,onFieldBlur:Fe}),xe=Pe.useDateFieldKeyboard({disabled:a,readOnly:r,fieldRef:S,focusNext:d,focusPrevious:pe,adjustSegment:ue,clearSegment:ce}),{isInvalid:ve}=ke.useDateFieldValidity({segments:I,currentValue:M,wasTouched:oe,isFocused:N!==null}),ye=u.useCallback((i,t)=>{const{advanced:we}=E(i,t);we&&d(i)},[E,d]),o=He.useInvalidState({formInvalid:Q,valueInvalid:ve}),he=q&&Ee.isIOS()?"textbox":"spinbutton",Se=i=>{if(a)return;const t=i.target.closest("label");!t||t.id!==h||(i.preventDefault(),R(w[0]))},qe=Ie(e.styles[e.baseClassNamePrefix],g&&Me.themeClassName(g),P&&e.styles[`${e.classModifierPrefix}fluid`],o&&e.styles[`${e.classModifierPrefix}error`],a&&e.styles[`${e.classModifierPrefix}disabled`],r&&e.styles[`${e.classModifierPrefix}read-only`],W);return s.jsxs("div",{className:qe,style:{...U,maxWidth:V},onMouseDownCapture:Se,children:[s.jsx(Re.LabelProvider,{ctxId:h,ctxDisabled:a,ctxRequired:x&&!B,children:D}),s.jsx("div",{...G,ref:le,id:H,role:"group","aria-label":Y,"aria-labelledby":ae,"aria-disabled":a||void 0,"aria-required":x||void 0,"aria-invalid":o||void 0,"aria-describedby":se,"aria-errormessage":v?y:void 0,tabIndex:De,className:e.styles[e.staticDateFieldClassNames.field],onMouseDown:ge,onFocus:me,children:s.jsx(Oe.ErrorBoundary,{fallback:s.jsx("span",{className:e.styles[e.staticDateFieldClassNames.segments],children:We}),onError:Ue,children:s.jsx(Be.DateFieldSegments,{parts:n,segmentText:de,segmentValues:I,focusedSegment:N,disabled:a,readOnly:r,invalid:o,role:he,onSegmentFocus:R,onSegmentBlur:fe,onSegmentInput:ye,onSegmentKeyDown:xe,registerSegmentRef:re})})}),s.jsx("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:e.styles[e.staticDateFieldClassNames.srStatus],children:be}),s.jsx("input",{type:"hidden",name:p,value:l.toISODateString(M),disabled:a}),s.jsxs(Ce.HelperTextProvider,{ctxId:Z,ctxDisabled:a,children:[m,v&&s.jsx(Ne.HelperText,{id:y,appearance:"negative",children:f})]}),ie(ee)]})});exports.DateField=Ye;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),i=require("./DateField.utils.cjs.js"),l=(e,a)=>{s.useEffect(()=>{process.env.NODE_ENV!=="production"&&i.isMinMaxMisconfigured(e,a)&&console.warn("DateField: `minDate` is after `maxDate` — no date satisfies both, so the blur clamp is disabled and values are left as typed.")},[i.dateKeyOrNull(e),i.dateKeyOrNull(a)])},r=(e,a)=>{const n=e instanceof Date&&!i.isValidDate(e),t=a instanceof Date&&!i.isValidDate(a);s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&console.warn("DateField: `value` is an Invalid Date; rendering with no value."),t&&console.warn("DateField: `defaultValue` is an Invalid Date; rendering with no value."))},[n,t])};exports.useDevInvalidValueWarning=r;exports.useDevMinMaxWarning=l;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-only guard: `minDate` after `maxDate` is a caller misconfig where no date
|
|
3
|
+
* satisfies both, so the blur clamp is disabled (values are left as typed). Warns
|
|
4
|
+
* once per prop change (stripped in production). Deps key on the primitive
|
|
5
|
+
* calendar day, not the `Date` object — an inline `new Date()` bound would
|
|
6
|
+
* otherwise re-run this every render and spam the warning.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useDevMinMaxWarning: (minDate: Date | null | undefined, maxDate: Date | null | undefined) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Dev-only guard: an Invalid Date prop renders with no value (segments show
|
|
11
|
+
* placeholders). Warns so the caller notices rather than debugging a silently
|
|
12
|
+
* empty field. Keyed on booleans, not the `Date` objects, so a fresh-but-valid
|
|
13
|
+
* `Date` each render doesn't churn.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useDevInvalidValueWarning: (value: Date | null | undefined, defaultValue: Date | null | undefined) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect as o } from "react";
|
|
2
|
+
import { isMinMaxMisconfigured as l, dateKeyOrNull as t, isValidDate as s } from "./DateField.utils.es.js";
|
|
3
|
+
const c = (e, a) => {
|
|
4
|
+
o(() => {
|
|
5
|
+
process.env.NODE_ENV !== "production" && l(e, a) && console.warn(
|
|
6
|
+
"DateField: `minDate` is after `maxDate` — no date satisfies both, so the blur clamp is disabled and values are left as typed."
|
|
7
|
+
);
|
|
8
|
+
}, [t(e), t(a)]);
|
|
9
|
+
}, u = (e, a) => {
|
|
10
|
+
const n = e instanceof Date && !s(e), i = a instanceof Date && !s(a);
|
|
11
|
+
o(() => {
|
|
12
|
+
process.env.NODE_ENV !== "production" && (n && console.warn(
|
|
13
|
+
"DateField: `value` is an Invalid Date; rendering with no value."
|
|
14
|
+
), i && console.warn(
|
|
15
|
+
"DateField: `defaultValue` is an Invalid Date; rendering with no value."
|
|
16
|
+
));
|
|
17
|
+
}, [n, i]);
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
u as useDevInvalidValueWarning,
|
|
21
|
+
c as useDevMinMaxWarning
|
|
22
|
+
};
|
|
@@ -1,236 +1,245 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { s as
|
|
5
|
-
import { t as
|
|
6
|
-
import { i as
|
|
7
|
-
import { H as
|
|
8
|
-
import { LabelProvider as
|
|
9
|
-
import { HelperTextProvider as
|
|
1
|
+
import { jsxs as B, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import Re from "clsx";
|
|
3
|
+
import { forwardRef as Ce, useMemo as Ee, useCallback as Oe } from "react";
|
|
4
|
+
import { s as r, b as Be, c as i, a as m } from "../../../chunks/DateField.Segment.BMXzpxgl.js";
|
|
5
|
+
import { t as Le } from "../../../chunks/constants.Cruz2A1w.js";
|
|
6
|
+
import { i as Ve } from "../../../chunks/helpers.CiQfGwdc.js";
|
|
7
|
+
import { H as Te } from "../../../chunks/form.context.BDYA2JQs.js";
|
|
8
|
+
import { LabelProvider as Ae } from "../../Form/contexts/label.context.es.js";
|
|
9
|
+
import { HelperTextProvider as Pe } from "../../Form/contexts/helperText.context.es.js";
|
|
10
10
|
import { useUniversalRef as qe } from "../../Form/hooks/useUniversalRef.hook.es.js";
|
|
11
|
-
import { useIsMounted as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
11
|
+
import { useIsMounted as Ke } from "../../../utils/hooks/useIsMounted.es.js";
|
|
12
|
+
import { ErrorBoundary as He } from "../ErrorBoundary/ErrorBoundary.es.js";
|
|
13
|
+
import { DateFieldSegments as We } from "./DateField.Segments.es.js";
|
|
14
|
+
import { useDevMinMaxWarning as Ye, useDevInvalidValueWarning as _e } from "./DateField.devWarnings.es.js";
|
|
15
|
+
import { getDateParts as $e, getSegmentOrder as je, toISODateString as ke, DEFAULT_LOCALE as L } from "./DateField.utils.es.js";
|
|
16
|
+
import { useDateFieldFocus as Ue } from "./useDateFieldFocus.es.js";
|
|
17
|
+
import { useDateFieldForm as ze } from "./useDateFieldForm.es.js";
|
|
18
|
+
import { useDateFieldKeyboard as Ge } from "./useDateFieldKeyboard.es.js";
|
|
19
|
+
import { useDateFieldSegments as Je } from "./useDateFieldSegments.es.js";
|
|
20
|
+
import { useDateFieldValidity as Qe } from "./useDateFieldValidity.es.js";
|
|
21
|
+
import { useDateFieldValue as Xe } from "./useDateFieldValue.es.js";
|
|
22
|
+
import { useInvalidState as Ze } from "./useInvalidState.es.js";
|
|
23
|
+
const ea = "MM/DD/YYYY", aa = () => {
|
|
24
|
+
process.env.NODE_ENV !== "production" && console.warn(
|
|
25
|
+
"DateField: segments failed to render; showing a static fallback."
|
|
26
|
+
);
|
|
27
|
+
}, Ma = Ce(
|
|
22
28
|
function({
|
|
23
|
-
value:
|
|
24
|
-
defaultValue:
|
|
25
|
-
onChange:
|
|
26
|
-
minDate:
|
|
27
|
-
maxDate:
|
|
28
|
-
getClampAnnouncement:
|
|
29
|
-
locale:
|
|
30
|
-
label:
|
|
31
|
-
helperText:
|
|
32
|
-
error:
|
|
33
|
-
hideRequiredMarker:
|
|
29
|
+
value: u,
|
|
30
|
+
defaultValue: c,
|
|
31
|
+
onChange: V,
|
|
32
|
+
minDate: f,
|
|
33
|
+
maxDate: p,
|
|
34
|
+
getClampAnnouncement: T,
|
|
35
|
+
locale: A,
|
|
36
|
+
label: g = null,
|
|
37
|
+
helperText: b = null,
|
|
38
|
+
error: v,
|
|
39
|
+
hideRequiredMarker: P = !1,
|
|
34
40
|
validationRules: q,
|
|
35
|
-
width:
|
|
36
|
-
theme:
|
|
37
|
-
fluid:
|
|
38
|
-
disabled:
|
|
39
|
-
readOnly:
|
|
40
|
-
required:
|
|
41
|
-
name:
|
|
42
|
-
id:
|
|
43
|
-
className:
|
|
44
|
-
style:
|
|
45
|
-
"aria-label":
|
|
41
|
+
width: K,
|
|
42
|
+
theme: D,
|
|
43
|
+
fluid: H = !1,
|
|
44
|
+
disabled: W = !1,
|
|
45
|
+
readOnly: Y = !1,
|
|
46
|
+
required: _ = !1,
|
|
47
|
+
name: F,
|
|
48
|
+
id: $,
|
|
49
|
+
className: j,
|
|
50
|
+
style: k,
|
|
51
|
+
"aria-label": U,
|
|
46
52
|
"aria-describedby": z,
|
|
47
53
|
"aria-labelledby": G,
|
|
48
54
|
...J
|
|
49
55
|
}, Q) {
|
|
50
56
|
const {
|
|
51
57
|
disabled: e,
|
|
52
|
-
readOnly:
|
|
53
|
-
required:
|
|
58
|
+
readOnly: t,
|
|
59
|
+
required: h,
|
|
54
60
|
invalid: X,
|
|
55
|
-
errorMessageProvided:
|
|
56
|
-
defaultValue:
|
|
57
|
-
errorId:
|
|
58
|
-
helperTextId:
|
|
59
|
-
validationErrorsId:
|
|
60
|
-
labelId:
|
|
61
|
-
ariaDescribedBy:
|
|
62
|
-
ariaLabelledBy:
|
|
63
|
-
showErrors:
|
|
64
|
-
} =
|
|
65
|
-
name:
|
|
66
|
-
disabled:
|
|
67
|
-
readOnly:
|
|
68
|
-
required:
|
|
69
|
-
defaultValue:
|
|
70
|
-
error:
|
|
71
|
-
hasHelperText: !!
|
|
72
|
-
hasLabel: !!
|
|
61
|
+
errorMessageProvided: S,
|
|
62
|
+
defaultValue: Z,
|
|
63
|
+
errorId: x,
|
|
64
|
+
helperTextId: ee,
|
|
65
|
+
validationErrorsId: ae,
|
|
66
|
+
labelId: y,
|
|
67
|
+
ariaDescribedBy: re,
|
|
68
|
+
ariaLabelledBy: se,
|
|
69
|
+
showErrors: oe
|
|
70
|
+
} = ze({
|
|
71
|
+
name: F,
|
|
72
|
+
disabled: W,
|
|
73
|
+
readOnly: Y,
|
|
74
|
+
required: _,
|
|
75
|
+
defaultValue: c,
|
|
76
|
+
error: v,
|
|
77
|
+
hasHelperText: !!b,
|
|
78
|
+
hasLabel: !!g,
|
|
73
79
|
validationRules: q,
|
|
74
80
|
ariaDescribedBy: z,
|
|
75
81
|
ariaLabelledBy: G
|
|
76
82
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
onChange: P,
|
|
97
|
-
minDate: l,
|
|
98
|
-
maxDate: o,
|
|
99
|
-
getClampAnnouncement: E
|
|
83
|
+
Ye(f, p), _e(u, c);
|
|
84
|
+
const { refFn: ie, ref: I } = qe(Q), { segmentRefs: te, registerSegmentRef: le } = Je(), ne = A ?? L, M = Ke(), l = $e(M ? ne : L), N = Ee(() => je(l), [l]), {
|
|
85
|
+
segmentText: de,
|
|
86
|
+
segmentValues: w,
|
|
87
|
+
currentValue: R,
|
|
88
|
+
wasTouched: me,
|
|
89
|
+
appendDigit: C,
|
|
90
|
+
adjustSegment: ue,
|
|
91
|
+
clearSegment: ce,
|
|
92
|
+
beginSegmentEdit: fe,
|
|
93
|
+
commitOnBlur: pe,
|
|
94
|
+
clampAnnouncement: ge
|
|
95
|
+
} = Xe({
|
|
96
|
+
value: u,
|
|
97
|
+
defaultValue: Z,
|
|
98
|
+
onChange: V,
|
|
99
|
+
minDate: f,
|
|
100
|
+
maxDate: p,
|
|
101
|
+
getClampAnnouncement: T
|
|
100
102
|
}), {
|
|
101
|
-
focusedSegment:
|
|
102
|
-
fieldTabIndex:
|
|
103
|
-
handleSegmentFocus:
|
|
104
|
-
handleFieldFocus:
|
|
105
|
-
handleFieldBlur:
|
|
106
|
-
handleFieldMouseDown:
|
|
107
|
-
focusNext:
|
|
108
|
-
focusPrevious:
|
|
109
|
-
} =
|
|
103
|
+
focusedSegment: E,
|
|
104
|
+
fieldTabIndex: be,
|
|
105
|
+
handleSegmentFocus: O,
|
|
106
|
+
handleFieldFocus: ve,
|
|
107
|
+
handleFieldBlur: De,
|
|
108
|
+
handleFieldMouseDown: Fe,
|
|
109
|
+
focusNext: n,
|
|
110
|
+
focusPrevious: he
|
|
111
|
+
} = Ue({
|
|
110
112
|
disabled: e,
|
|
111
|
-
fieldRef:
|
|
112
|
-
segmentRefs:
|
|
113
|
-
partsOrder:
|
|
114
|
-
onSegmentFocusChange:
|
|
115
|
-
onFieldBlur:
|
|
116
|
-
}),
|
|
113
|
+
fieldRef: I,
|
|
114
|
+
segmentRefs: te,
|
|
115
|
+
partsOrder: N,
|
|
116
|
+
onSegmentFocusChange: fe,
|
|
117
|
+
onFieldBlur: pe
|
|
118
|
+
}), Se = Ge({
|
|
117
119
|
disabled: e,
|
|
118
|
-
readOnly:
|
|
119
|
-
fieldRef:
|
|
120
|
-
focusNext:
|
|
121
|
-
focusPrevious:
|
|
122
|
-
adjustSegment:
|
|
123
|
-
clearSegment:
|
|
124
|
-
}), { isInvalid:
|
|
125
|
-
segments:
|
|
126
|
-
currentValue:
|
|
127
|
-
wasTouched:
|
|
128
|
-
isFocused:
|
|
129
|
-
}),
|
|
130
|
-
(s,
|
|
131
|
-
const { advanced:
|
|
132
|
-
|
|
120
|
+
readOnly: t,
|
|
121
|
+
fieldRef: I,
|
|
122
|
+
focusNext: n,
|
|
123
|
+
focusPrevious: he,
|
|
124
|
+
adjustSegment: ue,
|
|
125
|
+
clearSegment: ce
|
|
126
|
+
}), { isInvalid: xe } = Qe({
|
|
127
|
+
segments: w,
|
|
128
|
+
currentValue: R,
|
|
129
|
+
wasTouched: me,
|
|
130
|
+
isFocused: E !== null
|
|
131
|
+
}), ye = Oe(
|
|
132
|
+
(s, o) => {
|
|
133
|
+
const { advanced: we } = C(s, o);
|
|
134
|
+
we && n(s);
|
|
133
135
|
},
|
|
134
|
-
[
|
|
135
|
-
),
|
|
136
|
+
[C, n]
|
|
137
|
+
), d = Ze({
|
|
136
138
|
formInvalid: X,
|
|
137
|
-
valueInvalid:
|
|
138
|
-
}),
|
|
139
|
+
valueInvalid: xe
|
|
140
|
+
}), Ie = M && Ve() ? "textbox" : "spinbutton", Me = (s) => {
|
|
139
141
|
if (e) return;
|
|
140
|
-
const
|
|
141
|
-
!
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
e &&
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
const o = s.target.closest("label");
|
|
143
|
+
!o || o.id !== y || (s.preventDefault(), O(N[0]));
|
|
144
|
+
}, Ne = Re(
|
|
145
|
+
r[Be],
|
|
146
|
+
D && Le(D),
|
|
147
|
+
H && r[`${i}fluid`],
|
|
148
|
+
d && r[`${i}error`],
|
|
149
|
+
e && r[`${i}disabled`],
|
|
150
|
+
t && r[`${i}read-only`],
|
|
151
|
+
j
|
|
150
152
|
);
|
|
151
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ B(
|
|
152
154
|
"div",
|
|
153
155
|
{
|
|
154
|
-
className:
|
|
155
|
-
style: { ...
|
|
156
|
-
onMouseDownCapture:
|
|
156
|
+
className: Ne,
|
|
157
|
+
style: { ...k, maxWidth: K },
|
|
158
|
+
onMouseDownCapture: Me,
|
|
157
159
|
children: [
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
|
|
160
|
+
/* @__PURE__ */ a(
|
|
161
|
+
Ae,
|
|
160
162
|
{
|
|
161
|
-
ctxId:
|
|
163
|
+
ctxId: y,
|
|
162
164
|
ctxDisabled: e,
|
|
163
|
-
ctxRequired:
|
|
164
|
-
children:
|
|
165
|
+
ctxRequired: h && !P,
|
|
166
|
+
children: g
|
|
165
167
|
}
|
|
166
168
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
169
|
+
/* @__PURE__ */ a(
|
|
168
170
|
"div",
|
|
169
171
|
{
|
|
170
172
|
...J,
|
|
171
|
-
ref:
|
|
172
|
-
id:
|
|
173
|
+
ref: ie,
|
|
174
|
+
id: $,
|
|
173
175
|
role: "group",
|
|
174
|
-
"aria-label":
|
|
175
|
-
"aria-labelledby":
|
|
176
|
+
"aria-label": U,
|
|
177
|
+
"aria-labelledby": se,
|
|
176
178
|
"aria-disabled": e || void 0,
|
|
177
|
-
"aria-required":
|
|
178
|
-
"aria-invalid":
|
|
179
|
-
"aria-describedby":
|
|
180
|
-
"aria-errormessage":
|
|
181
|
-
tabIndex:
|
|
182
|
-
className:
|
|
183
|
-
onMouseDown:
|
|
184
|
-
onFocus:
|
|
185
|
-
children: /* @__PURE__ */
|
|
186
|
-
|
|
179
|
+
"aria-required": h || void 0,
|
|
180
|
+
"aria-invalid": d || void 0,
|
|
181
|
+
"aria-describedby": re,
|
|
182
|
+
"aria-errormessage": S ? x : void 0,
|
|
183
|
+
tabIndex: be,
|
|
184
|
+
className: r[m.field],
|
|
185
|
+
onMouseDown: Fe,
|
|
186
|
+
onFocus: ve,
|
|
187
|
+
children: /* @__PURE__ */ a(
|
|
188
|
+
He,
|
|
187
189
|
{
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
190
|
+
fallback: /* @__PURE__ */ a("span", { className: r[m.segments], children: ea }),
|
|
191
|
+
onError: aa,
|
|
192
|
+
children: /* @__PURE__ */ a(
|
|
193
|
+
We,
|
|
194
|
+
{
|
|
195
|
+
parts: l,
|
|
196
|
+
segmentText: de,
|
|
197
|
+
segmentValues: w,
|
|
198
|
+
focusedSegment: E,
|
|
199
|
+
disabled: e,
|
|
200
|
+
readOnly: t,
|
|
201
|
+
invalid: d,
|
|
202
|
+
role: Ie,
|
|
203
|
+
onSegmentFocus: O,
|
|
204
|
+
onSegmentBlur: De,
|
|
205
|
+
onSegmentInput: ye,
|
|
206
|
+
onSegmentKeyDown: Se,
|
|
207
|
+
registerSegmentRef: le
|
|
208
|
+
}
|
|
209
|
+
)
|
|
201
210
|
}
|
|
202
211
|
)
|
|
203
212
|
}
|
|
204
213
|
),
|
|
205
|
-
/* @__PURE__ */
|
|
214
|
+
/* @__PURE__ */ a(
|
|
206
215
|
"span",
|
|
207
216
|
{
|
|
208
217
|
role: "status",
|
|
209
218
|
"aria-live": "polite",
|
|
210
219
|
"aria-atomic": "true",
|
|
211
|
-
className:
|
|
212
|
-
children:
|
|
220
|
+
className: r[m.srStatus],
|
|
221
|
+
children: ge
|
|
213
222
|
}
|
|
214
223
|
),
|
|
215
|
-
/* @__PURE__ */
|
|
224
|
+
/* @__PURE__ */ a(
|
|
216
225
|
"input",
|
|
217
226
|
{
|
|
218
227
|
type: "hidden",
|
|
219
|
-
name:
|
|
220
|
-
value:
|
|
228
|
+
name: F,
|
|
229
|
+
value: ke(R),
|
|
221
230
|
disabled: e
|
|
222
231
|
}
|
|
223
232
|
),
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
|
|
226
|
-
|
|
233
|
+
/* @__PURE__ */ B(Pe, { ctxId: ee, ctxDisabled: e, children: [
|
|
234
|
+
b,
|
|
235
|
+
S && /* @__PURE__ */ a(Te, { id: x, appearance: "negative", children: v })
|
|
227
236
|
] }),
|
|
228
|
-
|
|
237
|
+
oe(ae)
|
|
229
238
|
]
|
|
230
239
|
}
|
|
231
240
|
);
|
|
232
241
|
}
|
|
233
242
|
);
|
|
234
243
|
export {
|
|
235
|
-
|
|
244
|
+
Ma as DateField
|
|
236
245
|
};
|