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,59 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
4
|
+
|
|
5
|
+
import { Button } from "../components/ui/button/Button";
|
|
6
|
+
import { Modal } from "../components/ui/modal/Modal";
|
|
7
|
+
import { ModalButtons } from "../components/ui/modal/ModalButtons";
|
|
8
|
+
import { toast } from "../components/ui/toaster/Toaster";
|
|
9
|
+
|
|
10
|
+
const docs = [
|
|
11
|
+
"Real-world setup: the storybook preview wraps every story in a stacking context",
|
|
12
|
+
"(`transform: translateZ(0)` above `ToasterProvider`), which mirrors what real apps",
|
|
13
|
+
"tend to do unintentionally.",
|
|
14
|
+
"",
|
|
15
|
+
"**Without the fix:** sonner's huge z-index is trapped inside that stacking context.",
|
|
16
|
+
"The modal portals to `document.body` and renders on top — the toast is hidden.",
|
|
17
|
+
"",
|
|
18
|
+
"**With the fix:** `ToasterProvider` portals `<SonnerToaster>` to `document.body`,",
|
|
19
|
+
"escaping the stacking context. The toast renders above the modal.",
|
|
20
|
+
].join("\n");
|
|
21
|
+
|
|
22
|
+
const meta: Meta = {
|
|
23
|
+
title: "Bugfixes/Toasts from a Modal",
|
|
24
|
+
tags: ["bugfixes"],
|
|
25
|
+
parameters: { docs: { description: { component: docs } } },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type Story = StoryObj;
|
|
29
|
+
|
|
30
|
+
const ToastFromModal: Story = {
|
|
31
|
+
render: () => {
|
|
32
|
+
const [open, setOpen] = useState(false);
|
|
33
|
+
|
|
34
|
+
const handleOpen = useCallback(() => { setOpen(true); }, []);
|
|
35
|
+
const handleClose = useCallback(() => { setOpen(false); }, []);
|
|
36
|
+
const handleToast = useCallback(() => {
|
|
37
|
+
toast.success("I should appear above the modal");
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<Button onClick={handleOpen}>Open modal</Button>
|
|
43
|
+
<Modal onClose={handleClose} isOpen={open} title={"Repro"} position={"bottom"} full={true}>
|
|
44
|
+
<p>Click the button — the toast must appear above this modal.</p>
|
|
45
|
+
<ModalButtons>
|
|
46
|
+
<ModalButtons.Button onClick={handleClose}>Cancel</ModalButtons.Button>
|
|
47
|
+
<ModalButtons.Button variant={"main"} onClick={handleToast}>
|
|
48
|
+
Show toast
|
|
49
|
+
</ModalButtons.Button>
|
|
50
|
+
</ModalButtons>
|
|
51
|
+
</Modal>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { ToastFromModal };
|
|
58
|
+
|
|
59
|
+
export default meta;
|
|
@@ -103,8 +103,54 @@ const InputRef: Story = {
|
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
const Validation: Story = {
|
|
107
|
+
render: () => {
|
|
108
|
+
const [submitted, setSubmitted] = React.useState<Record<string, string> | null>(null);
|
|
109
|
+
return (
|
|
110
|
+
<form
|
|
111
|
+
onSubmit={(e) => {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
const data = new FormData(e.currentTarget);
|
|
114
|
+
const result: Record<string, string> = {};
|
|
115
|
+
data.forEach((v, k) => {
|
|
116
|
+
if (typeof v === "string") {
|
|
117
|
+
result[k] = v;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
setSubmitted(result);
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<Gap>
|
|
124
|
+
<div>
|
|
125
|
+
{"Every input reads native validity (pattern / required / type)."
|
|
126
|
+
+ " Type something, blur the field or hit Submit — invalid fields turn red on their own."}
|
|
127
|
+
</div>
|
|
128
|
+
<Input name={"email"} label={"Email"} type={"email"} required={true} />
|
|
129
|
+
<Input name={"required"} label={"Required text"} required={true} />
|
|
130
|
+
<Input
|
|
131
|
+
name={"digits"}
|
|
132
|
+
label={"4 digits only"}
|
|
133
|
+
pattern={"\\d{4}"}
|
|
134
|
+
placeholder={"1234"}
|
|
135
|
+
/>
|
|
136
|
+
<Input
|
|
137
|
+
name={"short"}
|
|
138
|
+
label={"Min 5 characters"}
|
|
139
|
+
minLength={5}
|
|
140
|
+
defaultValue={"abc"}
|
|
141
|
+
/>
|
|
142
|
+
<Button type={"submit"}>{"Submit"}</Button>
|
|
143
|
+
{submitted
|
|
144
|
+
? <div>{"Submitted: " + JSON.stringify(submitted)}</div>
|
|
145
|
+
: null}
|
|
146
|
+
</Gap>
|
|
147
|
+
</form>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
106
152
|
export {
|
|
107
|
-
Primary, Mixed, WithLabel, FloatingLabel, InputRef,
|
|
153
|
+
Primary, Mixed, WithLabel, FloatingLabel, InputRef, Validation,
|
|
108
154
|
};
|
|
109
155
|
|
|
110
156
|
export default meta;
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useId, useRef, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import type { ObjectValue, Value } from "../../../types/form";
|
|
4
4
|
|
|
5
|
+
import { useNativeValidity } from "../../../utils";
|
|
5
6
|
import { Suggestions } from "../Suggestions";
|
|
6
7
|
import {
|
|
7
8
|
StyledInput,
|
|
@@ -53,6 +54,8 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
53
54
|
const isControlled = props.value !== undefined;
|
|
54
55
|
const hasValue = isControlled ? Boolean(props.value) : internalHasValue;
|
|
55
56
|
|
|
57
|
+
const validity = useNativeValidity(error);
|
|
58
|
+
|
|
56
59
|
const suggestionsId = useId();
|
|
57
60
|
const generatedInputId = useId();
|
|
58
61
|
const inputId = id ?? (label ? generatedInputId : undefined);
|
|
@@ -65,8 +68,9 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
65
68
|
|
|
66
69
|
const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
|
67
70
|
setFocused(false);
|
|
71
|
+
validity.onBlur(e);
|
|
68
72
|
onBlur?.(e);
|
|
69
|
-
}, [onBlur]);
|
|
73
|
+
}, [onBlur, validity]);
|
|
70
74
|
|
|
71
75
|
const handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback((e) => {
|
|
72
76
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
@@ -80,6 +84,7 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
80
84
|
if (!isControlled) {
|
|
81
85
|
setInternalHasValue(Boolean(e.currentTarget.value));
|
|
82
86
|
}
|
|
87
|
+
validity.onChange(e);
|
|
83
88
|
if (!suggestions) {
|
|
84
89
|
onChange?.(e);
|
|
85
90
|
return;
|
|
@@ -96,7 +101,7 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
96
101
|
}
|
|
97
102
|
infoRef.current.picked = false;
|
|
98
103
|
onChange?.(e);
|
|
99
|
-
}, [isControlled, suggestions, onChange, onSuggestionMatch]);
|
|
104
|
+
}, [isControlled, suggestions, onChange, onSuggestionMatch, validity]);
|
|
100
105
|
|
|
101
106
|
const prefixElem = prefix ? <StyledPrefix>{prefix}</StyledPrefix> : null;
|
|
102
107
|
const suffixElem = suffix ? <StyledSuffix>{suffix}</StyledSuffix> : null;
|
|
@@ -115,7 +120,7 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
115
120
|
<StyledLabel
|
|
116
121
|
htmlFor={inputId}
|
|
117
122
|
floating={floating}
|
|
118
|
-
error={
|
|
123
|
+
error={validity.finalError}
|
|
119
124
|
>
|
|
120
125
|
{label}
|
|
121
126
|
</StyledLabel>
|
|
@@ -128,7 +133,7 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
128
133
|
focused={focused}
|
|
129
134
|
disabled={Boolean(props.disabled)}
|
|
130
135
|
readOnly={Boolean(props.readOnly)}
|
|
131
|
-
error={
|
|
136
|
+
error={validity.finalError}
|
|
132
137
|
>
|
|
133
138
|
{prefixElem}
|
|
134
139
|
<StyledInputContainer>
|
|
@@ -143,7 +148,8 @@ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-fun
|
|
|
143
148
|
onKeyDown={handleKeyDown}
|
|
144
149
|
onFocus={handleFocus}
|
|
145
150
|
onBlur={handleBlur}
|
|
146
|
-
|
|
151
|
+
onInvalid={validity.onInvalid}
|
|
152
|
+
data-error={validity.finalError}
|
|
147
153
|
/>
|
|
148
154
|
<Suggestions id={suggestionsId} suggestions={suggestions} />
|
|
149
155
|
</StyledInputContainer>
|
|
@@ -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
|
+
};
|