@donotdev/components 0.2.0 → 0.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"initRipple.d.ts","sourceRoot":"","sources":["../../src/utils/initRipple.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAMjC;AA+CD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAMpC"}
1
+ {"version":3,"file":"initRipple.d.ts","sourceRoot":"","sources":["../../src/utils/initRipple.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAMjC;AAsDD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAMpC"}
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * @fileoverview Ripple effect initialization
4
4
  * @description Event delegation for ripple effect on all .dndev-interactive elements.
5
- * Call once at app startup. Uses CSS variable --ripple-opacity (0 = disabled).
5
+ * Call once at app startup. Uses CSS variable --ripple-opacity (0 or unset = disabled).
6
6
  *
7
7
  * @version 0.1.0
8
8
  * @since 0.1.0
@@ -38,14 +38,17 @@ function handleRipple(event) {
38
38
  return;
39
39
  // Check if ripple is disabled via CSS variable
40
40
  const styles = getComputedStyle(target);
41
- const rippleOpacity = parseFloat(styles.getPropertyValue('--ripple-opacity').trim() || '0.2');
42
- if (rippleOpacity <= 0)
41
+ const rippleOpacity = parseFloat(styles.getPropertyValue('--ripple-opacity'));
42
+ if (!(rippleOpacity > 0))
43
43
  return;
44
- // Get click position relative to target
44
+ // Get click position relative to the target's padding box (the ripple's containing block)
45
45
  const rect = target.getBoundingClientRect();
46
- const x = event.clientX - rect.left;
47
- const y = event.clientY - rect.top;
48
- // Calculate ripple size (diagonal of element)
46
+ const paddingBoxStart = rect.left + target.clientLeft;
47
+ const inlineOffset = styles.direction === 'rtl'
48
+ ? paddingBoxStart + target.clientWidth - event.clientX
49
+ : event.clientX - paddingBoxStart;
50
+ const blockOffset = event.clientY - rect.top - target.clientTop;
51
+ // Base ripple size on the element's longest side
49
52
  const size = Math.max(rect.width, rect.height);
50
53
  // Create ripple element
51
54
  const ripple = document.createElement('span');
@@ -53,14 +56,18 @@ function handleRipple(event) {
53
56
  ripple.style.cssText = `
54
57
  width: ${size}px;
55
58
  height: ${size}px;
56
- left: ${x}px;
57
- top: ${y}px;
59
+ inset-inline-start: ${inlineOffset - size / 2}px;
60
+ inset-block-start: ${blockOffset - size / 2}px;
58
61
  `;
62
+ // Clip inside a dedicated layer: layout rules can override the target's overflow
63
+ const clip = document.createElement('span');
64
+ clip.className = 'dndev-ripple-clip';
65
+ clip.appendChild(ripple);
59
66
  // Add to target
60
- target.appendChild(ripple);
67
+ target.appendChild(clip);
61
68
  // Remove after animation completes
62
69
  ripple.addEventListener('animationend', () => {
63
- ripple.remove();
70
+ clip.remove();
64
71
  }, { once: true });
65
72
  }
66
73
  /**
@@ -9,7 +9,7 @@ import { type VariantProps } from 'class-variance-authority';
9
9
  * Used by: Card, DualCard, StackedCards, Dialog, Sheet, Alert
10
10
  */
11
11
  export declare const surfaceVariants: (props?: ({
12
- variant?: "default" | "muted" | "accent" | "primary" | "destructive" | "outline" | "success" | "warning" | "secondary" | "glass" | null | undefined;
12
+ variant?: "default" | "muted" | "primary" | "secondary" | "accent" | "success" | "warning" | "destructive" | "outline" | "glass" | null | undefined;
13
13
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
14
14
  /** CVA variant props for surface components (Card, DualCard, etc.). */
15
15
  export type SurfaceVariantProps = VariantProps<typeof surfaceVariants>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/components",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Styled UI components for DoNotDev",