@cntyclub/ui-react 0.10.4 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1313,7 +1313,16 @@ interface SmoothWheelOptions {
1313
1313
  * Eased, momentum-style wheel scrolling for any scrollable element. Instead of
1314
1314
  * jumping `scrollTop`/`scrollLeft` by the raw wheel delta (which feels fast and
1315
1315
  * abrupt), it animates toward an accumulated target with `requestAnimationFrame`.
1316
- * At the start/end edge it lets the wheel bubble so the page can still scroll.
1316
+ *
1317
+ * It only smooths genuine mouse wheels. Trackpads already scroll smoothly with
1318
+ * OS-level inertia, so layering our own easing on top makes it fight the native
1319
+ * momentum — the container sticks, or snaps back to where the animation was
1320
+ * still heading. In the default vertical mode a trackpad therefore keeps native
1321
+ * behaviour; in horizontal mode we still translate a vertical mouse wheel into
1322
+ * horizontal scrolling (the whole point of the mode) but let a real horizontal
1323
+ * trackpad swipe scroll natively. Every time control returns to native
1324
+ * scrolling — trackpad, or an edge — the in-flight animation is cancelled and
1325
+ * the target resynced so it can never pull the position back.
1317
1326
  */
1318
1327
  declare function useSmoothWheel(ref: React$1.RefObject<HTMLElement | null>, { enabled, horizontal, multiplier, ease, }?: SmoothWheelOptions): void;
1319
1328
  interface SmoothScrollProps extends React$1.ComponentProps<"div"> {
package/dist/index.js CHANGED
@@ -972,6 +972,14 @@ function useSmoothWheel(ref, {
972
972
  let target = el[axisProp];
973
973
  let raf = 0;
974
974
  let animating = false;
975
+ let kind = null;
976
+ let lastTs = 0;
977
+ const releaseToNative = () => {
978
+ if (raf) cancelAnimationFrame(raf);
979
+ raf = 0;
980
+ animating = false;
981
+ target = el[axisProp];
982
+ };
975
983
  const tick = () => {
976
984
  const max = el[sizeProp] - el[clientProp];
977
985
  target = Math.max(0, Math.min(target, max));
@@ -979,27 +987,50 @@ function useSmoothWheel(ref, {
979
987
  const diff = target - current;
980
988
  if (Math.abs(diff) < 0.5) {
981
989
  el[axisProp] = target;
990
+ raf = 0;
982
991
  animating = false;
983
992
  return;
984
993
  }
985
994
  el[axisProp] = current + diff * ease;
986
995
  raf = requestAnimationFrame(tick);
987
996
  };
988
- const normalize = (event) => {
989
- let delta = horizontal && event.deltaX !== 0 ? event.deltaX : event.deltaY;
990
- if (event.deltaMode === 1) delta *= 16;
991
- else if (event.deltaMode === 2) delta *= el[clientProp];
992
- return delta;
997
+ const looksLikeTrackpad = (e) => e.deltaMode === 0 && (!Number.isInteger(e.deltaY) || e.deltaX !== 0 || Math.abs(e.deltaY) < 50);
998
+ const classify = (e, now) => {
999
+ if (kind === null || now - lastTs > 200) {
1000
+ kind = looksLikeTrackpad(e) ? "trackpad" : "mouse";
1001
+ } else if (kind === "mouse" && (e.deltaX !== 0 || !Number.isInteger(e.deltaY))) {
1002
+ kind = "trackpad";
1003
+ }
1004
+ return kind;
993
1005
  };
994
1006
  const onWheel = (event) => {
1007
+ if (event.ctrlKey) return;
995
1008
  const max = el[sizeProp] - el[clientProp];
996
1009
  if (max <= 0) return;
997
- if (!animating) target = el[axisProp];
998
- const delta = normalize(event) * multiplier;
1010
+ const now = performance.now();
1011
+ const source = classify(event, now);
1012
+ lastTs = now;
1013
+ if (horizontal) {
1014
+ if (event.deltaX !== 0 && Math.abs(event.deltaX) >= Math.abs(event.deltaY)) {
1015
+ releaseToNative();
1016
+ return;
1017
+ }
1018
+ } else if (source === "trackpad") {
1019
+ releaseToNative();
1020
+ return;
1021
+ }
1022
+ let delta = horizontal && event.deltaX !== 0 ? event.deltaX : event.deltaY;
1023
+ if (event.deltaMode === 1) delta *= 16;
1024
+ else if (event.deltaMode === 2) delta *= el[clientProp];
1025
+ delta *= multiplier;
999
1026
  if (delta === 0) return;
1027
+ if (!animating) target = el[axisProp];
1000
1028
  const atStart = target <= 0;
1001
1029
  const atEnd = target >= max;
1002
- if (delta < 0 && atStart || delta > 0 && atEnd) return;
1030
+ if (delta < 0 && atStart || delta > 0 && atEnd) {
1031
+ releaseToNative();
1032
+ return;
1033
+ }
1003
1034
  event.preventDefault();
1004
1035
  target = Math.max(0, Math.min(target + delta, max));
1005
1036
  if (!animating) {
@@ -1626,7 +1657,9 @@ function AvatarGroup({
1626
1657
  "aria-label": `${overflow} more`,
1627
1658
  className: cn(
1628
1659
  avatarVariants({ size }),
1629
- "bg-muted font-medium text-muted-foreground"
1660
+ // Solid neutral fill so the chip reads as a distinct surface in both
1661
+ // themes — the `bg-muted` token is only 4% opacity (near-transparent).
1662
+ "bg-stone-200 font-medium text-stone-600 dark:bg-stone-700 dark:text-stone-200"
1630
1663
  ),
1631
1664
  "data-slot": "avatar-group-overflow",
1632
1665
  children: [