@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
|
@@ -70,43 +70,43 @@ export type TimePickerSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
|
70
70
|
|
|
71
71
|
/** Per-size height + horizontal inset for the field frame (the kit input recipe). */
|
|
72
72
|
const fieldFrameSizeVariant = {
|
|
73
|
-
xs: { height: "
|
|
74
|
-
sm: { height: "
|
|
75
|
-
md: { height: "
|
|
76
|
-
lg: { height: "
|
|
77
|
-
xl: { height: "
|
|
73
|
+
xs: { height: "xs", paddingHorizontal: "xs" },
|
|
74
|
+
sm: { height: "sm", paddingHorizontal: "sm" },
|
|
75
|
+
md: { height: "md", paddingHorizontal: "sm" },
|
|
76
|
+
lg: { height: "lg", paddingHorizontal: "md" },
|
|
77
|
+
xl: { height: "xl", paddingHorizontal: "md" },
|
|
78
78
|
} as const;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* The bordered field row that holds the editable time segments. Mirrors the kit
|
|
82
82
|
* `Input` root recipe (border/background/radius + `focused`/`error`/`disabled`/
|
|
83
|
-
* `variant`), themed from the active Tamagui theme —
|
|
83
|
+
* `variant`), themed from the active Tamagui theme — `red9` keeps the error
|
|
84
84
|
* border red under every accent. The inner `SpinInput`/`AmPmInput` segments are
|
|
85
85
|
* rendered `variant="unstyled"` so only this frame draws a border.
|
|
86
86
|
*/
|
|
87
87
|
const TimePickerFieldFrame = styled(Box, {
|
|
88
|
-
|
|
88
|
+
displayName: "TimePickerField",
|
|
89
89
|
flexDirection: "row",
|
|
90
90
|
alignItems: "center",
|
|
91
91
|
minWidth: 0,
|
|
92
92
|
borderWidth: 1,
|
|
93
|
-
borderColor: "
|
|
94
|
-
backgroundColor: "
|
|
95
|
-
borderRadius: "
|
|
93
|
+
borderColor: "borderColor",
|
|
94
|
+
backgroundColor: "background",
|
|
95
|
+
borderRadius: "sm",
|
|
96
96
|
overflow: "hidden",
|
|
97
97
|
|
|
98
98
|
variants: {
|
|
99
99
|
size: fieldFrameSizeVariant,
|
|
100
100
|
variant: {
|
|
101
101
|
default: {},
|
|
102
|
-
filled: { backgroundColor: "
|
|
102
|
+
filled: { backgroundColor: "color2" },
|
|
103
103
|
unstyled: { borderWidth: 0, backgroundColor: "transparent" },
|
|
104
104
|
},
|
|
105
105
|
focused: {
|
|
106
|
-
true: { borderColor: "
|
|
106
|
+
true: { borderColor: "focusRingColor" },
|
|
107
107
|
},
|
|
108
108
|
error: {
|
|
109
|
-
true: { borderColor: "
|
|
109
|
+
true: { borderColor: "red9" },
|
|
110
110
|
},
|
|
111
111
|
disabled: {
|
|
112
112
|
true: { opacity: 0.6, pointerEvents: "none" },
|
|
@@ -628,7 +628,7 @@ const TimePickerComponent = React.forwardRef<TamaguiElement, TimePickerProps>(
|
|
|
628
628
|
: {};
|
|
629
629
|
|
|
630
630
|
const colon = (
|
|
631
|
-
<Text key="colon" color="
|
|
631
|
+
<Text key="colon" color="color" userSelect="none" paddingHorizontal={1} {...s.get("colon")}>
|
|
632
632
|
:
|
|
633
633
|
</Text>
|
|
634
634
|
);
|
|
@@ -811,7 +811,7 @@ const TimePickerComponent = React.forwardRef<TamaguiElement, TimePickerProps>(
|
|
|
811
811
|
scrollAreaProps={scrollAreaProps}
|
|
812
812
|
/>
|
|
813
813
|
) : (
|
|
814
|
-
<Box flexDirection="row" gap="
|
|
814
|
+
<Box flexDirection="row" gap="xs" {...s.get("dropdown")}>
|
|
815
815
|
<TimeControlsList
|
|
816
816
|
min={format === "12h" ? 1 : 0}
|
|
817
817
|
max={format === "12h" ? 12 : 23}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import { UnstyledButton } from "@knitui/components";
|
|
3
|
+
import { Text, UnstyledButton } from "@knitui/components";
|
|
4
4
|
import {
|
|
5
5
|
createStyledContext,
|
|
6
6
|
type GetProps,
|
|
@@ -9,12 +9,11 @@ import {
|
|
|
9
9
|
withStaticProperties,
|
|
10
10
|
} from "@knitui/core";
|
|
11
11
|
|
|
12
|
-
import { type CalendarSize,
|
|
12
|
+
import { type CalendarSize, cellFontVariant } from "../cell-metrics";
|
|
13
13
|
import { controlA11yProps } from "../internal/a11y";
|
|
14
14
|
import { hasPreventDefault } from "../internal/has-prevent-default";
|
|
15
|
-
import { webCursor } from "../internal/web-cursor";
|
|
16
|
-
import { TimeValue } from "../TimeValue";
|
|
17
15
|
import type { TimePickerAmPmLabels, TimePickerFormat } from "../types";
|
|
16
|
+
import { getFormattedTime } from "../utils";
|
|
18
17
|
|
|
19
18
|
// ── 2. Shared context ───────────────────────────────────────────────────────
|
|
20
19
|
// One `createStyledContext` carries `size` to the styled parts so the cell and
|
|
@@ -27,51 +26,37 @@ const TimePresetControlContext = createStyledContext<{ size: CalendarSize }>({ s
|
|
|
27
26
|
// ladder (the calendar twin of components' `controlMetrics`), expressed with raw
|
|
28
27
|
// values that resolve at module-load — NOT `getTokenValue`, which needs the live
|
|
29
28
|
// config.
|
|
30
|
-
const presetFontVariant = {
|
|
31
|
-
xxs: { fontSize: CELL_FONT.xxs },
|
|
32
|
-
xs: { fontSize: CELL_FONT.xs },
|
|
33
|
-
sm: { fontSize: CELL_FONT.sm },
|
|
34
|
-
md: { fontSize: CELL_FONT.md },
|
|
35
|
-
lg: { fontSize: CELL_FONT.lg },
|
|
36
|
-
xl: { fontSize: CELL_FONT.xl },
|
|
37
|
-
xxl: { fontSize: CELL_FONT.xxl },
|
|
38
|
-
} as const;
|
|
39
|
-
|
|
40
29
|
// ── 5. Styled parts ───────────────────────────────────────────────────────────
|
|
41
30
|
|
|
42
31
|
/**
|
|
43
32
|
* One preset time-cell. Accent comes from the active theme's palette ramp via
|
|
44
33
|
* the `theme` prop (no Mantine `color` prop): the active preset fills with
|
|
45
|
-
*
|
|
34
|
+
* `color9`/`color1` text — the `PickerControl`/`TimeGridControl` convention.
|
|
46
35
|
*
|
|
47
|
-
* 12. Interaction lives in real Tamagui pseudo-state (`
|
|
36
|
+
* 12. Interaction lives in real Tamagui pseudo-state (`hover:`/`press:` clauses)
|
|
48
37
|
* and the `active` variant, never a runtime hover state machine.
|
|
49
38
|
* 15. The active highlight is a boolean VARIANT, never a dynamic
|
|
50
39
|
* `opacity`/`display` style prop the web optimiser could fold onto the cell.
|
|
51
40
|
*/
|
|
52
41
|
const TimePresetControlFrame = styled(UnstyledButton.Frame, {
|
|
53
|
-
|
|
42
|
+
displayName: "TimePresetControl",
|
|
54
43
|
context: TimePresetControlContext,
|
|
55
44
|
alignItems: "center",
|
|
56
45
|
justifyContent: "center",
|
|
57
46
|
borderWidth: 1,
|
|
58
|
-
borderColor: "
|
|
59
|
-
borderRadius: "
|
|
60
|
-
paddingVertical: "
|
|
61
|
-
paddingHorizontal: "
|
|
62
|
-
backgroundColor: "transparent",
|
|
63
|
-
|
|
64
|
-
hoverStyle: { backgroundColor: "$color2" },
|
|
65
|
-
pressStyle: { backgroundColor: "$color3" },
|
|
47
|
+
borderColor: "borderColor",
|
|
48
|
+
borderRadius: "sm",
|
|
49
|
+
paddingVertical: "xs",
|
|
50
|
+
paddingHorizontal: "sm",
|
|
51
|
+
backgroundColor: "transparent hover:color2 press:color3",
|
|
52
|
+
cursor: "web:pointer",
|
|
66
53
|
|
|
67
54
|
variants: {
|
|
68
55
|
/** Active preset — solid accent fill. */
|
|
69
56
|
active: {
|
|
70
57
|
true: {
|
|
71
|
-
backgroundColor: "
|
|
72
|
-
borderColor: "
|
|
73
|
-
hoverStyle: { backgroundColor: "$color10" },
|
|
74
|
-
pressStyle: { backgroundColor: "$color8" },
|
|
58
|
+
backgroundColor: "color9 hover:color10 press:color8",
|
|
59
|
+
borderColor: "color9",
|
|
75
60
|
},
|
|
76
61
|
},
|
|
77
62
|
} as const,
|
|
@@ -80,20 +65,25 @@ const TimePresetControlFrame = styled(UnstyledButton.Frame, {
|
|
|
80
65
|
/**
|
|
81
66
|
* The preset's formatted-time label.
|
|
82
67
|
*
|
|
83
|
-
* 4. Idle text is the neutral
|
|
84
|
-
* contrast
|
|
68
|
+
* 4. Idle text is the neutral `color`; on the active accent fill it flips to the
|
|
69
|
+
* contrast `color1`. No hex, no Mantine `color` prop.
|
|
85
70
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
// A styled `Text` (NOT `styled(TimeValue)`): in v3, `styled()` over a plain
|
|
72
|
+
// React component hands it a resolved inline `style` and DROPS theme-name
|
|
73
|
+
// values (`color: "color1"` never reached the DOM), so the label is a real
|
|
74
|
+
// Tamagui leaf and the time is formatted with the same `getFormattedTime`
|
|
75
|
+
// `TimeValue` uses.
|
|
76
|
+
const TimePresetControlLabel = styled(Text, {
|
|
77
|
+
displayName: "TimePresetControlLabel",
|
|
88
78
|
context: TimePresetControlContext,
|
|
89
79
|
userSelect: "none",
|
|
90
|
-
color: "
|
|
80
|
+
color: "color",
|
|
91
81
|
|
|
92
82
|
variants: {
|
|
93
|
-
size:
|
|
83
|
+
size: cellFontVariant,
|
|
94
84
|
|
|
95
85
|
/** On the active accent fill, the label flips to the contrast color. */
|
|
96
|
-
active: { true: { color: "
|
|
86
|
+
active: { true: { color: "color1" } },
|
|
97
87
|
} as const,
|
|
98
88
|
|
|
99
89
|
defaultVariants: { size: "sm" },
|
|
@@ -128,7 +118,7 @@ export interface TimePresetControlProps extends Omit<
|
|
|
128
118
|
|
|
129
119
|
/**
|
|
130
120
|
* `TimePresetControl` — one selectable preset in the `TimePicker` dropdown,
|
|
131
|
-
* rendering its time through the shared `
|
|
121
|
+
* rendering its time through the shared `getFormattedTime` formatter (`TimeValue`'s). The `any`-free,
|
|
132
122
|
* cross-platform port of Mantine's `TimePresetControl`; focus-stealing is
|
|
133
123
|
* prevented on web via `onPressIn` + the `has-prevent-default` guard. Forwards
|
|
134
124
|
* its ref to the cell. Folder-local to the `TimePicker` dropdown.
|
|
@@ -167,14 +157,9 @@ function TimePresetControlImpl(
|
|
|
167
157
|
render="button"
|
|
168
158
|
{...others}
|
|
169
159
|
>
|
|
170
|
-
<TimePresetControlLabel
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
amPmLabels={amPmLabels}
|
|
174
|
-
withSeconds={withSeconds}
|
|
175
|
-
size={size}
|
|
176
|
-
active={active}
|
|
177
|
-
/>
|
|
160
|
+
<TimePresetControlLabel size={size} active={active}>
|
|
161
|
+
{getFormattedTime({ value, format, amPmLabels, withSeconds })}
|
|
162
|
+
</TimePresetControlLabel>
|
|
178
163
|
</TimePresetControlFrame>
|
|
179
164
|
);
|
|
180
165
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type GetProps,
|
|
7
7
|
slotStyles,
|
|
8
8
|
type SlotStyles,
|
|
9
|
+
styleable,
|
|
9
10
|
styled,
|
|
10
11
|
withStaticProperties,
|
|
11
12
|
} from "@knitui/core";
|
|
@@ -37,16 +38,16 @@ const labelFontVariant = {
|
|
|
37
38
|
|
|
38
39
|
/** The group container: label above a grid of preset cells. */
|
|
39
40
|
const TimePresetGroupFrame = styled(Stack, {
|
|
40
|
-
|
|
41
|
+
displayName: "TimePresetGroup",
|
|
41
42
|
context: TimePresetGroupContext,
|
|
42
|
-
gap: "
|
|
43
|
+
gap: "xs",
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
/** The group's section label. */
|
|
46
47
|
const TimePresetGroupLabel = styled(Text, {
|
|
47
|
-
|
|
48
|
+
displayName: "TimePresetGroupLabel",
|
|
48
49
|
context: TimePresetGroupContext,
|
|
49
|
-
color: "
|
|
50
|
+
color: "color11",
|
|
50
51
|
|
|
51
52
|
variants: {
|
|
52
53
|
size: labelFontVariant,
|
|
@@ -124,7 +125,8 @@ export interface TimePresetGroupProps extends TimePresetGroupFrameProps {
|
|
|
124
125
|
* each cell `role="option"`; native counterparts ride on each cell's own
|
|
125
126
|
* `accessibility*` props. Folder-local to the `TimePicker` dropdown.
|
|
126
127
|
*/
|
|
127
|
-
const TimePresetGroupComponent =
|
|
128
|
+
const TimePresetGroupComponent = styleable<TimePresetGroupProps>(
|
|
129
|
+
TimePresetGroupFrame,
|
|
128
130
|
function TimePresetGroup(props, ref) {
|
|
129
131
|
const {
|
|
130
132
|
value,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// `styled(ScrollArea)` wrapper: wrapping it re-types `ScrollArea`'s
|
|
22
22
|
// `shadowColor?: string` own-prop as a theme-token value, which collides with the
|
|
23
23
|
// inherited `string` (the documented ScrollArea shadowColor trap). For the same
|
|
24
|
-
// reason this root is a plain function rather than
|
|
24
|
+
// reason this root is a plain function rather than `styleable()`.
|
|
25
25
|
// ───────────────────────────────────────────────────────────────────────────
|
|
26
26
|
import { ScrollArea, type ScrollAreaProps, SimpleGrid, Stack } from "@knitui/components";
|
|
27
27
|
import {
|
|
@@ -60,15 +60,15 @@ const TimePresetsContext = createStyledContext<{ size: CalendarSize }>({ size: "
|
|
|
60
60
|
|
|
61
61
|
/** The grid wrapping a flat `string[]` of preset cells (web `role="list"`). */
|
|
62
62
|
const TimePresetsGrid = styled(SimpleGrid, {
|
|
63
|
-
|
|
63
|
+
displayName: "TimePresetsGrid",
|
|
64
64
|
context: TimePresetsContext,
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
/** The stack wrapping the labelled groups (web `role="list"`). */
|
|
68
68
|
const TimePresetsGroups = styled(Stack, {
|
|
69
|
-
|
|
69
|
+
displayName: "TimePresetsGroups",
|
|
70
70
|
context: TimePresetsContext,
|
|
71
|
-
gap: "
|
|
71
|
+
gap: "sm",
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
// ── 7. Per-slot `styles` sugar + per-item passthrough ───────────────────────────
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// 13 — typed `forwardRef`: the ref forwards to the underlying `Text` host
|
|
22
22
|
// (`TamaguiElement`), and every `TextProps` style prop passes through, so
|
|
23
23
|
// `styled(TimeValue, …)` (see `TimePresetControlLabel`) and a consumer ref
|
|
24
|
-
// both work. The dates-norm
|
|
24
|
+
// both work. The dates-norm `styleable()` wrapper is for components that own
|
|
25
25
|
// a styled Frame; this leaf renders the shared `Text` directly, so a typed
|
|
26
26
|
// `forwardRef` is the leaf-appropriate form (same call as `TimeInput`).
|
|
27
27
|
//
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
// interactive `TimeInput`/`TimePicker`).
|
|
44
44
|
// 11 — a11y axes: a plain text node carries its own accessible text content;
|
|
45
45
|
// there is no interactive role to wire on either platform.
|
|
46
|
-
// 12 — interaction styling (`
|
|
46
|
+
// 12 — interaction styling (`hover:`/`press:` clauses/`disabled`): a static
|
|
47
47
|
// label has no interactive state.
|
|
48
48
|
// 14 — `withStaticProperties` parts/slot markers: nothing to expose; there
|
|
49
49
|
// are no sub-parts or slots.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// `weekdaysRow` style slots) but is built on `@knitui/components` (`Box`/`Text`) +
|
|
6
6
|
// `@knitui/core` (`styled`/`createStyledContext`/slot sugar) + dayjs — NEVER HTML
|
|
7
7
|
// `<tr>`/`<th>`, so it renders on web AND native from one source. The labels are
|
|
8
|
-
// muted neutral text (
|
|
8
|
+
// muted neutral text (`color11`); there is NO Mantine-style `color` prop.
|
|
9
9
|
//
|
|
10
10
|
// This is a DISPLAY component (no selection, no min/max, no marker slots), so the
|
|
11
11
|
// checklist's controlled-value (#8), bounds (#10) and marker-slot (#6) rules are
|
|
@@ -24,11 +24,12 @@ import {
|
|
|
24
24
|
isWeb,
|
|
25
25
|
slotStyles,
|
|
26
26
|
type SlotStyles,
|
|
27
|
+
styleable,
|
|
27
28
|
styled,
|
|
28
29
|
withStaticProperties,
|
|
29
30
|
} from "@knitui/core";
|
|
30
31
|
|
|
31
|
-
import { type CalendarSize,
|
|
32
|
+
import { type CalendarSize, weekdayCellVariant } from "../cell-metrics";
|
|
32
33
|
import { useDatesContext } from "../DatesProvider";
|
|
33
34
|
import type { DateLabelFormat, DayOfWeek } from "../types";
|
|
34
35
|
import { getWeekdayNames } from "./get-weekdays-names/get-weekdays-names";
|
|
@@ -48,21 +49,11 @@ const WeekdaysRowContext = createStyledContext<{ size: WeekdaySize }>({ size: "m
|
|
|
48
49
|
// The numeric ladders live in `../cell-metrics` (`CELL_WIDTH`/`CELL_FONT`) so every
|
|
49
50
|
// grid component stays in lockstep. Raw ladder values (resolve at module-load) —
|
|
50
51
|
// never `getTokenValue`, which needs the live config.
|
|
51
|
-
const weekdayCellVariant = {
|
|
52
|
-
xxs: { width: CELL_WIDTH.xxs, fontSize: CELL_FONT.xxs },
|
|
53
|
-
xs: { width: CELL_WIDTH.xs, fontSize: CELL_FONT.xs },
|
|
54
|
-
sm: { width: CELL_WIDTH.sm, fontSize: CELL_FONT.sm },
|
|
55
|
-
md: { width: CELL_WIDTH.md, fontSize: CELL_FONT.md },
|
|
56
|
-
lg: { width: CELL_WIDTH.lg, fontSize: CELL_FONT.lg },
|
|
57
|
-
xl: { width: CELL_WIDTH.xl, fontSize: CELL_FONT.xl },
|
|
58
|
-
xxl: { width: CELL_WIDTH.xxl, fontSize: CELL_FONT.xxl },
|
|
59
|
-
} as const;
|
|
60
|
-
|
|
61
52
|
// ── 5. Styled parts ───────────────────────────────────────────────────────────
|
|
62
53
|
|
|
63
54
|
/** The header row — a flex row, never a `<tr>`. */
|
|
64
55
|
const WeekdaysRowFrame = styled(Box, {
|
|
65
|
-
|
|
56
|
+
displayName: "WeekdaysRow",
|
|
66
57
|
context: WeekdaysRowContext,
|
|
67
58
|
flexDirection: "row",
|
|
68
59
|
});
|
|
@@ -70,16 +61,16 @@ const WeekdaysRowFrame = styled(Box, {
|
|
|
70
61
|
/**
|
|
71
62
|
* A single weekday label cell.
|
|
72
63
|
*
|
|
73
|
-
* 4. Colour is a theme-ramp token ONLY: the muted neutral
|
|
64
|
+
* 4. Colour is a theme-ramp token ONLY: the muted neutral `color11`, never hex
|
|
74
65
|
* and never a Mantine-style `color` prop.
|
|
75
66
|
* 15. `fullWidth` stretches each column to an equal share of the row via a boolean
|
|
76
67
|
* VARIANT (mirrors Mantine's `data-full-width` header behaviour) — not a
|
|
77
68
|
* per-render dynamic style prop the optimiser could flatten.
|
|
78
69
|
*/
|
|
79
70
|
const Weekday = styled(Text, {
|
|
80
|
-
|
|
71
|
+
displayName: "Weekday",
|
|
81
72
|
context: WeekdaysRowContext,
|
|
82
|
-
color: "
|
|
73
|
+
color: "color11",
|
|
83
74
|
textAlign: "center",
|
|
84
75
|
userSelect: "none",
|
|
85
76
|
fontWeight: "500",
|
|
@@ -169,7 +160,8 @@ export interface WeekdaysRowProps extends Omit<WeekdaysRowFrameProps, "size" | "
|
|
|
169
160
|
* a11y: the row is `role="row"`, each label `role="columnheader"`, with native
|
|
170
161
|
* `accessibilityRole` counterparts (`columnheader` on web, `text` on native).
|
|
171
162
|
*/
|
|
172
|
-
const WeekdaysRowComponent =
|
|
163
|
+
const WeekdaysRowComponent = styleable<WeekdaysRowProps>(
|
|
164
|
+
WeekdaysRowFrame,
|
|
173
165
|
function WeekdaysRow(props, ref) {
|
|
174
166
|
const {
|
|
175
167
|
size = "md",
|