@tedi-design-system/react 18.0.0-rc.7 → 18.0.0-rc.9
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/_virtual/index.es13.js +2 -2
- package/_virtual/index.es14.js +2 -2
- package/bundle-stats.html +1 -1
- package/external/react-is/index.cjs.js +1 -1
- package/external/react-is/index.es.js +1 -1
- package/external/toposort/index.cjs.js +1 -1
- package/external/toposort/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/form/pickers/calendar/calendar.d.ts +6 -0
- package/src/community/components/form/pickers/datepicker/datepicker.d.ts +6 -0
- package/src/community/components/form/pickers/datetimepicker/datetimepicker.d.ts +6 -0
- package/src/community/components/form/pickers/timepicker/timepicker.d.ts +6 -0
- package/src/tedi/components/content/calendar/calendar-grid.cjs.js +1 -1
- package/src/tedi/components/content/calendar/calendar-grid.es.js +7 -6
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js +1 -1
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js +99 -79
- package/src/tedi/components/form/date-field/date-field-helpers.cjs.js +1 -0
- package/src/tedi/components/form/date-field/date-field-helpers.d.ts +66 -0
- package/src/tedi/components/form/date-field/date-field-helpers.es.js +28 -0
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +22 -0
- package/src/tedi/components/form/date-field/date-field.es.js +248 -212
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -0
- package/src/tedi/components/form/date-time-field/date-time-field.d.ts +207 -0
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +376 -0
- package/src/tedi/components/form/date-time-field/date-time-field.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/date-time-field/date-time-field.module.scss.es.js +30 -0
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +9 -0
- package/src/tedi/components/form/time-field/time-field.es.js +81 -79
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.cjs.js +1 -0
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.d.ts +52 -0
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.es.js +68 -0
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.module.scss.cjs.js +1 -0
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.module.scss.es.js +9 -0
- package/src/tedi/components/layout/mobile-nav/index.d.ts +2 -0
- package/src/tedi/components/layout/mobile-nav/mobile-nav.cjs.js +1 -0
- package/src/tedi/components/layout/mobile-nav/mobile-nav.d.ts +20 -0
- package/src/tedi/components/layout/{sidenav/components/sidenav-mobile/sidenav-mobile.es.js → mobile-nav/mobile-nav.es.js} +21 -20
- package/src/tedi/components/layout/sidenav/index.d.ts +2 -2
- package/src/tedi/components/layout/sidenav/sidenav.cjs.js +1 -1
- package/src/tedi/components/layout/sidenav/sidenav.d.ts +2 -11
- package/src/tedi/components/layout/sidenav/sidenav.es.js +27 -27
- package/src/tedi/components/layout/top-nav/components/top-nav-group/top-nav-group.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-group/top-nav-group.d.ts +34 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-group/top-nav-group.es.js +33 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.d.ts +66 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.es.js +101 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.d.ts +11 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.es.js +9 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-subitem/top-nav-subitem.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-subitem/top-nav-subitem.d.ts +28 -0
- package/src/tedi/components/layout/top-nav/components/top-nav-subitem/top-nav-subitem.es.js +30 -0
- package/src/tedi/components/layout/top-nav/index.d.ts +5 -0
- package/src/tedi/components/layout/top-nav/top-nav-context.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/top-nav-context.d.ts +11 -0
- package/src/tedi/components/layout/top-nav/top-nav-context.es.js +6 -0
- package/src/tedi/components/layout/top-nav/top-nav.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/top-nav.d.ts +91 -0
- package/src/tedi/components/layout/top-nav/top-nav.es.js +171 -0
- package/src/tedi/components/layout/top-nav/top-nav.module.scss.cjs.js +1 -0
- package/src/tedi/components/layout/top-nav/top-nav.module.scss.es.js +28 -0
- package/src/tedi/components/overlays/dropdown/dropdown.es.js +0 -3
- package/src/tedi/helpers/hooks/use-breakpoint.cjs.js +1 -1
- package/src/tedi/helpers/hooks/use-breakpoint.d.ts +7 -0
- package/src/tedi/helpers/hooks/use-breakpoint.es.js +22 -14
- package/src/tedi/index.d.ts +3 -0
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +28 -0
- package/src/tedi/providers/label-provider/labels-map.es.js +93 -65
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +237 -222
- package/src/tedi/components/layout/sidenav/components/sidenav-mobile/sidenav-mobile.cjs.js +0 -1
- package/src/tedi/components/layout/sidenav/components/sidenav-mobile/sidenav-mobile.d.ts +0 -14
- package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.cjs.js +0 -1
- package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.d.ts +0 -31
- package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.es.js +0 -48
- package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.module.scss.cjs.js +0 -1
- package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.module.scss.es.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
export type CalendarValue = Dayjs | null;
|
|
3
3
|
export type CalendarStatus = 'error' | 'success' | 'inactive';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use `Calendar` from `@tedi-design-system/react/tedi` instead.
|
|
6
|
+
*/
|
|
4
7
|
export interface CalendarProps {
|
|
5
8
|
/**
|
|
6
9
|
* Currently selected value. Accepts a dayjs date object.
|
|
@@ -86,5 +89,8 @@ export interface CalendarProps {
|
|
|
86
89
|
*/
|
|
87
90
|
shouldShowStatusOnDate?: (day: CalendarValue) => CalendarStatus | undefined;
|
|
88
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Use `Calendar` from `@tedi-design-system/react/tedi` instead.
|
|
94
|
+
*/
|
|
89
95
|
export declare const Calendar: (props: CalendarProps) => JSX.Element;
|
|
90
96
|
export default Calendar;
|
|
@@ -2,6 +2,9 @@ import { DateValidationError } from '@mui/x-date-pickers/internals';
|
|
|
2
2
|
import { Dayjs } from 'dayjs';
|
|
3
3
|
import { TextFieldProps } from '../../../../../tedi/components/form/textfield/textfield';
|
|
4
4
|
export type DatepickerValue = Dayjs | null;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `DateField` from `@tedi-design-system/react/tedi` instead.
|
|
7
|
+
*/
|
|
5
8
|
export interface DatePickerProps extends Omit<TextFieldProps, 'defaultValue' | 'value' | 'onChange'> {
|
|
6
9
|
/**
|
|
7
10
|
* Datepicker initial value. Accepts a dayjs date object.
|
|
@@ -85,5 +88,8 @@ export interface DatePickerProps extends Omit<TextFieldProps, 'defaultValue' | '
|
|
|
85
88
|
*/
|
|
86
89
|
onClose?: () => void;
|
|
87
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use `DateField` from `@tedi-design-system/react/tedi` instead.
|
|
93
|
+
*/
|
|
88
94
|
export declare const DatePicker: (props: DatePickerProps) => JSX.Element;
|
|
89
95
|
export default DatePicker;
|
|
@@ -3,6 +3,9 @@ import { DateTimeValidationError } from '@mui/x-date-pickers/internals/hooks/val
|
|
|
3
3
|
import { Dayjs } from 'dayjs';
|
|
4
4
|
import { TextFieldProps } from '../../../../../tedi/components/form/textfield/textfield';
|
|
5
5
|
export type DateTimepickerValue = Dayjs | null;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `DateTimeField` from `@tedi-design-system/react/tedi` instead.
|
|
8
|
+
*/
|
|
6
9
|
export interface DateTimePickerProps extends Omit<TextFieldProps, 'defaultValue' | 'value' | 'onChange'> {
|
|
7
10
|
/**
|
|
8
11
|
* DateTimepicker initial value. Accepts a dayjs date object.
|
|
@@ -125,5 +128,8 @@ export interface DateTimePickerProps extends Omit<TextFieldProps, 'defaultValue'
|
|
|
125
128
|
*/
|
|
126
129
|
onClose?: () => void;
|
|
127
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Use `DateTimeField` from `@tedi-design-system/react/tedi` instead.
|
|
133
|
+
*/
|
|
128
134
|
export declare const DateTimePicker: (props: DateTimePickerProps) => JSX.Element;
|
|
129
135
|
export default DateTimePicker;
|
|
@@ -3,6 +3,9 @@ import { TimeValidationError } from '@mui/x-date-pickers/internals/hooks/validat
|
|
|
3
3
|
import { Dayjs } from 'dayjs';
|
|
4
4
|
import { TextFieldProps } from '../../../../../tedi/components/form/textfield/textfield';
|
|
5
5
|
export type TimePickerValue = Dayjs | null;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `TimeField` from `@tedi-design-system/react/tedi` instead.
|
|
8
|
+
*/
|
|
6
9
|
export interface TimePickerProps extends Omit<TextFieldProps, 'defaultValue' | 'value' | 'onChange'> {
|
|
7
10
|
/**
|
|
8
11
|
* TimePicker initial value. Accepts a dayjs date object.
|
|
@@ -69,5 +72,8 @@ export interface TimePickerProps extends Omit<TextFieldProps, 'defaultValue' | '
|
|
|
69
72
|
*/
|
|
70
73
|
onClose?: () => void;
|
|
71
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use `TimeField` from `@tedi-design-system/react/tedi` instead.
|
|
77
|
+
*/
|
|
72
78
|
export declare const TimePicker: (props: TimePickerProps) => JSX.Element;
|
|
73
79
|
export default TimePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../../../../../external/classnames/index.cjs.js"),a=require("../../base/typography/text/text.cjs.js"),l=require("../../buttons/button/button.cjs.js"),r=require("./calendar.module.scss.cjs.js"),j=require("../../layout/grid/row.cjs.js"),h=require("../../layout/grid/col.cjs.js"),s=({headerLabel:u,prevAriaLabel:n,nextAriaLabel:c,onPrev:o,onNext:f,items:x,onSelect:p,showNavigation:d,className:_})=>e.jsxs("div",{className:i.default(r.default["tedi-calendar__picker-grid-container"],_),"data-testid":"tedi-picker-grid-container",children:[e.jsxs("div",{className:i.default(r.default["tedi-calendar__picker-grid-header"],{[r.default["tedi-calendar__picker--no-navigation"]]:!d}),children:[d&&e.jsx(l.Button,{type:"button",onClick:o,"aria-label":n,icon:"arrow_back",visualType:"neutral",children:e.jsx(a.Text,{modifiers:"capitalize-first",children:n})}),e.jsx(a.Text,{modifiers:"capitalize-first",children:u}),d&&e.jsx(l.Button,{type:"button",onClick:f,"aria-label":c,icon:"arrow_forward",visualType:"neutral",children:e.jsx(a.Text,{modifiers:"capitalize-first",children:c})})]}),e.jsx("div",{className:i.default(r.default["tedi-calendar__picker-grid"]),children:e.jsx(j.Row,{gutter:2,children:x.map(t=>e.jsx(h.Col,{width:4,children:e.jsx(l.Button,{onClick:()=>p(t.value),className:i.default(r.default["tedi-calendar__grid-button"],{[r.default["tedi-calendar__grid-button--selected"]]:t.isSelected}),"aria-pressed":t.isSelected,"data-testid":"tedi-calendar-grid-cell",noStyle:!0,children:t.label})},t.key))})})]});s.displayName="CalendarGrid";exports.CalendarGrid=s;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import a from "../../../../../external/classnames/index.es.js";
|
|
3
|
-
import { Text as
|
|
4
|
-
import { Button as
|
|
3
|
+
import { Text as t } from "../../base/typography/text/text.es.js";
|
|
4
|
+
import { Button as l } from "../../buttons/button/button.es.js";
|
|
5
5
|
import r from "./calendar.module.scss.es.js";
|
|
6
6
|
import { Row as h } from "../../layout/grid/row.es.js";
|
|
7
7
|
import { Col as k } from "../../layout/grid/col.es.js";
|
|
@@ -28,20 +28,21 @@ const y = ({
|
|
|
28
28
|
[r["tedi-calendar__picker--no-navigation"]]: !d
|
|
29
29
|
}),
|
|
30
30
|
children: [
|
|
31
|
-
d && /* @__PURE__ */ e(
|
|
32
|
-
/* @__PURE__ */ e(
|
|
33
|
-
d && /* @__PURE__ */ e(
|
|
31
|
+
d && /* @__PURE__ */ e(l, { type: "button", onClick: p, "aria-label": c, icon: "arrow_back", visualType: "neutral", children: /* @__PURE__ */ e(t, { modifiers: "capitalize-first", children: c }) }),
|
|
32
|
+
/* @__PURE__ */ e(t, { modifiers: "capitalize-first", children: s }),
|
|
33
|
+
d && /* @__PURE__ */ e(l, { type: "button", onClick: m, "aria-label": n, icon: "arrow_forward", visualType: "neutral", children: /* @__PURE__ */ e(t, { modifiers: "capitalize-first", children: n }) })
|
|
34
34
|
]
|
|
35
35
|
}
|
|
36
36
|
),
|
|
37
37
|
/* @__PURE__ */ e("div", { className: a(r["tedi-calendar__picker-grid"]), children: /* @__PURE__ */ e(h, { gutter: 2, children: f.map((i) => /* @__PURE__ */ e(k, { width: 4, children: /* @__PURE__ */ e(
|
|
38
|
-
|
|
38
|
+
l,
|
|
39
39
|
{
|
|
40
40
|
onClick: () => _(i.value),
|
|
41
41
|
className: a(r["tedi-calendar__grid-button"], {
|
|
42
42
|
[r["tedi-calendar__grid-button--selected"]]: i.isSelected
|
|
43
43
|
}),
|
|
44
44
|
"aria-pressed": i.isSelected,
|
|
45
|
+
"data-testid": "tedi-calendar-grid-cell",
|
|
45
46
|
noStyle: !0,
|
|
46
47
|
children: i.label
|
|
47
48
|
}
|
package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("../../../../../../../external/classnames/index.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("../../../../../../../external/classnames/index.cjs.js"),j=require("react"),m=require("../../../../base/icon/icon.cjs.js"),c=require("../../../../buttons/button/button.cjs.js"),r=require("./calendar-header.module.scss.cjs.js"),B=require("../../../../../../../external/react-day-picker/dist/esm/types/deprecated.cjs.js"),T=require("../../../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),l=require("../../../../overlays/dropdown/dropdown.cjs.js"),L=require("../../../../../providers/label-provider/use-labels.cjs.js");function A({calendarMonth:S,monthYearSelectType:v="dropdown",onOpenMonthGrid:q,onOpenYearGrid:N,showNavigation:p=!0,localeCode:f,disabledMatchers:o}){const g=v==="grid",{getLabel:u}=L.useLabels(),{goToMonth:_,nextMonth:D,previousMonth:k}=B.useNavigation(),i=S.date,a=i.getFullYear(),h=i.getMonth(),C=Array.from({length:12},(n,t)=>new Date(a,t,1).toLocaleString(f,{month:"long"})),F=new Date().getFullYear(),s=Array.from({length:21},(n,t)=>F-10+t),w=j.useCallback((n,t)=>{if(!(o!=null&&o.length))return!1;const d=new Date(n);for(;d<=t;){if(!T.dateMatchModifiers(d,o))return!1;d.setDate(d.getDate()+1)}return!0},[o]),I=j.useMemo(()=>{if(!(o!=null&&o.length))return new Set;const n=new Set;for(let t=0;t<12;t++){const d=new Date(a,t,1),x=new Date(a,t+1,0);w(d,x)&&n.add(t)}return n},[o,a,w]),Y=j.useMemo(()=>{if(!(o!=null&&o.length))return new Set;const n=new Set;for(const t of s){const d=new Date(t,0,1),x=new Date(t,11,31);w(d,x)&&n.add(t)}return n},[o,s,w]);return e.jsxs("div",{className:y.default(r.default["tedi-calendar__header"],{[r.default["tedi-calendar__no-navigation"]]:!p}),children:[p&&e.jsx(c.Button,{type:"button",onClick:()=>k&&_(k),"aria-label":u("pickers.previousMonth"),icon:"arrow_back",visualType:"neutral",children:u("pickers.previousMonth")}),g?e.jsxs(e.Fragment,{children:[e.jsxs(c.Button,{noStyle:!0,className:r.default["tedi-calendar__month-year-selector"],onClick:q,"data-testid":"tedi-calendar-month-trigger",children:[i.toLocaleString(f,{month:"long"}),e.jsx(m.Icon,{name:"arrow_drop_down",color:"tertiary",className:r.default["tedi-calendar__month-year-caret"]})]}),e.jsxs(c.Button,{noStyle:!0,className:r.default["tedi-calendar__month-year-selector"],onClick:N,"data-testid":"tedi-calendar-year-trigger",children:[i.getFullYear(),e.jsx(m.Icon,{name:"arrow_drop_down",color:"tertiary",className:r.default["tedi-calendar__month-year-caret"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(l.Dropdown,{className:y.default(r.default["tedi-calendar__month-year-dropdown"],{[r.default["tedi-calendar__picker-grid-dropdown"]]:g}),width:"auto",defaultActiveIndex:h,children:[e.jsx(l.Dropdown.Trigger,{children:e.jsxs(c.Button,{noStyle:!0,className:r.default["tedi-calendar__month-year-selector"],children:[i.toLocaleString(f,{month:"long"}),e.jsx(m.Icon,{name:"arrow_drop_down",color:"tertiary",className:r.default["tedi-calendar__month-year-caret"],"data-testid":"tedi-icon-arrow_drop_down"})]})}),e.jsx(l.Dropdown.Content,{children:C.map((n,t)=>e.jsx(l.Dropdown.Item,{index:t,active:h===t,disabled:I.has(t),onClick:()=>_(new Date(a,t)),children:n},n))})]}),e.jsxs(l.Dropdown,{className:y.default(r.default["tedi-calendar__month-year-dropdown"],{[r.default["tedi-calendar__picker-grid-dropdown"]]:g}),width:"auto",defaultActiveIndex:s.indexOf(a)===-1?void 0:s.indexOf(a),children:[e.jsx(l.Dropdown.Trigger,{children:e.jsxs(c.Button,{noStyle:!0,className:r.default["tedi-calendar__month-year-selector"],children:[i.getFullYear(),e.jsx(m.Icon,{name:"arrow_drop_down",color:"tertiary",className:r.default["tedi-calendar__month-year-caret"],"data-testid":"tedi-icon-arrow_drop_down"})]})}),e.jsx(l.Dropdown.Content,{children:s.map((n,t)=>e.jsx(l.Dropdown.Item,{index:t,active:a===n,disabled:Y.has(n),onClick:()=>_(new Date(n,h)),children:n},n))})]})]}),p&&e.jsx(c.Button,{type:"button",onClick:()=>D&&_(D),visualType:"neutral","aria-label":u("pickers.nextMonth"),icon:"arrow_forward",children:u("pickers.nextMonth")})]})}exports.CalendarHeader=A;
|
package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js
CHANGED
|
@@ -1,159 +1,179 @@
|
|
|
1
|
-
import { jsxs as a, jsx as o, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { Icon as
|
|
1
|
+
import { jsxs as a, jsx as o, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import D from "../../../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { useCallback as O, useMemo as N } from "react";
|
|
4
|
+
import { Icon as w } from "../../../../base/icon/icon.es.js";
|
|
5
5
|
import { Button as s } from "../../../../buttons/button/button.es.js";
|
|
6
|
-
import
|
|
7
|
-
import { useNavigation as
|
|
8
|
-
import { dateMatchModifiers as
|
|
9
|
-
import { Dropdown as
|
|
10
|
-
import { useLabels as
|
|
6
|
+
import r from "./calendar-header.module.scss.es.js";
|
|
7
|
+
import { useNavigation as B } from "../../../../../../../external/react-day-picker/dist/esm/types/deprecated.es.js";
|
|
8
|
+
import { dateMatchModifiers as G } from "../../../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
|
|
9
|
+
import { Dropdown as c } from "../../../../overlays/dropdown/dropdown.es.js";
|
|
10
|
+
import { useLabels as H } from "../../../../../providers/label-provider/use-labels.es.js";
|
|
11
11
|
function W({
|
|
12
|
-
calendarMonth:
|
|
12
|
+
calendarMonth: C,
|
|
13
13
|
monthYearSelectType: Y = "dropdown",
|
|
14
14
|
onOpenMonthGrid: F,
|
|
15
15
|
onOpenYearGrid: T,
|
|
16
|
-
showNavigation:
|
|
16
|
+
showNavigation: g = !0,
|
|
17
17
|
localeCode: h,
|
|
18
18
|
disabledMatchers: n
|
|
19
19
|
}) {
|
|
20
|
-
const
|
|
20
|
+
const f = Y === "grid", { getLabel: _ } = H(), { goToMonth: u, nextMonth: S, previousMonth: v } = B(), d = C.date, i = d.getFullYear(), y = d.getMonth(), A = Array.from(
|
|
21
21
|
{ length: 12 },
|
|
22
|
-
(
|
|
23
|
-
),
|
|
24
|
-
(
|
|
22
|
+
(t, e) => new Date(i, e, 1).toLocaleString(h, { month: "long" })
|
|
23
|
+
), I = (/* @__PURE__ */ new Date()).getFullYear(), m = Array.from({ length: 21 }, (t, e) => I - 10 + e), p = O(
|
|
24
|
+
(t, e) => {
|
|
25
25
|
if (!(n != null && n.length)) return !1;
|
|
26
|
-
const
|
|
27
|
-
for (;
|
|
28
|
-
if (!
|
|
29
|
-
|
|
26
|
+
const l = new Date(t);
|
|
27
|
+
for (; l <= e; ) {
|
|
28
|
+
if (!G(l, n)) return !1;
|
|
29
|
+
l.setDate(l.getDate() + 1);
|
|
30
30
|
}
|
|
31
31
|
return !0;
|
|
32
32
|
},
|
|
33
33
|
[n]
|
|
34
|
-
),
|
|
34
|
+
), L = N(() => {
|
|
35
35
|
if (!(n != null && n.length)) return /* @__PURE__ */ new Set();
|
|
36
|
-
const
|
|
36
|
+
const t = /* @__PURE__ */ new Set();
|
|
37
37
|
for (let e = 0; e < 12; e++) {
|
|
38
|
-
const
|
|
39
|
-
p(
|
|
38
|
+
const l = new Date(i, e, 1), k = new Date(i, e + 1, 0);
|
|
39
|
+
p(l, k) && t.add(e);
|
|
40
40
|
}
|
|
41
|
-
return
|
|
42
|
-
}, [n,
|
|
41
|
+
return t;
|
|
42
|
+
}, [n, i, p]), j = N(() => {
|
|
43
43
|
if (!(n != null && n.length)) return /* @__PURE__ */ new Set();
|
|
44
|
-
const
|
|
45
|
-
for (const e of
|
|
46
|
-
const
|
|
47
|
-
p(
|
|
44
|
+
const t = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const e of m) {
|
|
46
|
+
const l = new Date(e, 0, 1), k = new Date(e, 11, 31);
|
|
47
|
+
p(l, k) && t.add(e);
|
|
48
48
|
}
|
|
49
|
-
return
|
|
50
|
-
}, [n,
|
|
49
|
+
return t;
|
|
50
|
+
}, [n, m, p]);
|
|
51
51
|
return /* @__PURE__ */ a(
|
|
52
52
|
"div",
|
|
53
53
|
{
|
|
54
|
-
className:
|
|
55
|
-
[
|
|
54
|
+
className: D(r["tedi-calendar__header"], {
|
|
55
|
+
[r["tedi-calendar__no-navigation"]]: !g
|
|
56
56
|
}),
|
|
57
57
|
children: [
|
|
58
|
-
|
|
58
|
+
g && /* @__PURE__ */ o(
|
|
59
59
|
s,
|
|
60
60
|
{
|
|
61
61
|
type: "button",
|
|
62
|
-
onClick: () =>
|
|
63
|
-
"aria-label":
|
|
62
|
+
onClick: () => v && u(v),
|
|
63
|
+
"aria-label": _("pickers.previousMonth"),
|
|
64
64
|
icon: "arrow_back",
|
|
65
65
|
visualType: "neutral",
|
|
66
|
-
children:
|
|
66
|
+
children: _("pickers.previousMonth")
|
|
67
67
|
}
|
|
68
68
|
),
|
|
69
|
-
|
|
70
|
-
/* @__PURE__ */ a(s, { noStyle: !0, className: t["tedi-calendar__month-year-selector"], onClick: F, children: [
|
|
71
|
-
c.toLocaleString(h, { month: "long" }),
|
|
72
|
-
/* @__PURE__ */ o(u, { name: "arrow_drop_down", color: "tertiary", className: t["tedi-calendar__month-year-caret"] })
|
|
73
|
-
] }),
|
|
74
|
-
/* @__PURE__ */ a(s, { noStyle: !0, className: t["tedi-calendar__month-year-selector"], onClick: T, children: [
|
|
75
|
-
c.getFullYear(),
|
|
76
|
-
/* @__PURE__ */ o(u, { name: "arrow_drop_down", color: "tertiary", className: t["tedi-calendar__month-year-caret"] })
|
|
77
|
-
] })
|
|
78
|
-
] }) : /* @__PURE__ */ a(v, { children: [
|
|
69
|
+
f ? /* @__PURE__ */ a(x, { children: [
|
|
79
70
|
/* @__PURE__ */ a(
|
|
80
|
-
|
|
71
|
+
s,
|
|
81
72
|
{
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
noStyle: !0,
|
|
74
|
+
className: r["tedi-calendar__month-year-selector"],
|
|
75
|
+
onClick: F,
|
|
76
|
+
"data-testid": "tedi-calendar-month-trigger",
|
|
77
|
+
children: [
|
|
78
|
+
d.toLocaleString(h, { month: "long" }),
|
|
79
|
+
/* @__PURE__ */ o(w, { name: "arrow_drop_down", color: "tertiary", className: r["tedi-calendar__month-year-caret"] })
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ a(
|
|
84
|
+
s,
|
|
85
|
+
{
|
|
86
|
+
noStyle: !0,
|
|
87
|
+
className: r["tedi-calendar__month-year-selector"],
|
|
88
|
+
onClick: T,
|
|
89
|
+
"data-testid": "tedi-calendar-year-trigger",
|
|
90
|
+
children: [
|
|
91
|
+
d.getFullYear(),
|
|
92
|
+
/* @__PURE__ */ o(w, { name: "arrow_drop_down", color: "tertiary", className: r["tedi-calendar__month-year-caret"] })
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] }) : /* @__PURE__ */ a(x, { children: [
|
|
97
|
+
/* @__PURE__ */ a(
|
|
98
|
+
c,
|
|
99
|
+
{
|
|
100
|
+
className: D(r["tedi-calendar__month-year-dropdown"], {
|
|
101
|
+
[r["tedi-calendar__picker-grid-dropdown"]]: f
|
|
84
102
|
}),
|
|
85
103
|
width: "auto",
|
|
104
|
+
defaultActiveIndex: y,
|
|
86
105
|
children: [
|
|
87
|
-
/* @__PURE__ */ o(
|
|
88
|
-
|
|
106
|
+
/* @__PURE__ */ o(c.Trigger, { children: /* @__PURE__ */ a(s, { noStyle: !0, className: r["tedi-calendar__month-year-selector"], children: [
|
|
107
|
+
d.toLocaleString(h, { month: "long" }),
|
|
89
108
|
/* @__PURE__ */ o(
|
|
90
|
-
|
|
109
|
+
w,
|
|
91
110
|
{
|
|
92
111
|
name: "arrow_drop_down",
|
|
93
112
|
color: "tertiary",
|
|
94
|
-
className:
|
|
113
|
+
className: r["tedi-calendar__month-year-caret"],
|
|
95
114
|
"data-testid": "tedi-icon-arrow_drop_down"
|
|
96
115
|
}
|
|
97
116
|
)
|
|
98
117
|
] }) }),
|
|
99
|
-
/* @__PURE__ */ o(
|
|
100
|
-
|
|
118
|
+
/* @__PURE__ */ o(c.Content, { children: A.map((t, e) => /* @__PURE__ */ o(
|
|
119
|
+
c.Item,
|
|
101
120
|
{
|
|
102
121
|
index: e,
|
|
103
|
-
active:
|
|
104
|
-
disabled:
|
|
105
|
-
onClick: () =>
|
|
106
|
-
children:
|
|
122
|
+
active: y === e,
|
|
123
|
+
disabled: L.has(e),
|
|
124
|
+
onClick: () => u(new Date(i, e)),
|
|
125
|
+
children: t
|
|
107
126
|
},
|
|
108
|
-
|
|
127
|
+
t
|
|
109
128
|
)) })
|
|
110
129
|
]
|
|
111
130
|
}
|
|
112
131
|
),
|
|
113
132
|
/* @__PURE__ */ a(
|
|
114
|
-
|
|
133
|
+
c,
|
|
115
134
|
{
|
|
116
|
-
className:
|
|
117
|
-
[
|
|
135
|
+
className: D(r["tedi-calendar__month-year-dropdown"], {
|
|
136
|
+
[r["tedi-calendar__picker-grid-dropdown"]]: f
|
|
118
137
|
}),
|
|
119
138
|
width: "auto",
|
|
139
|
+
defaultActiveIndex: m.indexOf(i) === -1 ? void 0 : m.indexOf(i),
|
|
120
140
|
children: [
|
|
121
|
-
/* @__PURE__ */ o(
|
|
122
|
-
|
|
141
|
+
/* @__PURE__ */ o(c.Trigger, { children: /* @__PURE__ */ a(s, { noStyle: !0, className: r["tedi-calendar__month-year-selector"], children: [
|
|
142
|
+
d.getFullYear(),
|
|
123
143
|
/* @__PURE__ */ o(
|
|
124
|
-
|
|
144
|
+
w,
|
|
125
145
|
{
|
|
126
146
|
name: "arrow_drop_down",
|
|
127
147
|
color: "tertiary",
|
|
128
|
-
className:
|
|
148
|
+
className: r["tedi-calendar__month-year-caret"],
|
|
129
149
|
"data-testid": "tedi-icon-arrow_drop_down"
|
|
130
150
|
}
|
|
131
151
|
)
|
|
132
152
|
] }) }),
|
|
133
|
-
/* @__PURE__ */ o(
|
|
134
|
-
|
|
153
|
+
/* @__PURE__ */ o(c.Content, { children: m.map((t, e) => /* @__PURE__ */ o(
|
|
154
|
+
c.Item,
|
|
135
155
|
{
|
|
136
156
|
index: e,
|
|
137
|
-
active:
|
|
138
|
-
disabled:
|
|
139
|
-
onClick: () =>
|
|
140
|
-
children:
|
|
157
|
+
active: i === t,
|
|
158
|
+
disabled: j.has(t),
|
|
159
|
+
onClick: () => u(new Date(t, y)),
|
|
160
|
+
children: t
|
|
141
161
|
},
|
|
142
|
-
|
|
162
|
+
t
|
|
143
163
|
)) })
|
|
144
164
|
]
|
|
145
165
|
}
|
|
146
166
|
)
|
|
147
167
|
] }),
|
|
148
|
-
|
|
168
|
+
g && /* @__PURE__ */ o(
|
|
149
169
|
s,
|
|
150
170
|
{
|
|
151
171
|
type: "button",
|
|
152
|
-
onClick: () =>
|
|
172
|
+
onClick: () => S && u(S),
|
|
153
173
|
visualType: "neutral",
|
|
154
|
-
"aria-label":
|
|
174
|
+
"aria-label": _("pickers.nextMonth"),
|
|
155
175
|
icon: "arrow_forward",
|
|
156
|
-
children:
|
|
176
|
+
children: _("pickers.nextMonth")
|
|
157
177
|
}
|
|
158
178
|
)
|
|
159
179
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=4,d=8,c=e=>{const a=[];return e.disabled&&(Array.isArray(e.disabled)?a.push(...e.disabled):a.push(e.disabled)),e.minDate&&a.push({before:e.minDate}),e.maxDate&&a.push({after:e.maxDate}),e.disablePast&&a.push({before:new Date}),e.disableFuture&&a.push({after:new Date}),e.shouldDisableMonth&&a.push(s=>{var r;return((r=e.shouldDisableMonth)==null?void 0:r.call(e,s))??!1}),e.shouldDisableYear&&a.push(s=>{var r;return((r=e.shouldDisableYear)==null?void 0:r.call(e,s))??!1}),a},D=e=>{const a=new Date(2099,11,31),s=e.formatToParts(a),r=[],o=[];for(const t of s)t.type==="day"||t.type==="month"||t.type==="year"?r.push(t.type):t.type==="literal"&&r.length>0&&o.length<2&&o.push(t.value);return{fieldOrder:r,separators:o}},f=({fieldOrder:e,separators:a})=>{const s=r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.map((r,o)=>{const t=r==="year"?"\\d{4}":"\\d{2}";return`${o>0?s(a[o-1]??""):""}(${t})`}).join("")};exports.CALENDAR_POPOVER_OFFSET=l;exports.CALENDAR_POPOVER_PADDING=d;exports.buildDateRegexSource=f;exports.buildDisabledMatchers=c;exports.getLocaleDateParts=D;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
2
|
+
/**
|
|
3
|
+
* Floating-ui offset (in px) between the trigger input and the popover.
|
|
4
|
+
* Shared by `DateField` and `DateTimeField` so the popovers sit at the
|
|
5
|
+
* same distance from their triggers.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CALENDAR_POPOVER_OFFSET = 4;
|
|
8
|
+
/**
|
|
9
|
+
* Floating-ui shift / size middleware padding (in px) — keeps the popover
|
|
10
|
+
* away from the viewport edges by this amount when the size middleware
|
|
11
|
+
* caps its `maxWidth`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CALENDAR_POPOVER_PADDING = 8;
|
|
14
|
+
export type SelectedValueLike = Date | Date[] | DateRange | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the month the calendar should start on for any selection
|
|
17
|
+
* shape. Used by both `DateField` (single / multiple / range Date(s)) and
|
|
18
|
+
* `DateTimeField` (single Date or `{from, to}` range). For arrays the
|
|
19
|
+
* earliest date wins; for ranges the `from` (or `to` if `from` is unset)
|
|
20
|
+
* wins. Falls back to the explicit `fallback` and finally `new Date()`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getInitialMonth: (val: SelectedValueLike, fallback?: Date) => Date;
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for the `buildDisabledMatchers` helper. All fields are
|
|
25
|
+
* forwarded as-is to react-day-picker. `shouldDisableMonth` /
|
|
26
|
+
* `shouldDisableYear` are predicates passed to `DayPicker.disabled` to
|
|
27
|
+
* disable a date when its month / year is "off limits".
|
|
28
|
+
*/
|
|
29
|
+
export interface DisabledMatcherInputs {
|
|
30
|
+
disabled?: Matcher | Matcher[];
|
|
31
|
+
minDate?: Date;
|
|
32
|
+
maxDate?: Date;
|
|
33
|
+
disablePast?: boolean;
|
|
34
|
+
disableFuture?: boolean;
|
|
35
|
+
shouldDisableMonth?: (date: Date) => boolean;
|
|
36
|
+
shouldDisableYear?: (date: Date) => boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Composes a flat `Matcher[]` array from the date-field-style constraint
|
|
40
|
+
* props. Returns an empty array when nothing is set, which lets the
|
|
41
|
+
* caller pass `matchers.length ? matchers : undefined` straight through.
|
|
42
|
+
*/
|
|
43
|
+
export declare const buildDisabledMatchers: (inputs: DisabledMatcherInputs) => Matcher[];
|
|
44
|
+
/**
|
|
45
|
+
* Field order + literal separators extracted from a locale's date format,
|
|
46
|
+
* derived via `Intl.DateTimeFormat.formatToParts`. Used by parsers in
|
|
47
|
+
* `DateField` (date-only) and `DateTimeField` (date + " HH:mm") to build
|
|
48
|
+
* a regex that round-trips the displayed value in any locale.
|
|
49
|
+
*/
|
|
50
|
+
export interface LocaleDateParts {
|
|
51
|
+
fieldOrder: ('day' | 'month' | 'year')[];
|
|
52
|
+
separators: string[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Extract the date-portion field order and literal separators from a
|
|
56
|
+
* `dateFormatter`. The reference date `Dec 31, 2099` is used because all
|
|
57
|
+
* three components are unambiguously two-digit (day, month) / four-digit
|
|
58
|
+
* (year) values, so each `formatToParts` entry is unambiguous.
|
|
59
|
+
*/
|
|
60
|
+
export declare const getLocaleDateParts: (dateFormatter: Intl.DateTimeFormat) => LocaleDateParts;
|
|
61
|
+
/**
|
|
62
|
+
* Build the date-portion of a parsing regex from the locale's field
|
|
63
|
+
* order and separators. Caller appends time / range separators as needed
|
|
64
|
+
* — DateField uses `^${datePart}$`, DateTimeField uses `^${datePart}\s+(\d{2}):(\d{2})$`.
|
|
65
|
+
*/
|
|
66
|
+
export declare const buildDateRegexSource: ({ fieldOrder, separators }: LocaleDateParts) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const d = 4, f = 8, h = (e) => {
|
|
2
|
+
const a = [];
|
|
3
|
+
return e.disabled && (Array.isArray(e.disabled) ? a.push(...e.disabled) : a.push(e.disabled)), e.minDate && a.push({ before: e.minDate }), e.maxDate && a.push({ after: e.maxDate }), e.disablePast && a.push({ before: /* @__PURE__ */ new Date() }), e.disableFuture && a.push({ after: /* @__PURE__ */ new Date() }), e.shouldDisableMonth && a.push((o) => {
|
|
4
|
+
var r;
|
|
5
|
+
return ((r = e.shouldDisableMonth) == null ? void 0 : r.call(e, o)) ?? !1;
|
|
6
|
+
}), e.shouldDisableYear && a.push((o) => {
|
|
7
|
+
var r;
|
|
8
|
+
return ((r = e.shouldDisableYear) == null ? void 0 : r.call(e, o)) ?? !1;
|
|
9
|
+
}), a;
|
|
10
|
+
}, c = (e) => {
|
|
11
|
+
const a = new Date(2099, 11, 31), o = e.formatToParts(a), r = [], t = [];
|
|
12
|
+
for (const s of o)
|
|
13
|
+
s.type === "day" || s.type === "month" || s.type === "year" ? r.push(s.type) : s.type === "literal" && r.length > 0 && t.length < 2 && t.push(s.value);
|
|
14
|
+
return { fieldOrder: r, separators: t };
|
|
15
|
+
}, D = ({ fieldOrder: e, separators: a }) => {
|
|
16
|
+
const o = (r) => r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17
|
+
return e.map((r, t) => {
|
|
18
|
+
const s = r === "year" ? "\\d{4}" : "\\d{2}";
|
|
19
|
+
return `${t > 0 ? o(a[t - 1] ?? "") : ""}(${s})`;
|
|
20
|
+
}).join("");
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
d as CALENDAR_POPOVER_OFFSET,
|
|
24
|
+
f as CALENDAR_POPOVER_PADDING,
|
|
25
|
+
D as buildDateRegexSource,
|
|
26
|
+
h as buildDisabledMatchers,
|
|
27
|
+
c as getLocaleDateParts
|
|
28
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),D=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),ee=require("../../../../../external/classnames/index.cjs.js"),a=require("react"),Je=require("../../content/calendar/calendar.cjs.js"),Ke=require("../multi-value-field/multi-value-field.cjs.js"),Qe=require("../textfield/textfield.cjs.js"),x=require("./date-field.module.scss.cjs.js"),O=require("./date-field-helpers.cjs.js"),Xe=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),Ze=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),B=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),et=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),tt=require("../../../providers/label-provider/use-labels.cjs.js"),ce=require("../../../helpers/hooks/use-breakpoint.cjs.js"),rt=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),fe=a.forwardRef((v,C)=>{const{getCurrentBreakpointProps:me}=et.useBreakpointProps(v.defaultServerBreakpoint),{getLabel:pe}=tt.useLabels(),{useNativePicker:he=!1,enableCalendar:c=!0,calendarTrigger:j="button",numberOfMonths:I}=me(v),{id:te,mode:p="single",label:re,selected:N,onSelect:i,disabled:P,disabledMatchers:w,placeholder:ge,className:ye,formatDate:d,required:T,showOutsideDays:be=!0,parseDate:De,monthYearSelectType:xe,selectionLevel:R="days",locale:_e=Xe.et,localeCode:S="et-EE",initialMonth:L,closeOnSelect:Me,footer:Ae,defaultValue:q,minDate:$,maxDate:U,disablePast:ae,disableFuture:ie,shouldDisableMonth:W,shouldDisableYear:H,readOnly:Y,availableDays:Fe,inputProps:n,disabledDateErrorMessage:ke=pe("dateField.disabledDateError"),useNativePicker:at,enableCalendar:it,calendarTrigger:st,numberOfMonths:nt,defaultServerBreakpoint:ot,sm:lt,md:ut,lg:dt,xl:ct,xxl:ft,...Ce}=v,f=he&&p==="single",Ne=ce.useBreakpoint(v.defaultServerBreakpoint),Pe=ce.isBreakpointBelow(Ne,"md")&&typeof I=="number"&&I>1?1:I,[we,g]=a.useState(N??q),[m,_]=a.useState(!1),[Ee,se]=a.useState(R),[Oe,M]=a.useState(""),[ne,y]=a.useState(!1),o=N!==void 0,l=o?N:we,oe=a.useRef(null),ve=a.useCallback(e=>{oe.current=e,typeof C=="function"?C(e):C&&(C.current=e)},[C]),Re=e=>{if(!e)return"";const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),u=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${u}`},qe=f&&l instanceof Date?Re(l):"",G=a.useCallback((e,t)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((r,u)=>r.getTime()-u.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:t??new Date,[]),[Ve,z]=a.useState(()=>G(l,L));a.useEffect(()=>{m||z(G(l,L))},[l,L,m,G]),a.useEffect(()=>{m&&se(R)},[m,R]),a.useEffect(()=>{o&&g(N)},[N,o]);const b=a.useMemo(()=>new Intl.DateTimeFormat(S,{day:"2-digit",month:"2-digit",year:"numeric"}),[S]),A=a.useCallback(e=>{if(!e)return"";if(e instanceof Date)return b.format(e);if(Array.isArray(e))return e.map(t=>b.format(t)).join(", ");if(e.from){const t=b.format(e.from);return e.to?`${t} – ${b.format(e.to)}`:t}return""},[b]),J=Me??p==="single",le=p==="multiple"&&Array.isArray(l)?l.map((e,t)=>({id:t,label:d?d(e):A(e),date:e})):[],K=a.useMemo(()=>{const e=[];return P&&(Array.isArray(P)?e.push(...P):e.push(P)),w&&(Array.isArray(w)?e.push(...w):e.push(w)),$&&e.push({before:$}),U&&e.push({after:U}),ae&&e.push({before:new Date}),ie&&e.push({after:new Date}),W&&e.push(t=>W(t)),H&&e.push(t=>H(t)),e},[P,w,$,U,ae,ie,W,H]),F=a.useCallback(e=>rt.dateMatchModifiers(e,K),[K]),Be=(e,t,r,u)=>{if(o||g(e),i==null||i(e,t,r,u),e){const s=d?d(e):A(e);M(s)}else M("");J&&_(!1)},je=e=>{if(F(e))return;o||g(e),i==null||i(e,e,{},{});const t=d?d(e):A(e);M(t),J&&_(!1)},Ie=a.useMemo(()=>{const e=O.getLocaleDateParts(b),t=new RegExp(`^${O.buildDateRegexSource(e)}$`),{fieldOrder:r}=e;return u=>{const s=u.match(t);if(!s)return;const Q={};r.forEach((Ge,ze)=>{Q[Ge]=Number(s[ze+1])});const{day:k,month:X,year:Z}=Q;if(k===void 0||X===void 0||Z===void 0)return;const E=new Date(Z,X-1,k);if(!(isNaN(E.getTime())||E.getFullYear()!==Z||E.getMonth()!==X-1||E.getDate()!==k))return E}},[b]),Te=e=>{if(M(e),e.trim()===""){y(!1);return}const r=(De??(p==="single"?Ie:()=>{}))(e);if(!(p==="single"&&r instanceof Date||p==="multiple"&&Array.isArray(r)||p==="range"&&!!r&&!Array.isArray(r)&&"from"in r)){y(!1);return}const s=r&&!Array.isArray(r)&&"from"in r?r:null;if(r instanceof Date&&F(r)||Array.isArray(r)&&r.some(k=>k instanceof Date&&F(k))||!!s&&(s.from&&F(s.from)||s.to&&F(s.to))){y(!0);return}y(!1),o||g(r),i==null||i(r,r,{},{}),r instanceof Date&&z(r),J&&_(!1)};a.useEffect(()=>{if(o){const e=d?d(l):A(l);M(e)}},[l,o,d,A]),a.useEffect(()=>{if(!o&&q){const e=d?d(q):A(q);M(e)}},[]);const Se=D.useFloating({open:m,onOpenChange:_,placement:j==="input"?"bottom-start":"bottom-end",middleware:[B.offset(O.CALENDAR_POPOVER_OFFSET),B.flip(),B.shift({padding:O.CALENDAR_POPOVER_PADDING}),B.size({padding:O.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){const r=t.floating;r.style.width="max-content",r.style.maxWidth="",r.getBoundingClientRect().width>e?(r.style.width="min-content",r.style.maxWidth=`${e}px`):(r.style.width="",r.style.maxWidth="")}})],whileElementsMounted:Ze.autoUpdate}),{refs:ue,context:V,x:Le,y:$e,strategy:Ue}=Se,We=D.useClick(V),de=D.useInteractions([...c&&!f&&j==="input"?[We]:[],D.useDismiss(V,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),D.useRole(V,{role:"dialog"})]),He=()=>{var t;const e=(t=oe.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function")try{e.showPicker();return}catch{}e.focus()}},Ye=e=>{if(!e){y(!1),o||g(void 0),i==null||i(void 0,void 0,{},{});return}const[t,r,u]=e.split("-").map(Number);if(!t||!r||!u)return;const s=new Date(t,r-1,u);if(!Number.isNaN(s.getTime())){if(F(s)){y(!0);return}y(!1),o||g(s),i==null||i(s,s,{},{})}};return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:ee.default(x.default["tedi-date-field__container"],ye),...de.getReferenceProps(),ref:ue.setReference,children:p==="multiple"?h.jsx(Ke.MultiValueField,{...n,id:te,label:re,values:le.map(e=>e.label),icon:"calendar_today",onIconClick:()=>c&&_(e=>!e),iconButtonProps:c?{"aria-expanded":m,"aria-haspopup":"dialog"}:void 0,isClearable:!0,required:T,onChange:e=>{if(!Array.isArray(l))return;const t=le.filter(r=>e.includes(r.label)).map(r=>r.date);o||g(t),i==null||i(t,{},{},{})},className:ee.default(x.default["tedi-date-field__textfield"],{[x.default["tedi-date-field__icon--disabled"]]:!c||Y})}):h.jsx(Qe.TextField,{...n,ref:ve,id:te,label:re,readOnly:Y,value:f?qe:Oe,placeholder:ge,icon:"calendar_today","aria-expanded":c&&!f?m:void 0,isClearable:!0,onIconClick:()=>{c&&(f?He():_(e=>!e))},iconButtonProps:c&&!f?{"aria-expanded":m,"aria-haspopup":"dialog"}:void 0,onChange:e=>f?Ye(e):Te(e),required:T,invalid:ne||(n==null?void 0:n.invalid),helper:(()=>{const e=n==null?void 0:n.helper,t=ne?{text:ke,type:"error"}:null;return t?e?Array.isArray(e)?[...e,t]:[e,t]:t:e})(),className:ee.default(x.default["tedi-date-field__textfield"],{[x.default["tedi-date-field__textfield--disabled"]]:n==null?void 0:n.disabled,[x.default["tedi-date-field__icon--disabled"]]:!c||Y}),input:{...n==null?void 0:n.input,...f&&{type:"date"},...c&&!f&&j==="input"?{"aria-haspopup":"dialog","aria-expanded":m}:{}}})}),c&&!f&&h.jsx(D.FloatingPortal,{children:m&&h.jsx(D.FloatingFocusManager,{context:V,modal:!1,initialFocus:-1,children:h.jsx("div",{ref:ue.setFloating,...de.getFloatingProps({style:{position:Ue,top:$e??0,left:Le??0}}),children:h.jsx(Je.Calendar,{...Ce,numberOfMonths:Pe,view:Ee,selectionLevel:R,currentMonth:Ve,setCurrentMonth:z,setView:se,mode:p,value:l,locale:_e,localeCode:S,showOutsideDays:be,disabledMatchers:K,required:T,availableDays:Fe,footer:Ae,monthYearSelectType:xe,handleSelect:Be,applyValue:je,className:x.default["tedi-date-field__calendar"]})})})})]})});fe.displayName="DateField";exports.DateField=fe;
|