@knitui/dates 0.13.0 → 1.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/lib/commonjs/Calendar/Calendar.js +4 -4
- package/lib/commonjs/Calendar/Calendar.js.map +1 -1
- package/lib/commonjs/CalendarHeader/CalendarHeader.js +24 -152
- package/lib/commonjs/CalendarHeader/CalendarHeader.js.map +1 -1
- package/lib/commonjs/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/commonjs/DateTimePicker/DateTimePicker.js +1 -1
- package/lib/commonjs/DatesProvider/DatesProvider.js +1 -1
- package/lib/commonjs/Day/Day.js +74 -142
- package/lib/commonjs/Day/Day.js.map +1 -1
- package/lib/commonjs/DecadeLevel/DecadeLevel.js +5 -5
- package/lib/commonjs/DecadeLevel/DecadeLevel.js.map +1 -1
- package/lib/commonjs/InlineDateTimePicker/InlineDateTimePicker.js +16 -7
- package/lib/commonjs/InlineDateTimePicker/InlineDateTimePicker.js.map +1 -1
- package/lib/commonjs/LevelsGroup/LevelsGroup.js +3 -3
- package/lib/commonjs/LevelsGroup/LevelsGroup.js.map +1 -1
- package/lib/commonjs/MiniCalendar/MiniCalendar.js +37 -173
- package/lib/commonjs/MiniCalendar/MiniCalendar.js.map +1 -1
- package/lib/commonjs/Month/Month.js +15 -62
- package/lib/commonjs/Month/Month.js.map +1 -1
- package/lib/commonjs/MonthLevel/MonthLevel.js +5 -5
- package/lib/commonjs/MonthLevel/MonthLevel.js.map +1 -1
- package/lib/commonjs/MonthPicker/MonthPicker.js +1 -1
- package/lib/commonjs/MonthPickerInput/MonthPickerInput.js +1 -1
- package/lib/commonjs/MonthsList/MonthsList.js +8 -9
- package/lib/commonjs/MonthsList/MonthsList.js.map +1 -1
- package/lib/commonjs/PickerControl/PickerControl.js +41 -121
- package/lib/commonjs/PickerControl/PickerControl.js.map +1 -1
- package/lib/commonjs/PickerInputBase/PickerInputBase.js +1 -1
- package/lib/commonjs/TimeControlsList/TimeControl.js +19 -48
- package/lib/commonjs/TimeControlsList/TimeControl.js.map +1 -1
- package/lib/commonjs/TimeControlsList/TimeControlsList.js +1 -1
- package/lib/commonjs/TimeControlsList/TimeControlsList.js.map +1 -1
- package/lib/commonjs/TimeGrid/TimeGrid.js +50 -97
- package/lib/commonjs/TimeGrid/TimeGrid.js.map +1 -1
- package/lib/commonjs/TimeInput/TimeInput.js +1 -1
- package/lib/commonjs/TimePicker/TimePicker.js +20 -20
- package/lib/commonjs/TimePicker/TimePicker.js.map +1 -1
- package/lib/commonjs/TimePresets/TimePresetControl.js +32 -62
- package/lib/commonjs/TimePresets/TimePresetControl.js.map +1 -1
- package/lib/commonjs/TimePresets/TimePresetGroup.js +5 -5
- package/lib/commonjs/TimePresets/TimePresetGroup.js.map +1 -1
- package/lib/commonjs/TimePresets/TimePresets.js +4 -4
- package/lib/commonjs/TimePresets/TimePresets.js.map +1 -1
- package/lib/commonjs/TimeValue/TimeValue.js +2 -2
- package/lib/commonjs/WeekdaysRow/WeekdaysRow.js +7 -38
- package/lib/commonjs/WeekdaysRow/WeekdaysRow.js.map +1 -1
- package/lib/commonjs/YearLevel/YearLevel.js +5 -5
- package/lib/commonjs/YearLevel/YearLevel.js.map +1 -1
- package/lib/commonjs/YearPicker/YearPicker.js +1 -1
- package/lib/commonjs/YearPickerInput/YearPickerInput.js +1 -1
- package/lib/commonjs/YearsList/YearsList.js +8 -9
- package/lib/commonjs/YearsList/YearsList.js.map +1 -1
- package/lib/commonjs/_reference/ExampleControl.js +26 -91
- package/lib/commonjs/_reference/ExampleControl.js.map +1 -1
- package/lib/commonjs/_reference/README.md +3 -3
- package/lib/commonjs/cell-metrics.js +167 -37
- package/lib/commonjs/cell-metrics.js.map +1 -1
- package/lib/commonjs/internal/a11y.js +5 -3
- package/lib/commonjs/internal/a11y.js.map +1 -1
- package/lib/commonjs/internal/get-input-default-date.js +1 -1
- package/lib/commonjs/internal/select-on-focus.js +1 -1
- package/lib/module/Calendar/Calendar.js +5 -5
- package/lib/module/Calendar/Calendar.js.map +1 -1
- package/lib/module/CalendarHeader/CalendarHeader.js +26 -155
- package/lib/module/CalendarHeader/CalendarHeader.js.map +1 -1
- package/lib/module/DatePicker/DatePicker.js +1 -1
- package/lib/module/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/module/DateTimePicker/DateTimePicker.js +1 -1
- package/lib/module/DatesProvider/DatesProvider.js +1 -1
- package/lib/module/Day/Day.js +76 -144
- package/lib/module/Day/Day.js.map +1 -1
- package/lib/module/DecadeLevel/DecadeLevel.js +6 -6
- package/lib/module/DecadeLevel/DecadeLevel.js.map +1 -1
- package/lib/module/InlineDateTimePicker/InlineDateTimePicker.js +16 -7
- package/lib/module/InlineDateTimePicker/InlineDateTimePicker.js.map +1 -1
- package/lib/module/LevelsGroup/LevelsGroup.js +4 -4
- package/lib/module/LevelsGroup/LevelsGroup.js.map +1 -1
- package/lib/module/MiniCalendar/MiniCalendar.js +39 -175
- package/lib/module/MiniCalendar/MiniCalendar.js.map +1 -1
- package/lib/module/Month/Month.js +17 -64
- package/lib/module/Month/Month.js.map +1 -1
- package/lib/module/MonthLevel/MonthLevel.js +6 -6
- package/lib/module/MonthLevel/MonthLevel.js.map +1 -1
- package/lib/module/MonthPicker/MonthPicker.js +1 -1
- package/lib/module/MonthPickerInput/MonthPickerInput.js +1 -1
- package/lib/module/MonthsList/MonthsList.js +9 -10
- package/lib/module/MonthsList/MonthsList.js.map +1 -1
- package/lib/module/PickerControl/PickerControl.js +42 -122
- package/lib/module/PickerControl/PickerControl.js.map +1 -1
- package/lib/module/PickerInputBase/PickerInputBase.js +1 -1
- package/lib/module/TimeControlsList/TimeControl.js +20 -49
- package/lib/module/TimeControlsList/TimeControl.js.map +1 -1
- package/lib/module/TimeControlsList/TimeControlsList.js +1 -1
- package/lib/module/TimeControlsList/TimeControlsList.js.map +1 -1
- package/lib/module/TimeGrid/TimeGrid.js +53 -100
- package/lib/module/TimeGrid/TimeGrid.js.map +1 -1
- package/lib/module/TimeInput/TimeInput.js +1 -1
- package/lib/module/TimePicker/TimePicker.js +20 -20
- package/lib/module/TimePicker/TimePicker.js.map +1 -1
- package/lib/module/TimePresets/TimePresetControl.js +36 -65
- package/lib/module/TimePresets/TimePresetControl.js.map +1 -1
- package/lib/module/TimePresets/TimePresetGroup.js +6 -6
- package/lib/module/TimePresets/TimePresetGroup.js.map +1 -1
- package/lib/module/TimePresets/TimePresets.js +4 -4
- package/lib/module/TimePresets/TimePresets.js.map +1 -1
- package/lib/module/TimeValue/TimeValue.js +2 -2
- package/lib/module/WeekdaysRow/WeekdaysRow.js +8 -39
- package/lib/module/WeekdaysRow/WeekdaysRow.js.map +1 -1
- package/lib/module/YearLevel/YearLevel.js +6 -6
- package/lib/module/YearLevel/YearLevel.js.map +1 -1
- package/lib/module/YearPicker/YearPicker.js +1 -1
- package/lib/module/YearPickerInput/YearPickerInput.js +1 -1
- package/lib/module/YearsList/YearsList.js +9 -10
- package/lib/module/YearsList/YearsList.js.map +1 -1
- package/lib/module/_reference/ExampleControl.js +28 -93
- package/lib/module/_reference/ExampleControl.js.map +1 -1
- package/lib/module/_reference/README.md +3 -3
- package/lib/module/cell-metrics.js +166 -36
- package/lib/module/cell-metrics.js.map +1 -1
- package/lib/module/internal/a11y.js +5 -3
- package/lib/module/internal/a11y.js.map +1 -1
- package/lib/module/internal/get-input-default-date.js +1 -1
- package/lib/module/internal/select-on-focus.js +1 -1
- package/lib/typescript/Calendar/Calendar.d.ts +28 -21
- package/lib/typescript/Calendar/Calendar.d.ts.map +1 -1
- package/lib/typescript/Calendar/pick-calendar-props/pick-calendar-props.d.ts +1 -1
- package/lib/typescript/CalendarHeader/CalendarHeader.d.ts +190 -53
- package/lib/typescript/CalendarHeader/CalendarHeader.d.ts.map +1 -1
- package/lib/typescript/Day/Day.d.ts +103 -84
- package/lib/typescript/Day/Day.d.ts.map +1 -1
- package/lib/typescript/DecadeLevel/DecadeLevel.d.ts +172 -71
- package/lib/typescript/DecadeLevel/DecadeLevel.d.ts.map +1 -1
- package/lib/typescript/DecadeLevelGroup/DecadeLevelGroup.d.ts +171 -86
- package/lib/typescript/DecadeLevelGroup/DecadeLevelGroup.d.ts.map +1 -1
- package/lib/typescript/InlineDateTimePicker/InlineDateTimePicker.d.ts +64 -12
- package/lib/typescript/InlineDateTimePicker/InlineDateTimePicker.d.ts.map +1 -1
- package/lib/typescript/LevelsGroup/LevelsGroup.d.ts +27 -20
- package/lib/typescript/LevelsGroup/LevelsGroup.d.ts.map +1 -1
- package/lib/typescript/MiniCalendar/MiniCalendar.d.ts +247 -61
- package/lib/typescript/MiniCalendar/MiniCalendar.d.ts.map +1 -1
- package/lib/typescript/Month/Month.d.ts +164 -43
- package/lib/typescript/Month/Month.d.ts.map +1 -1
- package/lib/typescript/MonthLevel/MonthLevel.d.ts +208 -79
- package/lib/typescript/MonthLevel/MonthLevel.d.ts.map +1 -1
- package/lib/typescript/MonthLevelGroup/MonthLevelGroup.d.ts +207 -94
- package/lib/typescript/MonthLevelGroup/MonthLevelGroup.d.ts.map +1 -1
- package/lib/typescript/MonthsList/MonthsList.d.ts +91 -26
- package/lib/typescript/MonthsList/MonthsList.d.ts.map +1 -1
- package/lib/typescript/PickerControl/PickerControl.d.ts +79 -59
- package/lib/typescript/PickerControl/PickerControl.d.ts.map +1 -1
- package/lib/typescript/TimeControlsList/TimeControl.d.ts +19 -4
- package/lib/typescript/TimeControlsList/TimeControl.d.ts.map +1 -1
- package/lib/typescript/TimeControlsList/TimeControlsList.d.ts +66 -12
- package/lib/typescript/TimeControlsList/TimeControlsList.d.ts.map +1 -1
- package/lib/typescript/TimeGrid/TimeGrid.d.ts +98 -34
- package/lib/typescript/TimeGrid/TimeGrid.d.ts.map +1 -1
- package/lib/typescript/TimePicker/TimePicker.d.ts +43 -7
- package/lib/typescript/TimePicker/TimePicker.d.ts.map +1 -1
- package/lib/typescript/TimePresets/TimePresetControl.d.ts +65 -10
- package/lib/typescript/TimePresets/TimePresetControl.d.ts.map +1 -1
- package/lib/typescript/TimePresets/TimePresetGroup.d.ts +132 -44
- package/lib/typescript/TimePresets/TimePresetGroup.d.ts.map +1 -1
- package/lib/typescript/TimePresets/TimePresets.d.ts +237 -64
- package/lib/typescript/TimePresets/TimePresets.d.ts.map +1 -1
- package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts +81 -27
- package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts.map +1 -1
- package/lib/typescript/YearLevel/YearLevel.d.ts +172 -71
- package/lib/typescript/YearLevel/YearLevel.d.ts.map +1 -1
- package/lib/typescript/YearLevelGroup/YearLevelGroup.d.ts +171 -86
- package/lib/typescript/YearLevelGroup/YearLevelGroup.d.ts.map +1 -1
- package/lib/typescript/YearsList/YearsList.d.ts +91 -26
- package/lib/typescript/YearsList/YearsList.d.ts.map +1 -1
- package/lib/typescript/_reference/ExampleControl.d.ts +163 -43
- package/lib/typescript/_reference/ExampleControl.d.ts.map +1 -1
- package/lib/typescript/cell-metrics.d.ts +120 -0
- package/lib/typescript/cell-metrics.d.ts.map +1 -1
- package/lib/typescript/internal/a11y.d.ts +0 -14
- package/lib/typescript/internal/a11y.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/Calendar/Calendar.tsx +6 -5
- package/src/CalendarHeader/CalendarHeader.tsx +32 -74
- package/src/DatePicker/DatePicker.tsx +1 -1
- package/src/DatePickerInput/DatePickerInput.tsx +1 -1
- package/src/DateTimePicker/DateTimePicker.tsx +1 -1
- package/src/DatesProvider/DatesProvider.tsx +1 -1
- package/src/Day/Day.tsx +85 -82
- package/src/DecadeLevel/DecadeLevel.tsx +7 -5
- package/src/InlineDateTimePicker/InlineDateTimePicker.tsx +14 -7
- package/src/LevelsGroup/LevelsGroup.tsx +13 -13
- package/src/MiniCalendar/MiniCalendar.tsx +47 -91
- package/src/Month/Month.tsx +21 -37
- package/src/MonthLevel/MonthLevel.tsx +7 -5
- package/src/MonthPicker/MonthPicker.tsx +1 -1
- package/src/MonthPickerInput/MonthPickerInput.tsx +1 -1
- package/src/MonthsList/MonthsList.tsx +9 -10
- package/src/PickerControl/PickerControl.tsx +44 -89
- package/src/PickerInputBase/PickerInputBase.tsx +1 -1
- package/src/TimeControlsList/TimeControl.tsx +17 -28
- package/src/TimeControlsList/TimeControlsList.tsx +1 -1
- package/src/TimeGrid/TimeGrid.tsx +71 -61
- package/src/TimeInput/TimeInput.tsx +1 -1
- package/src/TimePicker/TimePicker.tsx +15 -15
- package/src/TimePresets/TimePresetControl.tsx +30 -45
- package/src/TimePresets/TimePresetGroup.tsx +7 -5
- package/src/TimePresets/TimePresets.tsx +4 -4
- package/src/TimeValue/TimeValue.tsx +2 -2
- package/src/WeekdaysRow/WeekdaysRow.tsx +9 -17
- package/src/YearLevel/YearLevel.tsx +121 -117
- package/src/YearPicker/YearPicker.tsx +1 -1
- package/src/YearPickerInput/YearPickerInput.tsx +1 -1
- package/src/YearsList/YearsList.tsx +142 -141
- package/src/_reference/ExampleControl.tsx +29 -53
- package/src/_reference/README.md +3 -3
- package/src/cell-metrics.ts +110 -36
- package/src/internal/a11y.ts +6 -3
- package/src/internal/get-input-default-date.ts +1 -1
- package/src/internal/select-on-focus.ts +1 -1
- package/lib/commonjs/internal/web-cursor.js +0 -24
- package/lib/commonjs/internal/web-cursor.js.map +0 -1
- package/lib/module/internal/web-cursor.js +0 -20
- package/lib/module/internal/web-cursor.js.map +0 -1
- package/lib/typescript/internal/web-cursor.d.ts +0 -10
- package/lib/typescript/internal/web-cursor.d.ts.map +0 -1
- package/src/internal/web-cursor.ts +0 -15
|
@@ -16,64 +16,26 @@ import {
|
|
|
16
16
|
type GetProps,
|
|
17
17
|
slotStyles,
|
|
18
18
|
type SlotStyles,
|
|
19
|
+
styleable,
|
|
19
20
|
styled,
|
|
20
21
|
withStaticProperties,
|
|
21
22
|
} from "@knitui/core";
|
|
22
23
|
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
type CalendarSize,
|
|
26
|
+
cellHeightVariant,
|
|
27
|
+
cellSquareVariant,
|
|
28
|
+
headerFontVariant,
|
|
29
|
+
iconFontVariant,
|
|
30
|
+
} from "../cell-metrics";
|
|
24
31
|
import { controlA11yProps } from "../internal/a11y";
|
|
25
32
|
import { hasPreventDefault } from "../internal/has-prevent-default";
|
|
26
|
-
import { webCursor } from "../internal/web-cursor";
|
|
27
33
|
|
|
28
34
|
// ── Sizing derived from the shared `cell-metrics` ladder ──────────────────────
|
|
29
35
|
// Never hard-code pixels: the header controls scale on the shared `CELL_WIDTH`
|
|
30
36
|
// ladder (the calendar twin of components' `controlMetrics`), so retuning the
|
|
31
37
|
// ladder moves every grid component together. Values resolve at module-load.
|
|
32
38
|
|
|
33
|
-
/** Square prev/next control size per `size`, from the shared `CELL_WIDTH` ladder. */
|
|
34
|
-
const controlSquareVariant = {
|
|
35
|
-
xxs: { width: CELL_WIDTH.xxs, height: CELL_WIDTH.xxs },
|
|
36
|
-
xs: { width: CELL_WIDTH.xs, height: CELL_WIDTH.xs },
|
|
37
|
-
sm: { width: CELL_WIDTH.sm, height: CELL_WIDTH.sm },
|
|
38
|
-
md: { width: CELL_WIDTH.md, height: CELL_WIDTH.md },
|
|
39
|
-
lg: { width: CELL_WIDTH.lg, height: CELL_WIDTH.lg },
|
|
40
|
-
xl: { width: CELL_WIDTH.xl, height: CELL_WIDTH.xl },
|
|
41
|
-
xxl: { width: CELL_WIDTH.xxl, height: CELL_WIDTH.xxl },
|
|
42
|
-
} as const;
|
|
43
|
-
|
|
44
|
-
/** Level (label) control height per `size`, from the shared `CELL_WIDTH` ladder. */
|
|
45
|
-
const levelHeightVariant = {
|
|
46
|
-
xxs: { height: CELL_WIDTH.xxs },
|
|
47
|
-
xs: { height: CELL_WIDTH.xs },
|
|
48
|
-
sm: { height: CELL_WIDTH.sm },
|
|
49
|
-
md: { height: CELL_WIDTH.md },
|
|
50
|
-
lg: { height: CELL_WIDTH.lg },
|
|
51
|
-
xl: { height: CELL_WIDTH.xl },
|
|
52
|
-
xxl: { height: CELL_WIDTH.xxl },
|
|
53
|
-
} as const;
|
|
54
|
-
|
|
55
|
-
/** Level label font per `size` (≈ control size / 2.6, capitalized month/year text). */
|
|
56
|
-
const levelFontVariant = {
|
|
57
|
-
xxs: { fontSize: Math.round(CELL_WIDTH.xxs / 2.6) },
|
|
58
|
-
xs: { fontSize: Math.round(CELL_WIDTH.xs / 2.6) },
|
|
59
|
-
sm: { fontSize: Math.round(CELL_WIDTH.sm / 2.6) },
|
|
60
|
-
md: { fontSize: Math.round(CELL_WIDTH.md / 2.6) },
|
|
61
|
-
lg: { fontSize: Math.round(CELL_WIDTH.lg / 2.6) },
|
|
62
|
-
xl: { fontSize: Math.round(CELL_WIDTH.xl / 2.6) },
|
|
63
|
-
xxl: { fontSize: Math.round(CELL_WIDTH.xxl / 2.6) },
|
|
64
|
-
} as const;
|
|
65
|
-
|
|
66
|
-
/** Chevron glyph font per `size` (≈ 55% of the control size). */
|
|
67
|
-
const iconFontVariant = {
|
|
68
|
-
xxs: { fontSize: Math.round(CELL_WIDTH.xxs * 0.55) },
|
|
69
|
-
xs: { fontSize: Math.round(CELL_WIDTH.xs * 0.55) },
|
|
70
|
-
sm: { fontSize: Math.round(CELL_WIDTH.sm * 0.55) },
|
|
71
|
-
md: { fontSize: Math.round(CELL_WIDTH.md * 0.55) },
|
|
72
|
-
lg: { fontSize: Math.round(CELL_WIDTH.lg * 0.55) },
|
|
73
|
-
xl: { fontSize: Math.round(CELL_WIDTH.xl * 0.55) },
|
|
74
|
-
xxl: { fontSize: Math.round(CELL_WIDTH.xxl * 0.55) },
|
|
75
|
-
} as const;
|
|
76
|
-
|
|
77
39
|
// ── Shared context ────────────────────────────────────────────────────────────
|
|
78
40
|
// One `createStyledContext` carries `size` to every styled part so the leaf
|
|
79
41
|
// controls read the SAME size the consumer set on the root WITHOUT prop-drilling.
|
|
@@ -83,12 +45,12 @@ const CalendarHeaderContext = createStyledContext<{ size: CalendarSize }>({ size
|
|
|
83
45
|
|
|
84
46
|
/** The header bar — a flex row; level control flexes to fill between prev/next. */
|
|
85
47
|
const CalendarHeaderFrame = styled(Box, {
|
|
86
|
-
|
|
48
|
+
displayName: "CalendarHeader",
|
|
87
49
|
context: CalendarHeaderContext,
|
|
88
50
|
flexDirection: "row",
|
|
89
51
|
alignItems: "center",
|
|
90
52
|
justifyContent: "space-between",
|
|
91
|
-
marginBottom: "
|
|
53
|
+
marginBottom: "xs",
|
|
92
54
|
|
|
93
55
|
variants: {
|
|
94
56
|
/** Header (and its level control) stretch to the full width of the container. */
|
|
@@ -102,30 +64,27 @@ const CalendarHeaderFrame = styled(Box, {
|
|
|
102
64
|
const headerControlBase = {
|
|
103
65
|
alignItems: "center",
|
|
104
66
|
justifyContent: "center",
|
|
105
|
-
borderRadius: "
|
|
106
|
-
backgroundColor: "transparent",
|
|
107
|
-
|
|
108
|
-
hoverStyle: { backgroundColor: "$color2" },
|
|
109
|
-
pressStyle: { backgroundColor: "$color3" },
|
|
67
|
+
borderRadius: "sm",
|
|
68
|
+
backgroundColor: "transparent hover:color2 press:color3",
|
|
69
|
+
cursor: "web:pointer",
|
|
110
70
|
} as const;
|
|
111
71
|
|
|
112
72
|
/** Prev/next square control — chevron button. */
|
|
113
73
|
const CalendarHeaderControl = styled(UnstyledButton.Frame, {
|
|
114
|
-
|
|
74
|
+
displayName: "CalendarHeaderControl",
|
|
115
75
|
context: CalendarHeaderContext,
|
|
116
76
|
...headerControlBase,
|
|
117
77
|
|
|
118
78
|
variants: {
|
|
119
|
-
size:
|
|
79
|
+
size: cellSquareVariant,
|
|
120
80
|
|
|
121
81
|
/** Disabled control — strongly dimmed, non-interactive (Mantine parity: 0.2). */
|
|
122
82
|
disabled: {
|
|
123
83
|
true: {
|
|
124
84
|
opacity: 0.2,
|
|
125
85
|
pointerEvents: "none",
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
pressStyle: { backgroundColor: "transparent" },
|
|
86
|
+
cursor: "web:not-allowed",
|
|
87
|
+
backgroundColor: "hover:transparent press:transparent",
|
|
129
88
|
},
|
|
130
89
|
},
|
|
131
90
|
} as const,
|
|
@@ -135,20 +94,19 @@ const CalendarHeaderControl = styled(UnstyledButton.Frame, {
|
|
|
135
94
|
|
|
136
95
|
/** Level (label) control — flexes to fill, switches to a static `div` at the top level. */
|
|
137
96
|
const CalendarHeaderLevel = styled(UnstyledButton.Frame, {
|
|
138
|
-
|
|
97
|
+
displayName: "CalendarHeaderLevel",
|
|
139
98
|
context: CalendarHeaderContext,
|
|
140
99
|
...headerControlBase,
|
|
141
100
|
flex: 1,
|
|
142
101
|
|
|
143
102
|
variants: {
|
|
144
|
-
size:
|
|
103
|
+
size: cellHeightVariant,
|
|
145
104
|
|
|
146
105
|
/** Non-interactive display label (top level) — default cursor, no hover. */
|
|
147
106
|
static: {
|
|
148
107
|
true: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
pressStyle: { backgroundColor: "transparent" },
|
|
108
|
+
cursor: "web:default",
|
|
109
|
+
backgroundColor: "hover:transparent press:transparent",
|
|
152
110
|
},
|
|
153
111
|
},
|
|
154
112
|
|
|
@@ -156,9 +114,8 @@ const CalendarHeaderLevel = styled(UnstyledButton.Frame, {
|
|
|
156
114
|
disabled: {
|
|
157
115
|
true: {
|
|
158
116
|
opacity: 0.2,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
pressStyle: { backgroundColor: "transparent" },
|
|
117
|
+
cursor: "web:not-allowed",
|
|
118
|
+
backgroundColor: "hover:transparent press:transparent",
|
|
162
119
|
},
|
|
163
120
|
},
|
|
164
121
|
} as const,
|
|
@@ -168,15 +125,15 @@ const CalendarHeaderLevel = styled(UnstyledButton.Frame, {
|
|
|
168
125
|
|
|
169
126
|
/** Level label text — capitalized, shares `size` via context. */
|
|
170
127
|
const CalendarHeaderLevelLabel = styled(Text, {
|
|
171
|
-
|
|
128
|
+
displayName: "CalendarHeaderLevelLabel",
|
|
172
129
|
context: CalendarHeaderContext,
|
|
173
|
-
color: "
|
|
130
|
+
color: "color",
|
|
174
131
|
fontWeight: "500",
|
|
175
132
|
textTransform: "capitalize",
|
|
176
133
|
userSelect: "none",
|
|
177
134
|
|
|
178
135
|
variants: {
|
|
179
|
-
size:
|
|
136
|
+
size: headerFontVariant,
|
|
180
137
|
} as const,
|
|
181
138
|
|
|
182
139
|
defaultVariants: { size: "md" },
|
|
@@ -184,9 +141,9 @@ const CalendarHeaderLevelLabel = styled(Text, {
|
|
|
184
141
|
|
|
185
142
|
/** Default chevron glyph — shares `size` via context. */
|
|
186
143
|
const CalendarHeaderIcon = styled(Text, {
|
|
187
|
-
|
|
144
|
+
displayName: "CalendarHeaderControlIcon",
|
|
188
145
|
context: CalendarHeaderContext,
|
|
189
|
-
color: "
|
|
146
|
+
color: "color",
|
|
190
147
|
userSelect: "none",
|
|
191
148
|
|
|
192
149
|
variants: {
|
|
@@ -309,9 +266,9 @@ export interface CalendarHeaderProps
|
|
|
309
266
|
* `hasNextLevel` is true, and a static, dimmed `div` at the topmost level.
|
|
310
267
|
* `__preventFocus` is ported via `onPressIn` + a cross-platform `preventDefault`
|
|
311
268
|
* guard, NOT a DOM `onMouseDown` handler. Forwards its ref + style props to the
|
|
312
|
-
* root via
|
|
269
|
+
* root via `styleable()`.
|
|
313
270
|
*
|
|
314
|
-
* Per-slot style sugar: `styles={{ control: { borderRadius: "
|
|
271
|
+
* Per-slot style sugar: `styles={{ control: { borderRadius: "lg" } }}` spreads
|
|
315
272
|
* onto the matching part; precedence is fixed (`defaults < styles[slot]`).
|
|
316
273
|
*
|
|
317
274
|
* a11y: prev/next/level each expose their `aria-label`s and `aria-disabled`;
|
|
@@ -325,7 +282,8 @@ export interface CalendarHeaderProps
|
|
|
325
282
|
* onLevelClick={zoomOut}
|
|
326
283
|
* />
|
|
327
284
|
*/
|
|
328
|
-
const CalendarHeaderComponent =
|
|
285
|
+
const CalendarHeaderComponent = styleable<CalendarHeaderProps>(
|
|
286
|
+
CalendarHeaderFrame,
|
|
329
287
|
function CalendarHeader(props, ref) {
|
|
330
288
|
const {
|
|
331
289
|
__preventFocus,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// subtree — never a dynamic `opacity`/`display` style prop (15). The `<Type>`
|
|
25
25
|
// generic is preserved through `forwardRef` (which would otherwise pin it at
|
|
26
26
|
// `"default"`), so the ref is forwarded via a typed `forwardRef` rather than
|
|
27
|
-
//
|
|
27
|
+
// `styleable()` (13) — the documented sibling-picker pattern.
|
|
28
28
|
// ───────────────────────────────────────────────────────────────────────────
|
|
29
29
|
import * as React from "react";
|
|
30
30
|
import { useRef } from "react";
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// dropdown subtree `PickerInputBase` owns — never a dynamic `opacity`/`display`
|
|
34
34
|
// style prop (15). The `<Type>` generic is preserved through `forwardRef` (which
|
|
35
35
|
// would otherwise pin it at `"default"`), so the ref is forwarded via a typed
|
|
36
|
-
// `forwardRef` rather than
|
|
36
|
+
// `forwardRef` rather than `styleable()` (13) — the documented sibling-picker
|
|
37
37
|
// pattern (`DatePicker` / `MonthPickerInput` / `YearPickerInput`).
|
|
38
38
|
// ───────────────────────────────────────────────────────────────────────────
|
|
39
39
|
import * as React from "react";
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// dropdown subtree + the `dropdownOpened` boolean — never a dynamic
|
|
29
29
|
// `opacity`/`display` style prop (15). The `<Type>` generic is preserved through
|
|
30
30
|
// `forwardRef` (which would otherwise pin it at `"default"`), so the ref is
|
|
31
|
-
// forwarded via a typed `forwardRef` rather than
|
|
31
|
+
// forwarded via a typed `forwardRef` rather than `styleable()` (13) — the
|
|
32
32
|
// documented sibling-picker pattern.
|
|
33
33
|
// ───────────────────────────────────────────────────────────────────────────
|
|
34
34
|
import * as React from "react";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// gold-standard checklist points are N/A here by design: there is no styled
|
|
10
10
|
// Frame or leaf part (#5), shared `createStyledContext` size axis (#2), derived
|
|
11
11
|
// `cell-metrics` sizing (#3), theme-ramp colors (#4), marker slots (#6), per-slot
|
|
12
|
-
// `styles` sugar (#7), date bounds (#10), interaction styling (#12),
|
|
12
|
+
// `styles` sugar (#7), date bounds (#10), interaction styling (#12), `styleable()`
|
|
13
13
|
// wrapper (#13), `withStaticProperties` parts (#14), or compiler-safe style
|
|
14
14
|
// pitfall (#15). What DOES apply — and is honored — is: documented provenance +
|
|
15
15
|
// cross-platform stance (#1), correct settings-context propagation with
|
package/src/Day/Day.tsx
CHANGED
|
@@ -3,12 +3,18 @@ import * as React from "react";
|
|
|
3
3
|
import dayjs, { type Dayjs } from "dayjs";
|
|
4
4
|
|
|
5
5
|
import { Text, UnstyledButton } from "@knitui/components";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
createStyledContext,
|
|
8
|
+
type GetProps,
|
|
9
|
+
styleable,
|
|
10
|
+
styled,
|
|
11
|
+
withStaticProperties,
|
|
12
|
+
} from "@knitui/core";
|
|
13
|
+
|
|
14
|
+
import { type CalendarSize, cellFontVariant, cellSquareVariant } from "../cell-metrics";
|
|
9
15
|
import { DatesProviderContext } from "../DatesProvider";
|
|
10
16
|
import { controlA11yProps } from "../internal/a11y";
|
|
11
|
-
import {
|
|
17
|
+
import { isCanonicalDateString } from "../internal/date-string-fast-path";
|
|
12
18
|
import type { DateStringValue } from "../types";
|
|
13
19
|
|
|
14
20
|
/** Day cell size — the kit's shared control size scale. */
|
|
@@ -29,41 +35,24 @@ export type RenderDay = (date: DateStringValue) => React.ReactNode;
|
|
|
29
35
|
// an UNCONSTRAINED parent (no calendar height set) resolves that percentage to
|
|
30
36
|
// "auto" and the cell would otherwise collapse to its label's line-height — the
|
|
31
37
|
// `minHeight` keeps it at the square size in that case.
|
|
32
|
-
const daySizeVariant = {
|
|
33
|
-
xxs: { width: CELL_WIDTH.xxs, height: CELL_WIDTH.xxs, minHeight: CELL_WIDTH.xxs },
|
|
34
|
-
xs: { width: CELL_WIDTH.xs, height: CELL_WIDTH.xs, minHeight: CELL_WIDTH.xs },
|
|
35
|
-
sm: { width: CELL_WIDTH.sm, height: CELL_WIDTH.sm, minHeight: CELL_WIDTH.sm },
|
|
36
|
-
md: { width: CELL_WIDTH.md, height: CELL_WIDTH.md, minHeight: CELL_WIDTH.md },
|
|
37
|
-
lg: { width: CELL_WIDTH.lg, height: CELL_WIDTH.lg, minHeight: CELL_WIDTH.lg },
|
|
38
|
-
xl: { width: CELL_WIDTH.xl, height: CELL_WIDTH.xl, minHeight: CELL_WIDTH.xl },
|
|
39
|
-
xxl: { width: CELL_WIDTH.xxl, height: CELL_WIDTH.xxl, minHeight: CELL_WIDTH.xxl },
|
|
40
|
-
} as const;
|
|
41
|
-
|
|
42
|
-
const dayFontVariant = {
|
|
43
|
-
xxs: { fontSize: CELL_FONT.xxs },
|
|
44
|
-
xs: { fontSize: CELL_FONT.xs },
|
|
45
|
-
sm: { fontSize: CELL_FONT.sm },
|
|
46
|
-
md: { fontSize: CELL_FONT.md },
|
|
47
|
-
lg: { fontSize: CELL_FONT.lg },
|
|
48
|
-
xl: { fontSize: CELL_FONT.xl },
|
|
49
|
-
xxl: { fontSize: CELL_FONT.xxl },
|
|
50
|
-
} as const;
|
|
51
|
-
|
|
52
38
|
const DayContext = createStyledContext<{ size: DaySize }>({ size: "md" });
|
|
53
39
|
|
|
54
40
|
/**
|
|
55
|
-
* Whether `
|
|
56
|
-
* allocating a single
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* dayjs instance wrapping it, and two more clones for dayjs' internal
|
|
60
|
-
* `startOf`/`endOf` bracket, i.e. ~4 allocations PER CELL (×42 cells, every
|
|
61
|
-
* render). Reading the three calendar fields off the instance we already have
|
|
62
|
-
* is exact (`year`/`month`/`date` are plain field reads, no clone) and costs
|
|
63
|
-
* only the one `Date` for "now".
|
|
41
|
+
* Whether `date` falls on today's LOCAL calendar date, compared without
|
|
42
|
+
* allocating a single dayjs instance: a canonical `YYYY-MM-DD` string is
|
|
43
|
+
* compared field-by-field against `new Date()`; anything else falls back to
|
|
44
|
+
* the parsed instance's plain field reads (`year`/`month`/`date`, no clone).
|
|
64
45
|
*/
|
|
65
|
-
function isSameDayAsToday(
|
|
46
|
+
function isSameDayAsToday(date: DateStringValue, parse: () => Dayjs): boolean {
|
|
66
47
|
const now = new Date();
|
|
48
|
+
if (isCanonicalDateString(date)) {
|
|
49
|
+
return (
|
|
50
|
+
Number(date.slice(8, 10)) === now.getDate() &&
|
|
51
|
+
Number(date.slice(5, 7)) === now.getMonth() + 1 &&
|
|
52
|
+
Number(date.slice(0, 4)) === now.getFullYear()
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
const day = parse();
|
|
67
56
|
return (
|
|
68
57
|
day.date() === now.getDate() &&
|
|
69
58
|
day.month() === now.getMonth() &&
|
|
@@ -71,36 +60,38 @@ function isSameDayAsToday(day: Dayjs): boolean {
|
|
|
71
60
|
);
|
|
72
61
|
}
|
|
73
62
|
|
|
63
|
+
/** `type="button"` for the interactive host — one frozen object, not one per cell render. */
|
|
64
|
+
const BUTTON_TYPE: { type: string } = Object.freeze({ type: "button" });
|
|
65
|
+
|
|
74
66
|
/**
|
|
75
67
|
* The atomic calendar cell — an `UnstyledButton`-based control composed via
|
|
76
68
|
* `styled`. Accent comes from the active theme's palette ramp via the `theme`
|
|
77
|
-
* prop (no Mantine `color` prop): a selected day fills with
|
|
78
|
-
* text; in-range days take a
|
|
69
|
+
* prop (no Mantine `color` prop): a selected day fills with `color9`/`color1`
|
|
70
|
+
* text; in-range days take a `color4` tint with the range edges rounded by the
|
|
79
71
|
* `firstInRange`/`lastInRange` corner variants (the `inRange` base squares all
|
|
80
72
|
* four corners, the edge variants round their own two — so a single-day range
|
|
81
|
-
* gets all four back). States use `
|
|
73
|
+
* gets all four back). States use `hover:`/`press:` clauses + a `disabled`
|
|
82
74
|
* variant, never a runtime hover flag or a `Pressable`.
|
|
83
75
|
*
|
|
84
|
-
* Variant precedence
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* on background.
|
|
76
|
+
* Variant precedence: Tamagui v3 applies active variants in the order the
|
|
77
|
+
* props are PASSED (later wins), not in declaration order — so the `Day`
|
|
78
|
+
* wrapper passes `inRange` before `firstInRange`/`lastInRange` (the edges win
|
|
79
|
+
* on radius) and `selected` last (a selected endpoint wins on background). A
|
|
80
|
+
* consumer composing `Day.Frame` directly must keep the same prop order.
|
|
88
81
|
*/
|
|
89
82
|
const DayFrame = styled(UnstyledButton.Frame, {
|
|
90
|
-
|
|
83
|
+
displayName: "Day",
|
|
91
84
|
context: DayContext,
|
|
92
85
|
alignItems: "center",
|
|
93
86
|
justifyContent: "center",
|
|
94
87
|
borderWidth: 0,
|
|
95
88
|
borderColor: "transparent",
|
|
96
|
-
borderRadius: "
|
|
97
|
-
backgroundColor: "transparent",
|
|
98
|
-
|
|
99
|
-
hoverStyle: { backgroundColor: "$color2" },
|
|
100
|
-
pressStyle: { backgroundColor: "$color3" },
|
|
89
|
+
borderRadius: "sm",
|
|
90
|
+
backgroundColor: "transparent hover:color2 press:color3",
|
|
91
|
+
cursor: "web:pointer",
|
|
101
92
|
|
|
102
93
|
variants: {
|
|
103
|
-
size:
|
|
94
|
+
size: cellSquareVariant,
|
|
104
95
|
|
|
105
96
|
/**
|
|
106
97
|
* Day fills its grid cell in BOTH axes. `width: "100%"` stretches it across
|
|
@@ -126,34 +117,30 @@ const DayFrame = styled(UnstyledButton.Frame, {
|
|
|
126
117
|
/** Day within a selected range — tinted background, squared corners. */
|
|
127
118
|
inRange: {
|
|
128
119
|
true: {
|
|
129
|
-
backgroundColor: "
|
|
120
|
+
backgroundColor: "color4 hover:color5 press:color5",
|
|
130
121
|
borderRadius: 0,
|
|
131
|
-
hoverStyle: { backgroundColor: "$color5" },
|
|
132
|
-
pressStyle: { backgroundColor: "$color5" },
|
|
133
122
|
},
|
|
134
123
|
},
|
|
135
124
|
|
|
136
125
|
/** First day of a range — round the inline-start corners. */
|
|
137
126
|
firstInRange: {
|
|
138
|
-
true: { borderTopLeftRadius: "
|
|
127
|
+
true: { borderTopLeftRadius: "sm", borderBottomLeftRadius: "sm" },
|
|
139
128
|
},
|
|
140
129
|
|
|
141
130
|
/** Last day of a range — round the inline-end corners. */
|
|
142
131
|
lastInRange: {
|
|
143
|
-
true: { borderTopRightRadius: "
|
|
132
|
+
true: { borderTopRightRadius: "sm", borderBottomRightRadius: "sm" },
|
|
144
133
|
},
|
|
145
134
|
|
|
146
135
|
/** Today's border highlight (only when not selected / in range). */
|
|
147
136
|
today: {
|
|
148
|
-
true: { borderWidth: 1, borderColor: "
|
|
137
|
+
true: { borderWidth: 1, borderColor: "color7" },
|
|
149
138
|
},
|
|
150
139
|
|
|
151
140
|
/** Selected day — solid accent fill. */
|
|
152
141
|
selected: {
|
|
153
142
|
true: {
|
|
154
|
-
backgroundColor: "
|
|
155
|
-
hoverStyle: { backgroundColor: "$color10" },
|
|
156
|
-
pressStyle: { backgroundColor: "$color8" },
|
|
143
|
+
backgroundColor: "color9 hover:color10 press:color8",
|
|
157
144
|
},
|
|
158
145
|
},
|
|
159
146
|
|
|
@@ -167,7 +154,7 @@ const DayFrame = styled(UnstyledButton.Frame, {
|
|
|
167
154
|
true: {
|
|
168
155
|
opacity: 0.5,
|
|
169
156
|
pointerEvents: "none",
|
|
170
|
-
|
|
157
|
+
cursor: "web:not-allowed",
|
|
171
158
|
},
|
|
172
159
|
},
|
|
173
160
|
|
|
@@ -175,9 +162,8 @@ const DayFrame = styled(UnstyledButton.Frame, {
|
|
|
175
162
|
static: {
|
|
176
163
|
true: {
|
|
177
164
|
userSelect: "auto",
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
pressStyle: { backgroundColor: "transparent" },
|
|
165
|
+
cursor: "web:default",
|
|
166
|
+
backgroundColor: "hover:transparent press:transparent",
|
|
181
167
|
},
|
|
182
168
|
},
|
|
183
169
|
} as const,
|
|
@@ -189,31 +175,32 @@ const DayFrame = styled(UnstyledButton.Frame, {
|
|
|
189
175
|
* The day-of-month label — shares `size` via context.
|
|
190
176
|
*
|
|
191
177
|
* Colour is expressed as boolean VARIANTS, never a per-render dynamic `color`
|
|
192
|
-
* style prop: the idle label is the neutral
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* the contrast colour (
|
|
178
|
+
* style prop: the idle label is the neutral `color`, a `weekend` label flips to
|
|
179
|
+
* `red9`, and on the solid accent fill a `selected` label flips to the contrast
|
|
180
|
+
* `color1`. `selected` is declared after `weekend` so a selected weekend takes
|
|
181
|
+
* the contrast colour (v3 applies variants in prop order — later wins — and the
|
|
182
|
+
* wrapper passes `selected` after `weekend`,
|
|
196
183
|
* mirroring `DayFrame`). Keeping colour in variants — not a runtime ternary —
|
|
197
184
|
* keeps the cell compiler-safe (no dynamic style prop for the optimiser to fold).
|
|
198
185
|
*/
|
|
199
186
|
const DayLabel = styled(Text, {
|
|
200
|
-
|
|
187
|
+
displayName: "DayLabel",
|
|
201
188
|
context: DayContext,
|
|
202
189
|
userSelect: "none",
|
|
203
|
-
color: "
|
|
190
|
+
color: "color",
|
|
204
191
|
variants: {
|
|
205
192
|
size: {
|
|
206
|
-
...
|
|
193
|
+
...cellFontVariant,
|
|
207
194
|
},
|
|
208
195
|
|
|
209
196
|
/** Weekend day — accent-error text colour. */
|
|
210
197
|
weekend: {
|
|
211
|
-
true: { color: "
|
|
198
|
+
true: { color: "red9" },
|
|
212
199
|
},
|
|
213
200
|
|
|
214
201
|
/** Selected day — contrast text on the solid accent fill. */
|
|
215
202
|
selected: {
|
|
216
|
-
true: { color: "
|
|
203
|
+
true: { color: "color1" },
|
|
217
204
|
},
|
|
218
205
|
} as const,
|
|
219
206
|
});
|
|
@@ -281,7 +268,7 @@ export interface DayProps extends Omit<
|
|
|
281
268
|
locale?: string;
|
|
282
269
|
}
|
|
283
270
|
|
|
284
|
-
const DayComponent =
|
|
271
|
+
const DayComponent = styleable<DayProps>(DayFrame, function Day(props, ref) {
|
|
285
272
|
const {
|
|
286
273
|
date,
|
|
287
274
|
size = "md",
|
|
@@ -311,11 +298,17 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
|
|
|
311
298
|
// (`getLocale = (input) => input || ctx.locale`), so a standalone `<Day>`
|
|
312
299
|
// resolves its locale exactly as before.
|
|
313
300
|
const ctx = React.useContext(DatesProviderContext);
|
|
314
|
-
|
|
301
|
+
|
|
302
|
+
// dayjs is parsed LAZILY and at most once: the grid path (`Month` passes an
|
|
303
|
+
// explicit `aria-label`, a canonical `YYYY-MM-DD` date and no `renderDay`)
|
|
304
|
+
// never needs an instance at all — the day-of-month is the string's last two
|
|
305
|
+
// digits — so 42 cells × every render allocate no dayjs/Date for content.
|
|
306
|
+
let parsed: Dayjs | undefined;
|
|
307
|
+
const parse = (): Dayjs => (parsed ??= dayjs(date));
|
|
315
308
|
|
|
316
309
|
// Only the `highlightToday` border consults "is this today", so the comparison
|
|
317
310
|
// is skipped entirely when the border is off (the default).
|
|
318
|
-
const isToday = highlightToday && isSameDayAsToday(
|
|
311
|
+
const isToday = highlightToday && isSameDayAsToday(date, parse);
|
|
319
312
|
|
|
320
313
|
// Locale-aware default label, read from `DatesProvider`. A static (display-only)
|
|
321
314
|
// day announces nothing — it is not an interactive date.
|
|
@@ -331,7 +324,10 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
|
|
|
331
324
|
const explicitAriaLabel = props["aria-label"];
|
|
332
325
|
const ariaLabel = isStatic
|
|
333
326
|
? undefined
|
|
334
|
-
: (explicitAriaLabel ??
|
|
327
|
+
: (explicitAriaLabel ??
|
|
328
|
+
parse()
|
|
329
|
+
.locale(locale || ctx.locale)
|
|
330
|
+
.format("D MMMM YYYY"));
|
|
335
331
|
|
|
336
332
|
// Mirror Mantine's data-attribute gating: a disabled day shows none of the
|
|
337
333
|
// selection/range/weekend/outside styling, and today's border is suppressed
|
|
@@ -344,14 +340,13 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
|
|
|
344
340
|
const isLastInRange = !disabled && lastInRange;
|
|
345
341
|
const showToday = isToday && highlightToday && !isSelected && !isInRange && !disabled;
|
|
346
342
|
|
|
347
|
-
const content = renderDay
|
|
343
|
+
const content = renderDay
|
|
344
|
+
? renderDay(date)
|
|
345
|
+
: isCanonicalDateString(date)
|
|
346
|
+
? Number(date.slice(8, 10))
|
|
347
|
+
: parse().date();
|
|
348
348
|
const isTextContent = typeof content === "string" || typeof content === "number";
|
|
349
349
|
|
|
350
|
-
// `type` is a runtime-only `<button>` attribute outside Tamagui's style types;
|
|
351
|
-
// narrow via a precise local object (spread → no excess-prop check). Only on
|
|
352
|
-
// the interactive (button) host, not the static `div`.
|
|
353
|
-
const elementProps: { type: string } = { type: "button" };
|
|
354
|
-
|
|
355
350
|
return (
|
|
356
351
|
<DayFrame
|
|
357
352
|
ref={ref}
|
|
@@ -359,11 +354,16 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
|
|
|
359
354
|
static={isStatic}
|
|
360
355
|
weekend={isWeekend}
|
|
361
356
|
outside={isOutside}
|
|
362
|
-
|
|
357
|
+
// v3 applies active variants in PROP ORDER at the call site (not in the
|
|
358
|
+
// order they are declared in `variants`), so this order IS the precedence:
|
|
359
|
+
// `inRange` squares the corners, the edge flags round their own two after
|
|
360
|
+
// it, and `selected` comes last so a selected range endpoint keeps the
|
|
361
|
+
// solid accent over the in-range tint.
|
|
363
362
|
inRange={isInRange}
|
|
364
363
|
firstInRange={isFirstInRange}
|
|
365
364
|
lastInRange={isLastInRange}
|
|
366
365
|
today={showToday}
|
|
366
|
+
selected={isSelected}
|
|
367
367
|
hidden={hidden}
|
|
368
368
|
fullWidth={fullWidth}
|
|
369
369
|
disabled={disabled}
|
|
@@ -381,7 +381,10 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
|
|
|
381
381
|
disabled,
|
|
382
382
|
})}
|
|
383
383
|
render={isStatic ? "div" : "button"}
|
|
384
|
-
|
|
384
|
+
// `type` is a runtime-only `<button>` attribute outside Tamagui's style
|
|
385
|
+
// types; spread from a frozen module constant (no excess-prop check, no
|
|
386
|
+
// per-render object). Only on the interactive (button) host.
|
|
387
|
+
{...(isStatic ? null : BUTTON_TYPE)}
|
|
385
388
|
{...rest}
|
|
386
389
|
>
|
|
387
390
|
{isTextContent ? (
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// (#11/#12) to `YearsList`/`PickerControl`. The numbered rules in
|
|
17
17
|
// `_reference/README.md` that apply here: #1 (this header), #2 (shared size
|
|
18
18
|
// context), #7 (`styles` sugar + `getYearControlProps` passthrough), #9 (locale),
|
|
19
|
-
// #10 (min/max bounds), #11 (delegated a11y), #13 (
|
|
19
|
+
// #10 (min/max bounds), #11 (delegated a11y), #13 (`styleable()` + typed ref),
|
|
20
20
|
// #14 (`withStaticProperties`), #15 (no dynamic hide styles — none used here).
|
|
21
21
|
// ───────────────────────────────────────────────────────────────────────────
|
|
22
22
|
import * as React from "react";
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
type GetProps,
|
|
30
30
|
slotStyles,
|
|
31
31
|
type SlotStyles,
|
|
32
|
+
styleable,
|
|
32
33
|
styled,
|
|
33
34
|
withStaticProperties,
|
|
34
35
|
} from "@knitui/core";
|
|
@@ -63,10 +64,10 @@ const DecadeLevelContext = createStyledContext<{ size: CalendarSize }>({ size: "
|
|
|
63
64
|
|
|
64
65
|
// ── 5/13. Styled root ───────────────────────────────────────────────────────
|
|
65
66
|
// The level root is a styled `Box` column (the dates norm: a real styled part so
|
|
66
|
-
//
|
|
67
|
+
// `styleable()` can forward a ref + style props onto it). It establishes the
|
|
67
68
|
// shared `size` context; the header and grid own the `size` variant themselves.
|
|
68
69
|
const DecadeLevelFrame = styled(Box, {
|
|
69
|
-
|
|
70
|
+
displayName: "DecadeLevel",
|
|
70
71
|
context: DecadeLevelContext,
|
|
71
72
|
flexDirection: "column",
|
|
72
73
|
|
|
@@ -152,7 +153,7 @@ export interface DecadeLevelProps extends DecadeLevelFrameProps, DecadeLevelSett
|
|
|
152
153
|
* `DatesProvider` locale. All `__onControl*` / `__getControlRef` / `__preventFocus`
|
|
153
154
|
* / `__stopPropagation` plumbing is forwarded straight to the `YearsList`.
|
|
154
155
|
*
|
|
155
|
-
* Per-slot style sugar: `styles={{ headerControl: { borderRadius: "
|
|
156
|
+
* Per-slot style sugar: `styles={{ headerControl: { borderRadius: "lg" } }}` routes
|
|
156
157
|
* onto the matching part; per-cell tuning stays on `getYearControlProps(date)`.
|
|
157
158
|
* a11y/interaction/sizing for the cells are delegated to `YearsList`/`PickerControl`
|
|
158
159
|
* and the header to `CalendarHeader`. Forwards its ref + style props to the root.
|
|
@@ -160,7 +161,8 @@ export interface DecadeLevelProps extends DecadeLevelFrameProps, DecadeLevelSett
|
|
|
160
161
|
* @example
|
|
161
162
|
* <DecadeLevel decade="2024-01-01" onNext={nextDecade} onPrevious={prevDecade} />
|
|
162
163
|
*/
|
|
163
|
-
const DecadeLevelComponent =
|
|
164
|
+
const DecadeLevelComponent = styleable<DecadeLevelProps>(
|
|
165
|
+
DecadeLevelFrame,
|
|
164
166
|
function DecadeLevel(props, ref) {
|
|
165
167
|
const {
|
|
166
168
|
// YearsList settings
|