@mks2508/mks-ui 0.5.1 → 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.
- package/dist/react-ui/index.js +8 -1
- package/dist/react-ui/primitives/index.js +5 -0
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts +103 -0
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts +10 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.js +59 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.js +78 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.js +51 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts +87 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.js +177 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.d.ts +28 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.js +5 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.js +47 -0
- package/dist/react-ui/primitives/waapi/index.d.ts +2 -0
- package/dist/react-ui/primitives/waapi/index.d.ts.map +1 -1
- package/dist/react-ui/primitives/waapi/index.js +6 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts +26 -16
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/DataCard.styles.js +36 -74
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts +50 -70
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/index.d.ts +24 -93
- package/dist/react-ui/ui/DataCard/index.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/index.js +76 -118
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle-Cm6-VceQ.css +304 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.css +303 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.js +0 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts +35 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +67 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +138 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -0
- package/dist/react-ui/ui/DynamicToggle/index.d.ts +31 -0
- package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -0
- package/dist/react-ui/ui/DynamicToggle/index.js +188 -0
- package/dist/react-ui/ui/Switch/index.js +1 -1
- package/dist/react-ui/ui/index.d.ts +1 -0
- package/dist/react-ui/ui/index.d.ts.map +1 -1
- package/dist/react-ui/ui/index.js +2 -0
- package/package.json +2 -2
- package/src/css.d.ts +1 -0
- package/src/react-ui/primitives/waapi/Gooey/Gooey.types.ts +123 -0
- package/src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx +80 -0
- package/src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx +77 -0
- package/src/react-ui/primitives/waapi/Gooey/MorphPath.tsx +58 -0
- package/src/react-ui/primitives/waapi/Gooey/gooey-utils.ts +244 -0
- package/src/react-ui/primitives/waapi/Gooey/index.ts +50 -0
- package/src/react-ui/primitives/waapi/Gooey/useMorphPath.ts +48 -0
- package/src/react-ui/primitives/waapi/index.ts +23 -0
- package/src/react-ui/ui/DataCard/DataCard.styles.ts +45 -101
- package/src/react-ui/ui/DataCard/DataCard.types.ts +52 -73
- package/src/react-ui/ui/DataCard/index.tsx +118 -184
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.css +303 -0
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +85 -0
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +174 -0
- package/src/react-ui/ui/DynamicToggle/index.tsx +294 -0
- package/src/react-ui/ui/DynamicToggle/prototype-v7.html +615 -0
- package/src/react-ui/ui/DynamicToggle/prototype.html +419 -0
- package/src/react-ui/ui/Switch/index.tsx +1 -1
- package/src/react-ui/ui/index.ts +3 -0
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-filter-dropdown.module-CNVWCefU.css → terminal-filter-dropdown.module-C6oDcFBS.css} +0 -0
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-session-tabs.module-cmyJ11jP.css → terminal-session-tabs.module-D_-sgyza.css} +0 -0
- /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-BycNI8nU.css → morphing-popover.module-B1ftlaYj.css} +0 -0
package/dist/react-ui/index.js
CHANGED
|
@@ -22,6 +22,11 @@ import { useCSSGridMorph } from "./primitives/waapi/Morph/techniques/useCSSGridM
|
|
|
22
22
|
import { useViewTransitions } from "./primitives/waapi/Morph/techniques/useViewTransitions.js";
|
|
23
23
|
import { useMorph } from "./primitives/waapi/Morph/useMorph.js";
|
|
24
24
|
import { Morph } from "./primitives/waapi/Morph/index.js";
|
|
25
|
+
import { GOOEY_DEFAULTS, buildColorMatrixValues, buildFilterString, computeBlur, morphPathDown, morphPathUp } from "./primitives/waapi/Gooey/gooey-utils.js";
|
|
26
|
+
import { GooeyFilter } from "./primitives/waapi/Gooey/GooeyFilter.js";
|
|
27
|
+
import { GooeyCanvas } from "./primitives/waapi/Gooey/GooeyCanvas.js";
|
|
28
|
+
import { useMorphPath } from "./primitives/waapi/Gooey/useMorphPath.js";
|
|
29
|
+
import { MorphPath } from "./primitives/waapi/Gooey/MorphPath.js";
|
|
25
30
|
import "./primitives/index.js";
|
|
26
31
|
import { getStrictContext } from "./lib/get-strict-context.js";
|
|
27
32
|
import { useControlledState } from "./hooks/State/UseControlledState.js";
|
|
@@ -68,6 +73,8 @@ import { dataCardStyles, dataCardVariants } from "./ui/DataCard/DataCard.styles.
|
|
|
68
73
|
import { DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, useDataCard } from "./ui/DataCard/index.js";
|
|
69
74
|
import { useListFormat } from "./hooks/Formatting/UseListFormat.js";
|
|
70
75
|
import { TextFlow } from "./ui/TextFlow/index.js";
|
|
76
|
+
import { dynamicToggleStyles, dynamicToggleVariants } from "./ui/DynamicToggle/DynamicToggle.styles.js";
|
|
77
|
+
import { DynamicToggle, DynamicToggleGroup, DynamicToggleOption, useDynamicToggle } from "./ui/DynamicToggle/index.js";
|
|
71
78
|
import "./ui/index.js";
|
|
72
79
|
import { MorphingPopover, MorphingPopoverWithTarget } from "./components/MorphingPopover/index.js";
|
|
73
80
|
import "./components/index.js";
|
|
@@ -108,4 +115,4 @@ import { HugeIcons } from "./icons/index.js";
|
|
|
108
115
|
import { IconWrapper } from "./lib/icon-wrapper.js";
|
|
109
116
|
import "./lib/index.js";
|
|
110
117
|
|
|
111
|
-
export { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionStyles, AccordionTrigger, ActivityIcon, AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogStyles, AlertDialogTitle, AlertDialogTrigger, ArrowDownToLineIcon, ArrowUpIcon, AutoHeight, Badge, BellElectricIcon, BellIcon, BotIcon, BoxIcon, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Check, Checkbox, CheckboxIndicator, CircleCheckIcon, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, CornerBracket, CountingNumber, DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, DeleteIcon, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EASINGS, EFFECTS, Edit2, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Globe, Highlight, HighlightItem, HomeIcon, HugeIcons, IconWrapper, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Layers, LayoutPanelTopIcon, ListIcon, Menu, MenuArrow, MenuCheckboxItem, MenuCheckboxItemIndicator, MenuGroup, MenuGroupLabel, MenuHighlight, MenuHighlightItem, MenuItem, MenuPopup, MenuPortal, MenuPositioner, MenuRadioGroup, MenuRadioItem, MenuRadioItemIndicator, MenuSeparator, MenuShortcut, MenuSubmenu, MenuSubmenuTrigger, MenuTrigger, Morph, MorphingPopover, MorphingPopoverWithTarget, PRESETS, Package, Palette, PlusIcon, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RESPONSIVE_CONFIGS, RefreshCw, ReorderRoot as Reorder, Rocket, Save, SearchIcon, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, SlidingNumber, SlidingText, Slot, Switch, SwitchIcon, SwitchThumb, TIMING, TRANSFORMS, Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab, TerminalIcon, TextFlow, Textarea, Tooltip, TooltipArrow, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, Trash2, TrendingDownIcon, TrendingUpIcon, Type, Upload, XIcon, accordionVariants, badgeVariants, bracketVariants, buttonStateStyles, buttonVariants, calculateSeparatorCoordination, cardVariants, checkboxStyles, cn, dataCardStyles, dataCardVariants, dialogStyles, fieldVariants, getResponsiveDuration, getResponsiveStagger, getStrictContext, inputGroupAddonVariants, inputGroupButtonVariants, popoverStyles, progressStyles, shouldShowSeparator, switchStyles, tabsIndicatorVariants, tabsListVariants, tabsTabVariants, tooltipStyles, useAccordionItem, useAlertDialog, useAnimationOrchestrator, useAutoHeight, useCSSGridMorph, useCheckbox, useComboboxAnchor, useControlledState, useDataCard, useDataState, useDialog, useElementRegistry, useFLIPAnimation, useFLIPClipPath, useHighlight, useIsInView, useListFormat, useMenu, useMenuActiveValue, useMorph, useMorphContext, usePopover, usePositionCapture, useProgress, useReorder, useReorderPresence, useSwitch, useTooltip, useViewTransitions };
|
|
118
|
+
export { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionStyles, AccordionTrigger, ActivityIcon, AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogStyles, AlertDialogTitle, AlertDialogTrigger, ArrowDownToLineIcon, ArrowUpIcon, AutoHeight, Badge, BellElectricIcon, BellIcon, BotIcon, BoxIcon, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Check, Checkbox, CheckboxIndicator, CircleCheckIcon, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, CornerBracket, CountingNumber, DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, DeleteIcon, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicToggle, DynamicToggleGroup, DynamicToggleOption, EASINGS, EFFECTS, Edit2, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, GOOEY_DEFAULTS, Globe, GooeyCanvas, GooeyFilter, Highlight, HighlightItem, HomeIcon, HugeIcons, IconWrapper, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Layers, LayoutPanelTopIcon, ListIcon, Menu, MenuArrow, MenuCheckboxItem, MenuCheckboxItemIndicator, MenuGroup, MenuGroupLabel, MenuHighlight, MenuHighlightItem, MenuItem, MenuPopup, MenuPortal, MenuPositioner, MenuRadioGroup, MenuRadioItem, MenuRadioItemIndicator, MenuSeparator, MenuShortcut, MenuSubmenu, MenuSubmenuTrigger, MenuTrigger, Morph, MorphPath, MorphingPopover, MorphingPopoverWithTarget, PRESETS, Package, Palette, PlusIcon, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RESPONSIVE_CONFIGS, RefreshCw, ReorderRoot as Reorder, Rocket, Save, SearchIcon, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, SlidingNumber, SlidingText, Slot, Switch, SwitchIcon, SwitchThumb, TIMING, TRANSFORMS, Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab, TerminalIcon, TextFlow, Textarea, Tooltip, TooltipArrow, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, Trash2, TrendingDownIcon, TrendingUpIcon, Type, Upload, XIcon, accordionVariants, badgeVariants, bracketVariants, buildColorMatrixValues, buildFilterString, buttonStateStyles, buttonVariants, calculateSeparatorCoordination, cardVariants, checkboxStyles, cn, computeBlur, dataCardStyles, dataCardVariants, dialogStyles, dynamicToggleStyles, dynamicToggleVariants, fieldVariants, getResponsiveDuration, getResponsiveStagger, getStrictContext, inputGroupAddonVariants, inputGroupButtonVariants, morphPathDown, morphPathUp, popoverStyles, progressStyles, shouldShowSeparator, switchStyles, tabsIndicatorVariants, tabsListVariants, tabsTabVariants, tooltipStyles, useAccordionItem, useAlertDialog, useAnimationOrchestrator, useAutoHeight, useCSSGridMorph, useCheckbox, useComboboxAnchor, useControlledState, useDataCard, useDataState, useDialog, useDynamicToggle, useElementRegistry, useFLIPAnimation, useFLIPClipPath, useHighlight, useIsInView, useListFormat, useMenu, useMenuActiveValue, useMorph, useMorphContext, useMorphPath, usePopover, usePositionCapture, useProgress, useReorder, useReorderPresence, useSwitch, useTooltip, useViewTransitions };
|
|
@@ -19,4 +19,9 @@ import { useCSSGridMorph } from "./waapi/Morph/techniques/useCSSGridMorph.js";
|
|
|
19
19
|
import { useViewTransitions } from "./waapi/Morph/techniques/useViewTransitions.js";
|
|
20
20
|
import { useMorph } from "./waapi/Morph/useMorph.js";
|
|
21
21
|
import { Morph } from "./waapi/Morph/index.js";
|
|
22
|
+
import { GOOEY_DEFAULTS, buildColorMatrixValues, buildFilterString, computeBlur, morphPathDown, morphPathUp } from "./waapi/Gooey/gooey-utils.js";
|
|
23
|
+
import { GooeyFilter } from "./waapi/Gooey/GooeyFilter.js";
|
|
24
|
+
import { GooeyCanvas } from "./waapi/Gooey/GooeyCanvas.js";
|
|
25
|
+
import { useMorphPath } from "./waapi/Gooey/useMorphPath.js";
|
|
26
|
+
import { MorphPath } from "./waapi/Gooey/MorphPath.js";
|
|
22
27
|
import "./waapi/index.js";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gooey morphing primitive types.
|
|
3
|
+
*
|
|
4
|
+
* @module @mks2508/mks-ui/react/primitives/waapi/Gooey
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* Props for the GooeyFilter SVG filter definition.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <GooeyFilter id="my-goo" blur={8} />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface IGooeyFilterProps {
|
|
16
|
+
/** Unique filter ID — referenced via `filter: url(#id)` */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Gaussian blur stdDeviation (default: 8) */
|
|
19
|
+
blur?: number;
|
|
20
|
+
/** Alpha channel multiplier in feColorMatrix (default: 20) */
|
|
21
|
+
alphaGain?: number;
|
|
22
|
+
/** Alpha channel offset in feColorMatrix (default: -10) */
|
|
23
|
+
alphaOffset?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Props for the GooeyCanvas container.
|
|
27
|
+
*
|
|
28
|
+
* Wraps children with an SVG gooey filter. All same-colored children
|
|
29
|
+
* inside automatically merge visually into an organic blob.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <GooeyCanvas height={40}>
|
|
34
|
+
* <div className="bg-card rounded-full h-10 w-64" />
|
|
35
|
+
* <div className="bg-card absolute bottom-full w-32 h-6" />
|
|
36
|
+
* </GooeyCanvas>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export interface IGooeyCanvasProps {
|
|
40
|
+
/** Blur radius override. If omitted, auto-calculated from `height`. */
|
|
41
|
+
blur?: number;
|
|
42
|
+
/** Element height — used to auto-calculate blur (default: 32) */
|
|
43
|
+
height?: number;
|
|
44
|
+
/** Drop-shadow outline blur in px (default: 0.5) */
|
|
45
|
+
outlineBlur?: number;
|
|
46
|
+
/** Drop-shadow outline color (default: 'var(--border)') */
|
|
47
|
+
outlineColor?: string;
|
|
48
|
+
/** Number of stacked drop-shadows for outline thickness (default: 2) */
|
|
49
|
+
outlineLayers?: number;
|
|
50
|
+
/** Alpha gain override */
|
|
51
|
+
alphaGain?: number;
|
|
52
|
+
/** Alpha offset override */
|
|
53
|
+
alphaOffset?: number;
|
|
54
|
+
/** Extra className on the filter container */
|
|
55
|
+
className?: string;
|
|
56
|
+
/** Content to merge with the gooey filter */
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Props for the MorphPath SVG path component.
|
|
61
|
+
*
|
|
62
|
+
* Renders a parametric `<path>` that morphs from a pill shape to a
|
|
63
|
+
* pill+body blob based on the `progress` value.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <svg>
|
|
68
|
+
* <MorphPath pillWidth={260} bodyWidth={180} totalHeight={60} progress={0.5} fill="var(--card)" />
|
|
69
|
+
* </svg>
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export interface IMorphPathProps extends React.SVGProps<SVGPathElement> {
|
|
73
|
+
/** Pill width in px */
|
|
74
|
+
pillWidth: number;
|
|
75
|
+
/** Body (expanded area) width in px */
|
|
76
|
+
bodyWidth: number;
|
|
77
|
+
/** Total height (pill + body) in px */
|
|
78
|
+
totalHeight: number;
|
|
79
|
+
/** Morph progress: 0 = pill only, 1 = fully expanded */
|
|
80
|
+
progress: number;
|
|
81
|
+
/** Pill height (default: 34) */
|
|
82
|
+
pillHeight?: number;
|
|
83
|
+
/** Body expansion direction relative to pill */
|
|
84
|
+
direction?: 'down' | 'up';
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for the useMorphPath hook.
|
|
88
|
+
*/
|
|
89
|
+
export interface IUseMorphPathOptions {
|
|
90
|
+
/** Pill width in px */
|
|
91
|
+
pillWidth: number;
|
|
92
|
+
/** Body width in px */
|
|
93
|
+
bodyWidth: number;
|
|
94
|
+
/** Total height in px */
|
|
95
|
+
totalHeight: number;
|
|
96
|
+
/** Morph progress 0→1 */
|
|
97
|
+
progress: number;
|
|
98
|
+
/** Pill height (default: 34) */
|
|
99
|
+
pillHeight?: number;
|
|
100
|
+
/** Body direction */
|
|
101
|
+
direction?: 'down' | 'up';
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=Gooey.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Gooey.types.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/Gooey/Gooey.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAMD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAgB,SAAQ,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;IACrE,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAMD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IGooeyCanvasProps } from './Gooey.types';
|
|
2
|
+
/**
|
|
3
|
+
* GooeyCanvas — container with gooey SVG filter applied.
|
|
4
|
+
*/
|
|
5
|
+
declare function GooeyCanvas({ blur, height, outlineBlur, outlineColor, outlineLayers, alphaGain, alphaOffset, className, children, }: IGooeyCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare namespace GooeyCanvas {
|
|
7
|
+
var displayName: string;
|
|
8
|
+
}
|
|
9
|
+
export { GooeyCanvas };
|
|
10
|
+
//# sourceMappingURL=GooeyCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GooeyCanvas.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;GAEG;AACH,iBAAS,WAAW,CAAC,EACnB,IAAI,EACJ,MAAW,EACX,WAAiB,EACjB,YAA8B,EAC9B,aAAiB,EACjB,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,GACT,EAAE,iBAAiB,2CA+BnB;kBAzCQ,WAAW;;;AA6CpB,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../../lib/utils.js";
|
|
4
|
+
import { buildFilterString, computeBlur } from "./gooey-utils.js";
|
|
5
|
+
import { GooeyFilter } from "./GooeyFilter.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx
|
|
10
|
+
/**
|
|
11
|
+
* GooeyCanvas — container that applies gooey SVG filter to children.
|
|
12
|
+
*
|
|
13
|
+
* Renders a GooeyFilter + a wrapper div with `filter: url(#id)`.
|
|
14
|
+
* All same-colored children inside merge organically. Optional drop-shadow
|
|
15
|
+
* outline traces the merged shape's edge.
|
|
16
|
+
*
|
|
17
|
+
* Blur auto-scales with height: `blur = Math.round(height * 0.15)`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <div style={{ position: 'relative' }}>
|
|
22
|
+
* <GooeyCanvas height={40}>
|
|
23
|
+
* <div className="absolute inset-0 bg-card rounded-full" />
|
|
24
|
+
* <div className="absolute bottom-full bg-card w-32 h-6 rounded-lg" />
|
|
25
|
+
* </GooeyCanvas>
|
|
26
|
+
* <div className="relative z-10">Content on top (not filtered)</div>
|
|
27
|
+
* </div>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @module @mks2508/mks-ui/react/primitives/waapi/Gooey
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* GooeyCanvas — container with gooey SVG filter applied.
|
|
34
|
+
*/
|
|
35
|
+
function GooeyCanvas({ blur, height = 32, outlineBlur = .5, outlineColor = "var(--border)", outlineLayers = 2, alphaGain, alphaOffset, className, children }) {
|
|
36
|
+
const filterId = React$1.useId().replace(/:/g, "") + "-goo";
|
|
37
|
+
const computedBlur = blur ?? computeBlur(height);
|
|
38
|
+
const filterStyle = React$1.useMemo(() => ({ filter: buildFilterString(filterId, outlineBlur, outlineColor, outlineLayers) }), [
|
|
39
|
+
filterId,
|
|
40
|
+
outlineBlur,
|
|
41
|
+
outlineColor,
|
|
42
|
+
outlineLayers
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(GooeyFilter, {
|
|
45
|
+
id: filterId,
|
|
46
|
+
blur: computedBlur,
|
|
47
|
+
alphaGain,
|
|
48
|
+
alphaOffset
|
|
49
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
50
|
+
"data-slot": "gooey-canvas",
|
|
51
|
+
style: filterStyle,
|
|
52
|
+
className: cn("absolute inset-0 rounded-[inherit] pointer-events-none z-0 overflow-visible", className),
|
|
53
|
+
children
|
|
54
|
+
})] });
|
|
55
|
+
}
|
|
56
|
+
GooeyCanvas.displayName = "GooeyCanvas";
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { GooeyCanvas };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IGooeyFilterProps } from './Gooey.types';
|
|
2
|
+
/**
|
|
3
|
+
* GooeyFilter — renders an SVG filter definition for gooey morphing.
|
|
4
|
+
*/
|
|
5
|
+
declare const GooeyFilter: import("react").MemoExoticComponent<({ id, blur, alphaGain, alphaOffset, }: IGooeyFilterProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export { GooeyFilter };
|
|
7
|
+
//# sourceMappingURL=GooeyFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GooeyFilter.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAUvD;;GAEG;AACH,QAAA,MAAM,WAAW,8EAKd,iBAAiB,6CAwBlB,CAAC;AAIH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { GOOEY_DEFAULTS, buildColorMatrixValues } from "./gooey-utils.js";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx
|
|
8
|
+
/**
|
|
9
|
+
* GooeyFilter — SVG filter definition for gooey morphing effects.
|
|
10
|
+
*
|
|
11
|
+
* Renders a hidden `<svg>` with a `<filter>` that uses `feGaussianBlur` +
|
|
12
|
+
* `feColorMatrix` + `feComposite` to merge same-colored shapes organically.
|
|
13
|
+
*
|
|
14
|
+
* Apply via `filter: url(#id)` on a container. All same-colored children merge.
|
|
15
|
+
* `feComposite operator="atop"` preserves sharp text/content on top.
|
|
16
|
+
*
|
|
17
|
+
* @param id - Unique filter ID
|
|
18
|
+
* @param blur - Gaussian blur stdDeviation (default: 8)
|
|
19
|
+
* @param alphaGain - Alpha multiplier for merge threshold (default: 20)
|
|
20
|
+
* @param alphaOffset - Alpha offset for edge sharpness (default: -10)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <GooeyFilter id="my-goo" blur={6} />
|
|
25
|
+
* <div style={{ filter: 'url(#my-goo)' }}>
|
|
26
|
+
* <div className="bg-card" /> // these merge
|
|
27
|
+
* <div className="bg-card" /> // organically
|
|
28
|
+
* </div>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @module @mks2508/mks-ui/react/primitives/waapi/Gooey
|
|
32
|
+
*/
|
|
33
|
+
const HIDDEN_SVG_STYLE = {
|
|
34
|
+
position: "absolute",
|
|
35
|
+
width: 0,
|
|
36
|
+
height: 0,
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
pointerEvents: "none"
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* GooeyFilter — renders an SVG filter definition for gooey morphing.
|
|
42
|
+
*/
|
|
43
|
+
const GooeyFilter = memo(function GooeyFilter({ id, blur = 8, alphaGain = GOOEY_DEFAULTS.ALPHA_GAIN, alphaOffset = GOOEY_DEFAULTS.ALPHA_OFFSET }) {
|
|
44
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
style: HIDDEN_SVG_STYLE,
|
|
47
|
+
children: /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", {
|
|
48
|
+
id,
|
|
49
|
+
x: "-20%",
|
|
50
|
+
y: "-20%",
|
|
51
|
+
width: "140%",
|
|
52
|
+
height: "140%",
|
|
53
|
+
colorInterpolationFilters: "sRGB",
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx("feGaussianBlur", {
|
|
56
|
+
in: "SourceGraphic",
|
|
57
|
+
stdDeviation: blur,
|
|
58
|
+
result: "blur"
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ jsx("feColorMatrix", {
|
|
61
|
+
in: "blur",
|
|
62
|
+
mode: "matrix",
|
|
63
|
+
values: buildColorMatrixValues(alphaGain, alphaOffset),
|
|
64
|
+
result: "goo"
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx("feComposite", {
|
|
67
|
+
in: "SourceGraphic",
|
|
68
|
+
in2: "goo",
|
|
69
|
+
operator: "atop"
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
}) })
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
GooeyFilter.displayName = "GooeyFilter";
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { GooeyFilter };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IMorphPathProps } from './Gooey.types';
|
|
2
|
+
/**
|
|
3
|
+
* MorphPath — parametric SVG path for pill→blob morphing.
|
|
4
|
+
*/
|
|
5
|
+
declare const MorphPath: import("react").MemoExoticComponent<({ pillWidth, bodyWidth, totalHeight, progress, pillHeight, direction, ...pathProps }: IMorphPathProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export { MorphPath };
|
|
7
|
+
//# sourceMappingURL=MorphPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MorphPath.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/Gooey/MorphPath.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;;GAEG;AACH,QAAA,MAAM,SAAS,6HAQZ,eAAe,6CAWhB,CAAC;AAIH,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { GOOEY_DEFAULTS } from "./gooey-utils.js";
|
|
4
|
+
import { useMorphPath } from "./useMorphPath.js";
|
|
5
|
+
import { memo } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/react-ui/primitives/waapi/Gooey/MorphPath.tsx
|
|
9
|
+
/**
|
|
10
|
+
* MorphPath — SVG `<path>` component with parametric pill-to-blob morphing.
|
|
11
|
+
*
|
|
12
|
+
* Generates a `<path d="...">` that transitions from a pill shape to an
|
|
13
|
+
* expanded blob based on the `progress` value (0→1). Uses quadratic Bezier
|
|
14
|
+
* curves at the junction for organic concave connections.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <svg width={300} height={80} style={{ position: 'absolute' }}>
|
|
19
|
+
* <MorphPath
|
|
20
|
+
* pillWidth={260}
|
|
21
|
+
* bodyWidth={180}
|
|
22
|
+
* totalHeight={80}
|
|
23
|
+
* progress={expanded ? 1 : 0}
|
|
24
|
+
* direction="up"
|
|
25
|
+
* fill="var(--card)"
|
|
26
|
+
* />
|
|
27
|
+
* </svg>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @module @mks2508/mks-ui/react/primitives/waapi/Gooey
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* MorphPath — parametric SVG path for pill→blob morphing.
|
|
34
|
+
*/
|
|
35
|
+
const MorphPath = memo(function MorphPath({ pillWidth, bodyWidth, totalHeight, progress, pillHeight = GOOEY_DEFAULTS.PILL_HEIGHT, direction = "down", ...pathProps }) {
|
|
36
|
+
return /* @__PURE__ */ jsx("path", {
|
|
37
|
+
d: useMorphPath({
|
|
38
|
+
pillWidth,
|
|
39
|
+
bodyWidth,
|
|
40
|
+
totalHeight,
|
|
41
|
+
progress,
|
|
42
|
+
pillHeight,
|
|
43
|
+
direction
|
|
44
|
+
}),
|
|
45
|
+
...pathProps
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
MorphPath.displayName = "MorphPath";
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { MorphPath };
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
/** Default gooey filter parameters. */
|
|
7
|
+
export declare const GOOEY_DEFAULTS: {
|
|
8
|
+
/** Blur = height * BLUR_RATIO */
|
|
9
|
+
readonly BLUR_RATIO: 0.15;
|
|
10
|
+
/** feColorMatrix alpha channel multiplier */
|
|
11
|
+
readonly ALPHA_GAIN: 20;
|
|
12
|
+
/** feColorMatrix alpha channel offset */
|
|
13
|
+
readonly ALPHA_OFFSET: -10;
|
|
14
|
+
/** Default pill height (px) */
|
|
15
|
+
readonly PILL_HEIGHT: 34;
|
|
16
|
+
/** Quadratic bezier curve factor at full expansion */
|
|
17
|
+
readonly CURVE_FACTOR: 14;
|
|
18
|
+
/** Max body corner radius (px) */
|
|
19
|
+
readonly MAX_CORNER_RADIUS: 16;
|
|
20
|
+
/** Corner radius to body-height ratio */
|
|
21
|
+
readonly CORNER_RATIO: 0.45;
|
|
22
|
+
/** Minimum body height delta to show rounded corners */
|
|
23
|
+
readonly MIN_BODY_DELTA: 8;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Compute the optimal Gaussian blur for a gooey filter based on element height.
|
|
27
|
+
*
|
|
28
|
+
* @param height - Element height in pixels
|
|
29
|
+
* @returns Blur stdDeviation value
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeBlur(height: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Build the feColorMatrix `values` string.
|
|
34
|
+
*
|
|
35
|
+
* @param gain - Alpha multiplier (default: 20)
|
|
36
|
+
* @param offset - Alpha offset (default: -10)
|
|
37
|
+
* @returns Matrix values string for feColorMatrix
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildColorMatrixValues(gain?: number, offset?: number): string;
|
|
40
|
+
/**
|
|
41
|
+
* Build the CSS filter string with gooey + optional drop-shadow outline.
|
|
42
|
+
*
|
|
43
|
+
* @param filterId - SVG filter ID to reference
|
|
44
|
+
* @param outlineBlur - Drop-shadow blur (px)
|
|
45
|
+
* @param outlineColor - Drop-shadow color
|
|
46
|
+
* @param outlineLayers - Number of stacked drop-shadows for thickness
|
|
47
|
+
* @returns CSS filter property value
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildFilterString(filterId: string, outlineBlur?: number, outlineColor?: string, outlineLayers?: number): string;
|
|
50
|
+
type PathFn = (pw: number, bw: number, th: number, t: number, ph: number) => string;
|
|
51
|
+
/**
|
|
52
|
+
* Memoize a path generation function — caches last result to avoid
|
|
53
|
+
* recomputing identical paths on consecutive animation frames.
|
|
54
|
+
*
|
|
55
|
+
* @param fn - Path generation function
|
|
56
|
+
* @returns Memoized function
|
|
57
|
+
*/
|
|
58
|
+
export declare function memoizePath(fn: PathFn): PathFn;
|
|
59
|
+
/**
|
|
60
|
+
* Generate an SVG path for a pill that morphs downward into a body blob.
|
|
61
|
+
* Adapted from goey-toast's morphPathRaw.
|
|
62
|
+
*
|
|
63
|
+
* @param pw - Pill width
|
|
64
|
+
* @param bw - Body width (expanded)
|
|
65
|
+
* @param th - Total height (pill + body)
|
|
66
|
+
* @param t - Transition progress 0 (pill only) → 1 (full blob)
|
|
67
|
+
* @param ph - Pill height (default: PILL_HEIGHT)
|
|
68
|
+
* @returns SVG path d-string
|
|
69
|
+
*/
|
|
70
|
+
export declare function morphPathDown(pw: number, bw: number, th: number, t: number, ph?: number): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generate an SVG path for a pill that morphs UPWARD into a body blob.
|
|
73
|
+
* Used for DynamicToggle's bubble-above-pill layout.
|
|
74
|
+
*
|
|
75
|
+
* @param pw - Pill width
|
|
76
|
+
* @param bw - Body (bubble) width
|
|
77
|
+
* @param th - Total height (bubble + pill)
|
|
78
|
+
* @param t - Transition progress 0 (pill only) → 1 (full blob with bubble)
|
|
79
|
+
* @param ph - Pill height
|
|
80
|
+
* @returns SVG path d-string
|
|
81
|
+
*/
|
|
82
|
+
export declare function morphPathUp(pw: number, bw: number, th: number, t: number, ph?: number): string;
|
|
83
|
+
/** Memoized versions for animation performance. */
|
|
84
|
+
export declare const morphPathDownMemo: PathFn;
|
|
85
|
+
export declare const morphPathUpMemo: PathFn;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=gooey-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gooey-utils.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/Gooey/gooey-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uCAAuC;AACvC,eAAO,MAAM,cAAc;IACzB,iCAAiC;;IAEjC,6CAA6C;;IAE7C,yCAAyC;;IAEzC,+BAA+B;;IAE/B,sDAAsD;;IAEtD,kCAAkC;;IAElC,yCAAyC;;IAEzC,wDAAwD;;CAEhD,CAAC;AAMX;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,GAAE,MAAkC,EACxC,MAAM,GAAE,MAAoC,GAC3C,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,MAAY,EACzB,YAAY,GAAE,MAAwB,EACtC,aAAa,GAAE,MAAU,GACxB,MAAM,CAKR;AAMD,KAAK,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;AAEpF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAW9C;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,EAAE,GAAE,MAAmC,GACtC,MAAM,CAwCR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,EAAE,GAAE,MAAmC,GACtC,MAAM,CAsDR;AAED,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,QAA6B,CAAC;AAC5D,eAAO,MAAM,eAAe,QAA2B,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
//#region src/react-ui/primitives/waapi/Gooey/gooey-utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gooey morphing utilities — pure functions for SVG filter and path generation.
|
|
4
|
+
*
|
|
5
|
+
* @module @mks2508/mks-ui/react/primitives/waapi/Gooey
|
|
6
|
+
*/
|
|
7
|
+
/** Default gooey filter parameters. */
|
|
8
|
+
const GOOEY_DEFAULTS = {
|
|
9
|
+
BLUR_RATIO: .15,
|
|
10
|
+
ALPHA_GAIN: 20,
|
|
11
|
+
ALPHA_OFFSET: -10,
|
|
12
|
+
PILL_HEIGHT: 34,
|
|
13
|
+
CURVE_FACTOR: 14,
|
|
14
|
+
MAX_CORNER_RADIUS: 16,
|
|
15
|
+
CORNER_RATIO: .45,
|
|
16
|
+
MIN_BODY_DELTA: 8
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Compute the optimal Gaussian blur for a gooey filter based on element height.
|
|
20
|
+
*
|
|
21
|
+
* @param height - Element height in pixels
|
|
22
|
+
* @returns Blur stdDeviation value
|
|
23
|
+
*/
|
|
24
|
+
function computeBlur(height) {
|
|
25
|
+
return Math.round(height * GOOEY_DEFAULTS.BLUR_RATIO);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build the feColorMatrix `values` string.
|
|
29
|
+
*
|
|
30
|
+
* @param gain - Alpha multiplier (default: 20)
|
|
31
|
+
* @param offset - Alpha offset (default: -10)
|
|
32
|
+
* @returns Matrix values string for feColorMatrix
|
|
33
|
+
*/
|
|
34
|
+
function buildColorMatrixValues(gain = GOOEY_DEFAULTS.ALPHA_GAIN, offset = GOOEY_DEFAULTS.ALPHA_OFFSET) {
|
|
35
|
+
return `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${gain} ${offset}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the CSS filter string with gooey + optional drop-shadow outline.
|
|
39
|
+
*
|
|
40
|
+
* @param filterId - SVG filter ID to reference
|
|
41
|
+
* @param outlineBlur - Drop-shadow blur (px)
|
|
42
|
+
* @param outlineColor - Drop-shadow color
|
|
43
|
+
* @param outlineLayers - Number of stacked drop-shadows for thickness
|
|
44
|
+
* @returns CSS filter property value
|
|
45
|
+
*/
|
|
46
|
+
function buildFilterString(filterId, outlineBlur = .5, outlineColor = "var(--border)", outlineLayers = 2) {
|
|
47
|
+
const goo = `url(#${filterId})`;
|
|
48
|
+
const shadow = `drop-shadow(0 0 ${outlineBlur}px ${outlineColor})`;
|
|
49
|
+
return `${goo} ${Array(outlineLayers).fill(shadow).join(" ")}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Memoize a path generation function — caches last result to avoid
|
|
53
|
+
* recomputing identical paths on consecutive animation frames.
|
|
54
|
+
*
|
|
55
|
+
* @param fn - Path generation function
|
|
56
|
+
* @returns Memoized function
|
|
57
|
+
*/
|
|
58
|
+
function memoizePath(fn) {
|
|
59
|
+
let lastArgs = null;
|
|
60
|
+
let lastResult = "";
|
|
61
|
+
return (pw, bw, th, t, ph) => {
|
|
62
|
+
if (lastArgs && lastArgs[0] === pw && lastArgs[1] === bw && lastArgs[2] === th && lastArgs[3] === t && lastArgs[4] === ph) return lastResult;
|
|
63
|
+
lastResult = fn(pw, bw, th, t, ph);
|
|
64
|
+
lastArgs = [
|
|
65
|
+
pw,
|
|
66
|
+
bw,
|
|
67
|
+
th,
|
|
68
|
+
t,
|
|
69
|
+
ph
|
|
70
|
+
];
|
|
71
|
+
return lastResult;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Generate an SVG path for a pill that morphs downward into a body blob.
|
|
76
|
+
* Adapted from goey-toast's morphPathRaw.
|
|
77
|
+
*
|
|
78
|
+
* @param pw - Pill width
|
|
79
|
+
* @param bw - Body width (expanded)
|
|
80
|
+
* @param th - Total height (pill + body)
|
|
81
|
+
* @param t - Transition progress 0 (pill only) → 1 (full blob)
|
|
82
|
+
* @param ph - Pill height (default: PILL_HEIGHT)
|
|
83
|
+
* @returns SVG path d-string
|
|
84
|
+
*/
|
|
85
|
+
function morphPathDown(pw, bw, th, t, ph = GOOEY_DEFAULTS.PILL_HEIGHT) {
|
|
86
|
+
const pr = ph / 2;
|
|
87
|
+
const pillW = Math.min(pw, bw);
|
|
88
|
+
const bodyH = ph + (th - ph) * t;
|
|
89
|
+
if (t <= 0 || bodyH - ph < GOOEY_DEFAULTS.MIN_BODY_DELTA) return [
|
|
90
|
+
`M 0,${pr}`,
|
|
91
|
+
`A ${pr},${pr} 0 0 1 ${pr},0`,
|
|
92
|
+
`H ${pillW - pr}`,
|
|
93
|
+
`A ${pr},${pr} 0 0 1 ${pillW},${pr}`,
|
|
94
|
+
`A ${pr},${pr} 0 0 1 ${pillW - pr},${ph}`,
|
|
95
|
+
`H ${pr}`,
|
|
96
|
+
`A ${pr},${pr} 0 0 1 0,${pr}`,
|
|
97
|
+
`Z`
|
|
98
|
+
].join(" ");
|
|
99
|
+
const curve = GOOEY_DEFAULTS.CURVE_FACTOR * t;
|
|
100
|
+
const cr = Math.min(GOOEY_DEFAULTS.MAX_CORNER_RADIUS, (bodyH - ph) * GOOEY_DEFAULTS.CORNER_RATIO);
|
|
101
|
+
const bodyW = pillW + (bw - pillW) * t;
|
|
102
|
+
const bodyTop = ph - curve;
|
|
103
|
+
const qEndX = Math.min(pillW + curve, bodyW - cr);
|
|
104
|
+
return [
|
|
105
|
+
`M 0,${pr}`,
|
|
106
|
+
`A ${pr},${pr} 0 0 1 ${pr},0`,
|
|
107
|
+
`H ${pillW - pr}`,
|
|
108
|
+
`A ${pr},${pr} 0 0 1 ${pillW},${pr}`,
|
|
109
|
+
`L ${pillW},${bodyTop}`,
|
|
110
|
+
`Q ${pillW},${bodyTop + curve} ${qEndX},${bodyTop + curve}`,
|
|
111
|
+
`H ${bodyW - cr}`,
|
|
112
|
+
`A ${cr},${cr} 0 0 1 ${bodyW},${bodyTop + curve + cr}`,
|
|
113
|
+
`L ${bodyW},${bodyH - cr}`,
|
|
114
|
+
`A ${cr},${cr} 0 0 1 ${bodyW - cr},${bodyH}`,
|
|
115
|
+
`H ${cr}`,
|
|
116
|
+
`A ${cr},${cr} 0 0 1 0,${bodyH - cr}`,
|
|
117
|
+
`Z`
|
|
118
|
+
].join(" ");
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generate an SVG path for a pill that morphs UPWARD into a body blob.
|
|
122
|
+
* Used for DynamicToggle's bubble-above-pill layout.
|
|
123
|
+
*
|
|
124
|
+
* @param pw - Pill width
|
|
125
|
+
* @param bw - Body (bubble) width
|
|
126
|
+
* @param th - Total height (bubble + pill)
|
|
127
|
+
* @param t - Transition progress 0 (pill only) → 1 (full blob with bubble)
|
|
128
|
+
* @param ph - Pill height
|
|
129
|
+
* @returns SVG path d-string
|
|
130
|
+
*/
|
|
131
|
+
function morphPathUp(pw, bw, th, t, ph = GOOEY_DEFAULTS.PILL_HEIGHT) {
|
|
132
|
+
const pr = ph / 2;
|
|
133
|
+
const pillW = Math.min(pw, bw);
|
|
134
|
+
const bubbleH = (th - ph) * t;
|
|
135
|
+
if (t <= 0 || bubbleH < GOOEY_DEFAULTS.MIN_BODY_DELTA) {
|
|
136
|
+
const y0 = th - ph;
|
|
137
|
+
return [
|
|
138
|
+
`M 0,${y0 + pr}`,
|
|
139
|
+
`A ${pr},${pr} 0 0 1 ${pr},${y0}`,
|
|
140
|
+
`H ${pillW - pr}`,
|
|
141
|
+
`A ${pr},${pr} 0 0 1 ${pillW},${y0 + pr}`,
|
|
142
|
+
`A ${pr},${pr} 0 0 1 ${pillW - pr},${y0 + ph}`,
|
|
143
|
+
`H ${pr}`,
|
|
144
|
+
`A ${pr},${pr} 0 0 1 0,${y0 + pr}`,
|
|
145
|
+
`Z`
|
|
146
|
+
].join(" ");
|
|
147
|
+
}
|
|
148
|
+
const curve = GOOEY_DEFAULTS.CURVE_FACTOR * t;
|
|
149
|
+
const cr = Math.min(GOOEY_DEFAULTS.MAX_CORNER_RADIUS, bubbleH * GOOEY_DEFAULTS.CORNER_RATIO);
|
|
150
|
+
const bubbleW = pillW + (bw - pillW) * t;
|
|
151
|
+
const pillTop = th - ph;
|
|
152
|
+
const bubbleBottom = pillTop + curve;
|
|
153
|
+
const bubbleTop = pillTop - bubbleH + curve;
|
|
154
|
+
const qEndX = Math.min(pillW + curve, bubbleW - cr);
|
|
155
|
+
return [
|
|
156
|
+
`M 0,${pillTop + pr}`,
|
|
157
|
+
`A ${pr},${pr} 0 0 1 0,${pillTop + ph - pr}`,
|
|
158
|
+
`A ${pr},${pr} 0 0 1 ${pr},${pillTop + ph}`,
|
|
159
|
+
`H ${pillW - pr}`,
|
|
160
|
+
`A ${pr},${pr} 0 0 1 ${pillW},${pillTop + ph - pr}`,
|
|
161
|
+
`L ${pillW},${bubbleBottom}`,
|
|
162
|
+
`Q ${pillW},${bubbleBottom - curve} ${qEndX},${bubbleBottom - curve}`,
|
|
163
|
+
`H ${bubbleW - cr}`,
|
|
164
|
+
`A ${cr},${cr} 0 0 0 ${bubbleW},${bubbleBottom - curve - cr}`,
|
|
165
|
+
`L ${bubbleW},${bubbleTop + cr}`,
|
|
166
|
+
`A ${cr},${cr} 0 0 0 ${bubbleW - cr},${bubbleTop}`,
|
|
167
|
+
`H ${cr}`,
|
|
168
|
+
`A ${cr},${cr} 0 0 0 0,${bubbleTop + cr}`,
|
|
169
|
+
`Z`
|
|
170
|
+
].join(" ");
|
|
171
|
+
}
|
|
172
|
+
/** Memoized versions for animation performance. */
|
|
173
|
+
const morphPathDownMemo = memoizePath(morphPathDown);
|
|
174
|
+
const morphPathUpMemo = memoizePath(morphPathUp);
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
export { GOOEY_DEFAULTS, buildColorMatrixValues, buildFilterString, computeBlur, memoizePath, morphPathDown, morphPathUp };
|