react-miui 0.34.0 → 0.35.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/.claude/settings.local.json +2 -1
- package/CHANGELOG.md +13 -0
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +1 -0
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/form/input/Input.d.ts.map +1 -1
- package/dist/components/form/input/Input.js +9 -5
- package/dist/components/form/input/Input.js.map +1 -1
- package/dist/components/form/timepicker/TimePicker.css.d.ts +99 -0
- package/dist/components/form/timepicker/TimePicker.css.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePicker.css.js +116 -0
- package/dist/components/form/timepicker/TimePicker.css.js.map +1 -0
- package/dist/components/form/timepicker/TimePicker.d.ts +22 -0
- package/dist/components/form/timepicker/TimePicker.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePicker.js +141 -0
- package/dist/components/form/timepicker/TimePicker.js.map +1 -0
- package/dist/components/form/timepicker/TimePicker.styled.d.ts +936 -0
- package/dist/components/form/timepicker/TimePicker.styled.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePicker.styled.js +29 -0
- package/dist/components/form/timepicker/TimePicker.styled.js.map +1 -0
- package/dist/components/form/timepicker/TimePickerModal.d.ts +17 -0
- package/dist/components/form/timepicker/TimePickerModal.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePickerModal.js +92 -0
- package/dist/components/form/timepicker/TimePickerModal.js.map +1 -0
- package/dist/components/form/timepicker/Wheel.d.ts +12 -0
- package/dist/components/form/timepicker/Wheel.d.ts.map +1 -0
- package/dist/components/form/timepicker/Wheel.js +187 -0
- package/dist/components/form/timepicker/Wheel.js.map +1 -0
- package/dist/components/form/timepicker/utils.d.ts +4 -0
- package/dist/components/form/timepicker/utils.d.ts.map +1 -0
- package/dist/components/form/timepicker/utils.js +62 -0
- package/dist/components/form/timepicker/utils.js.map +1 -0
- package/dist/components/icons/Clock.d.ts +7 -0
- package/dist/components/icons/Clock.d.ts.map +1 -0
- package/dist/components/icons/Clock.js +45 -0
- package/dist/components/icons/Clock.js.map +1 -0
- package/dist/components/icons/Icon.d.ts +2 -1
- package/dist/components/icons/Icon.d.ts.map +1 -1
- package/dist/components/icons/Icon.js +3 -0
- package/dist/components/icons/Icon.js.map +1 -1
- package/dist/components/ui/modal/Modal.d.ts +1 -2
- package/dist/components/ui/modal/Modal.d.ts.map +1 -1
- package/dist/components/ui/modal/Modal.js +114 -42
- package/dist/components/ui/modal/Modal.js.map +1 -1
- package/dist/components/ui/modal/Modal.styled.d.ts +1 -1
- package/dist/components/ui/modal/Modal.styled.d.ts.map +1 -1
- package/dist/components/ui/modal/Modal.styled.js +40 -25
- package/dist/components/ui/modal/Modal.styled.js.map +1 -1
- package/dist/theme.css-global.d.ts.map +1 -1
- package/dist/theme.css-global.js +0 -1
- package/dist/theme.css-global.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/useNativeValidity.d.ts +11 -0
- package/dist/utils/useNativeValidity.d.ts.map +1 -0
- package/dist/utils/useNativeValidity.js +32 -0
- package/dist/utils/useNativeValidity.js.map +1 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/index.Pop.html +7 -7
- package/docs/documents/Test.html +2 -2
- package/docs/enums/index.ICON.html +3 -2
- package/docs/functions/index.Action.html +3 -3
- package/docs/functions/index.Button.html +3 -3
- package/docs/functions/index.Card.html +2 -2
- package/docs/functions/index.Checkbox.html +3 -3
- package/docs/functions/index.Choice.html +2 -2
- package/docs/functions/index.ColorPicker.html +3 -3
- package/docs/functions/index.CoveringLoader.html +3 -3
- package/docs/functions/index.DirectionPad.html +2 -2
- package/docs/functions/index.Drawer.html +2 -2
- package/docs/functions/index.EqualActions.html +2 -2
- package/docs/functions/index.FullLoader.html +3 -3
- package/docs/functions/index.Gap.html +2 -2
- package/docs/functions/index.HandleEsc.html +3 -3
- package/docs/functions/index.Header.html +3 -3
- package/docs/functions/index.HeaderIconAction.html +3 -3
- package/docs/functions/index.Icon-1.html +2 -2
- package/docs/functions/index.If.html +3 -3
- package/docs/functions/index.Input.html +1 -1
- package/docs/functions/index.KeyValue.html +2 -2
- package/docs/functions/index.Label.html +2 -2
- package/docs/functions/index.Line.html +3 -3
- package/docs/functions/index.List.html +2 -2
- package/docs/functions/index.Loader.html +3 -3
- package/docs/functions/index.Loading.html +3 -3
- package/docs/functions/index.Message.html +3 -3
- package/docs/functions/index.Modal.html +2 -2
- package/docs/functions/index.ModalButtons.html +3 -3
- package/docs/functions/index.PopLoader.html +3 -3
- package/docs/functions/index.PopOption.html +2 -2
- package/docs/functions/index.Progress.html +2 -2
- package/docs/functions/index.SearchContainer.html +2 -2
- package/docs/functions/index.Section.html +4 -4
- package/docs/functions/index.Select.html +2 -2
- package/docs/functions/index.Selector.html +2 -2
- package/docs/functions/index.Spacer.html +2 -2
- package/docs/functions/index.Stats.html +2 -2
- package/docs/functions/index.StickyHeader.html +4 -4
- package/docs/functions/index.Table.html +2 -2
- package/docs/functions/index.TextArea.html +2 -2
- package/docs/functions/index.TimePicker.html +10 -0
- package/docs/functions/index.ToasterProvider.html +3 -3
- package/docs/functions/index.Toggle.html +3 -3
- package/docs/functions/index.ToolButton.html +3 -3
- package/docs/functions/index.Tooltip.html +3 -3
- package/docs/functions/index.TooltipProvider.html +2 -2
- package/docs/functions/index.borderPxToRem.html +1 -1
- package/docs/functions/index.createTheme.html +1 -1
- package/docs/functions/index.css.html +1 -1
- package/docs/functions/index.dimensionsPxToRem.html +1 -1
- package/docs/functions/index.fontPxToRem.html +1 -1
- package/docs/functions/index.getCssText.html +1 -1
- package/docs/functions/index.globalCss.html +2 -2
- package/docs/functions/index.injectGlobalStyles.html +1 -1
- package/docs/functions/index.keyframes.html +1 -1
- package/docs/functions/index.pxToRem.html +1 -1
- package/docs/functions/index.styled.html +1 -1
- package/docs/functions/index.toast.html +2 -2
- package/docs/functions/index.useToaster.html +1 -1
- package/docs/index.html +2 -2
- package/docs/interfaces/index.IconProps.html +2 -2
- package/docs/interfaces/index.InputCustomProps.html +3 -3
- package/docs/interfaces/index.LoaderProps.html +6 -6
- package/docs/interfaces/index.StickyHeaderProps.html +4 -4
- package/docs/interfaces/index.ToasterProviderProps.html +3 -3
- package/docs/interfaces/index.TooltipProps.html +14 -14
- package/docs/interfaces/index.TooltipProviderProps.html +5 -5
- package/docs/modules/index.html +1 -1
- package/docs/modules.html +1 -1
- package/docs/types/index.ActionProps.html +1 -1
- package/docs/types/index.CardProps.html +1 -1
- package/docs/types/index.CheckboxProps.html +2 -2
- package/docs/types/index.ChoiceProps.html +1 -1
- package/docs/types/index.ColorPickerProps.html +1 -1
- package/docs/types/index.DirectionPadProps.html +1 -1
- package/docs/types/index.DrawerFrom.html +1 -1
- package/docs/types/index.DrawerProps.html +2 -2
- package/docs/types/index.EqualActionsProps.html +1 -1
- package/docs/types/index.HeaderProps.html +1 -1
- package/docs/types/index.InputProps.html +1 -1
- package/docs/types/index.KeyValueProps.html +1 -1
- package/docs/types/index.LabelProps.html +1 -1
- package/docs/types/index.OverwriteProps.html +1 -1
- package/docs/types/index.ProgressProps.html +2 -2
- package/docs/types/index.SelectProps.html +1 -1
- package/docs/types/index.SelectorProps.html +1 -1
- package/docs/types/index.Stat.html +1 -1
- package/docs/types/index.StatsProps.html +1 -1
- package/docs/types/index.TextAreaProps.html +1 -1
- package/docs/types/index.ThemeCSS.html +1 -1
- package/docs/types/index.TimePickerProps.html +1 -0
- package/docs/types/index.ToggleProps.html +2 -2
- package/docs/variables/index.ActionBadgeSelector.html +1 -1
- package/docs/variables/index.ActionCircleSelector.html +1 -1
- package/docs/variables/index.CheckboxCheckmarkWrapperSelector.html +1 -1
- package/docs/variables/index.CheckboxTextLabelSelector.html +1 -1
- package/docs/variables/index.ChoiceItemSelector.html +1 -1
- package/docs/variables/index.ColorPickerColorDisplaySelector.html +1 -1
- package/docs/variables/index.DirectionPadButtonDotSelector.html +1 -1
- package/docs/variables/index.DirectionPadButtonSelector.html +1 -1
- package/docs/variables/index.DirectionPadLineSelector.html +1 -1
- package/docs/variables/index.DirectionPadMiddleSelector.html +1 -1
- package/docs/variables/index.DrawerContentSelector.html +1 -1
- package/docs/variables/index.HeaderAfterSelector.html +1 -1
- package/docs/variables/index.HeaderBeforeSelector.html +1 -1
- package/docs/variables/index.HeaderContentsSelector.html +1 -1
- package/docs/variables/index.HeaderIconActionIconSelector.html +1 -1
- package/docs/variables/index.InputContainerSelector.html +1 -1
- package/docs/variables/index.InputInputSelector.html +1 -1
- package/docs/variables/index.InputLabelSelector.html +1 -1
- package/docs/variables/index.InputPrefixSelector.html +1 -1
- package/docs/variables/index.InputSuffixSelector.html +1 -1
- package/docs/variables/index.KeyValueIconSelector.html +1 -1
- package/docs/variables/index.KeyValueItemSelector.html +1 -1
- package/docs/variables/index.KeyValueKeySelector.html +1 -1
- package/docs/variables/index.KeyValuePairSelector.html +1 -1
- package/docs/variables/index.KeyValueValueSelector.html +1 -1
- package/docs/variables/index.LabelTextSelector.html +1 -1
- package/docs/variables/index.ListItemInnerContainerClassNameSelector.html +1 -1
- package/docs/variables/index.ModalContainerSelector.html +1 -1
- package/docs/variables/index.ModalRemovePaddingSelector.html +1 -1
- package/docs/variables/index.ModalTitleSelector.html +1 -1
- package/docs/variables/index.PopListSelector.html +1 -1
- package/docs/variables/index.PopOptionButtonSelector.html +1 -1
- package/docs/variables/index.PopOptionIconSelector.html +1 -1
- package/docs/variables/index.PopOverlaySelector.html +1 -1
- package/docs/variables/index.ProgressBackgroundSelector.html +1 -1
- package/docs/variables/index.ProgressValueSelector.html +1 -1
- package/docs/variables/index.SelectorItemSelector.html +1 -1
- package/docs/variables/index.StatsItemSelector.html +1 -1
- package/docs/variables/index.StatsLabelSelector.html +1 -1
- package/docs/variables/index.StatsSeparatorSelector.html +1 -1
- package/docs/variables/index.StatsValueSelector.html +1 -1
- package/docs/variables/index.TextAreaLabelSelector.html +1 -1
- package/docs/variables/index.TextAreaTextAreaSelector.html +1 -1
- package/docs/variables/index.TextAreaWrapperSelector.html +1 -1
- package/docs/variables/index.ToggleStyledToggleSelector.html +1 -1
- package/docs/variables/index.TooltipContentSelector.html +1 -1
- package/docs/variables/index.config.html +1 -1
- package/docs/variables/index.cssReset.html +2 -2
- package/docs/variables/index.darkTheme.html +1 -1
- package/docs/variables/index.miuiScrollbars.html +1 -1
- package/docs/variables/index.theme.html +1 -1
- package/esm/components/form/index.d.ts +1 -0
- package/esm/components/form/index.d.ts.map +1 -1
- package/esm/components/form/index.js +1 -0
- package/esm/components/form/index.js.map +1 -1
- package/esm/components/form/input/Input.d.ts.map +1 -1
- package/esm/components/form/input/Input.js +9 -5
- package/esm/components/form/input/Input.js.map +1 -1
- package/esm/components/form/timepicker/TimePicker.css.d.ts +99 -0
- package/esm/components/form/timepicker/TimePicker.css.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePicker.css.js +102 -0
- package/esm/components/form/timepicker/TimePicker.css.js.map +1 -0
- package/esm/components/form/timepicker/TimePicker.d.ts +22 -0
- package/esm/components/form/timepicker/TimePicker.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePicker.js +93 -0
- package/esm/components/form/timepicker/TimePicker.js.map +1 -0
- package/esm/components/form/timepicker/TimePicker.styled.d.ts +936 -0
- package/esm/components/form/timepicker/TimePicker.styled.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePicker.styled.js +20 -0
- package/esm/components/form/timepicker/TimePicker.styled.js.map +1 -0
- package/esm/components/form/timepicker/TimePickerModal.d.ts +17 -0
- package/esm/components/form/timepicker/TimePickerModal.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePickerModal.js +56 -0
- package/esm/components/form/timepicker/TimePickerModal.js.map +1 -0
- package/esm/components/form/timepicker/Wheel.d.ts +12 -0
- package/esm/components/form/timepicker/Wheel.d.ts.map +1 -0
- package/esm/components/form/timepicker/Wheel.js +151 -0
- package/esm/components/form/timepicker/Wheel.js.map +1 -0
- package/esm/components/form/timepicker/utils.d.ts +4 -0
- package/esm/components/form/timepicker/utils.d.ts.map +1 -0
- package/esm/components/form/timepicker/utils.js +58 -0
- package/esm/components/form/timepicker/utils.js.map +1 -0
- package/esm/components/icons/Clock.d.ts +7 -0
- package/esm/components/icons/Clock.d.ts.map +1 -0
- package/esm/components/icons/Clock.js +9 -0
- package/esm/components/icons/Clock.js.map +1 -0
- package/esm/components/icons/Icon.d.ts +2 -1
- package/esm/components/icons/Icon.d.ts.map +1 -1
- package/esm/components/icons/Icon.js +3 -0
- package/esm/components/icons/Icon.js.map +1 -1
- package/esm/components/ui/modal/Modal.d.ts +1 -2
- package/esm/components/ui/modal/Modal.d.ts.map +1 -1
- package/esm/components/ui/modal/Modal.js +103 -43
- package/esm/components/ui/modal/Modal.js.map +1 -1
- package/esm/components/ui/modal/Modal.styled.d.ts +1 -1
- package/esm/components/ui/modal/Modal.styled.d.ts.map +1 -1
- package/esm/components/ui/modal/Modal.styled.js +40 -25
- package/esm/components/ui/modal/Modal.styled.js.map +1 -1
- package/esm/theme.css-global.d.ts.map +1 -1
- package/esm/theme.css-global.js +0 -1
- package/esm/theme.css-global.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/useNativeValidity.d.ts +11 -0
- package/esm/utils/useNativeValidity.d.ts.map +1 -0
- package/esm/utils/useNativeValidity.js +29 -0
- package/esm/utils/useNativeValidity.js.map +1 -0
- package/package.json +1 -1
- package/src/components/form/index.ts +1 -0
- package/src/components/form/input/Input.stories.tsx +47 -1
- package/src/components/form/input/Input.tsx +11 -5
- package/src/components/form/timepicker/TimePicker.css.ts +132 -0
- package/src/components/form/timepicker/TimePicker.stories.tsx +107 -0
- package/src/components/form/timepicker/TimePicker.styled.ts +52 -0
- package/src/components/form/timepicker/TimePicker.tsx +229 -0
- package/src/components/form/timepicker/TimePickerModal.tsx +131 -0
- package/src/components/form/timepicker/Wheel.tsx +201 -0
- package/src/components/form/timepicker/utils.ts +66 -0
- package/src/components/icons/Clock.tsx +38 -0
- package/src/components/icons/Icon.tsx +3 -0
- package/src/components/ui/modal/Modal.stories.tsx +43 -7
- package/src/components/ui/modal/Modal.styled.ts +46 -25
- package/src/components/ui/modal/Modal.tsx +135 -52
- package/src/theme.css-global.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/useNativeValidity.ts +57 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { ThemeCSS } from "../../../theme";
|
|
2
|
+
|
|
3
|
+
import { borderPxToRem, dimensionsPxToRem, fontPxToRem } from "../../../theme";
|
|
4
|
+
|
|
5
|
+
const ITEM_HEIGHT_PX = 200;
|
|
6
|
+
const VISIBLE_ITEMS = 5;
|
|
7
|
+
|
|
8
|
+
const wheelViewport = {
|
|
9
|
+
"position": "relative",
|
|
10
|
+
"height": dimensionsPxToRem(ITEM_HEIGHT_PX * VISIBLE_ITEMS),
|
|
11
|
+
"width": dimensionsPxToRem(360),
|
|
12
|
+
"overflowY": "scroll",
|
|
13
|
+
"scrollSnapType": "y mandatory",
|
|
14
|
+
"scrollbarWidth": "none",
|
|
15
|
+
"WebkitMaskImage":
|
|
16
|
+
"linear-gradient(to bottom, transparent 0%, transparent 10%, black 45%,"
|
|
17
|
+
+ " black 55%, transparent 90%, transparent 100%)",
|
|
18
|
+
"maskImage":
|
|
19
|
+
"linear-gradient(to bottom, transparent 0%, transparent 10%, black 45%,"
|
|
20
|
+
+ " black 55%, transparent 90%, transparent 100%)",
|
|
21
|
+
"overscrollBehavior": "contain",
|
|
22
|
+
|
|
23
|
+
"&::-webkit-scrollbar": {
|
|
24
|
+
display: "none",
|
|
25
|
+
},
|
|
26
|
+
"&:focus": {
|
|
27
|
+
outline: "none",
|
|
28
|
+
},
|
|
29
|
+
} satisfies ThemeCSS;
|
|
30
|
+
|
|
31
|
+
const wheelWrapper = {
|
|
32
|
+
position: "relative",
|
|
33
|
+
display: "flex",
|
|
34
|
+
} satisfies ThemeCSS;
|
|
35
|
+
|
|
36
|
+
const wheelFocusRing = {
|
|
37
|
+
position: "absolute",
|
|
38
|
+
top: "50%",
|
|
39
|
+
left: 0,
|
|
40
|
+
right: 0,
|
|
41
|
+
height: dimensionsPxToRem(ITEM_HEIGHT_PX),
|
|
42
|
+
transform: "translateY(-50%)",
|
|
43
|
+
pointerEvents: "none",
|
|
44
|
+
border: `${borderPxToRem(2)} solid transparent`,
|
|
45
|
+
borderRadius: dimensionsPxToRem(16),
|
|
46
|
+
boxSizing: "border-box",
|
|
47
|
+
transition: "border-color 0.15s",
|
|
48
|
+
} satisfies ThemeCSS;
|
|
49
|
+
|
|
50
|
+
const wheelPadder = {
|
|
51
|
+
height: dimensionsPxToRem(ITEM_HEIGHT_PX * 2),
|
|
52
|
+
} satisfies ThemeCSS;
|
|
53
|
+
|
|
54
|
+
const wheelItem = {
|
|
55
|
+
height: dimensionsPxToRem(ITEM_HEIGHT_PX),
|
|
56
|
+
display: "flex",
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
scrollSnapAlign: "center",
|
|
60
|
+
scrollSnapStop: "always",
|
|
61
|
+
fontSize: fontPxToRem(80),
|
|
62
|
+
fontVariantNumeric: "tabular-nums",
|
|
63
|
+
color: "$text",
|
|
64
|
+
userSelect: "none",
|
|
65
|
+
fontWeight: 500,
|
|
66
|
+
} satisfies ThemeCSS;
|
|
67
|
+
|
|
68
|
+
const wheelHighlight = {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: "50%",
|
|
71
|
+
left: 0,
|
|
72
|
+
right: 0,
|
|
73
|
+
height: dimensionsPxToRem(ITEM_HEIGHT_PX),
|
|
74
|
+
transform: "translateY(-50%)",
|
|
75
|
+
pointerEvents: "none",
|
|
76
|
+
borderTop: "1px solid $border",
|
|
77
|
+
borderBottom: "1px solid $border",
|
|
78
|
+
} satisfies ThemeCSS;
|
|
79
|
+
|
|
80
|
+
const wheelsContainer = {
|
|
81
|
+
display: "flex",
|
|
82
|
+
justifyContent: "center",
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
gap: dimensionsPxToRem(36),
|
|
85
|
+
position: "relative",
|
|
86
|
+
} satisfies ThemeCSS;
|
|
87
|
+
|
|
88
|
+
const wheelSeparator = {
|
|
89
|
+
fontSize: fontPxToRem(80),
|
|
90
|
+
color: "$text",
|
|
91
|
+
fontWeight: 500,
|
|
92
|
+
userSelect: "none",
|
|
93
|
+
pointerEvents: "none",
|
|
94
|
+
} satisfies ThemeCSS;
|
|
95
|
+
|
|
96
|
+
const suffixButton = {
|
|
97
|
+
"display": "flex",
|
|
98
|
+
"alignItems": "center",
|
|
99
|
+
"justifyContent": "center",
|
|
100
|
+
"background": "none",
|
|
101
|
+
"border": "none",
|
|
102
|
+
"padding": dimensionsPxToRem(24),
|
|
103
|
+
"margin": `0 -${dimensionsPxToRem(24)}`,
|
|
104
|
+
"cursor": "pointer",
|
|
105
|
+
"color": "$text",
|
|
106
|
+
|
|
107
|
+
"&:disabled": {
|
|
108
|
+
cursor: "not-allowed",
|
|
109
|
+
opacity: 0.5,
|
|
110
|
+
},
|
|
111
|
+
} satisfies ThemeCSS;
|
|
112
|
+
|
|
113
|
+
const timeInput = {
|
|
114
|
+
fontVariantNumeric: "tabular-nums",
|
|
115
|
+
letterSpacing: "0.05em",
|
|
116
|
+
caretColor: "$mainColor",
|
|
117
|
+
} satisfies ThemeCSS;
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
ITEM_HEIGHT_PX,
|
|
121
|
+
VISIBLE_ITEMS,
|
|
122
|
+
wheelViewport,
|
|
123
|
+
wheelWrapper,
|
|
124
|
+
wheelFocusRing,
|
|
125
|
+
wheelPadder,
|
|
126
|
+
wheelItem,
|
|
127
|
+
wheelHighlight,
|
|
128
|
+
wheelsContainer,
|
|
129
|
+
wheelSeparator,
|
|
130
|
+
suffixButton,
|
|
131
|
+
timeInput,
|
|
132
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
4
|
+
|
|
5
|
+
import { Gap } from "../../utils/Gap";
|
|
6
|
+
import { TimePicker } from "./TimePicker";
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof TimePicker> = {
|
|
9
|
+
title: "Components/Form/TimePicker",
|
|
10
|
+
component: TimePicker,
|
|
11
|
+
tags: ["autodocs", "form"],
|
|
12
|
+
argTypes: {
|
|
13
|
+
error: { type: "boolean" },
|
|
14
|
+
disabled: { type: "boolean" },
|
|
15
|
+
readOnly: { type: "boolean" },
|
|
16
|
+
withSeconds: { type: "boolean" },
|
|
17
|
+
minuteStep: { type: "number" },
|
|
18
|
+
secondStep: { type: "number" },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj<typeof TimePicker>;
|
|
23
|
+
|
|
24
|
+
const Primary: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
label: "Time",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Controlled: Story = {
|
|
31
|
+
render: () => {
|
|
32
|
+
const [value, setValue] = useState("14:30");
|
|
33
|
+
return (
|
|
34
|
+
<Gap>
|
|
35
|
+
<TimePicker label={"Time"} value={value} onChange={setValue} />
|
|
36
|
+
<div>{"Value: " + (value || "(empty)")}</div>
|
|
37
|
+
</Gap>
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const Uncontrolled: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
label: "Time",
|
|
45
|
+
defaultValue: "08:00",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const WithSeconds: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
label: "Time with seconds",
|
|
52
|
+
withSeconds: true,
|
|
53
|
+
defaultValue: "12:34:56",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const MinuteStep5: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
label: "Time (5 min step)",
|
|
60
|
+
minuteStep: 5,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const Validation: Story = {
|
|
65
|
+
render: () => {
|
|
66
|
+
const [submitted, setSubmitted] = useState<string | null>(null);
|
|
67
|
+
return (
|
|
68
|
+
<form
|
|
69
|
+
onSubmit={(e) => {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
const data = new FormData(e.currentTarget);
|
|
72
|
+
const v = data.get("time");
|
|
73
|
+
setSubmitted(typeof v === "string" ? v : "");
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
<Gap>
|
|
77
|
+
<div>
|
|
78
|
+
{"Type something invalid (e.g. \"9:5\" or \"abc\") and blur — TimePicker"
|
|
79
|
+
+ " reads native validity and auto-applies its error variant."}
|
|
80
|
+
</div>
|
|
81
|
+
<TimePicker name={"time"} label={"Time"} required={true} />
|
|
82
|
+
<button type={"submit"}>{"Submit"}</button>
|
|
83
|
+
{submitted !== null
|
|
84
|
+
? <div>{"Submitted: " + (submitted || "(empty)")}</div>
|
|
85
|
+
: null}
|
|
86
|
+
</Gap>
|
|
87
|
+
</form>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const Mixed: Story = {
|
|
93
|
+
render: () => (
|
|
94
|
+
<Gap>
|
|
95
|
+
<TimePicker label={"Default"} />
|
|
96
|
+
<TimePicker label={"With value"} defaultValue={"09:15"} />
|
|
97
|
+
<TimePicker label={"With seconds"} withSeconds={true} defaultValue={"23:59:30"} />
|
|
98
|
+
<TimePicker label={"Every 15 min"} minuteStep={15} />
|
|
99
|
+
<TimePicker label={"Disabled"} defaultValue={"10:00"} disabled={true} />
|
|
100
|
+
<TimePicker label={"Read only"} defaultValue={"10:00"} readOnly={true} />
|
|
101
|
+
<TimePicker label={"Error"} defaultValue={"10:00"} error={true} />
|
|
102
|
+
</Gap>
|
|
103
|
+
),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default meta;
|
|
107
|
+
export { Primary, Controlled, Uncontrolled, WithSeconds, MinuteStep5, Validation, Mixed };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { styled } from "../../../theme";
|
|
2
|
+
import { StyledInput } from "../input/Input.styled";
|
|
3
|
+
import {
|
|
4
|
+
suffixButton,
|
|
5
|
+
timeInput,
|
|
6
|
+
wheelFocusRing,
|
|
7
|
+
wheelHighlight,
|
|
8
|
+
wheelItem,
|
|
9
|
+
wheelPadder,
|
|
10
|
+
wheelsContainer,
|
|
11
|
+
wheelSeparator,
|
|
12
|
+
wheelViewport,
|
|
13
|
+
wheelWrapper,
|
|
14
|
+
} from "./TimePicker.css";
|
|
15
|
+
|
|
16
|
+
const StyledTimeInput = styled(StyledInput, timeInput);
|
|
17
|
+
|
|
18
|
+
const StyledSuffixButton = styled("button", suffixButton);
|
|
19
|
+
|
|
20
|
+
const StyledWheelsContainer = styled("div", wheelsContainer);
|
|
21
|
+
|
|
22
|
+
const StyledWheelViewport = styled("div", wheelViewport);
|
|
23
|
+
|
|
24
|
+
const StyledWheelWrapper = styled("div", wheelWrapper);
|
|
25
|
+
|
|
26
|
+
const StyledWheelPadder = styled("div", wheelPadder);
|
|
27
|
+
|
|
28
|
+
const StyledWheelItem = styled("div", wheelItem);
|
|
29
|
+
|
|
30
|
+
const StyledWheelHighlight = styled("div", wheelHighlight);
|
|
31
|
+
|
|
32
|
+
const StyledWheelSeparator = styled("div", wheelSeparator);
|
|
33
|
+
|
|
34
|
+
const StyledWheelFocusRing = styled("div", {
|
|
35
|
+
...wheelFocusRing,
|
|
36
|
+
[StyledWheelViewport.toString() + ":focus-visible + &"]: {
|
|
37
|
+
borderColor: "$focusColor",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
StyledTimeInput,
|
|
43
|
+
StyledSuffixButton,
|
|
44
|
+
StyledWheelsContainer,
|
|
45
|
+
StyledWheelViewport,
|
|
46
|
+
StyledWheelWrapper,
|
|
47
|
+
StyledWheelPadder,
|
|
48
|
+
StyledWheelItem,
|
|
49
|
+
StyledWheelHighlight,
|
|
50
|
+
StyledWheelSeparator,
|
|
51
|
+
StyledWheelFocusRing,
|
|
52
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react";
|
|
8
|
+
|
|
9
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
10
|
+
|
|
11
|
+
import { useNativeValidity } from "../../../utils/useNativeValidity";
|
|
12
|
+
import { Clock } from "../../icons/Clock";
|
|
13
|
+
import {
|
|
14
|
+
StyledInputContainer,
|
|
15
|
+
StyledLabel,
|
|
16
|
+
StyledSuffix,
|
|
17
|
+
StyledWrapper,
|
|
18
|
+
} from "../input/Input.styled";
|
|
19
|
+
import {
|
|
20
|
+
StyledSuffixButton,
|
|
21
|
+
StyledTimeInput,
|
|
22
|
+
} from "./TimePicker.styled";
|
|
23
|
+
import { TimePickerModal } from "./TimePickerModal";
|
|
24
|
+
|
|
25
|
+
const PATTERN_HHMM = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
26
|
+
const PATTERN_HHMMSS = "(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
27
|
+
const MAX_LEN_HHMM = 5;
|
|
28
|
+
const MAX_LEN_HHMMSS = 8;
|
|
29
|
+
|
|
30
|
+
const assertStep = (name: string, step: number): void => {
|
|
31
|
+
if (!Number.isInteger(step) || step < 1 || step > 60) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`TimePicker: \`${name}\` must be an integer between 1 and 60, got ${String(step)}`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
interface CustomProps {
|
|
39
|
+
children?: never;
|
|
40
|
+
label?: string;
|
|
41
|
+
pinnedLabel?: boolean;
|
|
42
|
+
error?: boolean;
|
|
43
|
+
withSeconds?: boolean;
|
|
44
|
+
minuteStep?: number;
|
|
45
|
+
secondStep?: number;
|
|
46
|
+
value?: string;
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
onChange?: (value: string) => void;
|
|
49
|
+
modalTitle?: React.ReactNode;
|
|
50
|
+
okLabel?: React.ReactNode;
|
|
51
|
+
cancelLabel?: React.ReactNode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type InputAttrs = Omit<
|
|
55
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
56
|
+
"value" | "defaultValue" | "onChange" | "type" | "prefix" | "pattern" | "placeholder" | "maxLength"
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
type Props = InputAttrs & CustomProps;
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line max-lines-per-function,max-statements
|
|
62
|
+
const TimePickerInner = ({
|
|
63
|
+
className,
|
|
64
|
+
label,
|
|
65
|
+
pinnedLabel = false,
|
|
66
|
+
error,
|
|
67
|
+
withSeconds = false,
|
|
68
|
+
minuteStep = 1,
|
|
69
|
+
secondStep = 1,
|
|
70
|
+
value,
|
|
71
|
+
defaultValue,
|
|
72
|
+
onChange,
|
|
73
|
+
onFocus,
|
|
74
|
+
onBlur,
|
|
75
|
+
disabled,
|
|
76
|
+
readOnly,
|
|
77
|
+
id,
|
|
78
|
+
modalTitle,
|
|
79
|
+
okLabel = "OK",
|
|
80
|
+
cancelLabel = "Cancel",
|
|
81
|
+
...rest
|
|
82
|
+
}: Props, ref: React.Ref<HTMLInputElement>) => {
|
|
83
|
+
assertStep("minuteStep", minuteStep);
|
|
84
|
+
if (withSeconds) {
|
|
85
|
+
assertStep("secondStep", secondStep);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const isControlled = value !== undefined;
|
|
89
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? "");
|
|
90
|
+
const currentValue = isControlled ? (value ?? "") : internalValue;
|
|
91
|
+
|
|
92
|
+
const [focused, setFocused] = useState(false);
|
|
93
|
+
const validity = useNativeValidity(error);
|
|
94
|
+
const { revalidate } = validity;
|
|
95
|
+
const inputRef = useForwardedRef(ref);
|
|
96
|
+
const generatedId = useId();
|
|
97
|
+
const inputId = id ?? (label ? generatedId : undefined);
|
|
98
|
+
|
|
99
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
100
|
+
|
|
101
|
+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
102
|
+
const next = e.target.value;
|
|
103
|
+
if (!isControlled) {
|
|
104
|
+
setInternalValue(next);
|
|
105
|
+
}
|
|
106
|
+
validity.onChange(e);
|
|
107
|
+
onChange?.(next);
|
|
108
|
+
}, [isControlled, onChange, validity]);
|
|
109
|
+
|
|
110
|
+
const handleFocus = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
|
111
|
+
setFocused(true);
|
|
112
|
+
onFocus?.(e);
|
|
113
|
+
}, [onFocus]);
|
|
114
|
+
|
|
115
|
+
const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
|
116
|
+
setFocused(false);
|
|
117
|
+
validity.onBlur(e);
|
|
118
|
+
onBlur?.(e);
|
|
119
|
+
}, [onBlur, validity]);
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
revalidate(inputRef.current);
|
|
123
|
+
}, [currentValue, revalidate, inputRef]);
|
|
124
|
+
|
|
125
|
+
const openModal = useCallback(() => {
|
|
126
|
+
setModalOpen(true);
|
|
127
|
+
}, []);
|
|
128
|
+
|
|
129
|
+
const closeModal = useCallback(() => {
|
|
130
|
+
setModalOpen(false);
|
|
131
|
+
inputRef.current?.focus();
|
|
132
|
+
}, [inputRef]);
|
|
133
|
+
|
|
134
|
+
const confirmModal = useCallback((next: string) => {
|
|
135
|
+
if (!isControlled) {
|
|
136
|
+
setInternalValue(next);
|
|
137
|
+
}
|
|
138
|
+
onChange?.(next);
|
|
139
|
+
setModalOpen(false);
|
|
140
|
+
inputRef.current?.focus();
|
|
141
|
+
}, [isControlled, onChange, inputRef]);
|
|
142
|
+
|
|
143
|
+
const hasValue = currentValue.length > 0;
|
|
144
|
+
const floating = Boolean(label) && (pinnedLabel || focused || hasValue);
|
|
145
|
+
const placeholder = withSeconds ? "--:--:--" : "--:--";
|
|
146
|
+
const pattern = withSeconds ? PATTERN_HHMMSS : PATTERN_HHMM;
|
|
147
|
+
const maxLength = withSeconds ? MAX_LEN_HHMMSS : MAX_LEN_HHMM;
|
|
148
|
+
const finalError = validity.finalError;
|
|
149
|
+
|
|
150
|
+
const labelElem = label
|
|
151
|
+
? (
|
|
152
|
+
<StyledLabel
|
|
153
|
+
htmlFor={inputId}
|
|
154
|
+
floating={floating}
|
|
155
|
+
error={finalError}
|
|
156
|
+
>
|
|
157
|
+
{label}
|
|
158
|
+
</StyledLabel>
|
|
159
|
+
)
|
|
160
|
+
: null;
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<>
|
|
164
|
+
<StyledWrapper
|
|
165
|
+
className={className}
|
|
166
|
+
focused={focused}
|
|
167
|
+
disabled={Boolean(disabled)}
|
|
168
|
+
readOnly={Boolean(readOnly)}
|
|
169
|
+
error={finalError}
|
|
170
|
+
>
|
|
171
|
+
<StyledInputContainer>
|
|
172
|
+
{labelElem}
|
|
173
|
+
<StyledTimeInput
|
|
174
|
+
ref={inputRef}
|
|
175
|
+
{...rest}
|
|
176
|
+
id={inputId}
|
|
177
|
+
type={"text"}
|
|
178
|
+
inputMode={"numeric"}
|
|
179
|
+
autoComplete={"off"}
|
|
180
|
+
value={currentValue}
|
|
181
|
+
placeholder={placeholder}
|
|
182
|
+
pattern={pattern}
|
|
183
|
+
maxLength={maxLength}
|
|
184
|
+
disabled={disabled}
|
|
185
|
+
readOnly={readOnly}
|
|
186
|
+
onChange={handleChange}
|
|
187
|
+
onFocus={handleFocus}
|
|
188
|
+
onBlur={handleBlur}
|
|
189
|
+
onInvalid={validity.onInvalid}
|
|
190
|
+
data-error={finalError}
|
|
191
|
+
/>
|
|
192
|
+
</StyledInputContainer>
|
|
193
|
+
<StyledSuffix>
|
|
194
|
+
<StyledSuffixButton
|
|
195
|
+
type={"button"}
|
|
196
|
+
onClick={openModal}
|
|
197
|
+
disabled={disabled}
|
|
198
|
+
aria-label={"Open time picker"}
|
|
199
|
+
>
|
|
200
|
+
<Clock />
|
|
201
|
+
</StyledSuffixButton>
|
|
202
|
+
</StyledSuffix>
|
|
203
|
+
</StyledWrapper>
|
|
204
|
+
<TimePickerModal
|
|
205
|
+
isOpen={modalOpen}
|
|
206
|
+
initialValue={currentValue}
|
|
207
|
+
withSeconds={withSeconds}
|
|
208
|
+
minuteStep={minuteStep}
|
|
209
|
+
secondStep={secondStep}
|
|
210
|
+
readOnly={Boolean(readOnly)}
|
|
211
|
+
title={modalTitle}
|
|
212
|
+
okLabel={okLabel}
|
|
213
|
+
cancelLabel={cancelLabel}
|
|
214
|
+
onClose={closeModal}
|
|
215
|
+
onConfirm={confirmModal}
|
|
216
|
+
/>
|
|
217
|
+
</>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const TimePickerRef = forwardRef(TimePickerInner);
|
|
222
|
+
TimePickerRef.displayName = "TimePicker";
|
|
223
|
+
TimePickerRef.toString = () => StyledWrapper.toString();
|
|
224
|
+
|
|
225
|
+
const TimePicker = TimePickerRef;
|
|
226
|
+
|
|
227
|
+
export { TimePicker };
|
|
228
|
+
|
|
229
|
+
export type { Props as TimePickerProps };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { Modal } from "../../ui/modal/Modal";
|
|
4
|
+
import { ModalButtons } from "../../ui/modal/ModalButtons";
|
|
5
|
+
import {
|
|
6
|
+
StyledWheelHighlight,
|
|
7
|
+
StyledWheelsContainer,
|
|
8
|
+
StyledWheelSeparator,
|
|
9
|
+
} from "./TimePicker.styled";
|
|
10
|
+
import { padTwo, parseTimeText } from "./utils";
|
|
11
|
+
import { Wheel } from "./Wheel";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
/** Current input value, parsed to seed the wheels when the modal opens. */
|
|
16
|
+
initialValue: string;
|
|
17
|
+
withSeconds: boolean;
|
|
18
|
+
minuteStep: number;
|
|
19
|
+
secondStep: number;
|
|
20
|
+
readOnly: boolean;
|
|
21
|
+
title?: React.ReactNode;
|
|
22
|
+
okLabel: React.ReactNode;
|
|
23
|
+
cancelLabel: React.ReactNode;
|
|
24
|
+
onClose: () => void;
|
|
25
|
+
onConfirm: (value: string) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const snapToStep = (v: number, step: number, max: number): number => {
|
|
29
|
+
const snapped = Math.round(v / step) * step;
|
|
30
|
+
return Math.min(snapped, max - (max % step === 0 ? step : max % step));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const TimePickerModal = ({
|
|
34
|
+
isOpen,
|
|
35
|
+
initialValue,
|
|
36
|
+
withSeconds,
|
|
37
|
+
minuteStep,
|
|
38
|
+
secondStep,
|
|
39
|
+
readOnly,
|
|
40
|
+
title,
|
|
41
|
+
okLabel,
|
|
42
|
+
cancelLabel,
|
|
43
|
+
onClose,
|
|
44
|
+
onConfirm,
|
|
45
|
+
}: Props) => {
|
|
46
|
+
const [draftHours, setDraftHours] = useState(0);
|
|
47
|
+
const [draftMinutes, setDraftMinutes] = useState(0);
|
|
48
|
+
const [draftSeconds, setDraftSeconds] = useState(0);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!isOpen) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const digits = parseTimeText(initialValue, withSeconds);
|
|
55
|
+
const hh = digits.length >= 2 ? parseInt(digits.slice(0, 2), 10) : 0;
|
|
56
|
+
const mmRaw = digits.length >= 4 ? parseInt(digits.slice(2, 4), 10) : 0;
|
|
57
|
+
const ssRaw = digits.length >= 6 ? parseInt(digits.slice(4, 6), 10) : 0;
|
|
58
|
+
setDraftHours(hh);
|
|
59
|
+
setDraftMinutes(snapToStep(mmRaw, minuteStep, 60));
|
|
60
|
+
setDraftSeconds(snapToStep(ssRaw, secondStep, 60));
|
|
61
|
+
}, [isOpen, initialValue, withSeconds, minuteStep, secondStep]);
|
|
62
|
+
|
|
63
|
+
const handleConfirm = useCallback(() => {
|
|
64
|
+
const next = padTwo(draftHours) + ":" + padTwo(draftMinutes)
|
|
65
|
+
+ (withSeconds ? ":" + padTwo(draftSeconds) : "");
|
|
66
|
+
onConfirm(next);
|
|
67
|
+
}, [draftHours, draftMinutes, draftSeconds, withSeconds, onConfirm]);
|
|
68
|
+
|
|
69
|
+
const handleWheelsKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
70
|
+
if (e.key === "Enter" && !readOnly) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
handleConfirm();
|
|
73
|
+
}
|
|
74
|
+
}, [readOnly, handleConfirm]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Modal
|
|
78
|
+
isOpen={isOpen}
|
|
79
|
+
onClose={onClose}
|
|
80
|
+
title={title}
|
|
81
|
+
>
|
|
82
|
+
<StyledWheelsContainer onKeyDown={handleWheelsKeyDown}>
|
|
83
|
+
<Wheel
|
|
84
|
+
count={24}
|
|
85
|
+
step={1}
|
|
86
|
+
value={draftHours}
|
|
87
|
+
onChange={setDraftHours}
|
|
88
|
+
ariaLabel={"Hours"}
|
|
89
|
+
autoFocus={true}
|
|
90
|
+
/>
|
|
91
|
+
<StyledWheelSeparator>{":"}</StyledWheelSeparator>
|
|
92
|
+
<Wheel
|
|
93
|
+
count={60}
|
|
94
|
+
step={minuteStep}
|
|
95
|
+
value={draftMinutes}
|
|
96
|
+
onChange={setDraftMinutes}
|
|
97
|
+
ariaLabel={"Minutes"}
|
|
98
|
+
/>
|
|
99
|
+
{withSeconds
|
|
100
|
+
? (
|
|
101
|
+
<>
|
|
102
|
+
<StyledWheelSeparator>{":"}</StyledWheelSeparator>
|
|
103
|
+
<Wheel
|
|
104
|
+
count={60}
|
|
105
|
+
step={secondStep}
|
|
106
|
+
value={draftSeconds}
|
|
107
|
+
onChange={setDraftSeconds}
|
|
108
|
+
ariaLabel={"Seconds"}
|
|
109
|
+
/>
|
|
110
|
+
</>
|
|
111
|
+
)
|
|
112
|
+
: null}
|
|
113
|
+
<StyledWheelHighlight aria-hidden={true} />
|
|
114
|
+
</StyledWheelsContainer>
|
|
115
|
+
<ModalButtons>
|
|
116
|
+
<ModalButtons.Button onClick={onClose}>
|
|
117
|
+
{cancelLabel}
|
|
118
|
+
</ModalButtons.Button>
|
|
119
|
+
{readOnly
|
|
120
|
+
? null
|
|
121
|
+
: (
|
|
122
|
+
<ModalButtons.Button variant={"main"} onClick={handleConfirm}>
|
|
123
|
+
{okLabel}
|
|
124
|
+
</ModalButtons.Button>
|
|
125
|
+
)}
|
|
126
|
+
</ModalButtons>
|
|
127
|
+
</Modal>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { TimePickerModal };
|