@knitui/dates 0.14.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
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
// labelled `TimePicker` segments, and the submit `ActionIcon`.
|
|
38
38
|
// 13. The `<Type>` generic is preserved through `forwardRef` (which would
|
|
39
39
|
// otherwise pin it at `"default"`), so the ref is forwarded via a typed
|
|
40
|
-
// `forwardRef` rather than
|
|
40
|
+
// `forwardRef` rather than `styleable()` — the documented sibling-picker
|
|
41
41
|
// pattern (`DatePicker` / `DateTimePicker`).
|
|
42
42
|
// 14. The styled wrapper parts (`.TimeWrapper` / `.TimeInput` / `.SubmitButton`
|
|
43
43
|
// / `.RangeInfo`) are attached as static properties so consumers can
|
|
@@ -90,19 +90,26 @@ export type InlineDateTimePickerSubmitButtonProps = ActionIconProps;
|
|
|
90
90
|
// to land on — the calendar twin of Mantine's `timeWrapper` / `rangeInfo`
|
|
91
91
|
// class-name slots.
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* The root's `fullWidth` stretch, spread CONDITIONALLY: in v3 an explicit
|
|
95
|
+
* `width={undefined}` still claims the call-site slot and clears a slot/consumer
|
|
96
|
+
* width, so the prop is only present when it is on.
|
|
97
|
+
*/
|
|
98
|
+
const FULL_WIDTH = { width: "100%" } as const;
|
|
99
|
+
|
|
93
100
|
/** Row wrapping the time input(s) and the submit button. */
|
|
94
101
|
const InlineDateTimePickerTimeWrapper = styled(Box, {
|
|
95
|
-
|
|
102
|
+
displayName: "InlineDateTimePickerTimeWrapper",
|
|
96
103
|
flexDirection: "row",
|
|
97
104
|
alignItems: "center",
|
|
98
|
-
gap: "
|
|
99
|
-
marginTop: "
|
|
105
|
+
gap: "xs",
|
|
106
|
+
marginTop: "xs",
|
|
100
107
|
});
|
|
101
108
|
|
|
102
109
|
/** Read-only summary of the selected range (range mode only). */
|
|
103
110
|
const InlineDateTimePickerRangeInfo = styled(Text, {
|
|
104
|
-
|
|
105
|
-
marginTop: "
|
|
111
|
+
displayName: "InlineDateTimePickerRangeInfo",
|
|
112
|
+
marginTop: "xs",
|
|
106
113
|
});
|
|
107
114
|
|
|
108
115
|
/**
|
|
@@ -446,7 +453,7 @@ function InlineDateTimePickerInner<Type extends DatePickerType = "default">(
|
|
|
446
453
|
);
|
|
447
454
|
|
|
448
455
|
return (
|
|
449
|
-
<Box ref={ref}
|
|
456
|
+
<Box ref={ref} {...(_fullWidth ? FULL_WIDTH : null)} {...s.get("root")} {...others}>
|
|
450
457
|
<DatePicker
|
|
451
458
|
// `fullWidth` makes the calendar fill BOTH axes (its frame carries
|
|
452
459
|
// `flexGrow: 1`), so when the picker is given a height the calendar fills
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
// What this frame DOES carry: provenance header (#1); the `styled(Box)` root
|
|
26
26
|
// Frame (#5); the `fullWidth` stretch as a boolean VARIANT, not a dynamic style
|
|
27
27
|
// prop, which is the compiler-safe form (#15 — no `._o-0`-style dynamic flatten);
|
|
28
|
-
//
|
|
28
|
+
// `styleable()` ref + style-prop forwarding to the root (#13); the styled Frame
|
|
29
29
|
// exposed via `withStaticProperties` (#14). A11y (#11) is deliberately
|
|
30
30
|
// FORWARDABLE rather than baked: Mantine's `LevelsGroup` carries no role of its
|
|
31
31
|
// own, and the callers pass `role="group"` (see `DecadeLevelGroup`), so the role
|
|
32
32
|
// flows through unchanged via `{...rest}` and is not hard-coded here.
|
|
33
33
|
// ───────────────────────────────────────────────────────────────────────────
|
|
34
34
|
import { Box } from "@knitui/components";
|
|
35
|
-
import { type GetProps, styled, withStaticProperties } from "@knitui/core";
|
|
35
|
+
import { type GetProps, styleable, styled, withStaticProperties } from "@knitui/core";
|
|
36
36
|
|
|
37
37
|
import { type CalendarSize, CELL_SPACING } from "../cell-metrics";
|
|
38
38
|
|
|
@@ -44,7 +44,7 @@ import { type CalendarSize, CELL_SPACING } from "../cell-metrics";
|
|
|
44
44
|
* column to an equal share of the container).
|
|
45
45
|
*/
|
|
46
46
|
const LevelsGroupFrame = styled(Box, {
|
|
47
|
-
|
|
47
|
+
displayName: "LevelsGroup",
|
|
48
48
|
flexDirection: "row",
|
|
49
49
|
// A small fixed gap between adjacent level columns, matching the calendar's
|
|
50
50
|
// shared cell spacing so columns read as one calendar (Mantine uses a fixed
|
|
@@ -93,17 +93,17 @@ export interface LevelsGroupProps extends LevelsGroupFrameProps {
|
|
|
93
93
|
* <MonthLevel month="2024-02-01" />
|
|
94
94
|
* </LevelsGroup>
|
|
95
95
|
*/
|
|
96
|
-
const LevelsGroupComponent =
|
|
97
|
-
|
|
98
|
-
ref
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
void _size;
|
|
96
|
+
const LevelsGroupComponent = styleable<LevelsGroupProps>(
|
|
97
|
+
LevelsGroupFrame,
|
|
98
|
+
function LevelsGroup({ size: _size, ...rest }, ref) {
|
|
99
|
+
// `size` is intentionally swallowed: the row layout does not depend on it,
|
|
100
|
+
// and forwarding it to the host would leak an unknown attribute. Levels are
|
|
101
|
+
// sized by their own `size` prop, set by the parent group.
|
|
102
|
+
void _size;
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
}
|
|
104
|
+
return <LevelsGroupFrame ref={ref} {...rest} />;
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
107
|
|
|
108
108
|
LevelsGroupComponent.displayName = "@knitui/dates/LevelsGroup";
|
|
109
109
|
|
|
@@ -31,15 +31,22 @@ import {
|
|
|
31
31
|
type GetProps,
|
|
32
32
|
slotStyles,
|
|
33
33
|
type SlotStyles,
|
|
34
|
+
styleable,
|
|
34
35
|
styled,
|
|
35
36
|
withStaticProperties,
|
|
36
37
|
} from "@knitui/core";
|
|
37
38
|
import { useUncontrolled } from "@knitui/hooks";
|
|
38
39
|
|
|
39
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
type CalendarSize,
|
|
42
|
+
CELL_FONT,
|
|
43
|
+
cellFontVariant,
|
|
44
|
+
cellMinWidthVariant,
|
|
45
|
+
cellSquareVariant,
|
|
46
|
+
iconFontVariant,
|
|
47
|
+
} from "../cell-metrics";
|
|
40
48
|
import { useDatesContext } from "../DatesProvider";
|
|
41
49
|
import { controlA11yProps } from "../internal/a11y";
|
|
42
|
-
import { webCursor } from "../internal/web-cursor";
|
|
43
50
|
import type { DateStringValue } from "../types";
|
|
44
51
|
import { isAfterMinDate, isBeforeMaxDate, toDateString } from "../utils";
|
|
45
52
|
|
|
@@ -55,39 +62,6 @@ const MiniCalendarContext = createStyledContext<{ size: CalendarSize }>({ size:
|
|
|
55
62
|
// retuning a ladder moves every grid component together. The raw values resolve
|
|
56
63
|
// at module-load — NOT `getTokenValue`, which needs the live config.
|
|
57
64
|
|
|
58
|
-
/** Square prev/next control size per `size`, from the shared `CELL_WIDTH` ladder. */
|
|
59
|
-
const controlSquareVariant = {
|
|
60
|
-
xxs: { width: CELL_WIDTH.xxs, height: CELL_WIDTH.xxs },
|
|
61
|
-
xs: { width: CELL_WIDTH.xs, height: CELL_WIDTH.xs },
|
|
62
|
-
sm: { width: CELL_WIDTH.sm, height: CELL_WIDTH.sm },
|
|
63
|
-
md: { width: CELL_WIDTH.md, height: CELL_WIDTH.md },
|
|
64
|
-
lg: { width: CELL_WIDTH.lg, height: CELL_WIDTH.lg },
|
|
65
|
-
xl: { width: CELL_WIDTH.xl, height: CELL_WIDTH.xl },
|
|
66
|
-
xxl: { width: CELL_WIDTH.xxl, height: CELL_WIDTH.xxl },
|
|
67
|
-
} as const;
|
|
68
|
-
|
|
69
|
-
/** Day-cell minimum width per `size` (taller than wide — two stacked labels). */
|
|
70
|
-
const dayWidthVariant = {
|
|
71
|
-
xxs: { minWidth: CELL_WIDTH.xxs },
|
|
72
|
-
xs: { minWidth: CELL_WIDTH.xs },
|
|
73
|
-
sm: { minWidth: CELL_WIDTH.sm },
|
|
74
|
-
md: { minWidth: CELL_WIDTH.md },
|
|
75
|
-
lg: { minWidth: CELL_WIDTH.lg },
|
|
76
|
-
xl: { minWidth: CELL_WIDTH.xl },
|
|
77
|
-
xxl: { minWidth: CELL_WIDTH.xxl },
|
|
78
|
-
} as const;
|
|
79
|
-
|
|
80
|
-
/** Day-number font per `size` (the shared cell-label ladder). */
|
|
81
|
-
const dayNumberFontVariant = {
|
|
82
|
-
xxs: { fontSize: CELL_FONT.xxs },
|
|
83
|
-
xs: { fontSize: CELL_FONT.xs },
|
|
84
|
-
sm: { fontSize: CELL_FONT.sm },
|
|
85
|
-
md: { fontSize: CELL_FONT.md },
|
|
86
|
-
lg: { fontSize: CELL_FONT.lg },
|
|
87
|
-
xl: { fontSize: CELL_FONT.xl },
|
|
88
|
-
xxl: { fontSize: CELL_FONT.xxl },
|
|
89
|
-
} as const;
|
|
90
|
-
|
|
91
65
|
/** Month-label font per `size` (≈ 72% of the day-number font). */
|
|
92
66
|
const monthFontVariant = {
|
|
93
67
|
xxs: { fontSize: Math.round(CELL_FONT.xxs * 0.72) },
|
|
@@ -99,51 +73,37 @@ const monthFontVariant = {
|
|
|
99
73
|
xxl: { fontSize: Math.round(CELL_FONT.xxl * 0.72) },
|
|
100
74
|
} as const;
|
|
101
75
|
|
|
102
|
-
/** Chevron glyph font per `size` (≈ 55% of the control size). */
|
|
103
|
-
const chevronFontVariant = {
|
|
104
|
-
xxs: { fontSize: Math.round(CELL_WIDTH.xxs * 0.55) },
|
|
105
|
-
xs: { fontSize: Math.round(CELL_WIDTH.xs * 0.55) },
|
|
106
|
-
sm: { fontSize: Math.round(CELL_WIDTH.sm * 0.55) },
|
|
107
|
-
md: { fontSize: Math.round(CELL_WIDTH.md * 0.55) },
|
|
108
|
-
lg: { fontSize: Math.round(CELL_WIDTH.lg * 0.55) },
|
|
109
|
-
xl: { fontSize: Math.round(CELL_WIDTH.xl * 0.55) },
|
|
110
|
-
xxl: { fontSize: Math.round(CELL_WIDTH.xxl * 0.55) },
|
|
111
|
-
} as const;
|
|
112
|
-
|
|
113
76
|
// ── Styled parts ────────────────────────────────────────────────────────────
|
|
114
77
|
|
|
115
78
|
/** The root row: prev control · day strip · next control. */
|
|
116
79
|
const MiniCalendarFrame = styled(Box, {
|
|
117
|
-
|
|
80
|
+
displayName: "MiniCalendar",
|
|
118
81
|
context: MiniCalendarContext,
|
|
119
82
|
flexDirection: "row",
|
|
120
83
|
alignItems: "center",
|
|
121
|
-
gap: "
|
|
84
|
+
gap: "xs",
|
|
122
85
|
});
|
|
123
86
|
|
|
124
87
|
/** Prev/next square control — chevron button. */
|
|
125
88
|
const MiniCalendarControl = styled(UnstyledButton.Frame, {
|
|
126
|
-
|
|
89
|
+
displayName: "MiniCalendarControl",
|
|
127
90
|
context: MiniCalendarContext,
|
|
128
91
|
alignItems: "center",
|
|
129
92
|
justifyContent: "center",
|
|
130
|
-
borderRadius: "
|
|
131
|
-
backgroundColor: "transparent",
|
|
132
|
-
|
|
133
|
-
hoverStyle: { backgroundColor: "$color2" },
|
|
134
|
-
pressStyle: { backgroundColor: "$color3" },
|
|
93
|
+
borderRadius: "sm",
|
|
94
|
+
backgroundColor: "transparent hover:color2 press:color3",
|
|
95
|
+
cursor: "web:pointer",
|
|
135
96
|
|
|
136
97
|
variants: {
|
|
137
|
-
size:
|
|
98
|
+
size: cellSquareVariant,
|
|
138
99
|
|
|
139
100
|
/** Disabled control — dimmed, non-interactive (Mantine parity: 0.3). */
|
|
140
101
|
disabled: {
|
|
141
102
|
true: {
|
|
142
103
|
opacity: 0.3,
|
|
143
104
|
pointerEvents: "none",
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
pressStyle: { backgroundColor: "transparent" },
|
|
105
|
+
cursor: "web:not-allowed",
|
|
106
|
+
backgroundColor: "hover:transparent press:transparent",
|
|
147
107
|
},
|
|
148
108
|
},
|
|
149
109
|
} as const,
|
|
@@ -153,17 +113,17 @@ const MiniCalendarControl = styled(UnstyledButton.Frame, {
|
|
|
153
113
|
|
|
154
114
|
/** The horizontal day strip wrapping the day buttons. */
|
|
155
115
|
const MiniCalendarDays = styled(Box, {
|
|
156
|
-
|
|
116
|
+
displayName: "MiniCalendarDays",
|
|
157
117
|
context: MiniCalendarContext,
|
|
158
118
|
flexDirection: "row",
|
|
159
119
|
alignItems: "stretch",
|
|
160
|
-
gap: "
|
|
120
|
+
gap: "xxs",
|
|
161
121
|
});
|
|
162
122
|
|
|
163
123
|
/**
|
|
164
124
|
* A single day button — month label stacked over the day-of-month number.
|
|
165
125
|
*
|
|
166
|
-
* 12. Interaction lives in real Tamagui pseudo-state (`
|
|
126
|
+
* 12. Interaction lives in real Tamagui pseudo-state (`hover:`/`press:` clauses)
|
|
167
127
|
* and a `disabled` variant (Mantine parity: 0.3 + non-interactive), never a
|
|
168
128
|
* runtime `onHoverIn` state machine.
|
|
169
129
|
* 15. The selected look is a boolean `selected` VARIANT (accent fill via the
|
|
@@ -171,29 +131,25 @@ const MiniCalendarDays = styled(Box, {
|
|
|
171
131
|
* the compiler can never extract a hide value onto the cell.
|
|
172
132
|
*/
|
|
173
133
|
const MiniCalendarDay = styled(UnstyledButton.Frame, {
|
|
174
|
-
|
|
134
|
+
displayName: "MiniCalendarDay",
|
|
175
135
|
context: MiniCalendarContext,
|
|
176
136
|
flexDirection: "column",
|
|
177
137
|
alignItems: "center",
|
|
178
138
|
justifyContent: "center",
|
|
179
139
|
gap: 2,
|
|
180
|
-
paddingVertical: "
|
|
181
|
-
paddingHorizontal: "
|
|
182
|
-
borderRadius: "
|
|
183
|
-
backgroundColor: "transparent",
|
|
184
|
-
|
|
185
|
-
hoverStyle: { backgroundColor: "$color2" },
|
|
186
|
-
pressStyle: { backgroundColor: "$color3" },
|
|
140
|
+
paddingVertical: "xs",
|
|
141
|
+
paddingHorizontal: "xxs",
|
|
142
|
+
borderRadius: "sm",
|
|
143
|
+
backgroundColor: "transparent hover:color2 press:color3",
|
|
144
|
+
cursor: "web:pointer",
|
|
187
145
|
|
|
188
146
|
variants: {
|
|
189
|
-
size:
|
|
147
|
+
size: cellMinWidthVariant,
|
|
190
148
|
|
|
191
|
-
/** Selected day — solid accent fill (the active theme's
|
|
149
|
+
/** Selected day — solid accent fill (the active theme's `color9`). */
|
|
192
150
|
selected: {
|
|
193
151
|
true: {
|
|
194
|
-
backgroundColor: "
|
|
195
|
-
hoverStyle: { backgroundColor: "$color10" },
|
|
196
|
-
pressStyle: { backgroundColor: "$color8" },
|
|
152
|
+
backgroundColor: "color9 hover:color10 press:color8",
|
|
197
153
|
},
|
|
198
154
|
},
|
|
199
155
|
|
|
@@ -202,9 +158,8 @@ const MiniCalendarDay = styled(UnstyledButton.Frame, {
|
|
|
202
158
|
true: {
|
|
203
159
|
opacity: 0.3,
|
|
204
160
|
pointerEvents: "none",
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
pressStyle: { backgroundColor: "transparent" },
|
|
161
|
+
cursor: "web:not-allowed",
|
|
162
|
+
backgroundColor: "hover:transparent press:transparent",
|
|
208
163
|
},
|
|
209
164
|
},
|
|
210
165
|
} as const,
|
|
@@ -216,7 +171,7 @@ const MiniCalendarDay = styled(UnstyledButton.Frame, {
|
|
|
216
171
|
* The small month label rendered above every day's number (Mantine parity:
|
|
217
172
|
* `.dayMonth` is always present, never toggled per-day). It's the regular
|
|
218
173
|
* foreground dimmed to `opacity: 0.65` (NOT an accent-tinted label), so it uses
|
|
219
|
-
* the neutral
|
|
174
|
+
* the neutral `color` ramp here — `color11` would paint it in the active
|
|
220
175
|
* theme's accent and is what made the label read as "differently coloured".
|
|
221
176
|
*
|
|
222
177
|
* 15. The 0.65 dim is a CONSTANT baked into the style, and the selected-state
|
|
@@ -227,42 +182,42 @@ const MiniCalendarDay = styled(UnstyledButton.Frame, {
|
|
|
227
182
|
* blanking the WHOLE cell (number included).
|
|
228
183
|
*/
|
|
229
184
|
const MiniCalendarDayMonth = styled(Text, {
|
|
230
|
-
|
|
185
|
+
displayName: "MiniCalendarDayMonth",
|
|
231
186
|
context: MiniCalendarContext,
|
|
232
187
|
userSelect: "none",
|
|
233
188
|
opacity: 0.65,
|
|
234
|
-
color: "
|
|
189
|
+
color: "color",
|
|
235
190
|
variants: {
|
|
236
191
|
size: monthFontVariant,
|
|
237
192
|
|
|
238
193
|
/** On a selected day's accent fill, the label flips to the contrast color. */
|
|
239
|
-
selected: { true: { color: "
|
|
194
|
+
selected: { true: { color: "color1" } },
|
|
240
195
|
} as const,
|
|
241
196
|
defaultVariants: { size: "md" },
|
|
242
197
|
});
|
|
243
198
|
|
|
244
199
|
/** The day-of-month number. */
|
|
245
200
|
const MiniCalendarDayNumber = styled(Text, {
|
|
246
|
-
|
|
201
|
+
displayName: "MiniCalendarDayNumber",
|
|
247
202
|
context: MiniCalendarContext,
|
|
248
203
|
userSelect: "none",
|
|
249
|
-
color: "
|
|
204
|
+
color: "color",
|
|
250
205
|
variants: {
|
|
251
|
-
size:
|
|
206
|
+
size: cellFontVariant,
|
|
252
207
|
|
|
253
208
|
/** On a selected day's accent fill, the number flips to the contrast color. */
|
|
254
|
-
selected: { true: { color: "
|
|
209
|
+
selected: { true: { color: "color1" } },
|
|
255
210
|
} as const,
|
|
256
211
|
defaultVariants: { size: "md" },
|
|
257
212
|
});
|
|
258
213
|
|
|
259
214
|
/** The default chevron glyph — shares `size` via context. */
|
|
260
215
|
const MiniCalendarChevron = styled(Text, {
|
|
261
|
-
|
|
216
|
+
displayName: "MiniCalendarChevron",
|
|
262
217
|
context: MiniCalendarContext,
|
|
263
218
|
userSelect: "none",
|
|
264
|
-
color: "
|
|
265
|
-
variants: { size:
|
|
219
|
+
color: "color",
|
|
220
|
+
variants: { size: iconFontVariant } as const,
|
|
266
221
|
defaultVariants: { size: "md" },
|
|
267
222
|
});
|
|
268
223
|
|
|
@@ -378,10 +333,10 @@ export interface MiniCalendarProps extends MiniCalendarFrameProps {
|
|
|
378
333
|
* uncontrolled via `useUncontrolled`); each day shows its month label above the
|
|
379
334
|
* day number. Accent on the selected day comes from the active Tamagui theme.
|
|
380
335
|
* Built from `Box` / `Text` / `UnstyledButton`; forwards its ref + style props to
|
|
381
|
-
* the root via
|
|
336
|
+
* the root via `styleable()`.
|
|
382
337
|
*
|
|
383
338
|
* Per-slot style sugar mirrors `@mantine/dates`' `styles`:
|
|
384
|
-
* `styles={{ day: { borderRadius: "
|
|
339
|
+
* `styles={{ day: { borderRadius: "lg" } }}` spreads onto the matching part;
|
|
385
340
|
* precedence is fixed (`defaults < styles[slot] < explicit props`).
|
|
386
341
|
*
|
|
387
342
|
* @example
|
|
@@ -391,7 +346,8 @@ export interface MiniCalendarProps extends MiniCalendarFrameProps {
|
|
|
391
346
|
* onChange={setValue}
|
|
392
347
|
* />
|
|
393
348
|
*/
|
|
394
|
-
const MiniCalendarComponent =
|
|
349
|
+
const MiniCalendarComponent = styleable<MiniCalendarProps>(
|
|
350
|
+
MiniCalendarFrame,
|
|
395
351
|
function MiniCalendar(props, ref) {
|
|
396
352
|
const {
|
|
397
353
|
date,
|
package/src/Month/Month.tsx
CHANGED
|
@@ -22,17 +22,24 @@ import { useMemo } from "react";
|
|
|
22
22
|
import dayjs from "dayjs";
|
|
23
23
|
|
|
24
24
|
import { Box, Text } from "@knitui/components";
|
|
25
|
+
import { hoverProps } from "@knitui/components/control-system";
|
|
25
26
|
import {
|
|
26
27
|
createStyledContext,
|
|
27
28
|
type GetProps,
|
|
28
29
|
slotStyles,
|
|
29
30
|
type SlotStyles,
|
|
31
|
+
styleable,
|
|
30
32
|
styled,
|
|
31
33
|
withStaticProperties,
|
|
32
34
|
} from "@knitui/core";
|
|
33
35
|
import { useCallbackRef } from "@knitui/hooks";
|
|
34
36
|
|
|
35
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
type CalendarSize,
|
|
39
|
+
CELL_SPACING,
|
|
40
|
+
cellFontVariant,
|
|
41
|
+
cellWidthVariant,
|
|
42
|
+
} from "../cell-metrics";
|
|
36
43
|
import { useDatesContext } from "../DatesProvider";
|
|
37
44
|
import { Day, type DayProps, type RenderDay } from "../Day";
|
|
38
45
|
import { areCellPropsEqual } from "../internal/are-cell-props-equal";
|
|
@@ -198,12 +205,9 @@ const MonthDayCell = React.memo(function MonthDayCell({
|
|
|
198
205
|
onDayKeyDown,
|
|
199
206
|
getDayRef,
|
|
200
207
|
}: MonthDayCellProps) {
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
const hoverHandlers: { onHoverIn?: (event: unknown) => void } = {
|
|
205
|
-
onHoverIn: (event) => onDayMouseEnter(event, date),
|
|
206
|
-
};
|
|
208
|
+
// Range hover preview. `hoverProps` maps to `onMouseEnter` on web (v3 wires no
|
|
209
|
+
// listener for `onHoverIn` alone) and keeps `onHoverIn` on native.
|
|
210
|
+
const hoverHandlers = hoverProps({ onHoverIn: (event) => onDayMouseEnter(event, date) });
|
|
207
211
|
|
|
208
212
|
return (
|
|
209
213
|
<MonthCell role="cell" fullWidth={fullWidth} {...cellProps}>
|
|
@@ -276,31 +280,11 @@ const MonthContext = createStyledContext<{ size: MonthSize }>({ size: "md" });
|
|
|
276
280
|
// The week-number column matches `Day`'s square `CELL_WIDTH` ladder so it lines
|
|
277
281
|
// up with the day grid; its label tracks the same `CELL_FONT` ladder. Raw ladder
|
|
278
282
|
// values (resolve at module-load) — never `getTokenValue`, which needs live config.
|
|
279
|
-
const weekNumberWidthVariant = {
|
|
280
|
-
xxs: { width: CELL_WIDTH.xxs },
|
|
281
|
-
xs: { width: CELL_WIDTH.xs },
|
|
282
|
-
sm: { width: CELL_WIDTH.sm },
|
|
283
|
-
md: { width: CELL_WIDTH.md },
|
|
284
|
-
lg: { width: CELL_WIDTH.lg },
|
|
285
|
-
xl: { width: CELL_WIDTH.xl },
|
|
286
|
-
xxl: { width: CELL_WIDTH.xxl },
|
|
287
|
-
} as const;
|
|
288
|
-
|
|
289
|
-
const weekNumberFontVariant = {
|
|
290
|
-
xxs: { fontSize: CELL_FONT.xxs },
|
|
291
|
-
xs: { fontSize: CELL_FONT.xs },
|
|
292
|
-
sm: { fontSize: CELL_FONT.sm },
|
|
293
|
-
md: { fontSize: CELL_FONT.md },
|
|
294
|
-
lg: { fontSize: CELL_FONT.lg },
|
|
295
|
-
xl: { fontSize: CELL_FONT.xl },
|
|
296
|
-
xxl: { fontSize: CELL_FONT.xxl },
|
|
297
|
-
} as const;
|
|
298
|
-
|
|
299
283
|
// ── 5. Styled parts ───────────────────────────────────────────────────────────
|
|
300
284
|
|
|
301
285
|
/** The grid container — a column of week rows (web `role="grid"`). */
|
|
302
286
|
const MonthFrame = styled(Box, {
|
|
303
|
-
|
|
287
|
+
displayName: "Month",
|
|
304
288
|
context: MonthContext,
|
|
305
289
|
flexDirection: "column",
|
|
306
290
|
|
|
@@ -320,7 +304,7 @@ const MonthFrame = styled(Box, {
|
|
|
320
304
|
|
|
321
305
|
/** A single week row (web `role="row"`). */
|
|
322
306
|
const MonthRow = styled(Box, {
|
|
323
|
-
|
|
307
|
+
displayName: "MonthRow",
|
|
324
308
|
context: MonthContext,
|
|
325
309
|
flexDirection: "row",
|
|
326
310
|
|
|
@@ -346,7 +330,7 @@ const MonthRow = styled(Box, {
|
|
|
346
330
|
* per-render `flexGrow` spread — so the optimiser has nothing dynamic to fold).
|
|
347
331
|
*/
|
|
348
332
|
const MonthCell = styled(Box, {
|
|
349
|
-
|
|
333
|
+
displayName: "MonthCell",
|
|
350
334
|
context: MonthContext,
|
|
351
335
|
alignItems: "center",
|
|
352
336
|
justifyContent: "center",
|
|
@@ -361,27 +345,27 @@ const MonthCell = styled(Box, {
|
|
|
361
345
|
|
|
362
346
|
/** The leading week-number cell (web `role="rowheader"`). */
|
|
363
347
|
const MonthWeekNumber = styled(Box, {
|
|
364
|
-
|
|
348
|
+
displayName: "MonthWeekNumber",
|
|
365
349
|
context: MonthContext,
|
|
366
350
|
alignItems: "center",
|
|
367
351
|
justifyContent: "center",
|
|
368
352
|
|
|
369
353
|
variants: {
|
|
370
|
-
size:
|
|
354
|
+
size: cellWidthVariant,
|
|
371
355
|
} as const,
|
|
372
356
|
|
|
373
357
|
defaultVariants: { size: "md" },
|
|
374
358
|
});
|
|
375
359
|
|
|
376
|
-
/** The week-number label — muted accent text (
|
|
360
|
+
/** The week-number label — muted accent text (`color11`). */
|
|
377
361
|
const MonthWeekNumberLabel = styled(Text, {
|
|
378
|
-
|
|
362
|
+
displayName: "MonthWeekNumberLabel",
|
|
379
363
|
context: MonthContext,
|
|
380
|
-
color: "
|
|
364
|
+
color: "color11",
|
|
381
365
|
userSelect: "none",
|
|
382
366
|
|
|
383
367
|
variants: {
|
|
384
|
-
size:
|
|
368
|
+
size: cellFontVariant,
|
|
385
369
|
} as const,
|
|
386
370
|
|
|
387
371
|
defaultVariants: { size: "md" },
|
|
@@ -543,7 +527,7 @@ export interface MonthProps extends MonthFrameProps, MonthSettings {
|
|
|
543
527
|
* would be the ideal child of `role="grid"`, but the cross-platform `Role` type
|
|
544
528
|
* has no `gridcell` member — only `cell` — so we use the portable value.)
|
|
545
529
|
*/
|
|
546
|
-
const MonthComponent =
|
|
530
|
+
const MonthComponent = styleable<MonthProps>(MonthFrame, function Month(props, ref) {
|
|
547
531
|
const {
|
|
548
532
|
__stopPropagation,
|
|
549
533
|
__preventFocus,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// a11y/interaction (#11/#12) to `Month`/`Day`. The numbered rules in
|
|
17
17
|
// `_reference/README.md` that apply here: #1 (this header), #2 (shared size
|
|
18
18
|
// context), #7 (`styles` sugar + `getDayProps` passthrough — owned by `Month`),
|
|
19
|
-
// #9 (locale), #10 (min/max bounds), #11 (delegated a11y), #13 (
|
|
19
|
+
// #9 (locale), #10 (min/max bounds), #11 (delegated a11y), #13 (`styleable()` +
|
|
20
20
|
// typed ref), #14 (`withStaticProperties`), #15 (no dynamic hide styles — none
|
|
21
21
|
// used here). Unlike `DecadeLevel`, a month is NOT the top level: it zooms out to
|
|
22
22
|
// a year, so the level control stays interactive (`onLevelClick`/`hasNextLevel`).
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type GetProps,
|
|
32
32
|
slotStyles,
|
|
33
33
|
type SlotStyles,
|
|
34
|
+
styleable,
|
|
34
35
|
styled,
|
|
35
36
|
withStaticProperties,
|
|
36
37
|
} from "@knitui/core";
|
|
@@ -59,10 +60,10 @@ const MonthLevelContext = createStyledContext<{ size: CalendarSize }>({ size: "m
|
|
|
59
60
|
|
|
60
61
|
// ── 5/13. Styled root ─────────────────────────────────────────────────────────
|
|
61
62
|
// The level root is a styled `Box` column (the dates norm: a real styled part so
|
|
62
|
-
//
|
|
63
|
+
// `styleable()` can forward a ref + style props onto it). It establishes the
|
|
63
64
|
// shared `size` context; the header and grid own the `size` variant themselves.
|
|
64
65
|
const MonthLevelFrame = styled(Box, {
|
|
65
|
-
|
|
66
|
+
displayName: "MonthLevel",
|
|
66
67
|
context: MonthLevelContext,
|
|
67
68
|
flexDirection: "column",
|
|
68
69
|
|
|
@@ -152,7 +153,7 @@ export interface MonthLevelProps extends MonthLevelFrameProps, MonthLevelSetting
|
|
|
152
153
|
* locale. All `__onDay*` / `__getDayRef` / `__preventFocus` / `__stopPropagation`
|
|
153
154
|
* plumbing is forwarded straight to the `Month`.
|
|
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 `getDayProps(date)`. The day
|
|
157
158
|
* grid's a11y/interaction/sizing are delegated to `Month`/`Day` and the header to
|
|
158
159
|
* `CalendarHeader`. Forwards its ref + style props to the root.
|
|
@@ -160,7 +161,8 @@ export interface MonthLevelProps extends MonthLevelFrameProps, MonthLevelSetting
|
|
|
160
161
|
* @example
|
|
161
162
|
* <MonthLevel month="2024-01-01" onNext={nextMonth} onPrevious={prevMonth} onLevelClick={zoomOut} />
|
|
162
163
|
*/
|
|
163
|
-
const MonthLevelComponent =
|
|
164
|
+
const MonthLevelComponent = styleable<MonthLevelProps>(
|
|
165
|
+
MonthLevelFrame,
|
|
164
166
|
function MonthLevel(props, ref) {
|
|
165
167
|
const {
|
|
166
168
|
// Month settings
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// subtree — never a dynamic `opacity`/`display` style prop (15). The `<Type>`
|
|
26
26
|
// generic is preserved through `forwardRef` (which would otherwise pin it at
|
|
27
27
|
// `"default"`), so the ref is forwarded via a typed `forwardRef` rather than
|
|
28
|
-
//
|
|
28
|
+
// `styleable()` (13) — the documented sibling-picker pattern.
|
|
29
29
|
// ───────────────────────────────────────────────────────────────────────────
|
|
30
30
|
import * as React from "react";
|
|
31
31
|
import { useRef } from "react";
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
// dropdown subtree `PickerInputBase` owns — never a dynamic `opacity`/`display`
|
|
38
38
|
// style prop (15). The `<Type>` generic is preserved through `forwardRef` (which
|
|
39
39
|
// would otherwise pin it at `"default"`), so the ref is forwarded via a typed
|
|
40
|
-
// `forwardRef` rather than
|
|
40
|
+
// `forwardRef` rather than `styleable()` (13) — the documented sibling-picker
|
|
41
41
|
// pattern (`MonthPicker` / `DatePickerInput` / `YearPickerInput`).
|
|
42
42
|
// ───────────────────────────────────────────────────────────────────────────
|
|
43
43
|
import * as React from "react";
|
|
@@ -23,11 +23,13 @@ import { useMemo } from "react";
|
|
|
23
23
|
import dayjs from "dayjs";
|
|
24
24
|
|
|
25
25
|
import { Box } from "@knitui/components";
|
|
26
|
+
import { hoverProps } from "@knitui/components/control-system";
|
|
26
27
|
import {
|
|
27
28
|
createStyledContext,
|
|
28
29
|
type GetProps,
|
|
29
30
|
slotStyles,
|
|
30
31
|
type SlotStyles,
|
|
32
|
+
styleable,
|
|
31
33
|
styled,
|
|
32
34
|
withStaticProperties,
|
|
33
35
|
} from "@knitui/core";
|
|
@@ -69,7 +71,7 @@ const MonthsListContext = createStyledContext<{ size: CalendarSize }>({ size: "m
|
|
|
69
71
|
|
|
70
72
|
/** The grid container — a column of month rows (web `role="grid"`). */
|
|
71
73
|
const MonthsListFrame = styled(Box, {
|
|
72
|
-
|
|
74
|
+
displayName: "MonthsList",
|
|
73
75
|
context: MonthsListContext,
|
|
74
76
|
flexDirection: "column",
|
|
75
77
|
|
|
@@ -88,7 +90,7 @@ const MonthsListFrame = styled(Box, {
|
|
|
88
90
|
|
|
89
91
|
/** A single month row (web `role="row"`). */
|
|
90
92
|
const MonthsListRow = styled(Box, {
|
|
91
|
-
|
|
93
|
+
displayName: "MonthsListRow",
|
|
92
94
|
context: MonthsListContext,
|
|
93
95
|
flexDirection: "row",
|
|
94
96
|
|
|
@@ -113,7 +115,7 @@ const MonthsListRow = styled(Box, {
|
|
|
113
115
|
* per-render `flexGrow` spread — so the optimiser has nothing dynamic to fold).
|
|
114
116
|
*/
|
|
115
117
|
const MonthsListCell = styled(Box, {
|
|
116
|
-
|
|
118
|
+
displayName: "MonthsListCell",
|
|
117
119
|
context: MonthsListContext,
|
|
118
120
|
alignItems: "center",
|
|
119
121
|
justifyContent: "center",
|
|
@@ -206,12 +208,8 @@ const MonthsListControlCell = React.memo(function MonthsListControlCell({
|
|
|
206
208
|
onControlKeyDown,
|
|
207
209
|
getControlRef,
|
|
208
210
|
}: MonthsListControlCellProps) {
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
// affordances (see `Month`). Native never fires it.
|
|
212
|
-
const hoverHandlers: { onHoverIn?: (event: unknown) => void } = {
|
|
213
|
-
onHoverIn: (event) => onControlMouseEnter(event, month),
|
|
214
|
-
};
|
|
211
|
+
// Range hover preview (see `Month`): `onMouseEnter` on web, `onHoverIn` on native.
|
|
212
|
+
const hoverHandlers = hoverProps({ onHoverIn: (event) => onControlMouseEnter(event, month) });
|
|
215
213
|
|
|
216
214
|
return (
|
|
217
215
|
<MonthsListCell role="cell" fullWidth={fullWidth} {...cellProps}>
|
|
@@ -342,7 +340,8 @@ export interface MonthsListProps extends MonthsListFrameProps, MonthsListSetting
|
|
|
342
340
|
* wrapping a `role="button"` control. (ARIA's `gridcell` would be the ideal child
|
|
343
341
|
* of `role="grid"`, but the cross-platform `Role` type has no `gridcell` member.)
|
|
344
342
|
*/
|
|
345
|
-
const MonthsListComponent =
|
|
343
|
+
const MonthsListComponent = styleable<MonthsListProps>(
|
|
344
|
+
MonthsListFrame,
|
|
346
345
|
function MonthsList(props, ref) {
|
|
347
346
|
const {
|
|
348
347
|
year,
|