react-miui 0.34.0 → 0.36.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 +17 -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/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.js +13 -3
- package/dist/components/layout/header/HeaderIconAction.js.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.styled.js +11 -17
- package/dist/components/layout/header/HeaderIconAction.styled.js.map +1 -1
- package/dist/components/layout/list/Item.d.ts.map +1 -1
- package/dist/components/layout/list/Item.js +17 -7
- package/dist/components/layout/list/Item.js.map +1 -1
- package/dist/components/layout/list/Item.styled.d.ts.map +1 -1
- package/dist/components/layout/list/Item.styled.js +2 -1
- package/dist/components/layout/list/Item.styled.js.map +1 -1
- package/dist/components/ui/button/Button.d.ts +94 -1
- package/dist/components/ui/button/Button.d.ts.map +1 -1
- package/dist/components/ui/button/Button.js +59 -2
- package/dist/components/ui/button/Button.js.map +1 -1
- package/dist/components/ui/button/Button.styled.d.ts +2 -2
- package/dist/components/ui/button/Button.styled.d.ts.map +1 -1
- package/dist/components/ui/button/Button.styled.js +4 -3
- package/dist/components/ui/button/Button.styled.js.map +1 -1
- package/dist/components/ui/directionPad/Button.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Button.js +7 -2
- package/dist/components/ui/directionPad/Button.js.map +1 -1
- package/dist/components/ui/directionPad/Button.styled.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Button.styled.js +2 -1
- package/dist/components/ui/directionPad/Button.styled.js.map +1 -1
- package/dist/components/ui/directionPad/Middle.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Middle.js +7 -1
- package/dist/components/ui/directionPad/Middle.js.map +1 -1
- package/dist/components/ui/directionPad/Middle.styled.d.ts.map +1 -1
- package/dist/components/ui/directionPad/Middle.styled.js +2 -1
- package/dist/components/ui/directionPad/Middle.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/modal/ModalButtons.d.ts +179 -1
- package/dist/components/ui/modal/ModalButtons.d.ts.map +1 -1
- package/dist/components/ui/modal/ModalButtons.js +63 -2
- package/dist/components/ui/modal/ModalButtons.js.map +1 -1
- package/dist/components/ui/modal/ModalButtons.styled.d.ts +90 -91
- package/dist/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
- package/dist/components/ui/modal/ModalButtons.styled.js +5 -7
- package/dist/components/ui/modal/ModalButtons.styled.js.map +1 -1
- package/dist/components/ui/pop/Pop.styled.d.ts.map +1 -1
- package/dist/components/ui/pop/Pop.styled.js +15 -17
- package/dist/components/ui/pop/Pop.styled.js.map +1 -1
- package/dist/components/ui/pop/PopOption.d.ts.map +1 -1
- package/dist/components/ui/pop/PopOption.js +7 -2
- package/dist/components/ui/pop/PopOption.js.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.d.ts +94 -1
- package/dist/components/ui/toolButton/ToolButton.d.ts.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.js +59 -2
- package/dist/components/ui/toolButton/ToolButton.js.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.styled.d.ts +2 -2
- package/dist/components/ui/toolButton/ToolButton.styled.d.ts.map +1 -1
- package/dist/components/ui/toolButton/ToolButton.styled.js +20 -25
- package/dist/components/ui/toolButton/ToolButton.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/dist/utils/useRipple.d.ts +15 -0
- package/dist/utils/useRipple.d.ts.map +1 -0
- package/dist/utils/useRipple.js +120 -0
- package/dist/utils/useRipple.js.map +1 -0
- package/dist/utils/useRipple.styled.d.ts +28 -0
- package/dist/utils/useRipple.styled.d.ts.map +1 -0
- package/dist/utils/useRipple.styled.js +36 -0
- package/dist/utils/useRipple.styled.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 -9
- 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 -9
- 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/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.js +13 -3
- package/esm/components/layout/header/HeaderIconAction.js.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.styled.js +11 -17
- package/esm/components/layout/header/HeaderIconAction.styled.js.map +1 -1
- package/esm/components/layout/list/Item.d.ts.map +1 -1
- package/esm/components/layout/list/Item.js +18 -8
- package/esm/components/layout/list/Item.js.map +1 -1
- package/esm/components/layout/list/Item.styled.d.ts.map +1 -1
- package/esm/components/layout/list/Item.styled.js +2 -1
- package/esm/components/layout/list/Item.styled.js.map +1 -1
- package/esm/components/ui/button/Button.d.ts +94 -1
- package/esm/components/ui/button/Button.d.ts.map +1 -1
- package/esm/components/ui/button/Button.js +15 -1
- package/esm/components/ui/button/Button.js.map +1 -1
- package/esm/components/ui/button/Button.styled.d.ts +2 -2
- package/esm/components/ui/button/Button.styled.d.ts.map +1 -1
- package/esm/components/ui/button/Button.styled.js +3 -2
- package/esm/components/ui/button/Button.styled.js.map +1 -1
- package/esm/components/ui/directionPad/Button.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Button.js +7 -2
- package/esm/components/ui/directionPad/Button.js.map +1 -1
- package/esm/components/ui/directionPad/Button.styled.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Button.styled.js +2 -1
- package/esm/components/ui/directionPad/Button.styled.js.map +1 -1
- package/esm/components/ui/directionPad/Middle.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Middle.js +7 -1
- package/esm/components/ui/directionPad/Middle.js.map +1 -1
- package/esm/components/ui/directionPad/Middle.styled.d.ts.map +1 -1
- package/esm/components/ui/directionPad/Middle.styled.js +2 -1
- package/esm/components/ui/directionPad/Middle.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/modal/ModalButtons.d.ts +179 -1
- package/esm/components/ui/modal/ModalButtons.d.ts.map +1 -1
- package/esm/components/ui/modal/ModalButtons.js +19 -1
- package/esm/components/ui/modal/ModalButtons.js.map +1 -1
- package/esm/components/ui/modal/ModalButtons.styled.d.ts +90 -91
- package/esm/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
- package/esm/components/ui/modal/ModalButtons.styled.js +3 -6
- package/esm/components/ui/modal/ModalButtons.styled.js.map +1 -1
- package/esm/components/ui/pop/Pop.styled.d.ts.map +1 -1
- package/esm/components/ui/pop/Pop.styled.js +15 -17
- package/esm/components/ui/pop/Pop.styled.js.map +1 -1
- package/esm/components/ui/pop/PopOption.d.ts.map +1 -1
- package/esm/components/ui/pop/PopOption.js +7 -2
- package/esm/components/ui/pop/PopOption.js.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.d.ts +94 -1
- package/esm/components/ui/toolButton/ToolButton.d.ts.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.js +15 -1
- package/esm/components/ui/toolButton/ToolButton.js.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.styled.d.ts +2 -2
- package/esm/components/ui/toolButton/ToolButton.styled.d.ts.map +1 -1
- package/esm/components/ui/toolButton/ToolButton.styled.js +19 -24
- package/esm/components/ui/toolButton/ToolButton.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/esm/utils/useRipple.d.ts +15 -0
- package/esm/utils/useRipple.d.ts.map +1 -0
- package/esm/utils/useRipple.js +84 -0
- package/esm/utils/useRipple.js.map +1 -0
- package/esm/utils/useRipple.styled.d.ts +28 -0
- package/esm/utils/useRipple.styled.d.ts.map +1 -0
- package/esm/utils/useRipple.styled.js +33 -0
- package/esm/utils/useRipple.styled.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/layout/header/HeaderIconAction.styled.ts +11 -18
- package/src/components/layout/header/HeaderIconAction.tsx +32 -5
- package/src/components/layout/list/Item.styled.ts +2 -1
- package/src/components/layout/list/Item.tsx +38 -5
- package/src/components/ui/button/Button.styled.ts +3 -2
- package/src/components/ui/button/Button.tsx +33 -1
- package/src/components/ui/directionPad/Button.styled.ts +2 -1
- package/src/components/ui/directionPad/Button.tsx +13 -1
- package/src/components/ui/directionPad/Middle.styled.ts +2 -1
- package/src/components/ui/directionPad/Middle.tsx +13 -1
- 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/modal/ModalButtons.styled.ts +4 -7
- package/src/components/ui/modal/ModalButtons.tsx +38 -1
- package/src/components/ui/pop/Pop.styled.ts +15 -18
- package/src/components/ui/pop/PopOption.tsx +15 -1
- package/src/components/ui/toolButton/ToolButton.styled.ts +20 -26
- package/src/components/ui/toolButton/ToolButton.tsx +33 -0
- package/src/theme.css-global.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/useNativeValidity.ts +57 -0
- package/src/utils/useRipple.styled.ts +56 -0
- package/src/utils/useRipple.tsx +139 -0
- package/src/components/ui/toolButton/ToolButton.ts +0 -1
|
@@ -1 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
6
|
+
import { StyledButton } from "./Button.styled";
|
|
7
|
+
|
|
8
|
+
type Props = React.ComponentProps<typeof StyledButton>;
|
|
9
|
+
|
|
10
|
+
const Button = forwardRef<HTMLButtonElement, Props>((props, ref) => {
|
|
11
|
+
const { children, onPointerDown, onKeyDown, ...rest } = props;
|
|
12
|
+
const innerRef = useForwardedRef(ref);
|
|
13
|
+
const ripple = useRipple({ ref: innerRef, onPointerDown, onKeyDown });
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<StyledButton
|
|
17
|
+
ref={innerRef}
|
|
18
|
+
onPointerDown={ripple.onPointerDown}
|
|
19
|
+
onKeyDown={ripple.onKeyDown}
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
{ripple.ripples}
|
|
24
|
+
</StyledButton>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
Button.displayName = "Button";
|
|
29
|
+
Button.toString = () => StyledButton.toString();
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
Button,
|
|
33
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
3
6
|
import { StyledButton, StyledDot } from "./Button.styled";
|
|
4
7
|
|
|
5
8
|
type PadButtonProps = {
|
|
@@ -7,9 +10,18 @@ type PadButtonProps = {
|
|
|
7
10
|
};
|
|
8
11
|
|
|
9
12
|
const PadButton = forwardRef<HTMLButtonElement, PadButtonProps>((props, ref) => {
|
|
13
|
+
const innerRef = useForwardedRef(ref);
|
|
14
|
+
const ripple = useRipple({ ref: innerRef, fromCenter: true });
|
|
15
|
+
|
|
10
16
|
return (
|
|
11
|
-
<StyledButton
|
|
17
|
+
<StyledButton
|
|
18
|
+
{...props}
|
|
19
|
+
ref={innerRef}
|
|
20
|
+
onPointerDown={ripple.onPointerDown}
|
|
21
|
+
onKeyDown={ripple.onKeyDown}
|
|
22
|
+
>
|
|
12
23
|
<StyledDot />
|
|
24
|
+
{ripple.ripples}
|
|
13
25
|
</StyledButton>
|
|
14
26
|
);
|
|
15
27
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { styled } from "../../../theme";
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
2
3
|
|
|
3
|
-
const StyledMiddle = styled("button", {
|
|
4
|
+
const StyledMiddle = styled("button", rippleHostStyles, {
|
|
4
5
|
display: "flex",
|
|
5
6
|
alignItems: "center",
|
|
6
7
|
justifyContent: "center",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
3
6
|
import { StyledMiddle } from "./Middle.styled";
|
|
4
7
|
|
|
5
8
|
type PadMiddleProps = {
|
|
@@ -8,9 +11,18 @@ type PadMiddleProps = {
|
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
const PadMiddle = forwardRef<HTMLButtonElement, PadMiddleProps>((props, ref) => {
|
|
14
|
+
const innerRef = useForwardedRef(ref);
|
|
15
|
+
const ripple = useRipple({ ref: innerRef, fromCenter: true });
|
|
16
|
+
|
|
11
17
|
return (
|
|
12
|
-
<StyledMiddle
|
|
18
|
+
<StyledMiddle
|
|
19
|
+
onClick={props.onClick}
|
|
20
|
+
ref={innerRef}
|
|
21
|
+
onPointerDown={ripple.onPointerDown}
|
|
22
|
+
onKeyDown={ripple.onKeyDown}
|
|
23
|
+
>
|
|
13
24
|
{props.label}
|
|
25
|
+
{ripple.ripples}
|
|
14
26
|
</StyledMiddle>
|
|
15
27
|
);
|
|
16
28
|
});
|
|
@@ -8,7 +8,6 @@ import { Label } from "../../form/Label";
|
|
|
8
8
|
import { List } from "../../layout/list/List";
|
|
9
9
|
import { Button } from "../button/Button";
|
|
10
10
|
import { Modal } from "./Modal";
|
|
11
|
-
import { RemovePadding } from "./Modal.styled";
|
|
12
11
|
import { ModalButtons } from "./ModalButtons";
|
|
13
12
|
|
|
14
13
|
const meta: Meta = {
|
|
@@ -77,19 +76,19 @@ const WithRemovedPaddingSections: Story = {
|
|
|
77
76
|
<div>
|
|
78
77
|
<Button onClick={handleOpen}>Open modal</Button>
|
|
79
78
|
<Modal onClose={handleClose} isOpen={open} position={"bottom"} full={true}>
|
|
80
|
-
<RemovePadding>
|
|
79
|
+
<Modal.RemovePadding>
|
|
81
80
|
<Label>
|
|
82
81
|
<Input placeholder={"New station"} />
|
|
83
82
|
</Label>
|
|
84
|
-
</RemovePadding>
|
|
83
|
+
</Modal.RemovePadding>
|
|
85
84
|
<Label>
|
|
86
85
|
<Input placeholder={"New station"} />
|
|
87
86
|
</Label>
|
|
88
|
-
<RemovePadding>
|
|
87
|
+
<Modal.RemovePadding>
|
|
89
88
|
<Label>
|
|
90
89
|
<Input placeholder={"New station"} />
|
|
91
90
|
</Label>
|
|
92
|
-
</RemovePadding>
|
|
91
|
+
</Modal.RemovePadding>
|
|
93
92
|
</Modal>
|
|
94
93
|
</div>
|
|
95
94
|
);
|
|
@@ -116,14 +115,50 @@ const WithList: Story = {
|
|
|
116
115
|
<div>
|
|
117
116
|
<Button onClick={handleOpen}>Open modal</Button>
|
|
118
117
|
<Modal onClose={handleClose} isOpen={open} position={"bottom"} full={true}>
|
|
119
|
-
<RemovePadding>
|
|
118
|
+
<Modal.RemovePadding>
|
|
120
119
|
<List inset={true}>
|
|
121
120
|
<List.Item selected={false} onClick={handleClose}>First item</List.Item>
|
|
122
121
|
<List.Item selected={true} onClick={handleClose}>Second item</List.Item>
|
|
123
122
|
<List.Item selected={false} onClick={handleClose}>Third item</List.Item>
|
|
124
123
|
<List.Item selected={false} onClick={handleClose}>Last option</List.Item>
|
|
125
124
|
</List>
|
|
126
|
-
</RemovePadding>
|
|
125
|
+
</Modal.RemovePadding>
|
|
126
|
+
</Modal>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Demonstrates a known issue: when the modal content is taller than the viewport,
|
|
134
|
+
* it gets clipped at the top and bottom because `ContainerStyled` has
|
|
135
|
+
* `maxHeight: 100%` but no `overflow: auto`. There is no scrolling inside the modal.
|
|
136
|
+
*/
|
|
137
|
+
const WithLongContent: Story = {
|
|
138
|
+
args: {},
|
|
139
|
+
render: () => {
|
|
140
|
+
const [open, setIsOpen] = useState(false);
|
|
141
|
+
|
|
142
|
+
const handleClose = useCallback(() => {
|
|
143
|
+
setIsOpen(false);
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
const handleOpen = useCallback(() => {
|
|
147
|
+
setIsOpen(true);
|
|
148
|
+
}, []);
|
|
149
|
+
|
|
150
|
+
const lines = Array.from({ length: 60 }, (_, i) => i + 1);
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<div>
|
|
154
|
+
<Button onClick={handleOpen}>Open modal</Button>
|
|
155
|
+
<Modal onClose={handleClose} isOpen={open} title={"Long content"}>
|
|
156
|
+
{lines.map((n) => (
|
|
157
|
+
<p key={n}>
|
|
158
|
+
Line {n} — Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
159
|
+
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
160
|
+
</p>
|
|
161
|
+
))}
|
|
127
162
|
</Modal>
|
|
128
163
|
</div>
|
|
129
164
|
);
|
|
@@ -134,6 +169,7 @@ export {
|
|
|
134
169
|
Primary,
|
|
135
170
|
WithRemovedPaddingSections,
|
|
136
171
|
WithList,
|
|
172
|
+
WithLongContent,
|
|
137
173
|
};
|
|
138
174
|
|
|
139
175
|
export default meta;
|
|
@@ -13,20 +13,25 @@ const overlay = keyframes({
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
const OverlayStyled = styled("div", {
|
|
16
|
-
position: "fixed",
|
|
17
|
-
zIndex: 4,
|
|
18
|
-
top: 0,
|
|
19
|
-
bottom: 0,
|
|
20
|
-
left: 0,
|
|
21
|
-
right: 0,
|
|
22
|
-
display: "flex",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
justifyContent: "center",
|
|
25
|
-
animation: `${overlay.toString()} 300ms`,
|
|
26
|
-
animationFillMode: "forwards",
|
|
27
|
-
backdropFilter: "blur(5px)",
|
|
16
|
+
"position": "fixed",
|
|
17
|
+
"zIndex": 4,
|
|
18
|
+
"top": 0,
|
|
19
|
+
"bottom": 0,
|
|
20
|
+
"left": 0,
|
|
21
|
+
"right": 0,
|
|
22
|
+
"display": "flex",
|
|
23
|
+
"alignItems": "center",
|
|
24
|
+
"justifyContent": "center",
|
|
25
|
+
"animation": `${overlay.toString()} 300ms`,
|
|
26
|
+
"animationFillMode": "forwards",
|
|
27
|
+
"backdropFilter": "blur(5px)",
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
30
|
+
animation: "none",
|
|
31
|
+
background: "rgba($background, 0.3)",
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
"variants": {
|
|
30
35
|
position: {
|
|
31
36
|
bottom: {
|
|
32
37
|
alignItems: "flex-end",
|
|
@@ -57,18 +62,33 @@ const RemovePadding = styled("div", {
|
|
|
57
62
|
});
|
|
58
63
|
|
|
59
64
|
const ContainerStyled = styled("div", {
|
|
60
|
-
background: "$modalBg",
|
|
61
|
-
borderRadius: dimensionsPxToRem(12),
|
|
62
|
-
maxWidth: pxToRem(333),
|
|
63
|
-
maxHeight: "100%",
|
|
64
|
-
width: "calc(100% - 30px)",
|
|
65
|
-
padding: PADDING,
|
|
66
|
-
position: "relative",
|
|
67
|
-
boxSizing: "border-box",
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
"background": "$modalBg",
|
|
66
|
+
"borderRadius": dimensionsPxToRem(12),
|
|
67
|
+
"maxWidth": pxToRem(333),
|
|
68
|
+
"maxHeight": "100%",
|
|
69
|
+
"width": "calc(100% - 30px)",
|
|
70
|
+
"padding": PADDING,
|
|
71
|
+
"position": "relative",
|
|
72
|
+
"boxSizing": "border-box",
|
|
73
|
+
"overflowY": "auto",
|
|
74
|
+
"overscrollBehavior": "contain",
|
|
75
|
+
"animation": `${container.toString()} 300ms`,
|
|
76
|
+
"animationFillMode": "forwards",
|
|
77
|
+
|
|
78
|
+
// The dialog uses tabindex=-1 to be programmatically focusable for initial focus
|
|
79
|
+
// fallback (when there is no focusable child). Hide the outline since it's only
|
|
80
|
+
// there as a focus target, not a user-visible affordance.
|
|
81
|
+
"&:focus": {
|
|
82
|
+
outline: "none",
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
86
|
+
animation: "none",
|
|
87
|
+
opacity: 1,
|
|
88
|
+
transform: "none",
|
|
89
|
+
},
|
|
70
90
|
|
|
71
|
-
variants: {
|
|
91
|
+
"variants": {
|
|
72
92
|
// TODO this is very not rwd, it should be a media query
|
|
73
93
|
full: {
|
|
74
94
|
true: {
|
|
@@ -84,11 +104,12 @@ const ContainerStyled = styled("div", {
|
|
|
84
104
|
},
|
|
85
105
|
});
|
|
86
106
|
|
|
87
|
-
const TitleStyled = styled("
|
|
107
|
+
const TitleStyled = styled("h2", {
|
|
88
108
|
fontSize: fontPxToRem(40),
|
|
89
109
|
textAlign: "center",
|
|
90
110
|
color: "$text3",
|
|
91
111
|
margin: `${dimensionsPxToRem(90)} 0`,
|
|
112
|
+
fontWeight: "inherit",
|
|
92
113
|
});
|
|
93
114
|
|
|
94
115
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { forwardRef, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
3
|
|
|
4
4
|
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
@@ -6,18 +6,34 @@ import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
|
6
6
|
import type { ThemeCSS } from "../../../theme";
|
|
7
7
|
|
|
8
8
|
import { fnWithProps } from "../../../types/fnWithProps";
|
|
9
|
+
import { HandleEsc } from "../../utils/HandleEsc";
|
|
9
10
|
import { ContainerStyled, NEGATIVE_PADDING, OverlayStyled, RemovePadding, TitleStyled } from "./Modal.styled";
|
|
10
11
|
|
|
11
12
|
type OverlayProps = React.ComponentProps<typeof OverlayStyled>;
|
|
12
13
|
type ContainerProps = React.ComponentProps<typeof ContainerStyled>;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const FOCUSABLE_SELECTOR = [
|
|
16
|
+
"a[href]",
|
|
17
|
+
"button:not([disabled])",
|
|
18
|
+
"input:not([disabled])",
|
|
19
|
+
"select:not([disabled])",
|
|
20
|
+
"textarea:not([disabled])",
|
|
21
|
+
"[tabindex]:not([tabindex=\"-1\"])",
|
|
22
|
+
].join(",");
|
|
23
|
+
|
|
24
|
+
const prefersReducedMotion = () => {
|
|
25
|
+
if (typeof window === "undefined") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
interface Props extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
15
32
|
onOverlayClick?: (() => void) | "close" | null;
|
|
16
33
|
closeOnEsc?: boolean;
|
|
17
34
|
onClose: () => void;
|
|
18
35
|
isOpen: boolean;
|
|
19
36
|
title?: React.ReactNode;
|
|
20
|
-
className?: string;
|
|
21
37
|
portal?: boolean | HTMLElement;
|
|
22
38
|
children: React.ReactNode;
|
|
23
39
|
|
|
@@ -39,57 +55,107 @@ const ModalBase = forwardRef<HTMLDivElement, Props>(({
|
|
|
39
55
|
portal = true,
|
|
40
56
|
position,
|
|
41
57
|
full,
|
|
58
|
+
...rest
|
|
42
59
|
}, ref) => {
|
|
43
60
|
const [isClosing, setIsClosing] = useState(false);
|
|
44
61
|
const [isRendered, setIsRendered] = useState(false);
|
|
45
62
|
const overlayRef = useRef<HTMLDivElement>(null);
|
|
46
63
|
const containerRef = useForwardedRef(ref);
|
|
64
|
+
const previouslyFocusedRef = useRef<HTMLElement | null>(null);
|
|
65
|
+
const titleId = useId();
|
|
47
66
|
|
|
48
67
|
useEffect(() => {
|
|
49
|
-
if (
|
|
68
|
+
if (isOpen) {
|
|
69
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
70
|
+
setIsRendered(true);
|
|
71
|
+
setIsClosing(false);
|
|
50
72
|
return;
|
|
51
73
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
document.addEventListener("keydown", onKeyDown);
|
|
59
|
-
return () => {
|
|
60
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
61
|
-
};
|
|
62
|
-
}, [isOpen, closeOnEsc, onClose]);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (!isOpen) {
|
|
66
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
67
|
-
setIsClosing(true);
|
|
74
|
+
// Under reduced motion the close animation is disabled, so onAnimationEnd will
|
|
75
|
+
// never fire — unmount synchronously instead.
|
|
76
|
+
if (prefersReducedMotion()) {
|
|
77
|
+
setIsRendered(false);
|
|
78
|
+
setIsClosing(false);
|
|
68
79
|
return;
|
|
69
80
|
}
|
|
70
|
-
|
|
71
|
-
setIsClosing(false);
|
|
81
|
+
setIsClosing(true);
|
|
72
82
|
}, [isOpen]);
|
|
73
83
|
|
|
74
84
|
useEffect(() => {
|
|
75
85
|
if (!isClosing) {
|
|
76
86
|
return;
|
|
77
87
|
}
|
|
78
|
-
|
|
88
|
+
const overlay = overlayRef.current;
|
|
89
|
+
const container = containerRef.current;
|
|
79
90
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
80
|
-
if (!
|
|
91
|
+
if (!overlay || !container) {
|
|
81
92
|
return;
|
|
82
93
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
// animationFillMode: forwards leaves the keyframe in its end state, so flipping
|
|
95
|
+
// animationDirection to reverse alone wouldn't replay it. Force a restart by
|
|
96
|
+
// clearing animation, triggering reflow, then letting the variant's reverse run.
|
|
97
|
+
overlay.style.animation = "none";
|
|
98
|
+
container.style.animation = "none";
|
|
86
99
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
overlay.offsetHeight;
|
|
101
|
+
overlay.style.removeProperty("animation");
|
|
102
|
+
container.style.removeProperty("animation");
|
|
90
103
|
}, [isClosing, containerRef]);
|
|
91
104
|
|
|
92
|
-
|
|
105
|
+
// Focus management: capture previous focus on open, set initial focus inside the
|
|
106
|
+
// dialog, restore focus on close. Tab containment + AT-hiding is delegated to the
|
|
107
|
+
// `inert` attribute on everything outside the modal subtree (native browser handles
|
|
108
|
+
// Tab cycling, screen-reader pruning, and pointer-event blocking).
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!isOpen || !isRendered) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const container = containerRef.current;
|
|
114
|
+
const overlay = overlayRef.current;
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
116
|
+
if (!container || !overlay) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
previouslyFocusedRef.current = document.activeElement instanceof HTMLElement
|
|
121
|
+
? document.activeElement
|
|
122
|
+
: null;
|
|
123
|
+
|
|
124
|
+
const focusables = container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR);
|
|
125
|
+
(focusables[0] ?? container).focus();
|
|
126
|
+
|
|
127
|
+
// Walk up from the overlay to <body>; at each level mark every sibling of the
|
|
128
|
+
// cursor as inert. Already-inert nodes (e.g. from a nesting modal) are skipped
|
|
129
|
+
// so that the outer owner remains responsible for cleanup — this gives correct
|
|
130
|
+
// stacking for nested modals without a separate registry.
|
|
131
|
+
const inerted: HTMLElement[] = [];
|
|
132
|
+
let cursor: HTMLElement = overlay;
|
|
133
|
+
while (cursor !== document.body) {
|
|
134
|
+
const parentEl: HTMLElement | null = cursor.parentElement;
|
|
135
|
+
if (!parentEl) {
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
for (const child of Array.from(parentEl.children)) {
|
|
139
|
+
if (child === cursor || !(child instanceof HTMLElement)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (!child.hasAttribute("inert")) {
|
|
143
|
+
child.setAttribute("inert", "");
|
|
144
|
+
inerted.push(child);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
cursor = parentEl;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return () => {
|
|
151
|
+
inerted.forEach((el) => {
|
|
152
|
+
el.removeAttribute("inert");
|
|
153
|
+
});
|
|
154
|
+
previouslyFocusedRef.current?.focus();
|
|
155
|
+
};
|
|
156
|
+
}, [isOpen, isRendered, containerRef]);
|
|
157
|
+
|
|
158
|
+
const titleElem = title ? <TitleStyled id={titleId}>{title}</TitleStyled> : null;
|
|
93
159
|
|
|
94
160
|
const handleOverlayClick = useCallback((e: React.MouseEvent) => {
|
|
95
161
|
if (e.target !== e.currentTarget) {
|
|
@@ -98,16 +164,18 @@ const ModalBase = forwardRef<HTMLDivElement, Props>(({
|
|
|
98
164
|
if (onOverlayClick === "close") {
|
|
99
165
|
onClose();
|
|
100
166
|
}
|
|
101
|
-
if (typeof onOverlayClick === "function") {
|
|
167
|
+
else if (typeof onOverlayClick === "function") {
|
|
102
168
|
onOverlayClick();
|
|
103
169
|
}
|
|
104
170
|
}, [onOverlayClick, onClose]);
|
|
105
171
|
|
|
106
|
-
const handleAnimationEnd = useCallback(() => {
|
|
172
|
+
const handleAnimationEnd = useCallback((e: React.AnimationEvent) => {
|
|
173
|
+
if (e.target !== e.currentTarget) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
107
176
|
if (isOpen) {
|
|
108
177
|
return;
|
|
109
178
|
}
|
|
110
|
-
|
|
111
179
|
setIsRendered(false);
|
|
112
180
|
}, [isOpen]);
|
|
113
181
|
|
|
@@ -116,30 +184,35 @@ const ModalBase = forwardRef<HTMLDivElement, Props>(({
|
|
|
116
184
|
}
|
|
117
185
|
|
|
118
186
|
const overlayVariants: Pick<OverlayProps, "isClosing" | "position"> = {};
|
|
119
|
-
|
|
120
|
-
|
|
187
|
+
if (isClosing) {
|
|
188
|
+
overlayVariants.isClosing = true;
|
|
189
|
+
}
|
|
190
|
+
if (position != null) {
|
|
191
|
+
overlayVariants.position = position;
|
|
192
|
+
}
|
|
121
193
|
|
|
122
194
|
const containerVariants: Pick<ContainerProps, "isClosing" | "full"> = {};
|
|
123
|
-
|
|
124
|
-
|
|
195
|
+
if (isClosing) {
|
|
196
|
+
containerVariants.isClosing = true;
|
|
197
|
+
}
|
|
198
|
+
if (full != null) {
|
|
199
|
+
containerVariants.full = full;
|
|
200
|
+
}
|
|
125
201
|
|
|
126
202
|
const childrenCount = React.Children.count(children);
|
|
127
203
|
|
|
128
204
|
const chld = React.Children.map(children, (child, index) => {
|
|
129
|
-
if (React.isValidElement(child)) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
css.marginTop = NEGATIVE_PADDING;
|
|
135
|
-
}
|
|
136
|
-
if (index === childrenCount - 1) {
|
|
137
|
-
css.marginBottom = NEGATIVE_PADDING;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return React.cloneElement(child, { css });
|
|
205
|
+
if (React.isValidElement(child) && child.type === RemovePadding) {
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
|
207
|
+
const css: ThemeCSS = { ...(child.props.css ?? {}) };
|
|
208
|
+
if (index === 0 && titleElem == null) {
|
|
209
|
+
css.marginTop = NEGATIVE_PADDING;
|
|
141
210
|
}
|
|
142
|
-
|
|
211
|
+
if (index === childrenCount - 1) {
|
|
212
|
+
css.marginBottom = NEGATIVE_PADDING;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return React.cloneElement(child, { css });
|
|
143
216
|
}
|
|
144
217
|
return child;
|
|
145
218
|
});
|
|
@@ -151,7 +224,17 @@ const ModalBase = forwardRef<HTMLDivElement, Props>(({
|
|
|
151
224
|
ref={overlayRef}
|
|
152
225
|
onAnimationEnd={handleAnimationEnd}
|
|
153
226
|
>
|
|
154
|
-
<
|
|
227
|
+
{closeOnEsc ? <HandleEsc onPress={onClose} /> : null}
|
|
228
|
+
<ContainerStyled
|
|
229
|
+
role={"dialog"}
|
|
230
|
+
aria-modal={true}
|
|
231
|
+
aria-labelledby={titleElem ? titleId : undefined}
|
|
232
|
+
tabIndex={-1}
|
|
233
|
+
className={className}
|
|
234
|
+
{...containerVariants}
|
|
235
|
+
ref={containerRef}
|
|
236
|
+
{...rest}
|
|
237
|
+
>
|
|
155
238
|
{titleElem}
|
|
156
239
|
{chld}
|
|
157
240
|
</ContainerStyled>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dimensionsPxToRem, styled } from "../../../theme";
|
|
2
|
-
import {
|
|
2
|
+
import { rippleHostStyles } from "../../../utils/useRipple.styled";
|
|
3
3
|
import { NEGATIVE_PADDING } from "./Modal.styled";
|
|
4
4
|
|
|
5
5
|
const Container = styled("div", {
|
|
@@ -9,7 +9,7 @@ const Container = styled("div", {
|
|
|
9
9
|
marginBottom: NEGATIVE_PADDING,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const StyledButton = styled("button", rippleHostStyles, {
|
|
13
13
|
"border": "none",
|
|
14
14
|
"borderTop": "1px solid $modalButtonBorder",
|
|
15
15
|
"background": "$modalButtonBg",
|
|
@@ -41,10 +41,7 @@ const Button = styled("button", {
|
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const ModalButtons = fnWithProps(Container, {
|
|
45
|
-
Button,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
44
|
export {
|
|
49
|
-
|
|
45
|
+
Container,
|
|
46
|
+
StyledButton,
|
|
50
47
|
};
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
|
|
4
|
+
|
|
5
|
+
import { fnWithProps } from "../../../types/fnWithProps";
|
|
6
|
+
import { useRipple } from "../../../utils/useRipple";
|
|
7
|
+
import { Container, StyledButton } from "./ModalButtons.styled";
|
|
8
|
+
|
|
9
|
+
type ButtonProps = React.ComponentProps<typeof StyledButton>;
|
|
10
|
+
|
|
11
|
+
const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
12
|
+
const { children, onPointerDown, onKeyDown, ...rest } = props;
|
|
13
|
+
const innerRef = useForwardedRef(ref);
|
|
14
|
+
const ripple = useRipple({ ref: innerRef, onPointerDown, onKeyDown });
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<StyledButton
|
|
18
|
+
ref={innerRef}
|
|
19
|
+
onPointerDown={ripple.onPointerDown}
|
|
20
|
+
onKeyDown={ripple.onKeyDown}
|
|
21
|
+
{...rest}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
{ripple.ripples}
|
|
25
|
+
</StyledButton>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
Button.displayName = "ModalButtons.Button";
|
|
30
|
+
Button.toString = () => StyledButton.toString();
|
|
31
|
+
|
|
32
|
+
const ModalButtons = fnWithProps(Container, {
|
|
33
|
+
Button,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ModalButtons,
|
|
38
|
+
};
|