@kanso-labs/kanso-ui 0.35.0 → 0.37.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 (220) hide show
  1. package/README.md +90 -9
  2. package/dist/button/context.js +7 -0
  3. package/dist/button/context.js.map +1 -0
  4. package/dist/button/group.js +25 -0
  5. package/dist/button/group.js.map +1 -0
  6. package/dist/button/hooks.js +81 -0
  7. package/dist/button/hooks.js.map +1 -0
  8. package/dist/button/index.d.ts +11 -0
  9. package/dist/button/index.js +273 -0
  10. package/dist/button/index.js.map +1 -0
  11. package/dist/button/styles.js +23 -0
  12. package/dist/button/styles.js.map +1 -0
  13. package/dist/calendar/index.js +473 -7
  14. package/dist/calendar/index.js.map +1 -1
  15. package/dist/calendar/styles.js +132 -4
  16. package/dist/calendar/styles.js.map +1 -1
  17. package/dist/chip/index.js +74 -9
  18. package/dist/chip/index.js.map +1 -1
  19. package/dist/chip/styles.js +78 -4
  20. package/dist/chip/styles.js.map +1 -1
  21. package/dist/collection/index.js +12 -9
  22. package/dist/collection/index.js.map +1 -1
  23. package/dist/collection/styles.js +21 -2
  24. package/dist/collection/styles.js.map +1 -1
  25. package/dist/color-scheme.d.ts +29 -0
  26. package/dist/color-scheme.js +32 -0
  27. package/dist/color-scheme.js.map +1 -0
  28. package/dist/components/avatar/index.js +35 -22
  29. package/dist/components/avatar/index.js.map +1 -1
  30. package/dist/components/badge/index.d.ts +40 -0
  31. package/dist/components/badge/index.js +102 -0
  32. package/dist/components/badge/index.js.map +1 -0
  33. package/dist/components/breadcrumbs/index.d.ts +1 -1
  34. package/dist/components/breadcrumbs/index.js +1 -1
  35. package/dist/components/breadcrumbs/index.js.map +1 -1
  36. package/dist/components/button/index.d.ts +58 -14
  37. package/dist/components/button/index.js +400 -147
  38. package/dist/components/button/index.js.map +1 -1
  39. package/dist/components/button-group/index.d.ts +54 -0
  40. package/dist/components/button-group/index.js +272 -0
  41. package/dist/components/button-group/index.js.map +1 -0
  42. package/dist/components/calendar/index.d.ts +9 -1
  43. package/dist/components/calendar/index.js +71 -44
  44. package/dist/components/calendar/index.js.map +1 -1
  45. package/dist/components/card/index.d.ts +1 -1
  46. package/dist/components/card/index.js +4 -4
  47. package/dist/components/card/index.js.map +1 -1
  48. package/dist/components/checkbox/index.js +15 -1
  49. package/dist/components/checkbox/index.js.map +1 -1
  50. package/dist/components/checkbox-group/index.js +1 -0
  51. package/dist/components/checkbox-group/index.js.map +1 -1
  52. package/dist/components/chip/index.d.ts +55 -8
  53. package/dist/components/chip/index.js +174 -63
  54. package/dist/components/chip/index.js.map +1 -1
  55. package/dist/components/chip-group/index.d.ts +16 -7
  56. package/dist/components/chip-group/index.js +58 -35
  57. package/dist/components/chip-group/index.js.map +1 -1
  58. package/dist/components/color-field/index.js +25 -23
  59. package/dist/components/color-field/index.js.map +1 -1
  60. package/dist/components/color-picker/index.js +42 -31
  61. package/dist/components/color-picker/index.js.map +1 -1
  62. package/dist/components/color-swatch-picker/index.d.ts +1 -1
  63. package/dist/components/color-swatch-picker/index.js +17 -13
  64. package/dist/components/color-swatch-picker/index.js.map +1 -1
  65. package/dist/components/combo-box/index.d.ts +5 -3
  66. package/dist/components/combo-box/index.js +63 -58
  67. package/dist/components/combo-box/index.js.map +1 -1
  68. package/dist/components/copy-field/index.d.ts +7 -6
  69. package/dist/components/copy-field/index.js +92 -90
  70. package/dist/components/copy-field/index.js.map +1 -1
  71. package/dist/components/currency/index.d.ts +8 -7
  72. package/dist/components/currency/index.js +43 -65
  73. package/dist/components/currency/index.js.map +1 -1
  74. package/dist/components/date-field/index.js +24 -22
  75. package/dist/components/date-field/index.js.map +1 -1
  76. package/dist/components/date-picker/index.d.ts +10 -2
  77. package/dist/components/date-picker/index.js +76 -69
  78. package/dist/components/date-picker/index.js.map +1 -1
  79. package/dist/components/date-range-picker/index.d.ts +10 -2
  80. package/dist/components/date-range-picker/index.js +93 -86
  81. package/dist/components/date-range-picker/index.js.map +1 -1
  82. package/dist/components/dialog/index.d.ts +1 -1
  83. package/dist/components/dialog/index.js +2 -2
  84. package/dist/components/dialog/index.js.map +1 -1
  85. package/dist/components/disclosure/index.d.ts +1 -1
  86. package/dist/components/disclosure/index.js +6 -6
  87. package/dist/components/disclosure/index.js.map +1 -1
  88. package/dist/components/fab/index.d.ts +72 -0
  89. package/dist/components/fab/index.js +89 -0
  90. package/dist/components/fab/index.js.map +1 -0
  91. package/dist/components/fab-menu/index.d.ts +90 -0
  92. package/dist/components/fab-menu/index.js +297 -0
  93. package/dist/components/fab-menu/index.js.map +1 -0
  94. package/dist/components/feed/index.d.ts +2 -1
  95. package/dist/components/feed/index.js +1 -1
  96. package/dist/components/feed/index.js.map +1 -1
  97. package/dist/components/icon-button/index.d.ts +11 -8
  98. package/dist/components/icon-button/index.js +244 -181
  99. package/dist/components/icon-button/index.js.map +1 -1
  100. package/dist/components/index.d.ts +30 -21
  101. package/dist/components/list/index.d.ts +15 -13
  102. package/dist/components/list/index.js +60 -61
  103. package/dist/components/list/index.js.map +1 -1
  104. package/dist/components/list-box/index.d.ts +3 -2
  105. package/dist/components/list-box/index.js +16 -16
  106. package/dist/components/list-box/index.js.map +1 -1
  107. package/dist/components/list-item/index.js +1 -1
  108. package/dist/components/list-item/index.js.map +1 -1
  109. package/dist/components/menu/index.d.ts +3 -2
  110. package/dist/components/menu/index.js +2 -2
  111. package/dist/components/menu/index.js.map +1 -1
  112. package/dist/components/navigation-bar/index.d.ts +50 -0
  113. package/dist/components/navigation-bar/index.js +129 -0
  114. package/dist/components/navigation-bar/index.js.map +1 -0
  115. package/dist/components/navigation-rail/index.d.ts +59 -0
  116. package/dist/components/navigation-rail/index.js +166 -0
  117. package/dist/components/navigation-rail/index.js.map +1 -0
  118. package/dist/components/navigation-tree/index.d.ts +1 -5
  119. package/dist/components/navigation-tree/index.js +3 -3
  120. package/dist/components/navigation-tree/index.js.map +1 -1
  121. package/dist/components/number-field/index.d.ts +6 -4
  122. package/dist/components/number-field/index.js +84 -84
  123. package/dist/components/number-field/index.js.map +1 -1
  124. package/dist/components/popover/index.d.ts +1 -1
  125. package/dist/components/popover/index.js +1 -1
  126. package/dist/components/popover/index.js.map +1 -1
  127. package/dist/components/radio-group/index.js +22 -11
  128. package/dist/components/radio-group/index.js.map +1 -1
  129. package/dist/components/range-calendar/index.d.ts +7 -1
  130. package/dist/components/range-calendar/index.js +71 -44
  131. package/dist/components/range-calendar/index.js.map +1 -1
  132. package/dist/components/search-field/index.d.ts +2 -1
  133. package/dist/components/search-field/index.js +24 -25
  134. package/dist/components/search-field/index.js.map +1 -1
  135. package/dist/components/search-view/index.d.ts +79 -0
  136. package/dist/components/search-view/index.js +255 -0
  137. package/dist/components/search-view/index.js.map +1 -0
  138. package/dist/components/segmented-button/index.d.ts +2 -2
  139. package/dist/components/segmented-button/index.js +60 -31
  140. package/dist/components/segmented-button/index.js.map +1 -1
  141. package/dist/components/select/index.js +1 -0
  142. package/dist/components/select/index.js.map +1 -1
  143. package/dist/components/sheet/index.d.ts +1 -1
  144. package/dist/components/sheet/index.js +2 -2
  145. package/dist/components/sheet/index.js.map +1 -1
  146. package/dist/components/slider/index.js +1 -1
  147. package/dist/components/slider/index.js.map +1 -1
  148. package/dist/components/snackbar/index.d.ts +2 -2
  149. package/dist/components/snackbar/index.js +28 -13
  150. package/dist/components/snackbar/index.js.map +1 -1
  151. package/dist/components/split-button/index.d.ts +83 -0
  152. package/dist/components/split-button/index.js +341 -0
  153. package/dist/components/split-button/index.js.map +1 -0
  154. package/dist/components/switch/index.js +11 -1
  155. package/dist/components/switch/index.js.map +1 -1
  156. package/dist/components/table/index.d.ts +11 -9
  157. package/dist/components/table/index.js +87 -31
  158. package/dist/components/table/index.js.map +1 -1
  159. package/dist/components/tabs/index.d.ts +35 -4
  160. package/dist/components/tabs/index.js +403 -93
  161. package/dist/components/tabs/index.js.map +1 -1
  162. package/dist/components/tag/index.d.ts +1 -1
  163. package/dist/components/tag/index.js.map +1 -1
  164. package/dist/components/text-area/index.d.ts +7 -5
  165. package/dist/components/text-area/index.js +28 -26
  166. package/dist/components/text-area/index.js.map +1 -1
  167. package/dist/components/text-field/index.d.ts +7 -5
  168. package/dist/components/text-field/index.js +28 -26
  169. package/dist/components/text-field/index.js.map +1 -1
  170. package/dist/components/time-field/index.js +24 -22
  171. package/dist/components/time-field/index.js.map +1 -1
  172. package/dist/components/tree/index.d.ts +7 -9
  173. package/dist/components/tree/index.js +15 -16
  174. package/dist/components/tree/index.js.map +1 -1
  175. package/dist/drag/index.js.map +1 -1
  176. package/dist/drag/styles.js +4 -1
  177. package/dist/drag/styles.js.map +1 -1
  178. package/dist/fab/styles.js +161 -0
  179. package/dist/fab/styles.js.map +1 -0
  180. package/dist/field/index.js +260 -214
  181. package/dist/field/index.js.map +1 -1
  182. package/dist/field/styles.js +10 -2
  183. package/dist/field/styles.js.map +1 -1
  184. package/dist/glyphs/index.js +55 -1
  185. package/dist/glyphs/index.js.map +1 -1
  186. package/dist/hooks/useRipple.js +199 -162
  187. package/dist/hooks/useRipple.js.map +1 -1
  188. package/dist/hooks/useToggleGroupDisabled.js +24 -0
  189. package/dist/hooks/useToggleGroupDisabled.js.map +1 -0
  190. package/dist/i18n/index.js +43 -0
  191. package/dist/i18n/index.js.map +1 -0
  192. package/dist/i18n/messages.js +387 -0
  193. package/dist/i18n/messages.js.map +1 -0
  194. package/dist/index.d.ts +31 -21
  195. package/dist/index.js +25 -16
  196. package/dist/navigation/context.js +7 -0
  197. package/dist/navigation/context.js.map +1 -0
  198. package/dist/navigation/index.d.ts +28 -0
  199. package/dist/navigation/index.js +96 -0
  200. package/dist/navigation/index.js.map +1 -0
  201. package/dist/navigation/styles.js +312 -0
  202. package/dist/navigation/styles.js.map +1 -0
  203. package/dist/react-aria.d.ts +2 -2
  204. package/dist/react-aria.js +2 -2
  205. package/dist/render/useRender.js +0 -1
  206. package/dist/render/useRender.js.map +1 -1
  207. package/dist/row/styles.js +33 -11
  208. package/dist/row/styles.js.map +1 -1
  209. package/dist/styles/focus.js.map +1 -1
  210. package/dist/styles/icon-button.js +9 -1
  211. package/dist/styles/icon-button.js.map +1 -1
  212. package/dist/styles/overlay.js +1 -0
  213. package/dist/styles/overlay.js.map +1 -1
  214. package/dist/styles/picker.js +1 -1
  215. package/dist/styles/picker.js.map +1 -1
  216. package/dist/styles.css +1104 -336
  217. package/dist/tokens/design.tokens.stylex.js +42 -1
  218. package/dist/tokens/design.tokens.stylex.js.map +1 -1
  219. package/dist/tokens.css +166 -53
  220. package/package.json +9 -5
@@ -2,7 +2,7 @@ import { props } from "../node_modules/@stylexjs/stylex/lib/es/stylex.js";
2
2
  import { rippleStyles as styles } from "../styles/ripple.js";
3
3
  import { motionDurationMs, motionEasing, spacingPx } from "../tokens/values.js";
4
4
  import { c } from "react/compiler-runtime";
5
- import { useRef, useState } from "react";
5
+ import { useEffect, useRef, useState } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  //#region src/hooks/useRipple.tsx
8
8
  /** How far the ripple grows past the host's corners. `spacing.sm`. */
@@ -47,7 +47,7 @@ function prefersReducedMotion() {
47
47
  return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
48
48
  }
49
49
  function useRipple(t0, t1, t2) {
50
- const $ = c(49);
50
+ const $ = c(52);
51
51
  const enabled = t0 === void 0 ? true : t0;
52
52
  let t3;
53
53
  if ($[0] !== t1) {
@@ -64,6 +64,7 @@ function useRipple(t0, t1, t2) {
64
64
  const rippleStartEvent = useRef(void 0);
65
65
  const initialSize = useRef(0);
66
66
  const rippleScale = useRef("1");
67
+ const removeDocumentListeners = useRef(void 0);
67
68
  let t4;
68
69
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
69
70
  t4 = (event) => {
@@ -146,6 +147,8 @@ function useRipple(t0, t1, t2) {
146
147
  let t9;
147
148
  if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
148
149
  t9 = async () => {
150
+ removeDocumentListeners.current?.();
151
+ removeDocumentListeners.current = void 0;
149
152
  rippleStartEvent.current = void 0;
150
153
  state.current = RippleState.Inactive;
151
154
  const animation = growAnimation.current;
@@ -165,230 +168,264 @@ function useRipple(t0, t1, t2) {
165
168
  const endPressAnimation = t9;
166
169
  let t10;
167
170
  if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
168
- t10 = () => state.current;
171
+ t10 = (host, pointerId) => {
172
+ removeDocumentListeners.current?.();
173
+ const document = host.ownerDocument;
174
+ const handleEnd = (event_1) => {
175
+ if (event_1.pointerId !== pointerId || event_1.composedPath().includes(host)) return;
176
+ endPressAnimation();
177
+ };
178
+ document.addEventListener("pointercancel", handleEnd, true);
179
+ document.addEventListener("pointerup", handleEnd, true);
180
+ removeDocumentListeners.current = () => {
181
+ document.removeEventListener("pointercancel", handleEnd, true);
182
+ document.removeEventListener("pointerup", handleEnd, true);
183
+ };
184
+ };
169
185
  $[8] = t10;
170
186
  } else t10 = $[8];
171
- const getState = t10;
187
+ const listenBeyondHost = t10;
172
188
  let t11;
189
+ let t12;
173
190
  if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
174
- t11 = async (event_1) => {
175
- if (!shouldReactToEvent(event_1)) return;
176
- rippleStartEvent.current = event_1;
177
- const target_0 = event_1.currentTarget;
178
- if (!isTouch(event_1)) {
191
+ t11 = () => () => {
192
+ removeDocumentListeners.current?.();
193
+ };
194
+ t12 = [];
195
+ $[9] = t11;
196
+ $[10] = t12;
197
+ } else {
198
+ t11 = $[9];
199
+ t12 = $[10];
200
+ }
201
+ useEffect(t11, t12);
202
+ let t13;
203
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
204
+ t13 = () => state.current;
205
+ $[11] = t13;
206
+ } else t13 = $[11];
207
+ const getState = t13;
208
+ let t14;
209
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
210
+ t14 = async (event_2) => {
211
+ if (!shouldReactToEvent(event_2)) return;
212
+ rippleStartEvent.current = event_2;
213
+ const target_0 = event_2.currentTarget;
214
+ listenBeyondHost(target_0, event_2.pointerId);
215
+ if (!isTouch(event_2)) {
179
216
  state.current = RippleState.WaitingForClick;
180
- startPressAnimation(target_0, event_1);
217
+ startPressAnimation(target_0, event_2);
181
218
  return;
182
219
  }
183
220
  state.current = RippleState.TouchDelay;
184
221
  await new Promise(_temp);
185
222
  if (getState() !== RippleState.TouchDelay) return;
186
223
  state.current = RippleState.Holding;
187
- startPressAnimation(target_0, event_1);
224
+ startPressAnimation(target_0, event_2);
188
225
  };
189
- $[9] = t11;
190
- } else t11 = $[9];
191
- const handlePointerDownAsync = t11;
192
- let t12;
193
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
194
- t12 = (event_2) => {
195
- handlePointerDownAsync(event_2);
226
+ $[12] = t14;
227
+ } else t14 = $[12];
228
+ const handlePointerDownAsync = t14;
229
+ let t15;
230
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
231
+ t15 = (event_3) => {
232
+ handlePointerDownAsync(event_3);
196
233
  };
197
- $[10] = t12;
198
- } else t12 = $[10];
199
- const handlePointerDown = t12;
200
- let t13;
201
- if ($[11] !== endsOnRelease) {
202
- t13 = (event_3) => {
203
- if (endsOnRelease && !isTouch(event_3)) {
204
- if (isPressPointer(event_3) && state.current === RippleState.WaitingForClick) endPressAnimation();
234
+ $[13] = t15;
235
+ } else t15 = $[13];
236
+ const handlePointerDown = t15;
237
+ let t16;
238
+ if ($[14] !== endsOnRelease) {
239
+ t16 = (event_4) => {
240
+ if (endsOnRelease && !isTouch(event_4)) {
241
+ if (isPressPointer(event_4) && state.current === RippleState.WaitingForClick) endPressAnimation();
205
242
  return;
206
243
  }
207
- if (!shouldReactToEvent(event_3)) return;
244
+ if (!shouldReactToEvent(event_4)) return;
208
245
  if (state.current === RippleState.Holding) state.current = RippleState.WaitingForClick;
209
246
  else if (state.current === RippleState.TouchDelay) {
210
247
  state.current = RippleState.WaitingForClick;
211
- startPressAnimation(event_3.currentTarget, rippleStartEvent.current);
248
+ startPressAnimation(event_4.currentTarget, rippleStartEvent.current);
212
249
  }
213
250
  if (endsOnRelease && state.current === RippleState.WaitingForClick) endPressAnimation();
214
251
  };
215
- $[11] = endsOnRelease;
216
- $[12] = t13;
217
- } else t13 = $[12];
218
- const handlePointerUp = t13;
219
- let t14;
220
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
221
- t14 = (event_4) => {
222
- if (isTouch(event_4) || !shouldReactToEvent(event_4)) return;
252
+ $[14] = endsOnRelease;
253
+ $[15] = t16;
254
+ } else t16 = $[15];
255
+ const handlePointerUp = t16;
256
+ let t17;
257
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
258
+ t17 = (event_5) => {
259
+ if (isTouch(event_5) || !shouldReactToEvent(event_5)) return;
223
260
  if (state.current !== RippleState.Inactive) endPressAnimation();
224
261
  };
225
- $[13] = t14;
226
- } else t14 = $[13];
227
- const handlePointerLeave = t14;
228
- let t15;
229
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
230
- t15 = (event_5) => {
231
- if (!shouldReactToEvent(event_5)) return;
262
+ $[16] = t17;
263
+ } else t17 = $[16];
264
+ const handlePointerLeave = t17;
265
+ let t18;
266
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
267
+ t18 = (event_6) => {
268
+ if (!shouldReactToEvent(event_6)) return;
232
269
  endPressAnimation();
233
270
  };
234
- $[14] = t15;
235
- } else t15 = $[14];
236
- const handlePointerCancel = t15;
237
- let t16;
238
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
239
- t16 = (event_6) => {
271
+ $[17] = t18;
272
+ } else t18 = $[17];
273
+ const handlePointerCancel = t18;
274
+ let t19;
275
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
276
+ t19 = (event_7) => {
240
277
  if (state.current === RippleState.WaitingForClick) {
241
278
  endPressAnimation();
242
279
  return;
243
280
  }
244
281
  if (state.current === RippleState.Inactive) {
245
- startPressAnimation(event_6.currentTarget);
282
+ startPressAnimation(event_7.currentTarget);
246
283
  endPressAnimation();
247
284
  }
248
285
  };
249
- $[15] = t16;
250
- } else t16 = $[15];
251
- const handleClick = t16;
252
- let t17;
253
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
254
- t17 = () => {
286
+ $[18] = t19;
287
+ } else t19 = $[18];
288
+ const handleClick = t19;
289
+ let t20;
290
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
291
+ t20 = () => {
255
292
  endPressAnimation();
256
293
  };
257
- $[16] = t17;
258
- } else t17 = $[16];
259
- const handleContextMenu = t17;
294
+ $[19] = t20;
295
+ } else t20 = $[19];
296
+ const handleContextMenu = t20;
260
297
  const { onClick: onClickProp, onContextMenu: onContextMenuProp, onPointerCancel: onPointerCancelProp, onPointerDown: onPointerDownProp, onPointerLeave: onPointerLeaveProp, onPointerUp: onPointerUpProp } = externalHandlers;
261
- let t18;
262
- if ($[17] !== onClickProp) {
263
- t18 = (event_7) => {
264
- handleClick(event_7);
265
- onClickProp?.(event_7);
266
- };
267
- $[17] = onClickProp;
268
- $[18] = t18;
269
- } else t18 = $[18];
270
- const onClick = t18;
271
- let t19;
272
- if ($[19] !== onContextMenuProp) {
273
- t19 = (event_8) => {
274
- handleContextMenu();
275
- onContextMenuProp?.(event_8);
276
- };
277
- $[19] = onContextMenuProp;
278
- $[20] = t19;
279
- } else t19 = $[20];
280
- const onContextMenu = t19;
281
- let t20;
282
- if ($[21] !== onPointerCancelProp) {
283
- t20 = (event_9) => {
284
- handlePointerCancel(event_9);
285
- onPointerCancelProp?.(event_9);
286
- };
287
- $[21] = onPointerCancelProp;
288
- $[22] = t20;
289
- } else t20 = $[22];
290
- const onPointerCancel = t20;
291
298
  let t21;
292
- if ($[23] !== onPointerDownProp) {
293
- t21 = (event_10) => {
294
- handlePointerDown(event_10);
295
- onPointerDownProp?.(event_10);
299
+ if ($[20] !== onClickProp) {
300
+ t21 = (event_8) => {
301
+ handleClick(event_8);
302
+ onClickProp?.(event_8);
296
303
  };
297
- $[23] = onPointerDownProp;
298
- $[24] = t21;
299
- } else t21 = $[24];
300
- const onPointerDown = t21;
304
+ $[20] = onClickProp;
305
+ $[21] = t21;
306
+ } else t21 = $[21];
307
+ const onClick = t21;
301
308
  let t22;
302
- if ($[25] !== onPointerLeaveProp) {
303
- t22 = (event_11) => {
304
- handlePointerLeave(event_11);
305
- onPointerLeaveProp?.(event_11);
309
+ if ($[22] !== onContextMenuProp) {
310
+ t22 = (event_9) => {
311
+ handleContextMenu();
312
+ onContextMenuProp?.(event_9);
306
313
  };
307
- $[25] = onPointerLeaveProp;
308
- $[26] = t22;
309
- } else t22 = $[26];
310
- const onPointerLeave = t22;
314
+ $[22] = onContextMenuProp;
315
+ $[23] = t22;
316
+ } else t22 = $[23];
317
+ const onContextMenu = t22;
311
318
  let t23;
312
- if ($[27] !== handlePointerUp || $[28] !== onPointerUpProp) {
313
- t23 = (event_12) => {
314
- handlePointerUp(event_12);
315
- onPointerUpProp?.(event_12);
319
+ if ($[24] !== onPointerCancelProp) {
320
+ t23 = (event_10) => {
321
+ handlePointerCancel(event_10);
322
+ onPointerCancelProp?.(event_10);
316
323
  };
317
- $[27] = handlePointerUp;
318
- $[28] = onPointerUpProp;
319
- $[29] = t23;
320
- } else t23 = $[29];
321
- const onPointerUp = t23;
324
+ $[24] = onPointerCancelProp;
325
+ $[25] = t23;
326
+ } else t23 = $[25];
327
+ const onPointerCancel = t23;
322
328
  let t24;
323
- if ($[30] !== onContextMenu || $[31] !== onPointerCancel || $[32] !== onPointerDown || $[33] !== onPointerLeave || $[34] !== onPointerUp) {
324
- t24 = {
329
+ if ($[26] !== onPointerDownProp) {
330
+ t24 = (event_11) => {
331
+ handlePointerDown(event_11);
332
+ onPointerDownProp?.(event_11);
333
+ };
334
+ $[26] = onPointerDownProp;
335
+ $[27] = t24;
336
+ } else t24 = $[27];
337
+ const onPointerDown = t24;
338
+ let t25;
339
+ if ($[28] !== onPointerLeaveProp) {
340
+ t25 = (event_12) => {
341
+ handlePointerLeave(event_12);
342
+ onPointerLeaveProp?.(event_12);
343
+ };
344
+ $[28] = onPointerLeaveProp;
345
+ $[29] = t25;
346
+ } else t25 = $[29];
347
+ const onPointerLeave = t25;
348
+ let t26;
349
+ if ($[30] !== handlePointerUp || $[31] !== onPointerUpProp) {
350
+ t26 = (event_13) => {
351
+ handlePointerUp(event_13);
352
+ onPointerUpProp?.(event_13);
353
+ };
354
+ $[30] = handlePointerUp;
355
+ $[31] = onPointerUpProp;
356
+ $[32] = t26;
357
+ } else t26 = $[32];
358
+ const onPointerUp = t26;
359
+ let t27;
360
+ if ($[33] !== onContextMenu || $[34] !== onPointerCancel || $[35] !== onPointerDown || $[36] !== onPointerLeave || $[37] !== onPointerUp) {
361
+ t27 = {
325
362
  onContextMenu,
326
363
  onPointerCancel,
327
364
  onPointerDown,
328
365
  onPointerLeave,
329
366
  onPointerUp
330
367
  };
331
- $[30] = onContextMenu;
332
- $[31] = onPointerCancel;
333
- $[32] = onPointerDown;
334
- $[33] = onPointerLeave;
335
- $[34] = onPointerUp;
336
- $[35] = t24;
337
- } else t24 = $[35];
338
- const pointer = t24;
339
- let t25;
340
- if ($[36] !== endsOnRelease || $[37] !== onClick || $[38] !== pointer) {
341
- t25 = endsOnRelease ? pointer : {
368
+ $[33] = onContextMenu;
369
+ $[34] = onPointerCancel;
370
+ $[35] = onPointerDown;
371
+ $[36] = onPointerLeave;
372
+ $[37] = onPointerUp;
373
+ $[38] = t27;
374
+ } else t27 = $[38];
375
+ const pointer = t27;
376
+ let t28;
377
+ if ($[39] !== endsOnRelease || $[40] !== onClick || $[41] !== pointer) {
378
+ t28 = endsOnRelease ? pointer : {
342
379
  onClick,
343
380
  ...pointer
344
381
  };
345
- $[36] = endsOnRelease;
346
- $[37] = onClick;
347
- $[38] = pointer;
348
- $[39] = t25;
349
- } else t25 = $[39];
350
- const handlers = t25;
351
- let t26;
352
- if ($[40] !== pressed) {
353
- t26 = props(styles.press, pressed && styles.pressed);
354
- $[40] = pressed;
355
- $[41] = t26;
356
- } else t26 = $[41];
357
- let t27;
358
- if ($[42] !== t26) {
359
- t27 = /* @__PURE__ */ jsx("span", {
382
+ $[39] = endsOnRelease;
383
+ $[40] = onClick;
384
+ $[41] = pointer;
385
+ $[42] = t28;
386
+ } else t28 = $[42];
387
+ const handlers = t28;
388
+ let t29;
389
+ if ($[43] !== pressed) {
390
+ t29 = props(styles.press, pressed && styles.pressed);
391
+ $[43] = pressed;
392
+ $[44] = t29;
393
+ } else t29 = $[44];
394
+ let t30;
395
+ if ($[45] !== t29) {
396
+ t30 = /* @__PURE__ */ jsx("span", {
360
397
  "aria-hidden": "true",
361
398
  ...surfaceProps,
362
399
  children: /* @__PURE__ */ jsx("span", {
363
400
  ref: rippleRef,
364
- ...t26
401
+ ...t29
365
402
  })
366
403
  });
367
- $[42] = t26;
368
- $[43] = t27;
369
- } else t27 = $[43];
370
- const surface = t27;
371
- let t28;
372
- if ($[44] !== handlers || $[45] !== surface) {
373
- t28 = {
404
+ $[45] = t29;
405
+ $[46] = t30;
406
+ } else t30 = $[46];
407
+ const surface = t30;
408
+ let t31;
409
+ if ($[47] !== handlers || $[48] !== surface) {
410
+ t31 = {
374
411
  handlers,
375
412
  surface
376
413
  };
377
- $[44] = handlers;
378
- $[45] = surface;
379
- $[46] = t28;
380
- } else t28 = $[46];
381
- const enabledResult = t28;
382
- let t29;
383
- if ($[47] !== externalHandlers) {
384
- t29 = {
414
+ $[47] = handlers;
415
+ $[48] = surface;
416
+ $[49] = t31;
417
+ } else t31 = $[49];
418
+ const enabledResult = t31;
419
+ let t32;
420
+ if ($[50] !== externalHandlers) {
421
+ t32 = {
385
422
  handlers: externalHandlers,
386
423
  surface: null
387
424
  };
388
- $[47] = externalHandlers;
389
- $[48] = t29;
390
- } else t29 = $[48];
391
- return enabled ? enabledResult : t29;
425
+ $[50] = externalHandlers;
426
+ $[51] = t32;
427
+ } else t32 = $[51];
428
+ return enabled ? enabledResult : t32;
392
429
  }
393
430
  function _temp(resolve_0) {
394
431
  setTimeout(resolve_0, motionDurationMs.short2);
@@ -1 +1 @@
1
- {"version":3,"file":"useRipple.js","names":["MouseEvent","MouseEventHandler","PointerEvent","PointerEventHandler","ReactNode","stylex","useCallback","useMemo","useRef","useState","rippleStyles","motionDurationMs","motionEasing","spacingPx","PADDING","sm","INITIAL_ORIGIN_SCALE","SOFT_EDGE_MINIMUM_SIZE","SOFT_EDGE_CONTAINER_RATIO","surfaceProps","props","surface","RippleState","Holding","Inactive","TouchDelay","WaitingForClick","const","ReleaseHandlers","Element","Omit","RippleEventHandlers","HostElement","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","isTouch","event","pointerType","prefersReducedMotion","window","matchMedia","matches","useRipple","enabled","externalHandlers","endsOnRelease","handlers","t0","t1","t2","$","_c","undefined","t3","pressed","setPressed","rippleRef","state","growAnimation","rippleStartEvent","initialSize","rippleScale","t4","Symbol","for","isPrimary","startEvent","current","pointerId","isPressPointer","t5","event_0","buttons","shouldReactToEvent","t6","rect","height","width","maxDimension","Math","max","softEdgeSize","size","floor","hypotenuse","hypot","maxRadius","determineRippleSize","t7","rect_0","positionEvent","height_0","left","top","width_0","size_0","endPoint","x","y","origin","clientX","clientY","startPoint","getTranslationCoordinates","t8","target","positionEvent_0","ripple","cancel","rect_1","getBoundingClientRect","size_1","endPoint_0","startPoint_0","style","animate","transform","duration","long1","easing","standard","fill","startPressAnimation","t9","animation","elapsed","currentTime","Infinity","medium1","Promise","resolve","setTimeout","endPressAnimation","t10","getState","t11","event_1","target_0","currentTarget","_temp","handlePointerDownAsync","t12","event_2","handlePointerDown","t13","event_3","handlePointerUp","t14","event_4","handlePointerLeave","t15","event_5","handlePointerCancel","t16","event_6","handleClick","t17","handleContextMenu","onClickProp","onContextMenuProp","onPointerCancelProp","onPointerDownProp","onPointerLeaveProp","onPointerUpProp","t18","event_7","t19","event_8","t20","event_9","t21","event_10","t22","event_11","t23","event_12","t24","pointer","t25","t26","press","t27","t28","enabledResult","t29","disabledResult","resolve_0","short2","stylex.props","rippleStyles","_c","disabledResult"],"sources":["../../src/hooks/useRipple.tsx"],"sourcesContent":["import type { MouseEvent, MouseEventHandler, PointerEvent, PointerEventHandler, ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useMemo, useRef, useState } from 'react';\nimport { rippleStyles } from '../styles/ripple';\nimport { motionDurationMs, motionEasing, spacingPx } from '../tokens/values';\n\n// Every timing this file drives is a motion token, spent at the point of use\n// below. They come from tokens/values rather than the StyleX theme because\n// element.animate() and setTimeout both reject a token's var() form, and the\n// same is true of the one geometry token: `PADDING` is added to a radius, and\n// a var() would concatenate rather than add. See src/styles/ripple.ts for the\n// opacity half of the mechanism, whose three timings are deliberately not\n// tokens.\n\n/** How far the ripple grows past the host's corners. `spacing.sm`. */\nconst PADDING = spacingPx.sm;\n\n// The rest are ratios and a pixel floor that no token group covers — spacing\n// is layout rhythm, and nothing in the set holds bare geometric ratios.\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\n\n// Static input, so this is computed once for every consumer of the module\n// rather than once per component instance.\nconst surfaceProps = stylex.props(rippleStyles.surface);\n\n/**\n * On touch: `Inactive -> TouchDelay -> WaitingForClick -> Inactive`, or\n * `Inactive -> TouchDelay -> Holding -> WaitingForClick -> Inactive` for a\n * held press.\n *\n * On mouse or pen: `Inactive -> WaitingForClick -> Inactive`.\n */\nconst RippleState = {\n /** A touch has been confirmed as a press (held past the touch delay). */\n Holding: 2,\n /** No press in progress. Touch down moves to TouchDelay; mouse/pen down moves to WaitingForClick. */\n Inactive: 0,\n /** Touch down received; waiting to see if it's a tap or a scroll/swipe. */\n TouchDelay: 1,\n /** The press has finished growing; waiting for the click that ends it. */\n WaitingForClick: 3\n} as const;\ntype ReleaseHandlers<HostElement extends Element> = Omit<RippleEventHandlers<HostElement>, 'onClick'>;\ninterface RippleEventHandlers<HostElement extends Element> {\n onClick?: MouseEventHandler<HostElement>;\n onContextMenu?: MouseEventHandler<HostElement>;\n onPointerCancel?: PointerEventHandler<HostElement>;\n onPointerDown?: PointerEventHandler<HostElement>;\n onPointerLeave?: PointerEventHandler<HostElement>;\n onPointerUp?: PointerEventHandler<HostElement>;\n}\ntype RippleState = (typeof RippleState)[keyof typeof RippleState];\nfunction isTouch(event: PointerEvent) {\n return event.pointerType === 'touch';\n}\n\n/**\n * Whether the reader has asked the OS for less motion.\n *\n * Growth is a Web Animations call, which makes it the one animation in the\n * library no `@media (prefers-reduced-motion: reduce)` branch can reach — see\n * src/styles/ripple.ts for the opacity half, which is CSS and carries one.\n *\n * Read at the press rather than once at mount, so a reader who changes the\n * setting is answered by their next press rather than by their next reload.\n * The press already reads layout through `getBoundingClientRect`, which costs\n * more than this does.\n */\nfunction prefersReducedMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/**\n * Renders a press ripple that grows from the pointer's position, or from\n * the element's center for a keyboard or other non-pointer activation.\n *\n * Growth runs via the Web Animations API on a single reused element (no\n * per-click DOM nodes to clean up), over a fixed duration independent of how\n * long the element is held — a real press-and-hold keeps the ripple\n * growing until release, while a quick tap is still held visible for a\n * minimum duration so it plays a complete animation rather than a flicker.\n *\n * Merges its own handlers with `externalHandlers` (e.g. a component's own\n * consumer-supplied props — ripple's own run first, then the external\n * ones) and returns `handlers` to spread onto the interactive element and\n * `surface`, the node to render as a child. The host element must\n * establish a positioning context (`position: relative` or similar) so\n * `surface`, which fills it via `inset: 0`, clips to its bounds and\n * inherits its shape.\n *\n * Pass `enabled: false` to opt out — no ripple listeners are attached and\n * no surface is rendered, leaving `externalHandlers` and a component's own\n * hover/press state layer (if any) untouched.\n *\n * Pass `endsOnRelease` for a host that never hears its own click: a\n * collection row, whose clicks React Aria's press handling keeps for itself.\n * The press then ends when the pointer is released over the host rather than\n * on the click that would follow, still held for the minimum a short press\n * gets. A keyboard press reaches such a host as no pointer event at all, so\n * it draws no ripple there.\n *\n * `handlers` and `surface` are hand-memoized (not left to build-tool\n * optimization) so a consumer rendering many instances — a list of icon\n * buttons, say — can memoize around them too, and so stability doesn't\n * depend on any particular compiler being configured.\n */\n// A host ending on the release never hears a click, so nothing is taken for\n// one and none is handed back: the handlers are the pointer ones alone, which\n// is also what a collection row's type admits.\nfunction useRipple<HostElement extends Element = Element>(enabled: boolean, externalHandlers: ReleaseHandlers<HostElement>, endsOnRelease: true): {\n handlers: ReleaseHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled?: boolean, externalHandlers?: RippleEventHandlers<HostElement>, endsOnRelease?: false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled = true, externalHandlers: RippleEventHandlers<HostElement> = {}, endsOnRelease = false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n} {\n const [pressed, setPressed] = useState(false);\n const rippleRef = useRef<HTMLSpanElement>(null);\n const state = useRef<RippleState>(RippleState.Inactive);\n const growAnimation = useRef<Animation | undefined>(undefined);\n const rippleStartEvent = useRef<PointerEvent<HostElement> | undefined>(undefined);\n const initialSize = useRef(0);\n const rippleScale = useRef('1');\n\n // Whether `event` comes from the pointer a press would follow: the primary\n // one, and the one that started the press already in flight, if any.\n const isPressPointer = useCallback((event: PointerEvent<HostElement>) => {\n if (!event.isPrimary) {\n return false;\n }\n const startEvent = rippleStartEvent.current;\n return !startEvent || startEvent.pointerId === event.pointerId;\n }, []);\n const shouldReactToEvent = useCallback((event: PointerEvent<HostElement>) => isPressPointer(event) && (isTouch(event) || event.buttons === 1), [isPressPointer]);\n const determineRippleSize = useCallback((rect: DOMRect) => {\n const {\n height,\n width\n } = rect;\n const maxDimension = Math.max(height, width);\n const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDimension, SOFT_EDGE_MINIMUM_SIZE);\n const size = Math.floor(maxDimension * INITIAL_ORIGIN_SCALE);\n const hypotenuse = Math.hypot(width, height);\n const maxRadius = hypotenuse + PADDING;\n initialSize.current = size;\n rippleScale.current = `${(maxRadius + softEdgeSize) / size}`;\n return `${size}px`;\n }, []);\n const getTranslationCoordinates = useCallback((rect: DOMRect, positionEvent?: PointerEvent<HostElement>) => {\n const {\n height,\n left,\n top,\n width\n } = rect;\n const size = initialSize.current;\n const endPoint = {\n x: (width - size) / 2,\n y: (height - size) / 2\n };\n const origin = positionEvent ? {\n x: positionEvent.clientX - left,\n y: positionEvent.clientY - top\n } : {\n x: width / 2,\n y: height / 2\n };\n const startPoint = {\n x: origin.x - size / 2,\n y: origin.y - size / 2\n };\n return {\n endPoint,\n startPoint\n };\n }, []);\n const startPressAnimation = useCallback((target: HostElement, positionEvent?: PointerEvent<HostElement>) => {\n const ripple = rippleRef.current;\n if (!ripple) {\n return;\n }\n setPressed(true);\n growAnimation.current?.cancel();\n\n // Read once and share: the two helpers below both only need the\n // target's rect, and a second `getBoundingClientRect()` call back to\n // back with the first would be a redundant layout read.\n const rect = target.getBoundingClientRect();\n const size = determineRippleSize(rect);\n const {\n endPoint,\n startPoint\n } = getTranslationCoordinates(rect, positionEvent);\n ripple.style.width = size;\n ripple.style.height = size;\n growAnimation.current = ripple.animate({\n transform: [`translate(${startPoint.x}px, ${startPoint.y}px) scale(1)`, `translate(${endPoint.x}px, ${endPoint.y}px) scale(${rippleScale.current})`]\n }, {\n // Growth runs over a fixed duration regardless of how long the\n // press is held, so the token is spent here rather than named as a\n // constant — element.animate() is one of the two places a StyleX\n // token could not have gone.\n //\n // Zeroed rather than skipped under reduced motion, which lands the\n // disc at its full size with the growth never drawn. Skipping the\n // call outright would leave `growAnimation` unset, and the release\n // below reads its `currentTime` to decide whether the press has\n // been visible long enough — so the press would still be shown, and\n // would stop being held for its minimum.\n duration: prefersReducedMotion() ? 0 : motionDurationMs.long1,\n easing: motionEasing.standard,\n fill: 'forwards'\n });\n }, [determineRippleSize, getTranslationCoordinates]);\n const endPressAnimation = useCallback(async () => {\n rippleStartEvent.current = undefined;\n state.current = RippleState.Inactive;\n const animation = growAnimation.current;\n const elapsed = typeof animation?.currentTime === 'number' ? animation.currentTime : Infinity;\n\n // The floor on how briefly a ripple may be visible, so a quick tap reads\n // as a deliberate ripple rather than a flicker.\n if (elapsed >= motionDurationMs.medium1) {\n setPressed(false);\n return;\n }\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.medium1 - elapsed);\n });\n if (growAnimation.current !== animation) {\n // A newer press started; let it own the pressed state instead.\n return;\n }\n setPressed(false);\n }, []);\n\n // Reads through a function so a stale narrowing of `state.current` from\n // before the `await` below isn't (incorrectly) carried across it — the\n // ref can change via a different handler while this one is suspended.\n const getState = useCallback(() => state.current, []);\n const handlePointerDownAsync = useCallback(async (event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n rippleStartEvent.current = event;\n const target = event.currentTarget;\n if (!isTouch(event)) {\n state.current = RippleState.WaitingForClick;\n startPressAnimation(target, event);\n return;\n }\n\n // Delay so a scroll/swipe starting on the element doesn't flash a\n // ripple — only a held (or quickly released) touch counts as a press.\n state.current = RippleState.TouchDelay;\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.short2);\n });\n if (getState() !== RippleState.TouchDelay) {\n return;\n }\n state.current = RippleState.Holding;\n startPressAnimation(target, event);\n }, [getState, shouldReactToEvent, startPressAnimation]);\n const handlePointerDown = useCallback((event: PointerEvent<HostElement>) => {\n void handlePointerDownAsync(event);\n }, [handlePointerDownAsync]);\n const handlePointerUp = useCallback((event: PointerEvent<HostElement>) => {\n // A mouse or pen release carries no pressed button, so the guard the\n // other handlers share turns it away, which is right while a click\n // follows to end the press. A host ending on the release matches it by\n // its pointer alone.\n if (endsOnRelease && !isTouch(event)) {\n if (isPressPointer(event) && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n return;\n }\n if (!shouldReactToEvent(event)) {\n return;\n }\n if (state.current === RippleState.Holding) {\n state.current = RippleState.WaitingForClick;\n } else if (state.current === RippleState.TouchDelay) {\n // Released before the delay elapsed: treat as a completed tap.\n state.current = RippleState.WaitingForClick;\n startPressAnimation(event.currentTarget, rippleStartEvent.current);\n }\n\n // The release is as far as such a host hears, so it is where the\n // press ends — see `endsOnRelease` above.\n if (endsOnRelease && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n }, [endPressAnimation, endsOnRelease, isPressPointer, shouldReactToEvent, startPressAnimation]);\n const handlePointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n if (isTouch(event) || !shouldReactToEvent(event)) {\n return;\n }\n if (state.current !== RippleState.Inactive) {\n void endPressAnimation();\n }\n }, [endPressAnimation, shouldReactToEvent]);\n const handlePointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n void endPressAnimation();\n }, [endPressAnimation, shouldReactToEvent]);\n const handleClick = useCallback((event: MouseEvent<HostElement>) => {\n if (state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n return;\n }\n if (state.current === RippleState.Inactive) {\n // No pointerdown preceded this click — keyboard activation, a\n // programmatic `.click()`, or assistive-tech-synthesized activation.\n // Play a complete, centered press immediately.\n startPressAnimation(event.currentTarget);\n void endPressAnimation();\n }\n }, [endPressAnimation, startPressAnimation]);\n const handleContextMenu = useCallback(() => {\n void endPressAnimation();\n }, [endPressAnimation]);\n const {\n onClick: onClickProp,\n onContextMenu: onContextMenuProp,\n onPointerCancel: onPointerCancelProp,\n onPointerDown: onPointerDownProp,\n onPointerLeave: onPointerLeaveProp,\n onPointerUp: onPointerUpProp\n } = externalHandlers;\n const onClick = useCallback((event: MouseEvent<HostElement>) => {\n handleClick(event);\n onClickProp?.(event);\n }, [handleClick, onClickProp]);\n const onContextMenu = useCallback((event: MouseEvent<HostElement>) => {\n handleContextMenu();\n onContextMenuProp?.(event);\n }, [handleContextMenu, onContextMenuProp]);\n const onPointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerCancel(event);\n onPointerCancelProp?.(event);\n }, [handlePointerCancel, onPointerCancelProp]);\n const onPointerDown = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerDown(event);\n onPointerDownProp?.(event);\n }, [handlePointerDown, onPointerDownProp]);\n const onPointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerLeave(event);\n onPointerLeaveProp?.(event);\n }, [handlePointerLeave, onPointerLeaveProp]);\n const onPointerUp = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerUp(event);\n onPointerUpProp?.(event);\n }, [handlePointerUp, onPointerUpProp]);\n const handlers = useMemo(() => {\n const pointer = {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n };\n return endsOnRelease ? pointer : {\n onClick,\n ...pointer\n };\n }, [endsOnRelease, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp]);\n const surface = useMemo(() => <span aria-hidden=\"true\" {...surfaceProps}>\n <span ref={rippleRef} {...stylex.props(rippleStyles.press, pressed && rippleStyles.pressed)} />\n </span>, [pressed]);\n\n // Two separate memos rather than one branching on `enabled`, so that\n // whichever branch is actually active stays keyed only on its own\n // inputs — the enabled result doesn't get a new identity every time\n // `externalHandlers` does (a component typically passes a fresh object\n // literal each render), and vice versa.\n const enabledResult = useMemo(() => ({\n handlers,\n surface\n }), [handlers, surface]);\n const disabledResult = useMemo(() => ({\n handlers: externalHandlers,\n surface: null\n }), [externalHandlers]);\n return enabled ? enabledResult : disabledResult;\n}\nexport { useRipple };"],"mappings":";;;;;;;;AAeA,MAAMc,UAAUD,UAAUE;AAI1B,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAC/B,MAAMC,4BAA4B;AAIlC,MAAMC,eAAed,MAAaK,OAAaW,OAAO;;;;;;;;AAStD,MAAMC,cAAc;;CAElBC,SAAS;;CAETC,UAAU;;CAEVC,YAAY;;CAEZC,iBAAiB;AACnB;AAWA,SAASa,QAAQC,OAAqB;CACpC,OAAOA,MAAMC,gBAAgB;AAC/B;;;;;;;;;;;;;AAcA,S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hD,OAAYgD,OAAQ;EAACJ,EAAA,MAAAI;EAAAJ,EAAA,MAAAiI;CAAA,OAAAA,MAAAjI,EAAA;CAAA,IAAAmI;CAAA,IAAAnI,EAAA,QAAAiI,KAAA;EADnEE,MAAA,oBAAA,QAAA;GAAkB,eAAA;GAAM,GAAKtK;GACrD,UAAA,oBAAA,QAAA;IAAWyC,KAAAA;IAAS,GAAM2H;GAAiE,CAAA;EACtF,CAAA;EAAAjI,EAAA,MAAAiI;EAAAjI,EAAA,MAAAmI;CAAA,OAAAA,MAAAnI,EAAA;CAFX,MAAAjC,UAA8BoK;CAEN,IAAAC;CAAA,IAAApI,EAAA,QAAAJ,YAAAI,EAAA,QAAAjC,SAAA;EAOaqK,MAAA;GAAAxI;GAAA7B;EAGrC;EAACiC,EAAA,MAAAJ;EAAAI,EAAA,MAAAjC;EAAAiC,EAAA,MAAAoI;CAAA,OAAAA,MAAApI,EAAA;CAHD,MAAAqI,gBAAqCD;CAGZ,IAAAE;CAAA,IAAAtI,EAAA,QAAAN,kBAAA;EACa4I,MAAA;GAAA1I,UAC1BF;GAAgB3B,SACjB;EACX;EAACiC,EAAA,MAAAN;EAAAM,EAAA,MAAAsI;CAAA,OAAAA,MAAAtI,EAAA;CAAuB,OACjBP,UAAA4I,gBAAAE;AAAwC;AAnRjD,SAAA9C,MAAA+C,WAAA;CAgJMvD,WAAWD,WAAS3H,iBAAgBoL,MAAO;AAAC"}
1
+ {"version":3,"file":"useRipple.js","names":["MouseEvent","MouseEventHandler","PointerEvent","PointerEventHandler","ReactNode","stylex","useCallback","useEffect","useMemo","useRef","useState","rippleStyles","motionDurationMs","motionEasing","spacingPx","PADDING","sm","INITIAL_ORIGIN_SCALE","SOFT_EDGE_MINIMUM_SIZE","SOFT_EDGE_CONTAINER_RATIO","surfaceProps","props","surface","RippleState","Holding","Inactive","TouchDelay","WaitingForClick","const","ReleaseHandlers","Element","Omit","RippleEventHandlers","HostElement","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","isTouch","event","pointerType","prefersReducedMotion","window","matchMedia","matches","useRipple","enabled","externalHandlers","endsOnRelease","handlers","t0","t1","t2","$","_c","undefined","t3","pressed","setPressed","rippleRef","state","growAnimation","rippleStartEvent","initialSize","rippleScale","removeDocumentListeners","t4","Symbol","for","isPrimary","startEvent","current","pointerId","isPressPointer","t5","event_0","buttons","shouldReactToEvent","t6","rect","height","width","maxDimension","Math","max","softEdgeSize","size","floor","hypotenuse","hypot","maxRadius","determineRippleSize","t7","rect_0","positionEvent","height_0","left","top","width_0","size_0","endPoint","x","y","origin","clientX","clientY","startPoint","getTranslationCoordinates","t8","target","positionEvent_0","ripple","cancel","rect_1","getBoundingClientRect","size_1","endPoint_0","startPoint_0","style","animate","transform","duration","long1","easing","standard","fill","startPressAnimation","t9","animation","elapsed","currentTime","Infinity","medium1","Promise","resolve","setTimeout","endPressAnimation","t10","host","document","ownerDocument","handleEnd","event_1","composedPath","includes","addEventListener","removeEventListener","listenBeyondHost","t11","t12","t13","getState","t14","event_2","target_0","currentTarget","_temp","handlePointerDownAsync","t15","event_3","handlePointerDown","t16","event_4","handlePointerUp","t17","event_5","handlePointerLeave","t18","event_6","handlePointerCancel","t19","event_7","handleClick","t20","handleContextMenu","onClickProp","onContextMenuProp","onPointerCancelProp","onPointerDownProp","onPointerLeaveProp","onPointerUpProp","t21","event_8","t22","event_9","t23","event_10","t24","event_11","t25","event_12","t26","event_13","t27","pointer","t28","t29","press","t30","t31","enabledResult","t32","disabledResult","resolve_0","short2","stylex.props","rippleStyles","_c","disabledResult"],"sources":["../../src/hooks/useRipple.tsx"],"sourcesContent":["import type { MouseEvent, MouseEventHandler, PointerEvent, PointerEventHandler, ReactNode } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { rippleStyles } from '../styles/ripple';\nimport { motionDurationMs, motionEasing, spacingPx } from '../tokens/values';\n\n// Every timing this file drives is a motion token, spent at the point of use\n// below. They come from tokens/values rather than the StyleX theme because\n// element.animate() and setTimeout both reject a token's var() form, and the\n// same is true of the one geometry token: `PADDING` is added to a radius, and\n// a var() would concatenate rather than add. See src/styles/ripple.ts for the\n// opacity half of the mechanism, whose three timings are deliberately not\n// tokens.\n\n/** How far the ripple grows past the host's corners. `spacing.sm`. */\nconst PADDING = spacingPx.sm;\n\n// The rest are ratios and a pixel floor that no token group covers — spacing\n// is layout rhythm, and nothing in the set holds bare geometric ratios.\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\n\n// Static input, so this is computed once for every consumer of the module\n// rather than once per component instance.\nconst surfaceProps = stylex.props(rippleStyles.surface);\n\n/**\n * On touch: `Inactive -> TouchDelay -> WaitingForClick -> Inactive`, or\n * `Inactive -> TouchDelay -> Holding -> WaitingForClick -> Inactive` for a\n * held press.\n *\n * On mouse or pen: `Inactive -> WaitingForClick -> Inactive`.\n */\nconst RippleState = {\n /** A touch has been confirmed as a press (held past the touch delay). */\n Holding: 2,\n /** No press in progress. Touch down moves to TouchDelay; mouse/pen down moves to WaitingForClick. */\n Inactive: 0,\n /** Touch down received; waiting to see if it's a tap or a scroll/swipe. */\n TouchDelay: 1,\n /** The press has finished growing; waiting for the click that ends it. */\n WaitingForClick: 3\n} as const;\ntype ReleaseHandlers<HostElement extends Element> = Omit<RippleEventHandlers<HostElement>, 'onClick'>;\ninterface RippleEventHandlers<HostElement extends Element> {\n onClick?: MouseEventHandler<HostElement>;\n onContextMenu?: MouseEventHandler<HostElement>;\n onPointerCancel?: PointerEventHandler<HostElement>;\n onPointerDown?: PointerEventHandler<HostElement>;\n onPointerLeave?: PointerEventHandler<HostElement>;\n onPointerUp?: PointerEventHandler<HostElement>;\n}\ntype RippleState = (typeof RippleState)[keyof typeof RippleState];\nfunction isTouch(event: PointerEvent) {\n return event.pointerType === 'touch';\n}\n\n/**\n * Whether the reader has asked the OS for less motion.\n *\n * Growth is a Web Animations call, which makes it the one animation in the\n * library no `@media (prefers-reduced-motion: reduce)` branch can reach — see\n * src/styles/ripple.ts for the opacity half, which is CSS and carries one.\n *\n * Read at the press rather than once at mount, so a reader who changes the\n * setting is answered by their next press rather than by their next reload.\n * The press already reads layout through `getBoundingClientRect`, which costs\n * more than this does.\n */\nfunction prefersReducedMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/**\n * Renders a press ripple that grows from the pointer's position, or from\n * the element's center for a keyboard or other non-pointer activation.\n *\n * Growth runs via the Web Animations API on a single reused element (no\n * per-click DOM nodes to clean up), over a fixed duration independent of how\n * long the element is held — a real press-and-hold keeps the ripple\n * growing until release, while a quick tap is still held visible for a\n * minimum duration so it plays a complete animation rather than a flicker.\n *\n * Merges its own handlers with `externalHandlers` (e.g. a component's own\n * consumer-supplied props — ripple's own run first, then the external\n * ones) and returns `handlers` to spread onto the interactive element and\n * `surface`, the node to render as a child. The host element must\n * establish a positioning context (`position: relative` or similar) so\n * `surface`, which fills it via `inset: 0`, clips to its bounds and\n * inherits its shape.\n *\n * Pass `enabled: false` to opt out — no ripple listeners are attached and\n * no surface is rendered, leaving `externalHandlers` and a component's own\n * hover/press state layer (if any) untouched.\n *\n * Pass `endsOnRelease` for a host that never hears its own click: a\n * collection row, whose clicks React Aria's press handling keeps for itself.\n * The press then ends when the pointer is released over the host rather than\n * on the click that would follow, still held for the minimum a short press\n * gets. A keyboard press reaches such a host as no pointer event at all, so\n * it draws no ripple there.\n *\n * `handlers` and `surface` are hand-memoized (not left to build-tool\n * optimization) so a consumer rendering many instances — a list of icon\n * buttons, say — can memoize around them too, and so stability doesn't\n * depend on any particular compiler being configured.\n */\n// A host ending on the release never hears a click, so nothing is taken for\n// one and none is handed back: the handlers are the pointer ones alone, which\n// is also what a collection row's type admits.\nfunction useRipple<HostElement extends Element = Element>(enabled: boolean, externalHandlers: ReleaseHandlers<HostElement>, endsOnRelease: true): {\n handlers: ReleaseHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled?: boolean, externalHandlers?: RippleEventHandlers<HostElement>, endsOnRelease?: false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n};\nfunction useRipple<HostElement extends Element = Element>(enabled = true, externalHandlers: RippleEventHandlers<HostElement> = {}, endsOnRelease = false): {\n handlers: RippleEventHandlers<HostElement>;\n surface: ReactNode;\n} {\n const [pressed, setPressed] = useState(false);\n const rippleRef = useRef<HTMLSpanElement>(null);\n const state = useRef<RippleState>(RippleState.Inactive);\n const growAnimation = useRef<Animation | undefined>(undefined);\n const rippleStartEvent = useRef<PointerEvent<HostElement> | undefined>(undefined);\n const initialSize = useRef(0);\n const rippleScale = useRef('1');\n // Removes the listeners a press keeps on its host's document, while one is\n // in flight — see `listenBeyondHost`.\n const removeDocumentListeners = useRef<(() => void) | undefined>(undefined);\n\n // Whether `event` comes from the pointer a press would follow: the primary\n // one, and the one that started the press already in flight, if any.\n const isPressPointer = useCallback((event: PointerEvent<HostElement>) => {\n if (!event.isPrimary) {\n return false;\n }\n const startEvent = rippleStartEvent.current;\n return !startEvent || startEvent.pointerId === event.pointerId;\n }, []);\n const shouldReactToEvent = useCallback((event: PointerEvent<HostElement>) => isPressPointer(event) && (isTouch(event) || event.buttons === 1), [isPressPointer]);\n const determineRippleSize = useCallback((rect: DOMRect) => {\n const {\n height,\n width\n } = rect;\n const maxDimension = Math.max(height, width);\n const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDimension, SOFT_EDGE_MINIMUM_SIZE);\n const size = Math.floor(maxDimension * INITIAL_ORIGIN_SCALE);\n const hypotenuse = Math.hypot(width, height);\n const maxRadius = hypotenuse + PADDING;\n initialSize.current = size;\n rippleScale.current = `${(maxRadius + softEdgeSize) / size}`;\n return `${size}px`;\n }, []);\n const getTranslationCoordinates = useCallback((rect: DOMRect, positionEvent?: PointerEvent<HostElement>) => {\n const {\n height,\n left,\n top,\n width\n } = rect;\n const size = initialSize.current;\n const endPoint = {\n x: (width - size) / 2,\n y: (height - size) / 2\n };\n const origin = positionEvent ? {\n x: positionEvent.clientX - left,\n y: positionEvent.clientY - top\n } : {\n x: width / 2,\n y: height / 2\n };\n const startPoint = {\n x: origin.x - size / 2,\n y: origin.y - size / 2\n };\n return {\n endPoint,\n startPoint\n };\n }, []);\n const startPressAnimation = useCallback((target: HostElement, positionEvent?: PointerEvent<HostElement>) => {\n const ripple = rippleRef.current;\n if (!ripple) {\n return;\n }\n setPressed(true);\n growAnimation.current?.cancel();\n\n // Read once and share: the two helpers below both only need the\n // target's rect, and a second `getBoundingClientRect()` call back to\n // back with the first would be a redundant layout read.\n const rect = target.getBoundingClientRect();\n const size = determineRippleSize(rect);\n const {\n endPoint,\n startPoint\n } = getTranslationCoordinates(rect, positionEvent);\n ripple.style.width = size;\n ripple.style.height = size;\n growAnimation.current = ripple.animate({\n transform: [`translate(${startPoint.x}px, ${startPoint.y}px) scale(1)`, `translate(${endPoint.x}px, ${endPoint.y}px) scale(${rippleScale.current})`]\n }, {\n // Growth runs over a fixed duration regardless of how long the\n // press is held, so the token is spent here rather than named as a\n // constant — element.animate() is one of the two places a StyleX\n // token could not have gone.\n //\n // Zeroed rather than skipped under reduced motion, which lands the\n // disc at its full size with the growth never drawn. Skipping the\n // call outright would leave `growAnimation` unset, and the release\n // below reads its `currentTime` to decide whether the press has\n // been visible long enough — so the press would still be shown, and\n // would stop being held for its minimum.\n duration: prefersReducedMotion() ? 0 : motionDurationMs.long1,\n easing: motionEasing.standard,\n fill: 'forwards'\n });\n }, [determineRippleSize, getTranslationCoordinates]);\n const endPressAnimation = useCallback(async () => {\n removeDocumentListeners.current?.();\n removeDocumentListeners.current = undefined;\n rippleStartEvent.current = undefined;\n state.current = RippleState.Inactive;\n const animation = growAnimation.current;\n const elapsed = typeof animation?.currentTime === 'number' ? animation.currentTime : Infinity;\n\n // The floor on how briefly a ripple may be visible, so a quick tap reads\n // as a deliberate ripple rather than a flicker.\n if (elapsed >= motionDurationMs.medium1) {\n setPressed(false);\n return;\n }\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.medium1 - elapsed);\n });\n if (growAnimation.current !== animation) {\n // A newer press started; let it own the pressed state instead.\n return;\n }\n setPressed(false);\n }, []);\n\n // A press can end somewhere other than its host. React Aria's press\n // handling releases the capture a touch takes on its pointerdown, so that a\n // finger can leave the element, and a press that turns into a scroll — or\n // a finger that slides off and lifts — then ends with a pointercancel or\n // pointerup on whatever is under it, which the host never hears. Left to\n // the host's handlers alone, the ripple held at its pressed opacity until\n // the next press on that host finished a cycle.\n //\n // So the press listens on its host's document, in the capture phase, for\n // its own pointer, the way React Aria's own press handling does. An end the\n // host does hear is left to the host's handlers, which run after these.\n const listenBeyondHost = useCallback((host: HostElement, pointerId: number) => {\n removeDocumentListeners.current?.();\n const document = host.ownerDocument;\n const handleEnd = (event: globalThis.PointerEvent) => {\n if (event.pointerId !== pointerId || event.composedPath().includes(host)) {\n return;\n }\n void endPressAnimation();\n };\n document.addEventListener('pointercancel', handleEnd, true);\n document.addEventListener('pointerup', handleEnd, true);\n removeDocumentListeners.current = () => {\n document.removeEventListener('pointercancel', handleEnd, true);\n document.removeEventListener('pointerup', handleEnd, true);\n };\n }, [endPressAnimation]);\n\n // A host unmounted mid-press leaves nothing listening behind it.\n useEffect(() => () => {\n removeDocumentListeners.current?.();\n }, []);\n\n // Reads through a function so a stale narrowing of `state.current` from\n // before the `await` below isn't (incorrectly) carried across it — the\n // ref can change via a different handler while this one is suspended.\n const getState = useCallback(() => state.current, []);\n const handlePointerDownAsync = useCallback(async (event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n rippleStartEvent.current = event;\n const target = event.currentTarget;\n listenBeyondHost(target, event.pointerId);\n if (!isTouch(event)) {\n state.current = RippleState.WaitingForClick;\n startPressAnimation(target, event);\n return;\n }\n\n // Delay so a scroll/swipe starting on the element doesn't flash a\n // ripple — only a held (or quickly released) touch counts as a press.\n state.current = RippleState.TouchDelay;\n await new Promise(resolve => {\n setTimeout(resolve, motionDurationMs.short2);\n });\n if (getState() !== RippleState.TouchDelay) {\n return;\n }\n state.current = RippleState.Holding;\n startPressAnimation(target, event);\n }, [getState, listenBeyondHost, shouldReactToEvent, startPressAnimation]);\n const handlePointerDown = useCallback((event: PointerEvent<HostElement>) => {\n void handlePointerDownAsync(event);\n }, [handlePointerDownAsync]);\n const handlePointerUp = useCallback((event: PointerEvent<HostElement>) => {\n // A mouse or pen release carries no pressed button, so the guard the\n // other handlers share turns it away, which is right while a click\n // follows to end the press. A host ending on the release matches it by\n // its pointer alone.\n if (endsOnRelease && !isTouch(event)) {\n if (isPressPointer(event) && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n return;\n }\n if (!shouldReactToEvent(event)) {\n return;\n }\n if (state.current === RippleState.Holding) {\n state.current = RippleState.WaitingForClick;\n } else if (state.current === RippleState.TouchDelay) {\n // Released before the delay elapsed: treat as a completed tap.\n state.current = RippleState.WaitingForClick;\n startPressAnimation(event.currentTarget, rippleStartEvent.current);\n }\n\n // The release is as far as such a host hears, so it is where the\n // press ends — see `endsOnRelease` above.\n if (endsOnRelease && state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n }\n }, [endPressAnimation, endsOnRelease, isPressPointer, shouldReactToEvent, startPressAnimation]);\n const handlePointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n if (isTouch(event) || !shouldReactToEvent(event)) {\n return;\n }\n if (state.current !== RippleState.Inactive) {\n void endPressAnimation();\n }\n }, [endPressAnimation, shouldReactToEvent]);\n const handlePointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n if (!shouldReactToEvent(event)) {\n return;\n }\n void endPressAnimation();\n }, [endPressAnimation, shouldReactToEvent]);\n const handleClick = useCallback((event: MouseEvent<HostElement>) => {\n if (state.current === RippleState.WaitingForClick) {\n void endPressAnimation();\n return;\n }\n if (state.current === RippleState.Inactive) {\n // No pointerdown preceded this click — keyboard activation, a\n // programmatic `.click()`, or assistive-tech-synthesized activation.\n // Play a complete, centered press immediately.\n startPressAnimation(event.currentTarget);\n void endPressAnimation();\n }\n }, [endPressAnimation, startPressAnimation]);\n const handleContextMenu = useCallback(() => {\n void endPressAnimation();\n }, [endPressAnimation]);\n const {\n onClick: onClickProp,\n onContextMenu: onContextMenuProp,\n onPointerCancel: onPointerCancelProp,\n onPointerDown: onPointerDownProp,\n onPointerLeave: onPointerLeaveProp,\n onPointerUp: onPointerUpProp\n } = externalHandlers;\n const onClick = useCallback((event: MouseEvent<HostElement>) => {\n handleClick(event);\n onClickProp?.(event);\n }, [handleClick, onClickProp]);\n const onContextMenu = useCallback((event: MouseEvent<HostElement>) => {\n handleContextMenu();\n onContextMenuProp?.(event);\n }, [handleContextMenu, onContextMenuProp]);\n const onPointerCancel = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerCancel(event);\n onPointerCancelProp?.(event);\n }, [handlePointerCancel, onPointerCancelProp]);\n const onPointerDown = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerDown(event);\n onPointerDownProp?.(event);\n }, [handlePointerDown, onPointerDownProp]);\n const onPointerLeave = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerLeave(event);\n onPointerLeaveProp?.(event);\n }, [handlePointerLeave, onPointerLeaveProp]);\n const onPointerUp = useCallback((event: PointerEvent<HostElement>) => {\n handlePointerUp(event);\n onPointerUpProp?.(event);\n }, [handlePointerUp, onPointerUpProp]);\n const handlers = useMemo(() => {\n const pointer = {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n };\n return endsOnRelease ? pointer : {\n onClick,\n ...pointer\n };\n }, [endsOnRelease, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp]);\n const surface = useMemo(() => <span aria-hidden=\"true\" {...surfaceProps}>\n <span ref={rippleRef} {...stylex.props(rippleStyles.press, pressed && rippleStyles.pressed)} />\n </span>, [pressed]);\n\n // Two separate memos rather than one branching on `enabled`, so that\n // whichever branch is actually active stays keyed only on its own\n // inputs — the enabled result doesn't get a new identity every time\n // `externalHandlers` does (a component typically passes a fresh object\n // literal each render), and vice versa.\n const enabledResult = useMemo(() => ({\n handlers,\n surface\n }), [handlers, surface]);\n const disabledResult = useMemo(() => ({\n handlers: externalHandlers,\n surface: null\n }), [externalHandlers]);\n return enabled ? enabledResult : disabledResult;\n}\nexport { useRipple };"],"mappings":";;;;;;;;AAeA,MAAMe,UAAUD,UAAUE;AAI1B,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAC/B,MAAMC,4BAA4B;AAIlC,MAAMC,eAAef,MAAaM,OAAaW,OAAO;;;;;;;;AAStD,MAAMC,cAAc;;CAElBC,SAAS;;CAETC,UAAU;;CAEVC,YAAY;;CAEZC,iBAAiB;AACnB;AAWA,SAASa,QAAQC,OAAqB;CACpC,OAAOA,MAAMC,gBAAgB;AAC/B;;;;;;;;;;;;;AAcA,SAASC,uBAAuB;CAC9B,OAAOC,OAAOC,WAAW,kCAAkC,CAAC,CAACC;AAC/D;AA+CA,SAAAC,UAAAK,IAAAC,IAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA0D,MAAAR,UAAAI,OAAAK,KAAAA,IAAA,OAAAL;CAAc,IAAAM;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAEK,KAAAL,OAAAI,KAAAA,IAAA,CAAsD,IAAtDJ;EAAuDE,EAAA,KAAAF;EAAAE,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAvD,MAAAN,mBAAAS;CAAyD,MAAAR,gBAAAI,OAAAG,KAAAA,IAAA,QAAAH;CAIjI,MAAA,CAAAK,SAAAC,cAA8BlD,SAAS,KAAK;CAC5C,MAAAmD,YAAkBpD,OAAwB,IAAI;CAC9C,MAAAqD,QAAcrD,OAAoBc,YAAWE,QAAS;CACtD,MAAAsC,gBAAsBtD,OAA8BgD,KAAAA,CAAS;CAC7D,MAAAO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MAAA+C,WAAA;CAuLMpE,WAAWD,WAAS5H,iBAAgBkM,MAAO;AAAC"}
@@ -0,0 +1,24 @@
1
+ import { useContext } from "react";
2
+ import { ToggleGroupStateContext } from "react-aria-components";
3
+ //#region src/hooks/useToggleGroupDisabled.ts
4
+ /**
5
+ * Whether the React Aria `ToggleButtonGroup` around a toggle disables it.
6
+ *
7
+ * The group does that through its own state rather than through the toggle's
8
+ * props, so it reaches the toggle's render state and nothing earlier. A
9
+ * ripple has to know earlier than that, since its handlers go on the element
10
+ * outside the render function, and this is where it reads the group.
11
+ *
12
+ * Only a toggle with an `id` belongs to the group: React Aria leaves one
13
+ * without an `id` to keep its own state, enabled whatever the group says.
14
+ * This follows the same rule, so a toggle the group does not disable keeps
15
+ * its ripple.
16
+ */
17
+ function useToggleGroupDisabled(id) {
18
+ const group = useContext(ToggleGroupStateContext);
19
+ return group !== null && id !== void 0 && group.isDisabled;
20
+ }
21
+ //#endregion
22
+ export { useToggleGroupDisabled };
23
+
24
+ //# sourceMappingURL=useToggleGroupDisabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToggleGroupDisabled.js","names":["Key","useContext","ToggleGroupStateContext","useToggleGroupDisabled","id","group","undefined","isDisabled"],"sources":["../../src/hooks/useToggleGroupDisabled.ts"],"sourcesContent":["import type { Key } from 'react-aria-components'\n\nimport { useContext } from 'react'\nimport { ToggleGroupStateContext } from 'react-aria-components'\n\n/**\n * Whether the React Aria `ToggleButtonGroup` around a toggle disables it.\n *\n * The group does that through its own state rather than through the toggle's\n * props, so it reaches the toggle's render state and nothing earlier. A\n * ripple has to know earlier than that, since its handlers go on the element\n * outside the render function, and this is where it reads the group.\n *\n * Only a toggle with an `id` belongs to the group: React Aria leaves one\n * without an `id` to keep its own state, enabled whatever the group says.\n * This follows the same rule, so a toggle the group does not disable keeps\n * its ripple.\n */\nfunction useToggleGroupDisabled(id: Key | undefined): boolean {\n const group = useContext(ToggleGroupStateContext)\n return group !== null && id !== undefined && group.isDisabled\n}\n\nexport { useToggleGroupDisabled }\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,SAAAG,uBAAAC,IAAA;CACE,MAAAC,QAAcJ,WAAWC,uBAAuB;CAAC,OAC1CG,UAAU,QAAQD,OAAOE,KAAAA,KAAaD,MAAKE;AAAW"}