@mks2508/mks-ui 0.5.2 → 0.5.4

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 (69) hide show
  1. package/dist/react-ui/index.js +8 -3
  2. package/dist/react-ui/primitives/index.js +5 -0
  3. package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts +103 -0
  4. package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts.map +1 -0
  5. package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts +10 -0
  6. package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts.map +1 -0
  7. package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.js +59 -0
  8. package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts +7 -0
  9. package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts.map +1 -0
  10. package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.js +78 -0
  11. package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts +7 -0
  12. package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts.map +1 -0
  13. package/dist/react-ui/primitives/waapi/Gooey/MorphPath.js +51 -0
  14. package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts +87 -0
  15. package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts.map +1 -0
  16. package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.js +177 -0
  17. package/dist/react-ui/primitives/waapi/Gooey/index.d.ts +28 -0
  18. package/dist/react-ui/primitives/waapi/Gooey/index.d.ts.map +1 -0
  19. package/dist/react-ui/primitives/waapi/Gooey/index.js +5 -0
  20. package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts +7 -0
  21. package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts.map +1 -0
  22. package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.js +47 -0
  23. package/dist/react-ui/primitives/waapi/index.d.ts +2 -0
  24. package/dist/react-ui/primitives/waapi/index.d.ts.map +1 -1
  25. package/dist/react-ui/primitives/waapi/index.js +6 -0
  26. package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts +26 -16
  27. package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts.map +1 -1
  28. package/dist/react-ui/ui/DataCard/DataCard.styles.js +36 -74
  29. package/dist/react-ui/ui/DataCard/DataCard.types.d.ts +50 -70
  30. package/dist/react-ui/ui/DataCard/DataCard.types.d.ts.map +1 -1
  31. package/dist/react-ui/ui/DataCard/index.d.ts +24 -93
  32. package/dist/react-ui/ui/DataCard/index.d.ts.map +1 -1
  33. package/dist/react-ui/ui/DataCard/index.js +76 -118
  34. package/dist/react-ui/ui/DynamicToggle/DynamicToggle-Cm6-VceQ.css +304 -0
  35. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.css +303 -0
  36. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.js +0 -0
  37. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts +20 -8
  38. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -1
  39. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +55 -27
  40. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +63 -14
  41. package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -1
  42. package/dist/react-ui/ui/DynamicToggle/index.d.ts +22 -20
  43. package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -1
  44. package/dist/react-ui/ui/DynamicToggle/index.js +115 -96
  45. package/dist/react-ui/ui/Switch/index.js +1 -1
  46. package/dist/react-ui/ui/index.js +2 -2
  47. package/package.json +2 -2
  48. package/src/css.d.ts +1 -0
  49. package/src/react-ui/primitives/waapi/Gooey/Gooey.types.ts +123 -0
  50. package/src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx +80 -0
  51. package/src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx +77 -0
  52. package/src/react-ui/primitives/waapi/Gooey/MorphPath.tsx +58 -0
  53. package/src/react-ui/primitives/waapi/Gooey/gooey-utils.ts +244 -0
  54. package/src/react-ui/primitives/waapi/Gooey/index.ts +50 -0
  55. package/src/react-ui/primitives/waapi/Gooey/useMorphPath.ts +48 -0
  56. package/src/react-ui/primitives/waapi/index.ts +23 -0
  57. package/src/react-ui/ui/DataCard/DataCard.styles.ts +45 -101
  58. package/src/react-ui/ui/DataCard/DataCard.types.ts +52 -73
  59. package/src/react-ui/ui/DataCard/index.tsx +118 -184
  60. package/src/react-ui/ui/DynamicToggle/DynamicToggle.css +244 -91
  61. package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +60 -40
  62. package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +95 -14
  63. package/src/react-ui/ui/DynamicToggle/index.tsx +150 -96
  64. package/src/react-ui/ui/DynamicToggle/prototype-v7.html +615 -0
  65. package/src/react-ui/ui/DynamicToggle/prototype.html +419 -0
  66. package/src/react-ui/ui/Switch/index.tsx +1 -1
  67. /package/dist/react-ui/blocks/Terminal/panel/{terminal-filter-dropdown.module-DAcl_XQZ.css → terminal-filter-dropdown.module-C6oDcFBS.css} +0 -0
  68. /package/dist/react-ui/blocks/Terminal/panel/{terminal-session-tabs.module-DNAop5e3.css → terminal-session-tabs.module-D_-sgyza.css} +0 -0
  69. /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-BJrjXisF.css → morphing-popover.module-B1ftlaYj.css} +0 -0
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Gooey morphing primitive types.
3
+ *
4
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
5
+ */
6
+
7
+ import type { ReactNode } from 'react';
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // GooeyFilter
11
+ // ---------------------------------------------------------------------------
12
+
13
+ /**
14
+ * Props for the GooeyFilter SVG filter definition.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <GooeyFilter id="my-goo" blur={8} />
19
+ * ```
20
+ */
21
+ export interface IGooeyFilterProps {
22
+ /** Unique filter ID — referenced via `filter: url(#id)` */
23
+ id: string;
24
+ /** Gaussian blur stdDeviation (default: 8) */
25
+ blur?: number;
26
+ /** Alpha channel multiplier in feColorMatrix (default: 20) */
27
+ alphaGain?: number;
28
+ /** Alpha channel offset in feColorMatrix (default: -10) */
29
+ alphaOffset?: number;
30
+ }
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // GooeyCanvas
34
+ // ---------------------------------------------------------------------------
35
+
36
+ /**
37
+ * Props for the GooeyCanvas container.
38
+ *
39
+ * Wraps children with an SVG gooey filter. All same-colored children
40
+ * inside automatically merge visually into an organic blob.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * <GooeyCanvas height={40}>
45
+ * <div className="bg-card rounded-full h-10 w-64" />
46
+ * <div className="bg-card absolute bottom-full w-32 h-6" />
47
+ * </GooeyCanvas>
48
+ * ```
49
+ */
50
+ export interface IGooeyCanvasProps {
51
+ /** Blur radius override. If omitted, auto-calculated from `height`. */
52
+ blur?: number;
53
+ /** Element height — used to auto-calculate blur (default: 32) */
54
+ height?: number;
55
+ /** Drop-shadow outline blur in px (default: 0.5) */
56
+ outlineBlur?: number;
57
+ /** Drop-shadow outline color (default: 'var(--border)') */
58
+ outlineColor?: string;
59
+ /** Number of stacked drop-shadows for outline thickness (default: 2) */
60
+ outlineLayers?: number;
61
+ /** Alpha gain override */
62
+ alphaGain?: number;
63
+ /** Alpha offset override */
64
+ alphaOffset?: number;
65
+ /** Extra className on the filter container */
66
+ className?: string;
67
+ /** Content to merge with the gooey filter */
68
+ children: ReactNode;
69
+ }
70
+
71
+ // ---------------------------------------------------------------------------
72
+ // MorphPath
73
+ // ---------------------------------------------------------------------------
74
+
75
+ /**
76
+ * Props for the MorphPath SVG path component.
77
+ *
78
+ * Renders a parametric `<path>` that morphs from a pill shape to a
79
+ * pill+body blob based on the `progress` value.
80
+ *
81
+ * @example
82
+ * ```tsx
83
+ * <svg>
84
+ * <MorphPath pillWidth={260} bodyWidth={180} totalHeight={60} progress={0.5} fill="var(--card)" />
85
+ * </svg>
86
+ * ```
87
+ */
88
+ export interface IMorphPathProps extends React.SVGProps<SVGPathElement> {
89
+ /** Pill width in px */
90
+ pillWidth: number;
91
+ /** Body (expanded area) width in px */
92
+ bodyWidth: number;
93
+ /** Total height (pill + body) in px */
94
+ totalHeight: number;
95
+ /** Morph progress: 0 = pill only, 1 = fully expanded */
96
+ progress: number;
97
+ /** Pill height (default: 34) */
98
+ pillHeight?: number;
99
+ /** Body expansion direction relative to pill */
100
+ direction?: 'down' | 'up';
101
+ }
102
+
103
+ // ---------------------------------------------------------------------------
104
+ // useMorphPath
105
+ // ---------------------------------------------------------------------------
106
+
107
+ /**
108
+ * Options for the useMorphPath hook.
109
+ */
110
+ export interface IUseMorphPathOptions {
111
+ /** Pill width in px */
112
+ pillWidth: number;
113
+ /** Body width in px */
114
+ bodyWidth: number;
115
+ /** Total height in px */
116
+ totalHeight: number;
117
+ /** Morph progress 0→1 */
118
+ progress: number;
119
+ /** Pill height (default: 34) */
120
+ pillHeight?: number;
121
+ /** Body direction */
122
+ direction?: 'down' | 'up';
123
+ }
@@ -0,0 +1,80 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * GooeyCanvas — container that applies gooey SVG filter to children.
5
+ *
6
+ * Renders a GooeyFilter + a wrapper div with `filter: url(#id)`.
7
+ * All same-colored children inside merge organically. Optional drop-shadow
8
+ * outline traces the merged shape's edge.
9
+ *
10
+ * Blur auto-scales with height: `blur = Math.round(height * 0.15)`.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <div style={{ position: 'relative' }}>
15
+ * <GooeyCanvas height={40}>
16
+ * <div className="absolute inset-0 bg-card rounded-full" />
17
+ * <div className="absolute bottom-full bg-card w-32 h-6 rounded-lg" />
18
+ * </GooeyCanvas>
19
+ * <div className="relative z-10">Content on top (not filtered)</div>
20
+ * </div>
21
+ * ```
22
+ *
23
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
24
+ */
25
+
26
+ import * as React from 'react';
27
+ import { cn } from '@/react-ui/lib/utils';
28
+ import { GooeyFilter } from './GooeyFilter';
29
+ import { computeBlur, buildFilterString, GOOEY_DEFAULTS } from './gooey-utils';
30
+ import type { IGooeyCanvasProps } from './Gooey.types';
31
+
32
+ /**
33
+ * GooeyCanvas — container with gooey SVG filter applied.
34
+ */
35
+ function GooeyCanvas({
36
+ blur,
37
+ height = 32,
38
+ outlineBlur = 0.5,
39
+ outlineColor = 'var(--border)',
40
+ outlineLayers = 2,
41
+ alphaGain,
42
+ alphaOffset,
43
+ className,
44
+ children,
45
+ }: IGooeyCanvasProps) {
46
+ const filterId = React.useId().replace(/:/g, '') + '-goo';
47
+ const computedBlur = blur ?? computeBlur(height);
48
+
49
+ const filterStyle = React.useMemo(
50
+ () => ({
51
+ filter: buildFilterString(filterId, outlineBlur, outlineColor, outlineLayers),
52
+ }),
53
+ [filterId, outlineBlur, outlineColor, outlineLayers],
54
+ );
55
+
56
+ return (
57
+ <>
58
+ <GooeyFilter
59
+ id={filterId}
60
+ blur={computedBlur}
61
+ alphaGain={alphaGain}
62
+ alphaOffset={alphaOffset}
63
+ />
64
+ <div
65
+ data-slot="gooey-canvas"
66
+ style={filterStyle}
67
+ className={cn(
68
+ 'absolute inset-0 rounded-[inherit] pointer-events-none z-0 overflow-visible',
69
+ className,
70
+ )}
71
+ >
72
+ {children}
73
+ </div>
74
+ </>
75
+ );
76
+ }
77
+
78
+ GooeyCanvas.displayName = 'GooeyCanvas';
79
+
80
+ export { GooeyCanvas };
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * GooeyFilter — SVG filter definition for gooey morphing effects.
5
+ *
6
+ * Renders a hidden `<svg>` with a `<filter>` that uses `feGaussianBlur` +
7
+ * `feColorMatrix` + `feComposite` to merge same-colored shapes organically.
8
+ *
9
+ * Apply via `filter: url(#id)` on a container. All same-colored children merge.
10
+ * `feComposite operator="atop"` preserves sharp text/content on top.
11
+ *
12
+ * @param id - Unique filter ID
13
+ * @param blur - Gaussian blur stdDeviation (default: 8)
14
+ * @param alphaGain - Alpha multiplier for merge threshold (default: 20)
15
+ * @param alphaOffset - Alpha offset for edge sharpness (default: -10)
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <GooeyFilter id="my-goo" blur={6} />
20
+ * <div style={{ filter: 'url(#my-goo)' }}>
21
+ * <div className="bg-card" /> // these merge
22
+ * <div className="bg-card" /> // organically
23
+ * </div>
24
+ * ```
25
+ *
26
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
27
+ */
28
+
29
+ import { memo } from 'react';
30
+ import { GOOEY_DEFAULTS, buildColorMatrixValues } from './gooey-utils';
31
+ import type { IGooeyFilterProps } from './Gooey.types';
32
+
33
+ const HIDDEN_SVG_STYLE = {
34
+ position: 'absolute' as const,
35
+ width: 0,
36
+ height: 0,
37
+ overflow: 'hidden' as const,
38
+ pointerEvents: 'none' as const,
39
+ };
40
+
41
+ /**
42
+ * GooeyFilter — renders an SVG filter definition for gooey morphing.
43
+ */
44
+ const GooeyFilter = memo(function GooeyFilter({
45
+ id,
46
+ blur = 8,
47
+ alphaGain = GOOEY_DEFAULTS.ALPHA_GAIN,
48
+ alphaOffset = GOOEY_DEFAULTS.ALPHA_OFFSET,
49
+ }: IGooeyFilterProps) {
50
+ return (
51
+ <svg aria-hidden="true" style={HIDDEN_SVG_STYLE}>
52
+ <defs>
53
+ <filter
54
+ id={id}
55
+ x="-20%"
56
+ y="-20%"
57
+ width="140%"
58
+ height="140%"
59
+ colorInterpolationFilters="sRGB"
60
+ >
61
+ <feGaussianBlur in="SourceGraphic" stdDeviation={blur} result="blur" />
62
+ <feColorMatrix
63
+ in="blur"
64
+ mode="matrix"
65
+ values={buildColorMatrixValues(alphaGain, alphaOffset)}
66
+ result="goo"
67
+ />
68
+ <feComposite in="SourceGraphic" in2="goo" operator="atop" />
69
+ </filter>
70
+ </defs>
71
+ </svg>
72
+ );
73
+ });
74
+
75
+ GooeyFilter.displayName = 'GooeyFilter';
76
+
77
+ export { GooeyFilter };
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * MorphPath — SVG `<path>` component with parametric pill-to-blob morphing.
5
+ *
6
+ * Generates a `<path d="...">` that transitions from a pill shape to an
7
+ * expanded blob based on the `progress` value (0→1). Uses quadratic Bezier
8
+ * curves at the junction for organic concave connections.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <svg width={300} height={80} style={{ position: 'absolute' }}>
13
+ * <MorphPath
14
+ * pillWidth={260}
15
+ * bodyWidth={180}
16
+ * totalHeight={80}
17
+ * progress={expanded ? 1 : 0}
18
+ * direction="up"
19
+ * fill="var(--card)"
20
+ * />
21
+ * </svg>
22
+ * ```
23
+ *
24
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
25
+ */
26
+
27
+ import { memo } from 'react';
28
+ import { useMorphPath } from './useMorphPath';
29
+ import type { IMorphPathProps } from './Gooey.types';
30
+ import { GOOEY_DEFAULTS } from './gooey-utils';
31
+
32
+ /**
33
+ * MorphPath — parametric SVG path for pill→blob morphing.
34
+ */
35
+ const MorphPath = memo(function MorphPath({
36
+ pillWidth,
37
+ bodyWidth,
38
+ totalHeight,
39
+ progress,
40
+ pillHeight = GOOEY_DEFAULTS.PILL_HEIGHT,
41
+ direction = 'down',
42
+ ...pathProps
43
+ }: IMorphPathProps) {
44
+ const d = useMorphPath({
45
+ pillWidth,
46
+ bodyWidth,
47
+ totalHeight,
48
+ progress,
49
+ pillHeight,
50
+ direction,
51
+ });
52
+
53
+ return <path d={d} {...pathProps} />;
54
+ });
55
+
56
+ MorphPath.displayName = 'MorphPath';
57
+
58
+ export { MorphPath };
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Gooey morphing utilities — pure functions for SVG filter and path generation.
3
+ *
4
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
5
+ */
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Constants
9
+ // ---------------------------------------------------------------------------
10
+
11
+ /** Default gooey filter parameters. */
12
+ export const GOOEY_DEFAULTS = {
13
+ /** Blur = height * BLUR_RATIO */
14
+ BLUR_RATIO: 0.15,
15
+ /** feColorMatrix alpha channel multiplier */
16
+ ALPHA_GAIN: 20,
17
+ /** feColorMatrix alpha channel offset */
18
+ ALPHA_OFFSET: -10,
19
+ /** Default pill height (px) */
20
+ PILL_HEIGHT: 34,
21
+ /** Quadratic bezier curve factor at full expansion */
22
+ CURVE_FACTOR: 14,
23
+ /** Max body corner radius (px) */
24
+ MAX_CORNER_RADIUS: 16,
25
+ /** Corner radius to body-height ratio */
26
+ CORNER_RATIO: 0.45,
27
+ /** Minimum body height delta to show rounded corners */
28
+ MIN_BODY_DELTA: 8,
29
+ } as const;
30
+
31
+ // ---------------------------------------------------------------------------
32
+ // Blur computation
33
+ // ---------------------------------------------------------------------------
34
+
35
+ /**
36
+ * Compute the optimal Gaussian blur for a gooey filter based on element height.
37
+ *
38
+ * @param height - Element height in pixels
39
+ * @returns Blur stdDeviation value
40
+ */
41
+ export function computeBlur(height: number): number {
42
+ return Math.round(height * GOOEY_DEFAULTS.BLUR_RATIO);
43
+ }
44
+
45
+ /**
46
+ * Build the feColorMatrix `values` string.
47
+ *
48
+ * @param gain - Alpha multiplier (default: 20)
49
+ * @param offset - Alpha offset (default: -10)
50
+ * @returns Matrix values string for feColorMatrix
51
+ */
52
+ export function buildColorMatrixValues(
53
+ gain: number = GOOEY_DEFAULTS.ALPHA_GAIN,
54
+ offset: number = GOOEY_DEFAULTS.ALPHA_OFFSET,
55
+ ): string {
56
+ return `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${gain} ${offset}`;
57
+ }
58
+
59
+ /**
60
+ * Build the CSS filter string with gooey + optional drop-shadow outline.
61
+ *
62
+ * @param filterId - SVG filter ID to reference
63
+ * @param outlineBlur - Drop-shadow blur (px)
64
+ * @param outlineColor - Drop-shadow color
65
+ * @param outlineLayers - Number of stacked drop-shadows for thickness
66
+ * @returns CSS filter property value
67
+ */
68
+ export function buildFilterString(
69
+ filterId: string,
70
+ outlineBlur: number = 0.5,
71
+ outlineColor: string = 'var(--border)',
72
+ outlineLayers: number = 2,
73
+ ): string {
74
+ const goo = `url(#${filterId})`;
75
+ const shadow = `drop-shadow(0 0 ${outlineBlur}px ${outlineColor})`;
76
+ const shadows = Array(outlineLayers).fill(shadow).join(' ');
77
+ return `${goo} ${shadows}`;
78
+ }
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // Path memoization
82
+ // ---------------------------------------------------------------------------
83
+
84
+ type PathFn = (pw: number, bw: number, th: number, t: number, ph: number) => string;
85
+
86
+ /**
87
+ * Memoize a path generation function — caches last result to avoid
88
+ * recomputing identical paths on consecutive animation frames.
89
+ *
90
+ * @param fn - Path generation function
91
+ * @returns Memoized function
92
+ */
93
+ export function memoizePath(fn: PathFn): PathFn {
94
+ let lastArgs: [number, number, number, number, number] | null = null;
95
+ let lastResult = '';
96
+ return (pw, bw, th, t, ph) => {
97
+ if (lastArgs && lastArgs[0] === pw && lastArgs[1] === bw && lastArgs[2] === th && lastArgs[3] === t && lastArgs[4] === ph) {
98
+ return lastResult;
99
+ }
100
+ lastResult = fn(pw, bw, th, t, ph);
101
+ lastArgs = [pw, bw, th, t, ph];
102
+ return lastResult;
103
+ };
104
+ }
105
+
106
+ // ---------------------------------------------------------------------------
107
+ // Parametric SVG path generation
108
+ // ---------------------------------------------------------------------------
109
+
110
+ /**
111
+ * Generate an SVG path for a pill that morphs downward into a body blob.
112
+ * Adapted from goey-toast's morphPathRaw.
113
+ *
114
+ * @param pw - Pill width
115
+ * @param bw - Body width (expanded)
116
+ * @param th - Total height (pill + body)
117
+ * @param t - Transition progress 0 (pill only) → 1 (full blob)
118
+ * @param ph - Pill height (default: PILL_HEIGHT)
119
+ * @returns SVG path d-string
120
+ */
121
+ export function morphPathDown(
122
+ pw: number,
123
+ bw: number,
124
+ th: number,
125
+ t: number,
126
+ ph: number = GOOEY_DEFAULTS.PILL_HEIGHT,
127
+ ): string {
128
+ const pr = ph / 2;
129
+ const pillW = Math.min(pw, bw);
130
+ const bodyH = ph + (th - ph) * t;
131
+
132
+ // Pure pill when t ≤ 0 or body too small
133
+ if (t <= 0 || bodyH - ph < GOOEY_DEFAULTS.MIN_BODY_DELTA) {
134
+ return [
135
+ `M 0,${pr}`,
136
+ `A ${pr},${pr} 0 0 1 ${pr},0`,
137
+ `H ${pillW - pr}`,
138
+ `A ${pr},${pr} 0 0 1 ${pillW},${pr}`,
139
+ `A ${pr},${pr} 0 0 1 ${pillW - pr},${ph}`,
140
+ `H ${pr}`,
141
+ `A ${pr},${pr} 0 0 1 0,${pr}`,
142
+ `Z`,
143
+ ].join(' ');
144
+ }
145
+
146
+ const curve = GOOEY_DEFAULTS.CURVE_FACTOR * t;
147
+ const cr = Math.min(GOOEY_DEFAULTS.MAX_CORNER_RADIUS, (bodyH - ph) * GOOEY_DEFAULTS.CORNER_RATIO);
148
+ const bodyW = pillW + (bw - pillW) * t;
149
+ const bodyTop = ph - curve;
150
+ const qEndX = Math.min(pillW + curve, bodyW - cr);
151
+
152
+ return [
153
+ `M 0,${pr}`,
154
+ `A ${pr},${pr} 0 0 1 ${pr},0`,
155
+ `H ${pillW - pr}`,
156
+ `A ${pr},${pr} 0 0 1 ${pillW},${pr}`,
157
+ `L ${pillW},${bodyTop}`,
158
+ `Q ${pillW},${bodyTop + curve} ${qEndX},${bodyTop + curve}`,
159
+ `H ${bodyW - cr}`,
160
+ `A ${cr},${cr} 0 0 1 ${bodyW},${bodyTop + curve + cr}`,
161
+ `L ${bodyW},${bodyH - cr}`,
162
+ `A ${cr},${cr} 0 0 1 ${bodyW - cr},${bodyH}`,
163
+ `H ${cr}`,
164
+ `A ${cr},${cr} 0 0 1 0,${bodyH - cr}`,
165
+ `Z`,
166
+ ].join(' ');
167
+ }
168
+
169
+ /**
170
+ * Generate an SVG path for a pill that morphs UPWARD into a body blob.
171
+ * Used for DynamicToggle's bubble-above-pill layout.
172
+ *
173
+ * @param pw - Pill width
174
+ * @param bw - Body (bubble) width
175
+ * @param th - Total height (bubble + pill)
176
+ * @param t - Transition progress 0 (pill only) → 1 (full blob with bubble)
177
+ * @param ph - Pill height
178
+ * @returns SVG path d-string
179
+ */
180
+ export function morphPathUp(
181
+ pw: number,
182
+ bw: number,
183
+ th: number,
184
+ t: number,
185
+ ph: number = GOOEY_DEFAULTS.PILL_HEIGHT,
186
+ ): string {
187
+ const pr = ph / 2;
188
+ const pillW = Math.min(pw, bw);
189
+ const bubbleH = (th - ph) * t;
190
+
191
+ // Pure pill when t ≤ 0 or bubble too small
192
+ if (t <= 0 || bubbleH < GOOEY_DEFAULTS.MIN_BODY_DELTA) {
193
+ const y0 = th - ph;
194
+ return [
195
+ `M 0,${y0 + pr}`,
196
+ `A ${pr},${pr} 0 0 1 ${pr},${y0}`,
197
+ `H ${pillW - pr}`,
198
+ `A ${pr},${pr} 0 0 1 ${pillW},${y0 + pr}`,
199
+ `A ${pr},${pr} 0 0 1 ${pillW - pr},${y0 + ph}`,
200
+ `H ${pr}`,
201
+ `A ${pr},${pr} 0 0 1 0,${y0 + pr}`,
202
+ `Z`,
203
+ ].join(' ');
204
+ }
205
+
206
+ const curve = GOOEY_DEFAULTS.CURVE_FACTOR * t;
207
+ const cr = Math.min(GOOEY_DEFAULTS.MAX_CORNER_RADIUS, bubbleH * GOOEY_DEFAULTS.CORNER_RATIO);
208
+ const bubbleW = pillW + (bw - pillW) * t;
209
+ const pillTop = th - ph;
210
+ const bubbleBottom = pillTop + curve;
211
+ const bubbleTop = pillTop - bubbleH + curve;
212
+ const qEndX = Math.min(pillW + curve, bubbleW - cr);
213
+
214
+ return [
215
+ // Pill bottom-left
216
+ `M 0,${pillTop + pr}`,
217
+ `A ${pr},${pr} 0 0 1 0,${pillTop + ph - pr}`,
218
+ // Pill bottom
219
+ `A ${pr},${pr} 0 0 1 ${pr},${pillTop + ph}`,
220
+ `H ${pillW - pr}`,
221
+ `A ${pr},${pr} 0 0 1 ${pillW},${pillTop + ph - pr}`,
222
+ // Pill right up to junction
223
+ `L ${pillW},${bubbleBottom}`,
224
+ // Right organic curve: pill to bubble
225
+ `Q ${pillW},${bubbleBottom - curve} ${qEndX},${bubbleBottom - curve}`,
226
+ // Bubble right side
227
+ `H ${bubbleW - cr}`,
228
+ `A ${cr},${cr} 0 0 0 ${bubbleW},${bubbleBottom - curve - cr}`,
229
+ // Bubble right edge up
230
+ `L ${bubbleW},${bubbleTop + cr}`,
231
+ // Bubble top-right corner
232
+ `A ${cr},${cr} 0 0 0 ${bubbleW - cr},${bubbleTop}`,
233
+ // Bubble top
234
+ `H ${cr}`,
235
+ // Bubble top-left corner
236
+ `A ${cr},${cr} 0 0 0 0,${bubbleTop + cr}`,
237
+ // Left edge down to pill
238
+ `Z`,
239
+ ].join(' ');
240
+ }
241
+
242
+ /** Memoized versions for animation performance. */
243
+ export const morphPathDownMemo = memoizePath(morphPathDown);
244
+ export const morphPathUpMemo = memoizePath(morphPathUp);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Gooey — SVG-based morphing primitives for organic shape merging.
3
+ *
4
+ * Two techniques:
5
+ * - **Filter**: `GooeyCanvas` / `GooeyFilter` — SVG filter merges same-colored shapes
6
+ * - **Path**: `MorphPath` / `useMorphPath` — parametric SVG path with Bezier junctions
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * // Filter approach — automatic merge
11
+ * <GooeyCanvas height={40}>
12
+ * <div className="bg-card rounded-full h-10 w-64" />
13
+ * <div className="bg-card absolute bottom-full rounded-lg h-6 w-32" />
14
+ * </GooeyCanvas>
15
+ *
16
+ * // Path approach — precise control
17
+ * <svg><MorphPath pillWidth={260} bodyWidth={180} totalHeight={60} progress={0.5} fill="var(--card)" /></svg>
18
+ * ```
19
+ *
20
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
21
+ */
22
+
23
+ // Components
24
+ export { GooeyFilter } from './GooeyFilter';
25
+ export { GooeyCanvas } from './GooeyCanvas';
26
+ export { MorphPath } from './MorphPath';
27
+
28
+ // Hooks
29
+ export { useMorphPath } from './useMorphPath';
30
+
31
+ // Utilities
32
+ export {
33
+ GOOEY_DEFAULTS,
34
+ computeBlur,
35
+ buildColorMatrixValues,
36
+ buildFilterString,
37
+ memoizePath,
38
+ morphPathDown,
39
+ morphPathUp,
40
+ morphPathDownMemo,
41
+ morphPathUpMemo,
42
+ } from './gooey-utils';
43
+
44
+ // Types
45
+ export type {
46
+ IGooeyFilterProps,
47
+ IGooeyCanvasProps,
48
+ IMorphPathProps,
49
+ IUseMorphPathOptions,
50
+ } from './Gooey.types';
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * useMorphPath — hook that generates a parametric SVG path d-string.
5
+ *
6
+ * Returns a memoized path for a pill shape morphing into a blob.
7
+ * Use with `<path d={path} />` in an SVG element.
8
+ *
9
+ * @param opts - Dimensions and progress
10
+ * @returns SVG path d-string
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const path = useMorphPath({
15
+ * pillWidth: 260,
16
+ * bodyWidth: 180,
17
+ * totalHeight: 60,
18
+ * progress: expanded ? 1 : 0,
19
+ * direction: 'up',
20
+ * });
21
+ * return <svg><path d={path} fill="var(--card)" /></svg>;
22
+ * ```
23
+ *
24
+ * @module @mks2508/mks-ui/react/primitives/waapi/Gooey
25
+ */
26
+
27
+ import { useMemo } from 'react';
28
+ import { morphPathDown, morphPathUp, GOOEY_DEFAULTS } from './gooey-utils';
29
+ import type { IUseMorphPathOptions } from './Gooey.types';
30
+
31
+ /**
32
+ * Generate a parametric SVG morph path from dimensions and progress.
33
+ */
34
+ function useMorphPath({
35
+ pillWidth,
36
+ bodyWidth,
37
+ totalHeight,
38
+ progress,
39
+ pillHeight = GOOEY_DEFAULTS.PILL_HEIGHT,
40
+ direction = 'down',
41
+ }: IUseMorphPathOptions): string {
42
+ return useMemo(() => {
43
+ const fn = direction === 'up' ? morphPathUp : morphPathDown;
44
+ return fn(pillWidth, bodyWidth, totalHeight, progress, pillHeight);
45
+ }, [pillWidth, bodyWidth, totalHeight, progress, pillHeight, direction]);
46
+ }
47
+
48
+ export { useMorphPath };