@klinking/colander 0.0.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/dist/formats/date.cjs +49 -0
- package/dist/formats/date.d.cts +45 -0
- package/dist/formats/date.d.mts +45 -0
- package/dist/formats/date.mjs +2 -0
- package/dist/formats/object.cjs +49 -0
- package/dist/formats/object.d.cts +45 -0
- package/dist/formats/object.d.mts +45 -0
- package/dist/formats/object.mjs +2 -0
- package/dist/formats/plain-date-time.cjs +49 -0
- package/dist/formats/plain-date-time.d.cts +45 -0
- package/dist/formats/plain-date-time.d.mts +45 -0
- package/dist/formats/plain-date-time.mjs +2 -0
- package/dist/formats/plain-date.cjs +49 -0
- package/dist/formats/plain-date.d.cts +45 -0
- package/dist/formats/plain-date.d.mts +45 -0
- package/dist/formats/plain-date.mjs +2 -0
- package/dist/formats/plain-month-day.cjs +49 -0
- package/dist/formats/plain-month-day.d.cts +45 -0
- package/dist/formats/plain-month-day.d.mts +45 -0
- package/dist/formats/plain-month-day.mjs +2 -0
- package/dist/formats/plain-year-month.cjs +49 -0
- package/dist/formats/plain-year-month.d.cts +45 -0
- package/dist/formats/plain-year-month.d.mts +45 -0
- package/dist/formats/plain-year-month.mjs +2 -0
- package/dist/formats/zoned-date-time.cjs +49 -0
- package/dist/formats/zoned-date-time.d.cts +45 -0
- package/dist/formats/zoned-date-time.d.mts +45 -0
- package/dist/formats/zoned-date-time.mjs +2 -0
- package/dist/index.cjs +49 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/temporal-polyfill-DTx0VIX5.mjs +4556 -0
- package/dist/temporal-polyfill-DU8VfleL.cjs +4860 -0
- package/dist/weeks-view-context-BN6qR-83.d.mts +2022 -0
- package/dist/weeks-view-context-aHGgYkpt.d.cts +2022 -0
- package/package.json +89 -0
- package/src/calendar-context.ts +22 -0
- package/src/calendar-provider.test.tsx +123 -0
- package/src/calendar-provider.tsx +538 -0
- package/src/calendar-types.ts +212 -0
- package/src/compute-weeks-in-window.test.ts +83 -0
- package/src/compute-weeks-in-window.ts +40 -0
- package/src/context.ts +34 -0
- package/src/day-cell.tsx +635 -0
- package/src/drag-handle.tsx +137 -0
- package/src/formats/date.ts +110 -0
- package/src/formats/formats.test.ts +18 -0
- package/src/formats/object.ts +110 -0
- package/src/formats/plain-date-time.ts +110 -0
- package/src/formats/plain-date.ts +110 -0
- package/src/formats/plain-month-day.ts +110 -0
- package/src/formats/plain-year-month.ts +110 -0
- package/src/formats/zoned-date-time.ts +110 -0
- package/src/grid-header.tsx +141 -0
- package/src/grid.event-perf.test.tsx +282 -0
- package/src/grid.perf.test.tsx +467 -0
- package/src/grid.tsx +608 -0
- package/src/index.ts +116 -0
- package/src/keyboard.test.ts +498 -0
- package/src/keyboard.ts +142 -0
- package/src/month-separator.test.tsx +183 -0
- package/src/month-separator.tsx +238 -0
- package/src/month-view-context.ts +26 -0
- package/src/month-view-types.ts +89 -0
- package/src/month-view.test.tsx +1433 -0
- package/src/month-view.tsx +373 -0
- package/src/navigation.tsx +350 -0
- package/src/overflow.test.ts +124 -0
- package/src/overflow.ts +233 -0
- package/src/range-preview.tsx +90 -0
- package/src/resolve-first-week.test.ts +132 -0
- package/src/resolve-first-week.ts +145 -0
- package/src/root-selection.ts +621 -0
- package/src/selected-range.tsx +163 -0
- package/src/temporal-polyfill.test.ts +317 -0
- package/src/temporal-polyfill.ts +566 -0
- package/src/test-temporal.ts +17 -0
- package/src/types.ts +814 -0
- package/src/utils.bench.ts +183 -0
- package/src/utils.test.ts +983 -0
- package/src/utils.ts +493 -0
- package/src/view-context.ts +28 -0
- package/src/week-number.tsx +118 -0
- package/src/weeks-grid.tsx +265 -0
- package/src/weeks-keyboard.test.ts +222 -0
- package/src/weeks-keyboard.ts +156 -0
- package/src/weeks-navigation.tsx +209 -0
- package/src/weeks-view-context.ts +26 -0
- package/src/weeks-view-state.ts +421 -0
- package/src/weeks-view-types.ts +102 -0
- package/src/weeks-view.test.tsx +479 -0
- package/src/weeks-view.tsx +127 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @generated by scripts/generate-formats.ts — do not edit manually
|
|
2
|
+
type F = "PlainMonthDay";
|
|
3
|
+
|
|
4
|
+
export { CalendarProvider } from "../calendar-provider";
|
|
5
|
+
|
|
6
|
+
export { MonthView, MonthViewRoot } from "../month-view";
|
|
7
|
+
|
|
8
|
+
export { Grid, GridBody, WeekTemplate, DayCellTemplate, DayButton } from "../grid";
|
|
9
|
+
|
|
10
|
+
export { GridHeader, GridHeaderCell } from "../grid-header";
|
|
11
|
+
|
|
12
|
+
export { DateString, TimeString, MonthYearString, PrevMonthButton, NextMonthButton } from "../navigation";
|
|
13
|
+
|
|
14
|
+
export { RangeSelected } from "../selected-range";
|
|
15
|
+
|
|
16
|
+
export { RangePreview } from "../range-preview";
|
|
17
|
+
|
|
18
|
+
export { RangeStartDragHandle, RangeEndDragHandle } from "../drag-handle";
|
|
19
|
+
|
|
20
|
+
export { WeekNumberCell, WeekNumberHeader } from "../week-number";
|
|
21
|
+
|
|
22
|
+
export { WeeksView, WeeksViewRoot } from "../weeks-view";
|
|
23
|
+
|
|
24
|
+
export { PrevWeeksButton, NextWeeksButton, WeekCount } from "../weeks-navigation";
|
|
25
|
+
|
|
26
|
+
export { MonthSeparator, MonthSeparatorRow, MonthSeparatorCell, MonthSeparatorMonth, MonthSeparatorYear, MonthSeparatorWeekCount } from "../month-separator";
|
|
27
|
+
|
|
28
|
+
export { computePreviewRange } from "../root-selection";
|
|
29
|
+
|
|
30
|
+
export { computeWeeksInWindow } from "../compute-weeks-in-window";
|
|
31
|
+
|
|
32
|
+
export { resolveFirstWeek, resolveFirstWeekSpec } from "../resolve-first-week";
|
|
33
|
+
|
|
34
|
+
export { Temporal } from "../temporal-polyfill";
|
|
35
|
+
|
|
36
|
+
export { useCalendarStable, useCalendarState } from "../calendar-context";
|
|
37
|
+
|
|
38
|
+
export { useMonthViewStable, useMonthViewState } from "../month-view-context";
|
|
39
|
+
|
|
40
|
+
export { useViewContext } from "../view-context";
|
|
41
|
+
|
|
42
|
+
export { DayCellDataContext, WeekDataContext, GridContext } from "../context";
|
|
43
|
+
|
|
44
|
+
import type { RootState as _RootState, GridProps as _GridProps, GridState as _GridState, GridHeaderProps as _GridHeaderProps, GridHeaderState as _GridHeaderState, GridHeaderCellProps as _GridHeaderCellProps, GridHeaderCellState as _GridHeaderCellState, GridBodyProps as _GridBodyProps, GridBodyState as _GridBodyState, WeekTemplateProps as _WeekTemplateProps, WeekTemplateState as _WeekTemplateState, DayCellTemplateProps as _DayCellTemplateProps, DayCellTemplateState as _DayCellTemplateState, DayButtonProps as _DayButtonProps, DayButtonState as _DayButtonState, RangeSelectedProps as _RangeSelectedProps, RangeSelectedState as _RangeSelectedState, RangePreviewProps as _RangePreviewProps, RangePreviewState as _RangePreviewState, DragHandleState as _DragHandleState, RangeStartDragHandleProps as _RangeStartDragHandleProps, RangeEndDragHandleProps as _RangeEndDragHandleProps, DateStringProps as _DateStringProps, DateStringState as _DateStringState, TimeStringProps as _TimeStringProps, TimeStringState as _TimeStringState, MonthYearStringProps as _MonthYearStringProps, MonthYearStringState as _MonthYearStringState, PrevMonthButtonProps as _PrevMonthButtonProps, NextMonthButtonProps as _NextMonthButtonProps, NavButtonState as _NavButtonState, DateRange as _DateRange, ValueForFormat as _ValueForFormat, RawValueForFormat as _RawValueForFormat, WeekNumberCellProps as _WeekNumberCellProps, WeekNumberCellState as _WeekNumberCellState, WeekNumberHeaderProps as _WeekNumberHeaderProps, WeekNumberHeaderState as _WeekNumberHeaderState } from "../types";
|
|
45
|
+
export type RootState = _RootState<F>;
|
|
46
|
+
export type GridProps = _GridProps<F>;
|
|
47
|
+
export type GridState = _GridState<F>;
|
|
48
|
+
export type GridHeaderProps = _GridHeaderProps<F>;
|
|
49
|
+
export type GridHeaderState = _GridHeaderState<F>;
|
|
50
|
+
export type GridHeaderCellProps = _GridHeaderCellProps<F>;
|
|
51
|
+
export type GridHeaderCellState = _GridHeaderCellState<F>;
|
|
52
|
+
export type GridBodyProps = _GridBodyProps<F>;
|
|
53
|
+
export type GridBodyState = _GridBodyState<F>;
|
|
54
|
+
export type WeekTemplateProps = _WeekTemplateProps<F>;
|
|
55
|
+
export type WeekTemplateState = _WeekTemplateState<F>;
|
|
56
|
+
export type DayCellTemplateProps = _DayCellTemplateProps<F>;
|
|
57
|
+
export type DayCellTemplateState = _DayCellTemplateState<F>;
|
|
58
|
+
export type DayButtonProps = _DayButtonProps<F>;
|
|
59
|
+
export type DayButtonState = _DayButtonState<F>;
|
|
60
|
+
export type RangeSelectedProps = _RangeSelectedProps<F>;
|
|
61
|
+
export type RangeSelectedState = _RangeSelectedState<F>;
|
|
62
|
+
export type RangePreviewProps = _RangePreviewProps<F>;
|
|
63
|
+
export type RangePreviewState = _RangePreviewState<F>;
|
|
64
|
+
export type DragHandleState = _DragHandleState<F>;
|
|
65
|
+
export type RangeStartDragHandleProps = _RangeStartDragHandleProps<F>;
|
|
66
|
+
export type RangeEndDragHandleProps = _RangeEndDragHandleProps<F>;
|
|
67
|
+
export type DateStringProps = _DateStringProps<F>;
|
|
68
|
+
export type DateStringState = _DateStringState<F>;
|
|
69
|
+
export type TimeStringProps = _TimeStringProps<F>;
|
|
70
|
+
export type TimeStringState = _TimeStringState<F>;
|
|
71
|
+
export type MonthYearStringProps = _MonthYearStringProps<F>;
|
|
72
|
+
export type MonthYearStringState = _MonthYearStringState<F>;
|
|
73
|
+
export type PrevMonthButtonProps = _PrevMonthButtonProps<F>;
|
|
74
|
+
export type NextMonthButtonProps = _NextMonthButtonProps<F>;
|
|
75
|
+
export type NavButtonState = _NavButtonState<F>;
|
|
76
|
+
export type DateRange = _DateRange<F>;
|
|
77
|
+
export type ValueForFormat = _ValueForFormat<F>;
|
|
78
|
+
export type RawValueForFormat = _RawValueForFormat<F>;
|
|
79
|
+
export type WeekNumberCellProps = _WeekNumberCellProps<F>;
|
|
80
|
+
export type WeekNumberCellState = _WeekNumberCellState<F>;
|
|
81
|
+
export type WeekNumberHeaderProps = _WeekNumberHeaderProps<F>;
|
|
82
|
+
export type WeekNumberHeaderState = _WeekNumberHeaderState<F>;
|
|
83
|
+
export type { DragHandleOwnProps, ValueFormat, DateValueObject, PlainDateObject, TemporalNamespace, WeekStartDay, RangeMode, OutsideDays, ValueChangeMeta, MonthData } from "../types";
|
|
84
|
+
|
|
85
|
+
import type { CalendarProviderProps as _CalendarProviderProps } from "../calendar-types";
|
|
86
|
+
export type CalendarProviderProps = _CalendarProviderProps<F>;
|
|
87
|
+
|
|
88
|
+
export type { CalendarStableContextValue, CalendarStateContextValue } from "../calendar-types";
|
|
89
|
+
|
|
90
|
+
export type { MonthViewRootProps, MonthViewStableContextValue, MonthViewStateContextValue } from "../month-view-types";
|
|
91
|
+
|
|
92
|
+
export type { MonthViewProps } from "../month-view";
|
|
93
|
+
|
|
94
|
+
export type { ViewContextValue } from "../view-context";
|
|
95
|
+
|
|
96
|
+
export type { WeeksViewRootProps, WeeksViewStableContextValue, WeeksViewStateContextValue, WindowInfo, VisibleMonth } from "../weeks-view-types";
|
|
97
|
+
|
|
98
|
+
export type { WeeksViewProps, WeeksViewRootHandle } from "../weeks-view";
|
|
99
|
+
|
|
100
|
+
export type { WeeksNavButtonState, WeeksNavButtonOwnProps, PrevWeeksButtonProps, NextWeeksButtonProps, WeekCountState, WeekCountProps } from "../weeks-navigation";
|
|
101
|
+
|
|
102
|
+
export { useWeeksViewStable, useWeeksViewState } from "../weeks-view-context";
|
|
103
|
+
|
|
104
|
+
export type { WeekDescriptor } from "../compute-weeks-in-window";
|
|
105
|
+
|
|
106
|
+
export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
|
|
107
|
+
|
|
108
|
+
export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
|
|
109
|
+
|
|
110
|
+
export type { MonthSeparatorState } from "../month-separator";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @generated by scripts/generate-formats.ts — do not edit manually
|
|
2
|
+
type F = "PlainYearMonth";
|
|
3
|
+
|
|
4
|
+
export { CalendarProvider } from "../calendar-provider";
|
|
5
|
+
|
|
6
|
+
export { MonthView, MonthViewRoot } from "../month-view";
|
|
7
|
+
|
|
8
|
+
export { Grid, GridBody, WeekTemplate, DayCellTemplate, DayButton } from "../grid";
|
|
9
|
+
|
|
10
|
+
export { GridHeader, GridHeaderCell } from "../grid-header";
|
|
11
|
+
|
|
12
|
+
export { DateString, TimeString, MonthYearString, PrevMonthButton, NextMonthButton } from "../navigation";
|
|
13
|
+
|
|
14
|
+
export { RangeSelected } from "../selected-range";
|
|
15
|
+
|
|
16
|
+
export { RangePreview } from "../range-preview";
|
|
17
|
+
|
|
18
|
+
export { RangeStartDragHandle, RangeEndDragHandle } from "../drag-handle";
|
|
19
|
+
|
|
20
|
+
export { WeekNumberCell, WeekNumberHeader } from "../week-number";
|
|
21
|
+
|
|
22
|
+
export { WeeksView, WeeksViewRoot } from "../weeks-view";
|
|
23
|
+
|
|
24
|
+
export { PrevWeeksButton, NextWeeksButton, WeekCount } from "../weeks-navigation";
|
|
25
|
+
|
|
26
|
+
export { MonthSeparator, MonthSeparatorRow, MonthSeparatorCell, MonthSeparatorMonth, MonthSeparatorYear, MonthSeparatorWeekCount } from "../month-separator";
|
|
27
|
+
|
|
28
|
+
export { computePreviewRange } from "../root-selection";
|
|
29
|
+
|
|
30
|
+
export { computeWeeksInWindow } from "../compute-weeks-in-window";
|
|
31
|
+
|
|
32
|
+
export { resolveFirstWeek, resolveFirstWeekSpec } from "../resolve-first-week";
|
|
33
|
+
|
|
34
|
+
export { Temporal } from "../temporal-polyfill";
|
|
35
|
+
|
|
36
|
+
export { useCalendarStable, useCalendarState } from "../calendar-context";
|
|
37
|
+
|
|
38
|
+
export { useMonthViewStable, useMonthViewState } from "../month-view-context";
|
|
39
|
+
|
|
40
|
+
export { useViewContext } from "../view-context";
|
|
41
|
+
|
|
42
|
+
export { DayCellDataContext, WeekDataContext, GridContext } from "../context";
|
|
43
|
+
|
|
44
|
+
import type { RootState as _RootState, GridProps as _GridProps, GridState as _GridState, GridHeaderProps as _GridHeaderProps, GridHeaderState as _GridHeaderState, GridHeaderCellProps as _GridHeaderCellProps, GridHeaderCellState as _GridHeaderCellState, GridBodyProps as _GridBodyProps, GridBodyState as _GridBodyState, WeekTemplateProps as _WeekTemplateProps, WeekTemplateState as _WeekTemplateState, DayCellTemplateProps as _DayCellTemplateProps, DayCellTemplateState as _DayCellTemplateState, DayButtonProps as _DayButtonProps, DayButtonState as _DayButtonState, RangeSelectedProps as _RangeSelectedProps, RangeSelectedState as _RangeSelectedState, RangePreviewProps as _RangePreviewProps, RangePreviewState as _RangePreviewState, DragHandleState as _DragHandleState, RangeStartDragHandleProps as _RangeStartDragHandleProps, RangeEndDragHandleProps as _RangeEndDragHandleProps, DateStringProps as _DateStringProps, DateStringState as _DateStringState, TimeStringProps as _TimeStringProps, TimeStringState as _TimeStringState, MonthYearStringProps as _MonthYearStringProps, MonthYearStringState as _MonthYearStringState, PrevMonthButtonProps as _PrevMonthButtonProps, NextMonthButtonProps as _NextMonthButtonProps, NavButtonState as _NavButtonState, DateRange as _DateRange, ValueForFormat as _ValueForFormat, RawValueForFormat as _RawValueForFormat, WeekNumberCellProps as _WeekNumberCellProps, WeekNumberCellState as _WeekNumberCellState, WeekNumberHeaderProps as _WeekNumberHeaderProps, WeekNumberHeaderState as _WeekNumberHeaderState } from "../types";
|
|
45
|
+
export type RootState = _RootState<F>;
|
|
46
|
+
export type GridProps = _GridProps<F>;
|
|
47
|
+
export type GridState = _GridState<F>;
|
|
48
|
+
export type GridHeaderProps = _GridHeaderProps<F>;
|
|
49
|
+
export type GridHeaderState = _GridHeaderState<F>;
|
|
50
|
+
export type GridHeaderCellProps = _GridHeaderCellProps<F>;
|
|
51
|
+
export type GridHeaderCellState = _GridHeaderCellState<F>;
|
|
52
|
+
export type GridBodyProps = _GridBodyProps<F>;
|
|
53
|
+
export type GridBodyState = _GridBodyState<F>;
|
|
54
|
+
export type WeekTemplateProps = _WeekTemplateProps<F>;
|
|
55
|
+
export type WeekTemplateState = _WeekTemplateState<F>;
|
|
56
|
+
export type DayCellTemplateProps = _DayCellTemplateProps<F>;
|
|
57
|
+
export type DayCellTemplateState = _DayCellTemplateState<F>;
|
|
58
|
+
export type DayButtonProps = _DayButtonProps<F>;
|
|
59
|
+
export type DayButtonState = _DayButtonState<F>;
|
|
60
|
+
export type RangeSelectedProps = _RangeSelectedProps<F>;
|
|
61
|
+
export type RangeSelectedState = _RangeSelectedState<F>;
|
|
62
|
+
export type RangePreviewProps = _RangePreviewProps<F>;
|
|
63
|
+
export type RangePreviewState = _RangePreviewState<F>;
|
|
64
|
+
export type DragHandleState = _DragHandleState<F>;
|
|
65
|
+
export type RangeStartDragHandleProps = _RangeStartDragHandleProps<F>;
|
|
66
|
+
export type RangeEndDragHandleProps = _RangeEndDragHandleProps<F>;
|
|
67
|
+
export type DateStringProps = _DateStringProps<F>;
|
|
68
|
+
export type DateStringState = _DateStringState<F>;
|
|
69
|
+
export type TimeStringProps = _TimeStringProps<F>;
|
|
70
|
+
export type TimeStringState = _TimeStringState<F>;
|
|
71
|
+
export type MonthYearStringProps = _MonthYearStringProps<F>;
|
|
72
|
+
export type MonthYearStringState = _MonthYearStringState<F>;
|
|
73
|
+
export type PrevMonthButtonProps = _PrevMonthButtonProps<F>;
|
|
74
|
+
export type NextMonthButtonProps = _NextMonthButtonProps<F>;
|
|
75
|
+
export type NavButtonState = _NavButtonState<F>;
|
|
76
|
+
export type DateRange = _DateRange<F>;
|
|
77
|
+
export type ValueForFormat = _ValueForFormat<F>;
|
|
78
|
+
export type RawValueForFormat = _RawValueForFormat<F>;
|
|
79
|
+
export type WeekNumberCellProps = _WeekNumberCellProps<F>;
|
|
80
|
+
export type WeekNumberCellState = _WeekNumberCellState<F>;
|
|
81
|
+
export type WeekNumberHeaderProps = _WeekNumberHeaderProps<F>;
|
|
82
|
+
export type WeekNumberHeaderState = _WeekNumberHeaderState<F>;
|
|
83
|
+
export type { DragHandleOwnProps, ValueFormat, DateValueObject, PlainDateObject, TemporalNamespace, WeekStartDay, RangeMode, OutsideDays, ValueChangeMeta, MonthData } from "../types";
|
|
84
|
+
|
|
85
|
+
import type { CalendarProviderProps as _CalendarProviderProps } from "../calendar-types";
|
|
86
|
+
export type CalendarProviderProps = _CalendarProviderProps<F>;
|
|
87
|
+
|
|
88
|
+
export type { CalendarStableContextValue, CalendarStateContextValue } from "../calendar-types";
|
|
89
|
+
|
|
90
|
+
export type { MonthViewRootProps, MonthViewStableContextValue, MonthViewStateContextValue } from "../month-view-types";
|
|
91
|
+
|
|
92
|
+
export type { MonthViewProps } from "../month-view";
|
|
93
|
+
|
|
94
|
+
export type { ViewContextValue } from "../view-context";
|
|
95
|
+
|
|
96
|
+
export type { WeeksViewRootProps, WeeksViewStableContextValue, WeeksViewStateContextValue, WindowInfo, VisibleMonth } from "../weeks-view-types";
|
|
97
|
+
|
|
98
|
+
export type { WeeksViewProps, WeeksViewRootHandle } from "../weeks-view";
|
|
99
|
+
|
|
100
|
+
export type { WeeksNavButtonState, WeeksNavButtonOwnProps, PrevWeeksButtonProps, NextWeeksButtonProps, WeekCountState, WeekCountProps } from "../weeks-navigation";
|
|
101
|
+
|
|
102
|
+
export { useWeeksViewStable, useWeeksViewState } from "../weeks-view-context";
|
|
103
|
+
|
|
104
|
+
export type { WeekDescriptor } from "../compute-weeks-in-window";
|
|
105
|
+
|
|
106
|
+
export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
|
|
107
|
+
|
|
108
|
+
export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
|
|
109
|
+
|
|
110
|
+
export type { MonthSeparatorState } from "../month-separator";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @generated by scripts/generate-formats.ts — do not edit manually
|
|
2
|
+
type F = "ZonedDateTime";
|
|
3
|
+
|
|
4
|
+
export { CalendarProvider } from "../calendar-provider";
|
|
5
|
+
|
|
6
|
+
export { MonthView, MonthViewRoot } from "../month-view";
|
|
7
|
+
|
|
8
|
+
export { Grid, GridBody, WeekTemplate, DayCellTemplate, DayButton } from "../grid";
|
|
9
|
+
|
|
10
|
+
export { GridHeader, GridHeaderCell } from "../grid-header";
|
|
11
|
+
|
|
12
|
+
export { DateString, TimeString, MonthYearString, PrevMonthButton, NextMonthButton } from "../navigation";
|
|
13
|
+
|
|
14
|
+
export { RangeSelected } from "../selected-range";
|
|
15
|
+
|
|
16
|
+
export { RangePreview } from "../range-preview";
|
|
17
|
+
|
|
18
|
+
export { RangeStartDragHandle, RangeEndDragHandle } from "../drag-handle";
|
|
19
|
+
|
|
20
|
+
export { WeekNumberCell, WeekNumberHeader } from "../week-number";
|
|
21
|
+
|
|
22
|
+
export { WeeksView, WeeksViewRoot } from "../weeks-view";
|
|
23
|
+
|
|
24
|
+
export { PrevWeeksButton, NextWeeksButton, WeekCount } from "../weeks-navigation";
|
|
25
|
+
|
|
26
|
+
export { MonthSeparator, MonthSeparatorRow, MonthSeparatorCell, MonthSeparatorMonth, MonthSeparatorYear, MonthSeparatorWeekCount } from "../month-separator";
|
|
27
|
+
|
|
28
|
+
export { computePreviewRange } from "../root-selection";
|
|
29
|
+
|
|
30
|
+
export { computeWeeksInWindow } from "../compute-weeks-in-window";
|
|
31
|
+
|
|
32
|
+
export { resolveFirstWeek, resolveFirstWeekSpec } from "../resolve-first-week";
|
|
33
|
+
|
|
34
|
+
export { Temporal } from "../temporal-polyfill";
|
|
35
|
+
|
|
36
|
+
export { useCalendarStable, useCalendarState } from "../calendar-context";
|
|
37
|
+
|
|
38
|
+
export { useMonthViewStable, useMonthViewState } from "../month-view-context";
|
|
39
|
+
|
|
40
|
+
export { useViewContext } from "../view-context";
|
|
41
|
+
|
|
42
|
+
export { DayCellDataContext, WeekDataContext, GridContext } from "../context";
|
|
43
|
+
|
|
44
|
+
import type { RootState as _RootState, GridProps as _GridProps, GridState as _GridState, GridHeaderProps as _GridHeaderProps, GridHeaderState as _GridHeaderState, GridHeaderCellProps as _GridHeaderCellProps, GridHeaderCellState as _GridHeaderCellState, GridBodyProps as _GridBodyProps, GridBodyState as _GridBodyState, WeekTemplateProps as _WeekTemplateProps, WeekTemplateState as _WeekTemplateState, DayCellTemplateProps as _DayCellTemplateProps, DayCellTemplateState as _DayCellTemplateState, DayButtonProps as _DayButtonProps, DayButtonState as _DayButtonState, RangeSelectedProps as _RangeSelectedProps, RangeSelectedState as _RangeSelectedState, RangePreviewProps as _RangePreviewProps, RangePreviewState as _RangePreviewState, DragHandleState as _DragHandleState, RangeStartDragHandleProps as _RangeStartDragHandleProps, RangeEndDragHandleProps as _RangeEndDragHandleProps, DateStringProps as _DateStringProps, DateStringState as _DateStringState, TimeStringProps as _TimeStringProps, TimeStringState as _TimeStringState, MonthYearStringProps as _MonthYearStringProps, MonthYearStringState as _MonthYearStringState, PrevMonthButtonProps as _PrevMonthButtonProps, NextMonthButtonProps as _NextMonthButtonProps, NavButtonState as _NavButtonState, DateRange as _DateRange, ValueForFormat as _ValueForFormat, RawValueForFormat as _RawValueForFormat, WeekNumberCellProps as _WeekNumberCellProps, WeekNumberCellState as _WeekNumberCellState, WeekNumberHeaderProps as _WeekNumberHeaderProps, WeekNumberHeaderState as _WeekNumberHeaderState } from "../types";
|
|
45
|
+
export type RootState = _RootState<F>;
|
|
46
|
+
export type GridProps = _GridProps<F>;
|
|
47
|
+
export type GridState = _GridState<F>;
|
|
48
|
+
export type GridHeaderProps = _GridHeaderProps<F>;
|
|
49
|
+
export type GridHeaderState = _GridHeaderState<F>;
|
|
50
|
+
export type GridHeaderCellProps = _GridHeaderCellProps<F>;
|
|
51
|
+
export type GridHeaderCellState = _GridHeaderCellState<F>;
|
|
52
|
+
export type GridBodyProps = _GridBodyProps<F>;
|
|
53
|
+
export type GridBodyState = _GridBodyState<F>;
|
|
54
|
+
export type WeekTemplateProps = _WeekTemplateProps<F>;
|
|
55
|
+
export type WeekTemplateState = _WeekTemplateState<F>;
|
|
56
|
+
export type DayCellTemplateProps = _DayCellTemplateProps<F>;
|
|
57
|
+
export type DayCellTemplateState = _DayCellTemplateState<F>;
|
|
58
|
+
export type DayButtonProps = _DayButtonProps<F>;
|
|
59
|
+
export type DayButtonState = _DayButtonState<F>;
|
|
60
|
+
export type RangeSelectedProps = _RangeSelectedProps<F>;
|
|
61
|
+
export type RangeSelectedState = _RangeSelectedState<F>;
|
|
62
|
+
export type RangePreviewProps = _RangePreviewProps<F>;
|
|
63
|
+
export type RangePreviewState = _RangePreviewState<F>;
|
|
64
|
+
export type DragHandleState = _DragHandleState<F>;
|
|
65
|
+
export type RangeStartDragHandleProps = _RangeStartDragHandleProps<F>;
|
|
66
|
+
export type RangeEndDragHandleProps = _RangeEndDragHandleProps<F>;
|
|
67
|
+
export type DateStringProps = _DateStringProps<F>;
|
|
68
|
+
export type DateStringState = _DateStringState<F>;
|
|
69
|
+
export type TimeStringProps = _TimeStringProps<F>;
|
|
70
|
+
export type TimeStringState = _TimeStringState<F>;
|
|
71
|
+
export type MonthYearStringProps = _MonthYearStringProps<F>;
|
|
72
|
+
export type MonthYearStringState = _MonthYearStringState<F>;
|
|
73
|
+
export type PrevMonthButtonProps = _PrevMonthButtonProps<F>;
|
|
74
|
+
export type NextMonthButtonProps = _NextMonthButtonProps<F>;
|
|
75
|
+
export type NavButtonState = _NavButtonState<F>;
|
|
76
|
+
export type DateRange = _DateRange<F>;
|
|
77
|
+
export type ValueForFormat = _ValueForFormat<F>;
|
|
78
|
+
export type RawValueForFormat = _RawValueForFormat<F>;
|
|
79
|
+
export type WeekNumberCellProps = _WeekNumberCellProps<F>;
|
|
80
|
+
export type WeekNumberCellState = _WeekNumberCellState<F>;
|
|
81
|
+
export type WeekNumberHeaderProps = _WeekNumberHeaderProps<F>;
|
|
82
|
+
export type WeekNumberHeaderState = _WeekNumberHeaderState<F>;
|
|
83
|
+
export type { DragHandleOwnProps, ValueFormat, DateValueObject, PlainDateObject, TemporalNamespace, WeekStartDay, RangeMode, OutsideDays, ValueChangeMeta, MonthData } from "../types";
|
|
84
|
+
|
|
85
|
+
import type { CalendarProviderProps as _CalendarProviderProps } from "../calendar-types";
|
|
86
|
+
export type CalendarProviderProps = _CalendarProviderProps<F>;
|
|
87
|
+
|
|
88
|
+
export type { CalendarStableContextValue, CalendarStateContextValue } from "../calendar-types";
|
|
89
|
+
|
|
90
|
+
export type { MonthViewRootProps, MonthViewStableContextValue, MonthViewStateContextValue } from "../month-view-types";
|
|
91
|
+
|
|
92
|
+
export type { MonthViewProps } from "../month-view";
|
|
93
|
+
|
|
94
|
+
export type { ViewContextValue } from "../view-context";
|
|
95
|
+
|
|
96
|
+
export type { WeeksViewRootProps, WeeksViewStableContextValue, WeeksViewStateContextValue, WindowInfo, VisibleMonth } from "../weeks-view-types";
|
|
97
|
+
|
|
98
|
+
export type { WeeksViewProps, WeeksViewRootHandle } from "../weeks-view";
|
|
99
|
+
|
|
100
|
+
export type { WeeksNavButtonState, WeeksNavButtonOwnProps, PrevWeeksButtonProps, NextWeeksButtonProps, WeekCountState, WeekCountProps } from "../weeks-navigation";
|
|
101
|
+
|
|
102
|
+
export { useWeeksViewStable, useWeeksViewState } from "../weeks-view-context";
|
|
103
|
+
|
|
104
|
+
export type { WeekDescriptor } from "../compute-weeks-in-window";
|
|
105
|
+
|
|
106
|
+
export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
|
|
107
|
+
|
|
108
|
+
export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
|
|
109
|
+
|
|
110
|
+
export type { MonthSeparatorState } from "../month-separator";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { forwardRef, useMemo } from "react";
|
|
4
|
+
import { useCalendarStable } from "./calendar-context";
|
|
5
|
+
import { useMonthViewState } from "./month-view-context";
|
|
6
|
+
import type { StateAttributesMapping } from "./types";
|
|
7
|
+
import type {
|
|
8
|
+
ValueFormat,
|
|
9
|
+
GridHeaderCellProps,
|
|
10
|
+
GridHeaderState,
|
|
11
|
+
GridHeaderProps,
|
|
12
|
+
GridHeaderCellState,
|
|
13
|
+
} from "./types";
|
|
14
|
+
import { getWeekdayNames, getReferenceWeekStart } from "./utils";
|
|
15
|
+
|
|
16
|
+
function useGridHeaderCellState(index: number) {
|
|
17
|
+
const { locale, temporal: T, weekStartDay } = useCalendarStable();
|
|
18
|
+
const { rootState } = useMonthViewState();
|
|
19
|
+
|
|
20
|
+
const weekdayNames = useMemo(
|
|
21
|
+
() => getWeekdayNames(locale, T, weekStartDay),
|
|
22
|
+
[locale, T, weekStartDay],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const state = useMemo<GridHeaderCellState>(
|
|
26
|
+
() => ({
|
|
27
|
+
root: rootState as unknown as GridHeaderCellState["root"],
|
|
28
|
+
dayOfWeek: index,
|
|
29
|
+
long: weekdayNames[index].long,
|
|
30
|
+
short: weekdayNames[index].short,
|
|
31
|
+
narrow: weekdayNames[index].narrow,
|
|
32
|
+
}),
|
|
33
|
+
[rootState, index, weekdayNames],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const defaultProps: Record<string, unknown> = {
|
|
37
|
+
scope: "col",
|
|
38
|
+
abbr: state.long,
|
|
39
|
+
"aria-label": state.long,
|
|
40
|
+
children: state.narrow,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return { state, defaultProps };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const gridHeaderStateAttributesMapping = {
|
|
47
|
+
root: () => null,
|
|
48
|
+
} as const satisfies StateAttributesMapping<GridHeaderState>;
|
|
49
|
+
|
|
50
|
+
const gridHeaderCellStateAttributesMapping = {
|
|
51
|
+
root: () => null,
|
|
52
|
+
dayOfWeek: () => null,
|
|
53
|
+
long: () => null,
|
|
54
|
+
short: () => null,
|
|
55
|
+
narrow: () => null,
|
|
56
|
+
} as const satisfies StateAttributesMapping<GridHeaderCellState>;
|
|
57
|
+
|
|
58
|
+
function GridHeaderCellInstanceFn(
|
|
59
|
+
props: Omit<GridHeaderCellProps, "index"> & { index: number },
|
|
60
|
+
ref: React.ForwardedRef<HTMLTableCellElement>,
|
|
61
|
+
) {
|
|
62
|
+
const { render, index, ...otherProps } = props;
|
|
63
|
+
const { state, defaultProps } = useGridHeaderCellState(index);
|
|
64
|
+
|
|
65
|
+
return useRender({
|
|
66
|
+
defaultTagName: "th",
|
|
67
|
+
render,
|
|
68
|
+
ref: ref ? [ref] : [],
|
|
69
|
+
state,
|
|
70
|
+
stateAttributesMapping: gridHeaderCellStateAttributesMapping,
|
|
71
|
+
props: mergeProps<"th">(defaultProps, otherProps),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const GridHeaderCellInstance = forwardRef(GridHeaderCellInstanceFn) as <
|
|
76
|
+
F extends ValueFormat = ValueFormat,
|
|
77
|
+
>(
|
|
78
|
+
props: Omit<GridHeaderCellProps<F>, "index"> & {
|
|
79
|
+
index: number;
|
|
80
|
+
} & React.RefAttributes<HTMLTableCellElement>,
|
|
81
|
+
) => React.ReactElement | null;
|
|
82
|
+
|
|
83
|
+
function GridHeaderCellFn(
|
|
84
|
+
props: GridHeaderCellProps,
|
|
85
|
+
ref: React.ForwardedRef<HTMLTableCellElement>,
|
|
86
|
+
) {
|
|
87
|
+
const { index: indexProp, ...restProps } = props;
|
|
88
|
+
const { temporal: T } = useCalendarStable();
|
|
89
|
+
const Instance = GridHeaderCellInstance;
|
|
90
|
+
|
|
91
|
+
if (indexProp != null) {
|
|
92
|
+
return <Instance {...restProps} ref={ref} index={indexProp} />;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const daysInWeek = getReferenceWeekStart(T).daysInWeek;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
{Array.from({ length: daysInWeek }, (_, i) => (
|
|
100
|
+
<Instance key={i} {...restProps} ref={ref} index={i} />
|
|
101
|
+
))}
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Renders weekday column headers (`<th>`). When no `index` is provided,
|
|
108
|
+
* renders all 7 days (Sunday–Saturday). Each cell includes `abbr` and
|
|
109
|
+
* `aria-label` with the full weekday name.
|
|
110
|
+
*/
|
|
111
|
+
export const GridHeaderCell = forwardRef(GridHeaderCellFn) as <F extends ValueFormat = ValueFormat>(
|
|
112
|
+
props: GridHeaderCellProps<F> & React.RefAttributes<HTMLTableCellElement>,
|
|
113
|
+
) => React.ReactElement | null;
|
|
114
|
+
|
|
115
|
+
function GridHeaderFn(props: GridHeaderProps, ref: React.ForwardedRef<HTMLTableSectionElement>) {
|
|
116
|
+
const { render, children, ...otherProps } = props;
|
|
117
|
+
const { rootState } = useMonthViewState();
|
|
118
|
+
|
|
119
|
+
const state = useMemo<GridHeaderState>(
|
|
120
|
+
() => ({ root: rootState as unknown as GridHeaderState["root"] }),
|
|
121
|
+
[rootState],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const defaultProps: Record<string, unknown> = {
|
|
125
|
+
children: <tr>{children ?? <GridHeaderCell />}</tr>,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return useRender({
|
|
129
|
+
defaultTagName: "thead",
|
|
130
|
+
render,
|
|
131
|
+
ref: ref ? [ref] : [],
|
|
132
|
+
state,
|
|
133
|
+
stateAttributesMapping: gridHeaderStateAttributesMapping,
|
|
134
|
+
props: mergeProps<"thead">(defaultProps, otherProps),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Table header section (`<thead>`) wrapping a row of {@link GridHeaderCell}s. */
|
|
139
|
+
export const GridHeader = forwardRef(GridHeaderFn) as <F extends ValueFormat = ValueFormat>(
|
|
140
|
+
props: GridHeaderProps<F> & React.RefAttributes<HTMLTableSectionElement>,
|
|
141
|
+
) => React.ReactElement | null;
|