react-miui 0.35.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.
Files changed (290) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/components/layout/header/HeaderIconAction.d.ts.map +1 -1
  3. package/dist/components/layout/header/HeaderIconAction.js +13 -3
  4. package/dist/components/layout/header/HeaderIconAction.js.map +1 -1
  5. package/dist/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
  6. package/dist/components/layout/header/HeaderIconAction.styled.js +11 -17
  7. package/dist/components/layout/header/HeaderIconAction.styled.js.map +1 -1
  8. package/dist/components/layout/list/Item.d.ts.map +1 -1
  9. package/dist/components/layout/list/Item.js +17 -7
  10. package/dist/components/layout/list/Item.js.map +1 -1
  11. package/dist/components/layout/list/Item.styled.d.ts.map +1 -1
  12. package/dist/components/layout/list/Item.styled.js +2 -1
  13. package/dist/components/layout/list/Item.styled.js.map +1 -1
  14. package/dist/components/ui/button/Button.d.ts +94 -1
  15. package/dist/components/ui/button/Button.d.ts.map +1 -1
  16. package/dist/components/ui/button/Button.js +59 -2
  17. package/dist/components/ui/button/Button.js.map +1 -1
  18. package/dist/components/ui/button/Button.styled.d.ts +2 -2
  19. package/dist/components/ui/button/Button.styled.d.ts.map +1 -1
  20. package/dist/components/ui/button/Button.styled.js +4 -3
  21. package/dist/components/ui/button/Button.styled.js.map +1 -1
  22. package/dist/components/ui/directionPad/Button.d.ts.map +1 -1
  23. package/dist/components/ui/directionPad/Button.js +7 -2
  24. package/dist/components/ui/directionPad/Button.js.map +1 -1
  25. package/dist/components/ui/directionPad/Button.styled.d.ts.map +1 -1
  26. package/dist/components/ui/directionPad/Button.styled.js +2 -1
  27. package/dist/components/ui/directionPad/Button.styled.js.map +1 -1
  28. package/dist/components/ui/directionPad/Middle.d.ts.map +1 -1
  29. package/dist/components/ui/directionPad/Middle.js +7 -1
  30. package/dist/components/ui/directionPad/Middle.js.map +1 -1
  31. package/dist/components/ui/directionPad/Middle.styled.d.ts.map +1 -1
  32. package/dist/components/ui/directionPad/Middle.styled.js +2 -1
  33. package/dist/components/ui/directionPad/Middle.styled.js.map +1 -1
  34. package/dist/components/ui/modal/ModalButtons.d.ts +179 -1
  35. package/dist/components/ui/modal/ModalButtons.d.ts.map +1 -1
  36. package/dist/components/ui/modal/ModalButtons.js +63 -2
  37. package/dist/components/ui/modal/ModalButtons.js.map +1 -1
  38. package/dist/components/ui/modal/ModalButtons.styled.d.ts +90 -91
  39. package/dist/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
  40. package/dist/components/ui/modal/ModalButtons.styled.js +5 -7
  41. package/dist/components/ui/modal/ModalButtons.styled.js.map +1 -1
  42. package/dist/components/ui/pop/Pop.styled.d.ts.map +1 -1
  43. package/dist/components/ui/pop/Pop.styled.js +15 -17
  44. package/dist/components/ui/pop/Pop.styled.js.map +1 -1
  45. package/dist/components/ui/pop/PopOption.d.ts.map +1 -1
  46. package/dist/components/ui/pop/PopOption.js +7 -2
  47. package/dist/components/ui/pop/PopOption.js.map +1 -1
  48. package/dist/components/ui/toolButton/ToolButton.d.ts +94 -1
  49. package/dist/components/ui/toolButton/ToolButton.d.ts.map +1 -1
  50. package/dist/components/ui/toolButton/ToolButton.js +59 -2
  51. package/dist/components/ui/toolButton/ToolButton.js.map +1 -1
  52. package/dist/components/ui/toolButton/ToolButton.styled.d.ts +2 -2
  53. package/dist/components/ui/toolButton/ToolButton.styled.d.ts.map +1 -1
  54. package/dist/components/ui/toolButton/ToolButton.styled.js +20 -25
  55. package/dist/components/ui/toolButton/ToolButton.styled.js.map +1 -1
  56. package/dist/utils/useRipple.d.ts +15 -0
  57. package/dist/utils/useRipple.d.ts.map +1 -0
  58. package/dist/utils/useRipple.js +120 -0
  59. package/dist/utils/useRipple.js.map +1 -0
  60. package/dist/utils/useRipple.styled.d.ts +28 -0
  61. package/dist/utils/useRipple.styled.d.ts.map +1 -0
  62. package/dist/utils/useRipple.styled.js +36 -0
  63. package/dist/utils/useRipple.styled.js.map +1 -0
  64. package/docs/classes/index.Pop.html +7 -7
  65. package/docs/documents/Test.html +2 -2
  66. package/docs/enums/index.ICON.html +2 -2
  67. package/docs/functions/index.Action.html +3 -3
  68. package/docs/functions/index.Button.html +3 -9
  69. package/docs/functions/index.Card.html +2 -2
  70. package/docs/functions/index.Checkbox.html +3 -3
  71. package/docs/functions/index.Choice.html +2 -2
  72. package/docs/functions/index.ColorPicker.html +3 -3
  73. package/docs/functions/index.CoveringLoader.html +3 -3
  74. package/docs/functions/index.DirectionPad.html +2 -2
  75. package/docs/functions/index.Drawer.html +2 -2
  76. package/docs/functions/index.EqualActions.html +2 -2
  77. package/docs/functions/index.FullLoader.html +3 -3
  78. package/docs/functions/index.Gap.html +2 -2
  79. package/docs/functions/index.HandleEsc.html +3 -3
  80. package/docs/functions/index.Header.html +3 -3
  81. package/docs/functions/index.HeaderIconAction.html +3 -3
  82. package/docs/functions/index.Icon-1.html +2 -2
  83. package/docs/functions/index.If.html +3 -3
  84. package/docs/functions/index.Input.html +1 -1
  85. package/docs/functions/index.KeyValue.html +2 -2
  86. package/docs/functions/index.Label.html +2 -2
  87. package/docs/functions/index.Line.html +3 -3
  88. package/docs/functions/index.List.html +2 -2
  89. package/docs/functions/index.Loader.html +3 -3
  90. package/docs/functions/index.Loading.html +3 -3
  91. package/docs/functions/index.Message.html +3 -3
  92. package/docs/functions/index.Modal.html +2 -2
  93. package/docs/functions/index.ModalButtons.html +3 -3
  94. package/docs/functions/index.PopLoader.html +3 -3
  95. package/docs/functions/index.PopOption.html +2 -2
  96. package/docs/functions/index.Progress.html +2 -2
  97. package/docs/functions/index.SearchContainer.html +2 -2
  98. package/docs/functions/index.Section.html +4 -4
  99. package/docs/functions/index.Select.html +2 -2
  100. package/docs/functions/index.Selector.html +2 -2
  101. package/docs/functions/index.Spacer.html +2 -2
  102. package/docs/functions/index.Stats.html +2 -2
  103. package/docs/functions/index.StickyHeader.html +4 -4
  104. package/docs/functions/index.Table.html +2 -2
  105. package/docs/functions/index.TextArea.html +2 -2
  106. package/docs/functions/index.TimePicker.html +2 -2
  107. package/docs/functions/index.ToasterProvider.html +3 -3
  108. package/docs/functions/index.Toggle.html +3 -3
  109. package/docs/functions/index.ToolButton.html +3 -9
  110. package/docs/functions/index.Tooltip.html +3 -3
  111. package/docs/functions/index.TooltipProvider.html +2 -2
  112. package/docs/functions/index.borderPxToRem.html +1 -1
  113. package/docs/functions/index.createTheme.html +1 -1
  114. package/docs/functions/index.css.html +1 -1
  115. package/docs/functions/index.dimensionsPxToRem.html +1 -1
  116. package/docs/functions/index.fontPxToRem.html +1 -1
  117. package/docs/functions/index.getCssText.html +1 -1
  118. package/docs/functions/index.globalCss.html +2 -2
  119. package/docs/functions/index.injectGlobalStyles.html +1 -1
  120. package/docs/functions/index.keyframes.html +1 -1
  121. package/docs/functions/index.pxToRem.html +1 -1
  122. package/docs/functions/index.styled.html +1 -1
  123. package/docs/functions/index.toast.html +2 -2
  124. package/docs/functions/index.useToaster.html +1 -1
  125. package/docs/index.html +2 -2
  126. package/docs/interfaces/index.IconProps.html +2 -2
  127. package/docs/interfaces/index.InputCustomProps.html +3 -3
  128. package/docs/interfaces/index.LoaderProps.html +6 -6
  129. package/docs/interfaces/index.StickyHeaderProps.html +4 -4
  130. package/docs/interfaces/index.ToasterProviderProps.html +3 -3
  131. package/docs/interfaces/index.TooltipProps.html +14 -14
  132. package/docs/interfaces/index.TooltipProviderProps.html +5 -5
  133. package/docs/modules/index.html +1 -1
  134. package/docs/modules.html +1 -1
  135. package/docs/types/index.ActionProps.html +1 -1
  136. package/docs/types/index.CardProps.html +1 -1
  137. package/docs/types/index.CheckboxProps.html +2 -2
  138. package/docs/types/index.ChoiceProps.html +1 -1
  139. package/docs/types/index.ColorPickerProps.html +1 -1
  140. package/docs/types/index.DirectionPadProps.html +1 -1
  141. package/docs/types/index.DrawerFrom.html +1 -1
  142. package/docs/types/index.DrawerProps.html +2 -2
  143. package/docs/types/index.EqualActionsProps.html +1 -1
  144. package/docs/types/index.HeaderProps.html +1 -1
  145. package/docs/types/index.InputProps.html +1 -1
  146. package/docs/types/index.KeyValueProps.html +1 -1
  147. package/docs/types/index.LabelProps.html +1 -1
  148. package/docs/types/index.OverwriteProps.html +1 -1
  149. package/docs/types/index.ProgressProps.html +2 -2
  150. package/docs/types/index.SelectProps.html +1 -1
  151. package/docs/types/index.SelectorProps.html +1 -1
  152. package/docs/types/index.Stat.html +1 -1
  153. package/docs/types/index.StatsProps.html +1 -1
  154. package/docs/types/index.TextAreaProps.html +1 -1
  155. package/docs/types/index.ThemeCSS.html +1 -1
  156. package/docs/types/index.TimePickerProps.html +1 -1
  157. package/docs/types/index.ToggleProps.html +2 -2
  158. package/docs/variables/index.ActionBadgeSelector.html +1 -1
  159. package/docs/variables/index.ActionCircleSelector.html +1 -1
  160. package/docs/variables/index.CheckboxCheckmarkWrapperSelector.html +1 -1
  161. package/docs/variables/index.CheckboxTextLabelSelector.html +1 -1
  162. package/docs/variables/index.ChoiceItemSelector.html +1 -1
  163. package/docs/variables/index.ColorPickerColorDisplaySelector.html +1 -1
  164. package/docs/variables/index.DirectionPadButtonDotSelector.html +1 -1
  165. package/docs/variables/index.DirectionPadButtonSelector.html +1 -1
  166. package/docs/variables/index.DirectionPadLineSelector.html +1 -1
  167. package/docs/variables/index.DirectionPadMiddleSelector.html +1 -1
  168. package/docs/variables/index.DrawerContentSelector.html +1 -1
  169. package/docs/variables/index.HeaderAfterSelector.html +1 -1
  170. package/docs/variables/index.HeaderBeforeSelector.html +1 -1
  171. package/docs/variables/index.HeaderContentsSelector.html +1 -1
  172. package/docs/variables/index.HeaderIconActionIconSelector.html +1 -1
  173. package/docs/variables/index.InputContainerSelector.html +1 -1
  174. package/docs/variables/index.InputInputSelector.html +1 -1
  175. package/docs/variables/index.InputLabelSelector.html +1 -1
  176. package/docs/variables/index.InputPrefixSelector.html +1 -1
  177. package/docs/variables/index.InputSuffixSelector.html +1 -1
  178. package/docs/variables/index.KeyValueIconSelector.html +1 -1
  179. package/docs/variables/index.KeyValueItemSelector.html +1 -1
  180. package/docs/variables/index.KeyValueKeySelector.html +1 -1
  181. package/docs/variables/index.KeyValuePairSelector.html +1 -1
  182. package/docs/variables/index.KeyValueValueSelector.html +1 -1
  183. package/docs/variables/index.LabelTextSelector.html +1 -1
  184. package/docs/variables/index.ListItemInnerContainerClassNameSelector.html +1 -1
  185. package/docs/variables/index.ModalContainerSelector.html +1 -1
  186. package/docs/variables/index.ModalRemovePaddingSelector.html +1 -1
  187. package/docs/variables/index.ModalTitleSelector.html +1 -1
  188. package/docs/variables/index.PopListSelector.html +1 -1
  189. package/docs/variables/index.PopOptionButtonSelector.html +1 -1
  190. package/docs/variables/index.PopOptionIconSelector.html +1 -1
  191. package/docs/variables/index.PopOverlaySelector.html +1 -1
  192. package/docs/variables/index.ProgressBackgroundSelector.html +1 -1
  193. package/docs/variables/index.ProgressValueSelector.html +1 -1
  194. package/docs/variables/index.SelectorItemSelector.html +1 -1
  195. package/docs/variables/index.StatsItemSelector.html +1 -1
  196. package/docs/variables/index.StatsLabelSelector.html +1 -1
  197. package/docs/variables/index.StatsSeparatorSelector.html +1 -1
  198. package/docs/variables/index.StatsValueSelector.html +1 -1
  199. package/docs/variables/index.TextAreaLabelSelector.html +1 -1
  200. package/docs/variables/index.TextAreaTextAreaSelector.html +1 -1
  201. package/docs/variables/index.TextAreaWrapperSelector.html +1 -1
  202. package/docs/variables/index.ToggleStyledToggleSelector.html +1 -1
  203. package/docs/variables/index.TooltipContentSelector.html +1 -1
  204. package/docs/variables/index.config.html +1 -1
  205. package/docs/variables/index.cssReset.html +2 -2
  206. package/docs/variables/index.darkTheme.html +1 -1
  207. package/docs/variables/index.miuiScrollbars.html +1 -1
  208. package/docs/variables/index.theme.html +1 -1
  209. package/esm/components/layout/header/HeaderIconAction.d.ts.map +1 -1
  210. package/esm/components/layout/header/HeaderIconAction.js +13 -3
  211. package/esm/components/layout/header/HeaderIconAction.js.map +1 -1
  212. package/esm/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
  213. package/esm/components/layout/header/HeaderIconAction.styled.js +11 -17
  214. package/esm/components/layout/header/HeaderIconAction.styled.js.map +1 -1
  215. package/esm/components/layout/list/Item.d.ts.map +1 -1
  216. package/esm/components/layout/list/Item.js +18 -8
  217. package/esm/components/layout/list/Item.js.map +1 -1
  218. package/esm/components/layout/list/Item.styled.d.ts.map +1 -1
  219. package/esm/components/layout/list/Item.styled.js +2 -1
  220. package/esm/components/layout/list/Item.styled.js.map +1 -1
  221. package/esm/components/ui/button/Button.d.ts +94 -1
  222. package/esm/components/ui/button/Button.d.ts.map +1 -1
  223. package/esm/components/ui/button/Button.js +15 -1
  224. package/esm/components/ui/button/Button.js.map +1 -1
  225. package/esm/components/ui/button/Button.styled.d.ts +2 -2
  226. package/esm/components/ui/button/Button.styled.d.ts.map +1 -1
  227. package/esm/components/ui/button/Button.styled.js +3 -2
  228. package/esm/components/ui/button/Button.styled.js.map +1 -1
  229. package/esm/components/ui/directionPad/Button.d.ts.map +1 -1
  230. package/esm/components/ui/directionPad/Button.js +7 -2
  231. package/esm/components/ui/directionPad/Button.js.map +1 -1
  232. package/esm/components/ui/directionPad/Button.styled.d.ts.map +1 -1
  233. package/esm/components/ui/directionPad/Button.styled.js +2 -1
  234. package/esm/components/ui/directionPad/Button.styled.js.map +1 -1
  235. package/esm/components/ui/directionPad/Middle.d.ts.map +1 -1
  236. package/esm/components/ui/directionPad/Middle.js +7 -1
  237. package/esm/components/ui/directionPad/Middle.js.map +1 -1
  238. package/esm/components/ui/directionPad/Middle.styled.d.ts.map +1 -1
  239. package/esm/components/ui/directionPad/Middle.styled.js +2 -1
  240. package/esm/components/ui/directionPad/Middle.styled.js.map +1 -1
  241. package/esm/components/ui/modal/ModalButtons.d.ts +179 -1
  242. package/esm/components/ui/modal/ModalButtons.d.ts.map +1 -1
  243. package/esm/components/ui/modal/ModalButtons.js +19 -1
  244. package/esm/components/ui/modal/ModalButtons.js.map +1 -1
  245. package/esm/components/ui/modal/ModalButtons.styled.d.ts +90 -91
  246. package/esm/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
  247. package/esm/components/ui/modal/ModalButtons.styled.js +3 -6
  248. package/esm/components/ui/modal/ModalButtons.styled.js.map +1 -1
  249. package/esm/components/ui/pop/Pop.styled.d.ts.map +1 -1
  250. package/esm/components/ui/pop/Pop.styled.js +15 -17
  251. package/esm/components/ui/pop/Pop.styled.js.map +1 -1
  252. package/esm/components/ui/pop/PopOption.d.ts.map +1 -1
  253. package/esm/components/ui/pop/PopOption.js +7 -2
  254. package/esm/components/ui/pop/PopOption.js.map +1 -1
  255. package/esm/components/ui/toolButton/ToolButton.d.ts +94 -1
  256. package/esm/components/ui/toolButton/ToolButton.d.ts.map +1 -1
  257. package/esm/components/ui/toolButton/ToolButton.js +15 -1
  258. package/esm/components/ui/toolButton/ToolButton.js.map +1 -1
  259. package/esm/components/ui/toolButton/ToolButton.styled.d.ts +2 -2
  260. package/esm/components/ui/toolButton/ToolButton.styled.d.ts.map +1 -1
  261. package/esm/components/ui/toolButton/ToolButton.styled.js +19 -24
  262. package/esm/components/ui/toolButton/ToolButton.styled.js.map +1 -1
  263. package/esm/utils/useRipple.d.ts +15 -0
  264. package/esm/utils/useRipple.d.ts.map +1 -0
  265. package/esm/utils/useRipple.js +84 -0
  266. package/esm/utils/useRipple.js.map +1 -0
  267. package/esm/utils/useRipple.styled.d.ts +28 -0
  268. package/esm/utils/useRipple.styled.d.ts.map +1 -0
  269. package/esm/utils/useRipple.styled.js +33 -0
  270. package/esm/utils/useRipple.styled.js.map +1 -0
  271. package/package.json +1 -1
  272. package/src/components/layout/header/HeaderIconAction.styled.ts +11 -18
  273. package/src/components/layout/header/HeaderIconAction.tsx +32 -5
  274. package/src/components/layout/list/Item.styled.ts +2 -1
  275. package/src/components/layout/list/Item.tsx +38 -5
  276. package/src/components/ui/button/Button.styled.ts +3 -2
  277. package/src/components/ui/button/Button.tsx +33 -1
  278. package/src/components/ui/directionPad/Button.styled.ts +2 -1
  279. package/src/components/ui/directionPad/Button.tsx +13 -1
  280. package/src/components/ui/directionPad/Middle.styled.ts +2 -1
  281. package/src/components/ui/directionPad/Middle.tsx +13 -1
  282. package/src/components/ui/modal/ModalButtons.styled.ts +4 -7
  283. package/src/components/ui/modal/ModalButtons.tsx +38 -1
  284. package/src/components/ui/pop/Pop.styled.ts +15 -18
  285. package/src/components/ui/pop/PopOption.tsx +15 -1
  286. package/src/components/ui/toolButton/ToolButton.styled.ts +20 -26
  287. package/src/components/ui/toolButton/ToolButton.tsx +33 -0
  288. package/src/utils/useRipple.styled.ts +56 -0
  289. package/src/utils/useRipple.tsx +139 -0
  290. package/src/components/ui/toolButton/ToolButton.ts +0 -1
@@ -0,0 +1,84 @@
1
+ import React, { useCallback, useRef, useState } from "react";
2
+ const HALF = 2;
3
+ const RIPPLE_SPEED_PX_PER_MS = 1.5;
4
+ const RIPPLE_MIN_DURATION_MS = 250;
5
+ const prefersReducedMotion = () => {
6
+ if (typeof window === "undefined") {
7
+ return false;
8
+ }
9
+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
10
+ };
11
+ const isDisabled = (el) => {
12
+ if ("disabled" in el && el.disabled) {
13
+ return true;
14
+ }
15
+ return el.getAttribute("aria-disabled") === "true";
16
+ };
17
+ const isRippleDisabledByCssVar = (el) => {
18
+ if (typeof window === "undefined") {
19
+ return false;
20
+ }
21
+ return window.getComputedStyle(el).getPropertyValue("--miui-ripple").trim() === "0";
22
+ };
23
+ const useRipple = (args) => {
24
+ const { ref, onPointerDown, onKeyDown, fromCenter = false } = args;
25
+ const [ripples, setRipples] = useState([]);
26
+ const idCounter = useRef(0);
27
+ const addRippleAt = useCallback((clientX, clientY) => {
28
+ const el = ref.current;
29
+ if (!el || isDisabled(el) || prefersReducedMotion() || isRippleDisabledByCssVar(el)) {
30
+ return;
31
+ }
32
+ const rect = el.getBoundingClientRect();
33
+ const x = clientX - rect.left;
34
+ const y = clientY - rect.top;
35
+ const maxX = Math.max(x, rect.width - x);
36
+ const maxY = Math.max(y, rect.height - y);
37
+ const size = Math.hypot(maxX, maxY) * HALF;
38
+ const duration = Math.max(RIPPLE_MIN_DURATION_MS, size / RIPPLE_SPEED_PX_PER_MS);
39
+ idCounter.current += 1;
40
+ const id = idCounter.current;
41
+ setRipples((arr) => [...arr, { id, x, y, size, duration }]);
42
+ }, [ref]);
43
+ const handlePointerDown = useCallback((evt) => {
44
+ if (fromCenter) {
45
+ const el = ref.current;
46
+ if (el) {
47
+ const rect = el.getBoundingClientRect();
48
+ addRippleAt(rect.left + (rect.width / HALF), rect.top + (rect.height / HALF));
49
+ }
50
+ }
51
+ else {
52
+ addRippleAt(evt.clientX, evt.clientY);
53
+ }
54
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(evt);
55
+ }, [addRippleAt, onPointerDown, fromCenter, ref]);
56
+ const handleKeyDown = useCallback((evt) => {
57
+ if (!evt.repeat && (evt.key === "Enter" || evt.key === " ")) {
58
+ const el = ref.current;
59
+ if (el) {
60
+ const rect = el.getBoundingClientRect();
61
+ addRippleAt(rect.left + (rect.width / HALF), rect.top + (rect.height / HALF));
62
+ }
63
+ }
64
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(evt);
65
+ }, [addRippleAt, ref, onKeyDown]);
66
+ const handleAnimationEnd = useCallback((evt) => {
67
+ const id = Number(evt.currentTarget.dataset.rippleId);
68
+ setRipples((arr) => arr.filter((r) => r.id !== id));
69
+ }, []);
70
+ const elements = ripples.map((r) => (React.createElement("span", { key: r.id, "data-miui-ripple": true, "data-ripple-id": r.id, "aria-hidden": true, style: {
71
+ left: `${String(r.x - (r.size / HALF))}px`,
72
+ top: `${String(r.y - (r.size / HALF))}px`,
73
+ width: `${String(r.size)}px`,
74
+ height: `${String(r.size)}px`,
75
+ animationDuration: `${String(r.duration)}ms`,
76
+ }, onAnimationEnd: handleAnimationEnd })));
77
+ return {
78
+ onPointerDown: handlePointerDown,
79
+ onKeyDown: handleKeyDown,
80
+ ripples: elements,
81
+ };
82
+ };
83
+ export { useRipple };
84
+ //# sourceMappingURL=useRipple.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRipple.js","sourceRoot":"","sources":["../../src/utils/useRipple.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU7D,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,MAAM,oBAAoB,GAAG,GAAY,EAAE;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,EAAe,EAAW,EAAE;IAC5C,IAAI,UAAU,IAAI,EAAE,IAAK,EAAwB,CAAC,QAAQ,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,EAAe,EAAW,EAAE;IAC1D,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC;AACxF,CAAC,CAAC;AA6BF,MAAM,SAAS,GAAG,CAAwB,IAAsB,EAAsB,EAAE;IACpF,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,GAAG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OAAO,EAAE,QAAQ;KACpB,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ declare const rippleHostStyles: {
2
+ position: string;
3
+ overflow: string;
4
+ WebkitTapHighlightColor: string;
5
+ transition: string;
6
+ "&:where(a, button):hover:not(:disabled):not([aria-disabled='true'])": {
7
+ boxShadow: string;
8
+ };
9
+ "&:where(a, button):active:not(:disabled):not([aria-disabled='true'])": {
10
+ boxShadow: string;
11
+ };
12
+ "@media (prefers-reduced-motion: reduce)": {
13
+ transition: string;
14
+ };
15
+ "& > span[data-miui-ripple]": {
16
+ position: string;
17
+ pointerEvents: string;
18
+ borderRadius: string;
19
+ backgroundColor: string;
20
+ transform: string;
21
+ opacity: number;
22
+ animationName: string;
23
+ animationTimingFunction: string;
24
+ animationFillMode: string;
25
+ };
26
+ };
27
+ export { rippleHostStyles, };
28
+ //# sourceMappingURL=useRipple.styled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRipple.styled.d.ts","sourceRoot":"","sources":["../../src/utils/useRipple.styled.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrB,CAAC;AAEF,OAAO,EACH,gBAAgB,GACnB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { keyframes } from "../theme.js";
2
+ const rippleKeyframes = keyframes({
3
+ "0%": { transform: "scale(0)", opacity: 0.35 },
4
+ "100%": { transform: "scale(1)", opacity: 0 },
5
+ });
6
+ const rippleHostStyles = {
7
+ "position": "relative",
8
+ "overflow": "hidden",
9
+ "WebkitTapHighlightColor": "transparent",
10
+ "transition": "box-shadow 150ms ease-out",
11
+ "&:where(a, button):hover:not(:disabled):not([aria-disabled='true'])": {
12
+ boxShadow: "inset 0 0 0 9999px color-mix(in srgb, currentColor calc(6% * var(--miui-ripple, 1)), transparent)",
13
+ },
14
+ "&:where(a, button):active:not(:disabled):not([aria-disabled='true'])": {
15
+ boxShadow: "inset 0 0 0 9999px color-mix(in srgb, currentColor calc(12% * var(--miui-ripple, 1)), transparent)",
16
+ },
17
+ "@media (prefers-reduced-motion: reduce)": {
18
+ transition: "none",
19
+ },
20
+ "& > span[data-miui-ripple]": {
21
+ position: "absolute",
22
+ pointerEvents: "none",
23
+ borderRadius: "50%",
24
+ backgroundColor: "currentColor",
25
+ transform: "scale(0)",
26
+ opacity: 0,
27
+ animationName: String(rippleKeyframes),
28
+ animationTimingFunction: "ease-out",
29
+ animationFillMode: "forwards",
30
+ },
31
+ };
32
+ export { rippleHostStyles, };
33
+ //# sourceMappingURL=useRipple.styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRipple.styled.js","sourceRoot":"","sources":["../../src/utils/useRipple.styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,eAAe,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE;IAC9C,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE;CAChD,CAAC,CAAC;AAaH,MAAM,gBAAgB,GAAG;IACrB,UAAU,EAAE,UAAU;IACtB,UAAU,EAAE,QAAQ;IACpB,yBAAyB,EAAE,aAAa;IACxC,YAAY,EAAE,2BAA2B;IAOzC,qEAAqE,EAAE;QACnE,SAAS,EAAE,mGAAmG;KACjH;IACD,sEAAsE,EAAE;QACpE,SAAS,EAAE,oGAAoG;KAClH;IAED,yCAAyC,EAAE;QACvC,UAAU,EAAE,MAAM;KACrB;IAED,4BAA4B,EAAE;QAC1B,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,MAAM;QACrB,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,cAAc;QAC/B,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,CAAC;QACV,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC;QACtC,uBAAuB,EAAE,UAAU;QACnC,iBAAiB,EAAE,UAAU;KAChC;CACJ,CAAC;AAEF,OAAO,EACH,gBAAgB,GACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-miui",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "author": "Jacek Nowacki",
5
5
  "license": "MIT",
6
6
  "exports": {
@@ -1,24 +1,17 @@
1
1
  import { borderPxToRem, css, pxToRem, styled } from "../../../theme";
2
+ import { rippleHostStyles } from "../../../utils/useRipple.styled";
2
3
  import { Icon } from "../../icons/Icon";
3
4
 
4
- const sharedStyles = css({
5
- "width": pxToRem(30),
6
- "height": pxToRem(30),
7
- "background": "none",
8
- "borderRadius": "666px",
9
- "display": "inline-flex",
10
- "alignItems": "center",
11
- "justifyContent": "center",
12
- "border": borderPxToRem(2),
13
- "color": "currentColor",
14
-
15
- "&:hover": {
16
- background: "#00000022",
17
- },
18
- "&:active": {
19
- background: "#00000011",
20
- color: "currentColor",
21
- },
5
+ const sharedStyles = css(rippleHostStyles, {
6
+ width: pxToRem(30),
7
+ height: pxToRem(30),
8
+ background: "none",
9
+ borderRadius: "666px",
10
+ display: "inline-flex",
11
+ alignItems: "center",
12
+ justifyContent: "center",
13
+ border: borderPxToRem(2),
14
+ color: "currentColor",
22
15
  });
23
16
 
24
17
  const Btn = styled("button", sharedStyles);
@@ -1,8 +1,11 @@
1
1
  import React, { forwardRef } from "react";
2
2
 
3
+ import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
4
+
3
5
  import type { ReactNode } from "react";
4
6
  import type { ICON } from "../../icons/Icon";
5
7
 
8
+ import { useRipple } from "../../../utils/useRipple";
6
9
  import { A, Btn, sharedStyles, StyledIcon } from "./HeaderIconAction.styled";
7
10
 
8
11
  interface LinkProps { // @TODO extract? - same on list item
@@ -41,8 +44,10 @@ interface Props {
41
44
  * Use this component if you need a clickable icon that stylistically fits the header.
42
45
  * It can be a simple link, a button or a custom link component.
43
46
  */
44
- const HeaderIconAction = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props>((props, ref) => {
47
+ const HeaderIconAction = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props>((props, ref) => { // eslint-disable-line max-lines-per-function
45
48
  const { icon, href, to, Link, className, ...restProps } = props;
49
+ const innerRef = useForwardedRef<HTMLAnchorElement | HTMLButtonElement | null>(ref);
50
+ const ripple = useRipple({ ref: innerRef });
46
51
 
47
52
  let content: ReactNode = icon;
48
53
  if (typeof icon === "string") {
@@ -56,23 +61,45 @@ const HeaderIconAction = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props
56
61
 
57
62
  return (
58
63
  <Link href={to} {...restProps}>
59
- <A ref={ref as React.Ref<HTMLAnchorElement>} className={props.className}>{content}</A>
64
+ <A
65
+ ref={innerRef as React.Ref<HTMLAnchorElement>}
66
+ className={props.className}
67
+ onPointerDown={ripple.onPointerDown}
68
+ onKeyDown={ripple.onKeyDown}
69
+ >
70
+ {content}
71
+ {ripple.ripples}
72
+ </A>
60
73
  </Link>
61
74
  );
62
75
  }
63
76
 
64
77
  if (href) {
65
78
  return (
66
- <A ref={ref as React.Ref<HTMLAnchorElement>} href={href} className={props.className} {...restProps}>
79
+ <A
80
+ ref={innerRef as React.Ref<HTMLAnchorElement>}
81
+ href={href}
82
+ className={props.className}
83
+ onPointerDown={ripple.onPointerDown}
84
+ onKeyDown={ripple.onKeyDown}
85
+ {...restProps}
86
+ >
67
87
  {content}
88
+ {ripple.ripples}
68
89
  </A>
69
90
  );
70
91
  }
71
92
 
72
93
  return (
73
-
74
- <Btn ref={ref as React.Ref<HTMLButtonElement>} className={props.className} onClick={props.onClick}>
94
+ <Btn
95
+ ref={innerRef as React.Ref<HTMLButtonElement>}
96
+ className={props.className}
97
+ onClick={props.onClick}
98
+ onPointerDown={ripple.onPointerDown}
99
+ onKeyDown={ripple.onKeyDown}
100
+ >
75
101
  {content}
102
+ {ripple.ripples}
76
103
  </Btn>
77
104
  );
78
105
  });
@@ -1,7 +1,8 @@
1
1
  import { css, dimensionsPxToRem, fontPxToRem, pxToRem, styled } from "../../../theme";
2
+ import { rippleHostStyles } from "../../../utils/useRipple.styled";
2
3
  import { Icon } from "../../icons/Icon";
3
4
 
4
- const StyledInnerContainer = styled("div", {
5
+ const StyledInnerContainer = styled("div", rippleHostStyles, {
5
6
  display: "flex",
6
7
  minHeight: dimensionsPxToRem(174),
7
8
  alignItems: "center",
@@ -1,6 +1,7 @@
1
- import React, { forwardRef } from "react";
1
+ import React, { forwardRef, useRef } from "react";
2
2
 
3
3
  import { fnWithProps } from "../../../types/fnWithProps";
4
+ import { useRipple } from "../../../utils/useRipple";
4
5
  import { ICON } from "../../icons/Icon";
5
6
  import { StyledIcon, StyledInnerContainer, StyledItem, StyledNoIcon } from "./Item.styled";
6
7
  import { Label } from "./Label";
@@ -68,7 +69,10 @@ type StyledItemProps = React.ComponentProps<typeof StyledItem>;
68
69
  */
69
70
  const ItemBase = forwardRef<
70
71
  HTMLLIElement, StyledItemProps & Props
71
- >(({ href, to, onClick, Link, ratio, ...props }, ref) => {
72
+ >(({ href, to, onClick, Link, ratio, ...props }, ref) => { // eslint-disable-line max-lines-per-function
73
+ const innerRef = useRef<HTMLElement | null>(null);
74
+ const ripple = useRipple({ ref: innerRef });
75
+
72
76
  const r = ratio ? ratio.split("/") : [];
73
77
 
74
78
  const pre = typeof props.selected === "boolean"
@@ -92,6 +96,11 @@ const ItemBase = forwardRef<
92
96
  });
93
97
  }) ?? [];
94
98
 
99
+ const interactive = Boolean(onClick ?? href ?? to);
100
+ const rippleProps = interactive
101
+ ? { onPointerDown: ripple.onPointerDown, onKeyDown: ripple.onKeyDown }
102
+ : {};
103
+
95
104
  if (to) {
96
105
  if (!Link) {
97
106
  throw new TypeError("`to` prop given without `Link` component");
@@ -99,7 +108,16 @@ const ItemBase = forwardRef<
99
108
 
100
109
  return (
101
110
  <StyledItem {...props} ref={ref}>
102
- <Link href={to}><StyledInnerContainer as={"a"} href={to}>{pre}{ren}</StyledInnerContainer></Link>
111
+ <Link href={to}>
112
+ <StyledInnerContainer
113
+ as={"a"}
114
+ href={to}
115
+ ref={innerRef as React.Ref<HTMLAnchorElement>}
116
+ {...rippleProps}
117
+ >
118
+ {pre}{ren}{ripple.ripples}
119
+ </StyledInnerContainer>
120
+ </Link>
103
121
  </StyledItem>
104
122
  );
105
123
  }
@@ -107,7 +125,15 @@ const ItemBase = forwardRef<
107
125
  if (href) {
108
126
  return (
109
127
  <StyledItem {...props} ref={ref}>
110
- <StyledInnerContainer as={"a"} href={href} onClick={onClick}>{pre}{ren}</StyledInnerContainer>
128
+ <StyledInnerContainer
129
+ as={"a"}
130
+ href={href}
131
+ onClick={onClick}
132
+ ref={innerRef as React.Ref<HTMLAnchorElement>}
133
+ {...rippleProps}
134
+ >
135
+ {pre}{ren}{ripple.ripples}
136
+ </StyledInnerContainer>
111
137
  </StyledItem>
112
138
  );
113
139
  }
@@ -115,7 +141,14 @@ const ItemBase = forwardRef<
115
141
  if (onClick) {
116
142
  return (
117
143
  <StyledItem {...props} ref={ref}>
118
- <StyledInnerContainer as={"button"} onClick={onClick}>{pre}{ren}</StyledInnerContainer>
144
+ <StyledInnerContainer
145
+ as={"button"}
146
+ onClick={onClick}
147
+ ref={innerRef as React.Ref<HTMLButtonElement>}
148
+ {...rippleProps}
149
+ >
150
+ {pre}{ren}{ripple.ripples}
151
+ </StyledInnerContainer>
119
152
  </StyledItem>
120
153
  );
121
154
  }
@@ -1,9 +1,10 @@
1
1
  import { borderPxToRem, dimensionsPxToRem, fontPxToRem, pxToRem, styled } from "../../../theme";
2
+ import { rippleHostStyles } from "../../../utils/useRipple.styled";
2
3
 
3
4
  /**
4
5
  * Call-to-action button.
5
6
  */
6
- const Button = styled("button", {
7
+ const StyledButton = styled("button", rippleHostStyles, {
7
8
  "height": dimensionsPxToRem(118),
8
9
  "background": "$green1",
9
10
  "border": `${borderPxToRem(1)} solid $green1Darker`,
@@ -39,5 +40,5 @@ const Button = styled("button", {
39
40
  });
40
41
 
41
42
  export {
42
- Button,
43
+ StyledButton,
43
44
  };
@@ -1 +1,33 @@
1
- export { Button } from "./Button.styled";
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,6 +1,7 @@
1
1
  import { styled } from "../../../theme";
2
+ import { rippleHostStyles } from "../../../utils/useRipple.styled";
2
3
 
3
- const StyledButton = styled("button", {
4
+ const StyledButton = styled("button", rippleHostStyles, {
4
5
  height: "50px",
5
6
  width: "50px",
6
7
  margin: "0",
@@ -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 {...props} ref={ref}>
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 onClick={props.onClick} ref={ref}>
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
  });
@@ -1,5 +1,5 @@
1
1
  import { dimensionsPxToRem, styled } from "../../../theme";
2
- import { fnWithProps } from "../../../types/fnWithProps";
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 Button = styled("button", {
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
- ModalButtons,
45
+ Container,
46
+ StyledButton,
50
47
  };
@@ -1 +1,38 @@
1
- export { ModalButtons } from "./ModalButtons.styled";
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
+ };
@@ -1,4 +1,5 @@
1
1
  import { dimensionsPxToRem, fontPxToRem, styled } from "../../../theme";
2
+ import { rippleHostStyles } from "../../../utils/useRipple.styled";
2
3
 
3
4
  const Overlay = styled("div", {
4
5
  position: "fixed",
@@ -26,24 +27,20 @@ const ListItem = styled("li", {
26
27
  },
27
28
  });
28
29
 
29
- const Button = styled("button", {
30
- "border": "none",
31
- "background": "$background",
32
- "height": dimensionsPxToRem(116),
33
- "padding": `0 ${dimensionsPxToRem(42)}`,
34
- "boxSizing": "border-box",
35
- "width": "100%",
36
- "minWidth": dimensionsPxToRem(460),
37
- "textAlign": "left",
38
- "color": "$popText",
39
- "fontSize": fontPxToRem(26),
40
- "fontWeight": "revert",
41
- "display": "flex",
42
- "alignItems": "center",
43
-
44
- "&:hover": {
45
- background: "$activeBg",
46
- },
30
+ const Button = styled("button", rippleHostStyles, {
31
+ border: "none",
32
+ background: "$background",
33
+ height: dimensionsPxToRem(116),
34
+ padding: `0 ${dimensionsPxToRem(42)}`,
35
+ boxSizing: "border-box",
36
+ width: "100%",
37
+ minWidth: dimensionsPxToRem(460),
38
+ textAlign: "left",
39
+ color: "$popText",
40
+ fontSize: fontPxToRem(26),
41
+ fontWeight: "revert",
42
+ display: "flex",
43
+ alignItems: "center",
47
44
  });
48
45
 
49
46
  const Icon = styled("div", {
@@ -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 { Button, FakeIcon, Icon, ListItem } from "./Pop.styled";
4
7
 
5
8
  interface Props {
@@ -11,13 +14,24 @@ interface Props {
11
14
  }
12
15
 
13
16
  const PopOption = forwardRef<HTMLLIElement, Props>((props, ref) => {
17
+ const buttonRef = useForwardedRef<HTMLButtonElement | null>(null);
18
+ const ripple = useRipple({ ref: buttonRef });
19
+
14
20
  const ic = props.icon
15
21
  ? <Icon>{props.icon}</Icon>
16
22
  : ((props.forceEmptyIcon ?? true) ? <FakeIcon /> : null);
17
23
 
18
24
  return (
19
25
  <ListItem ref={ref} className={props.className}>
20
- <Button onClick={props.onClick}>{ic}{props.children}</Button>
26
+ <Button
27
+ ref={buttonRef}
28
+ onClick={props.onClick}
29
+ onPointerDown={ripple.onPointerDown}
30
+ onKeyDown={ripple.onKeyDown}
31
+ >
32
+ {ic}{props.children}
33
+ {ripple.ripples}
34
+ </Button>
21
35
  </ListItem>
22
36
  );
23
37
  });