react-miui 0.33.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.json +12 -0
- package/.claude/settings.local.json +5 -1
- package/.storybook/preview.tsx +10 -4
- package/CHANGELOG.md +22 -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/drawer/Drawer.d.ts +10 -1
- package/dist/components/ui/drawer/Drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer/Drawer.js +135 -15
- package/dist/components/ui/drawer/Drawer.js.map +1 -1
- package/dist/components/ui/drawer/Drawer.styled.d.ts +86 -1
- package/dist/components/ui/drawer/Drawer.styled.d.ts.map +1 -1
- package/dist/components/ui/drawer/Drawer.styled.js +13 -1
- package/dist/components/ui/drawer/Drawer.styled.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/components/ui/toaster/Toaster.d.ts.map +1 -1
- package/dist/components/ui/toaster/Toaster.js +7 -1
- package/dist/components/ui/toaster/Toaster.js.map +1 -1
- package/dist/components/ui/tooltip/Tooltip.d.ts +30 -0
- package/dist/components/ui/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip/Tooltip.js +81 -0
- package/dist/components/ui/tooltip/Tooltip.js.map +1 -0
- package/dist/components/ui/tooltip/Tooltip.styled.d.ts +173 -0
- package/dist/components/ui/tooltip/Tooltip.styled.d.ts.map +1 -0
- package/dist/components/ui/tooltip/Tooltip.styled.js +65 -0
- package/dist/components/ui/tooltip/Tooltip.styled.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.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/highlight.css +7 -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 +4 -4
- package/docs/functions/index.Card.html +3 -3
- 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 +3 -3
- 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 +4 -4
- 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 +4 -4
- 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 +3 -3
- package/docs/functions/index.Section.html +4 -4
- package/docs/functions/index.Select.html +3 -3
- package/docs/functions/index.Selector.html +2 -2
- package/docs/functions/index.Spacer.html +3 -3
- package/docs/functions/index.Stats.html +2 -2
- package/docs/functions/index.StickyHeader.html +4 -4
- package/docs/functions/index.Table.html +3 -3
- 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 +4 -4
- package/docs/functions/index.Tooltip.html +18 -0
- package/docs/functions/index.TooltipProvider.html +6 -0
- 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 +36 -0
- package/docs/interfaces/index.TooltipProviderProps.html +13 -0
- 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 -0
- package/docs/types/index.DrawerProps.html +28 -1
- 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 -0
- 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/drawer/Drawer.d.ts +10 -1
- package/esm/components/ui/drawer/Drawer.d.ts.map +1 -1
- package/esm/components/ui/drawer/Drawer.js +139 -15
- package/esm/components/ui/drawer/Drawer.js.map +1 -1
- package/esm/components/ui/drawer/Drawer.styled.d.ts +86 -1
- package/esm/components/ui/drawer/Drawer.styled.d.ts.map +1 -1
- package/esm/components/ui/drawer/Drawer.styled.js +12 -1
- package/esm/components/ui/drawer/Drawer.styled.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/components/ui/toaster/Toaster.d.ts.map +1 -1
- package/esm/components/ui/toaster/Toaster.js +8 -2
- package/esm/components/ui/toaster/Toaster.js.map +1 -1
- package/esm/components/ui/tooltip/Tooltip.d.ts +30 -0
- package/esm/components/ui/tooltip/Tooltip.d.ts.map +1 -0
- package/esm/components/ui/tooltip/Tooltip.js +43 -0
- package/esm/components/ui/tooltip/Tooltip.js.map +1 -0
- package/esm/components/ui/tooltip/Tooltip.styled.d.ts +173 -0
- package/esm/components/ui/tooltip/Tooltip.styled.d.ts.map +1 -0
- package/esm/components/ui/tooltip/Tooltip.styled.js +28 -0
- package/esm/components/ui/tooltip/Tooltip.styled.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.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 +2 -1
- package/pnpm-workspace.yaml +3 -0
- package/src/bugfixes/ToastsFromModal.stories.tsx +59 -0
- 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/drawer/Drawer.stories.tsx +143 -59
- package/src/components/ui/drawer/Drawer.styled.ts +13 -0
- package/src/components/ui/drawer/Drawer.tsx +214 -20
- 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/components/ui/toaster/Toaster.tsx +12 -2
- package/src/components/ui/tooltip/Tooltip.stories.tsx +285 -0
- package/src/components/ui/tooltip/Tooltip.styled.ts +36 -0
- package/src/components/ui/tooltip/Tooltip.tsx +195 -0
- package/src/index.ts +1 -0
- 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,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface CustomProps {
|
|
3
|
+
children?: never;
|
|
4
|
+
label?: string;
|
|
5
|
+
pinnedLabel?: boolean;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
withSeconds?: boolean;
|
|
8
|
+
minuteStep?: number;
|
|
9
|
+
secondStep?: number;
|
|
10
|
+
value?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
|
+
modalTitle?: React.ReactNode;
|
|
14
|
+
okLabel?: React.ReactNode;
|
|
15
|
+
cancelLabel?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
type InputAttrs = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "type" | "prefix" | "pattern" | "placeholder" | "maxLength">;
|
|
18
|
+
type Props = InputAttrs & CustomProps;
|
|
19
|
+
declare const TimePicker: React.ForwardRefExoticComponent<InputAttrs & CustomProps & React.RefAttributes<HTMLInputElement>>;
|
|
20
|
+
export { TimePicker };
|
|
21
|
+
export type { Props as TimePickerProps };
|
|
22
|
+
//# sourceMappingURL=TimePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../../src/components/form/timepicker/TimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AA+Bf,UAAU,WAAW;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC;AAED,KAAK,UAAU,GAAG,IAAI,CAClB,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC3C,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CACtG,CAAC;AAEF,KAAK,KAAK,GAAG,UAAU,GAAG,WAAW,CAAC;AAsKtC,QAAA,MAAM,UAAU,mGAAgB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,YAAY,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useEffect, useId, useState, } from "react";
|
|
2
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
3
|
+
import { useNativeValidity } from "../../../utils/useNativeValidity.js";
|
|
4
|
+
import { Clock } from "../../icons/Clock.js";
|
|
5
|
+
import { StyledInputContainer, StyledLabel, StyledSuffix, StyledWrapper, } from "../input/Input.styled.js";
|
|
6
|
+
import { StyledSuffixButton, StyledTimeInput, } from "./TimePicker.styled.js";
|
|
7
|
+
import { TimePickerModal } from "./TimePickerModal.js";
|
|
8
|
+
const PATTERN_HHMM = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
9
|
+
const PATTERN_HHMMSS = "(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
10
|
+
const MAX_LEN_HHMM = 5;
|
|
11
|
+
const MAX_LEN_HHMMSS = 8;
|
|
12
|
+
const assertStep = (name, step) => {
|
|
13
|
+
if (!Number.isInteger(step) || step < 1 || step > 60) {
|
|
14
|
+
throw new Error(`TimePicker: \`${name}\` must be an integer between 1 and 60, got ${String(step)}`);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const TimePickerInner = ({ className, label, pinnedLabel = false, error, withSeconds = false, minuteStep = 1, secondStep = 1, value, defaultValue, onChange, onFocus, onBlur, disabled, readOnly, id, modalTitle, okLabel = "OK", cancelLabel = "Cancel", ...rest }, ref) => {
|
|
18
|
+
assertStep("minuteStep", minuteStep);
|
|
19
|
+
if (withSeconds) {
|
|
20
|
+
assertStep("secondStep", secondStep);
|
|
21
|
+
}
|
|
22
|
+
const isControlled = value !== undefined;
|
|
23
|
+
const [internalValue, setInternalValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : "");
|
|
24
|
+
const currentValue = isControlled ? (value !== null && value !== void 0 ? value : "") : internalValue;
|
|
25
|
+
const [focused, setFocused] = useState(false);
|
|
26
|
+
const validity = useNativeValidity(error);
|
|
27
|
+
const { revalidate } = validity;
|
|
28
|
+
const inputRef = useForwardedRef(ref);
|
|
29
|
+
const generatedId = useId();
|
|
30
|
+
const inputId = id !== null && id !== void 0 ? id : (label ? generatedId : undefined);
|
|
31
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
32
|
+
const handleChange = useCallback((e) => {
|
|
33
|
+
const next = e.target.value;
|
|
34
|
+
if (!isControlled) {
|
|
35
|
+
setInternalValue(next);
|
|
36
|
+
}
|
|
37
|
+
validity.onChange(e);
|
|
38
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
39
|
+
}, [isControlled, onChange, validity]);
|
|
40
|
+
const handleFocus = useCallback((e) => {
|
|
41
|
+
setFocused(true);
|
|
42
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
43
|
+
}, [onFocus]);
|
|
44
|
+
const handleBlur = useCallback((e) => {
|
|
45
|
+
setFocused(false);
|
|
46
|
+
validity.onBlur(e);
|
|
47
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
48
|
+
}, [onBlur, validity]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
revalidate(inputRef.current);
|
|
51
|
+
}, [currentValue, revalidate, inputRef]);
|
|
52
|
+
const openModal = useCallback(() => {
|
|
53
|
+
setModalOpen(true);
|
|
54
|
+
}, []);
|
|
55
|
+
const closeModal = useCallback(() => {
|
|
56
|
+
var _a;
|
|
57
|
+
setModalOpen(false);
|
|
58
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
59
|
+
}, [inputRef]);
|
|
60
|
+
const confirmModal = useCallback((next) => {
|
|
61
|
+
var _a;
|
|
62
|
+
if (!isControlled) {
|
|
63
|
+
setInternalValue(next);
|
|
64
|
+
}
|
|
65
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
66
|
+
setModalOpen(false);
|
|
67
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
68
|
+
}, [isControlled, onChange, inputRef]);
|
|
69
|
+
const hasValue = currentValue.length > 0;
|
|
70
|
+
const floating = Boolean(label) && (pinnedLabel || focused || hasValue);
|
|
71
|
+
const placeholder = withSeconds ? "--:--:--" : "--:--";
|
|
72
|
+
const pattern = withSeconds ? PATTERN_HHMMSS : PATTERN_HHMM;
|
|
73
|
+
const maxLength = withSeconds ? MAX_LEN_HHMMSS : MAX_LEN_HHMM;
|
|
74
|
+
const finalError = validity.finalError;
|
|
75
|
+
const labelElem = label
|
|
76
|
+
? (React.createElement(StyledLabel, { htmlFor: inputId, floating: floating, error: finalError }, label))
|
|
77
|
+
: null;
|
|
78
|
+
return (React.createElement(React.Fragment, null,
|
|
79
|
+
React.createElement(StyledWrapper, { className: className, focused: focused, disabled: Boolean(disabled), readOnly: Boolean(readOnly), error: finalError },
|
|
80
|
+
React.createElement(StyledInputContainer, null,
|
|
81
|
+
labelElem,
|
|
82
|
+
React.createElement(StyledTimeInput, { ref: inputRef, ...rest, id: inputId, type: "text", inputMode: "numeric", autoComplete: "off", value: currentValue, placeholder: placeholder, pattern: pattern, maxLength: maxLength, disabled: disabled, readOnly: readOnly, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onInvalid: validity.onInvalid, "data-error": finalError })),
|
|
83
|
+
React.createElement(StyledSuffix, null,
|
|
84
|
+
React.createElement(StyledSuffixButton, { type: "button", onClick: openModal, disabled: disabled, "aria-label": "Open time picker" },
|
|
85
|
+
React.createElement(Clock, null)))),
|
|
86
|
+
React.createElement(TimePickerModal, { isOpen: modalOpen, initialValue: currentValue, withSeconds: withSeconds, minuteStep: minuteStep, secondStep: secondStep, readOnly: Boolean(readOnly), title: modalTitle, okLabel: okLabel, cancelLabel: cancelLabel, onClose: closeModal, onConfirm: confirmModal })));
|
|
87
|
+
};
|
|
88
|
+
const TimePickerRef = forwardRef(TimePickerInner);
|
|
89
|
+
TimePickerRef.displayName = "TimePicker";
|
|
90
|
+
TimePickerRef.toString = () => StyledWrapper.toString();
|
|
91
|
+
const TimePicker = TimePickerRef;
|
|
92
|
+
export { TimePicker };
|
|
93
|
+
//# sourceMappingURL=TimePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.js","sourceRoot":"","sources":["../../../../src/components/form/timepicker/TimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,EACL,QAAQ,GACX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACH,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,aAAa,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,kBAAkB,EAClB,eAAe,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,YA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