@vegastack/design 0.3.2 → 0.4.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.
- package/bin/verify-registry-item.mjs +1 -0
- package/dist/chunk-LRQSVCP6.js +182 -0
- package/dist/create-animated-icon.cjs +437 -0
- package/dist/create-animated-icon.d.cts +210 -0
- package/dist/create-animated-icon.d.ts +210 -0
- package/dist/create-animated-icon.js +350 -0
- package/dist/icons/index.cjs +26 -0
- package/dist/icons/index.d.cts +15 -8
- package/dist/icons/index.d.ts +15 -8
- package/dist/icons/index.js +1 -1
- package/dist/index.cjs +142 -3
- package/dist/index.d.cts +273 -1
- package/dist/index.d.ts +273 -1
- package/dist/index.js +21 -3
- package/package.json +20 -9
- package/preset.css +1 -1
- package/skills/vegastack-consume/SKILL.md +5 -5
- package/skills/vegastack-design-audit/SKILL.md +3 -1
- package/skills/vegastack-design-system/SKILL.md +105 -3
- package/skills/vegastack-design-system/references/components.md +21 -15
- package/dist/chunk-FBU37ITM.js +0 -52
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as motion_react from 'motion/react';
|
|
2
|
+
import { motion, Variants, Transition, useAnimation } from 'motion/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Motion's imperative controls. `motion` does not export a public name for this
|
|
7
|
+
* type (`LegacyAnimationControls` lives in `motion-dom` and is not re-exported),
|
|
8
|
+
* so it is derived from the hook that produces it.
|
|
9
|
+
*/
|
|
10
|
+
type AnimatedIconControls = ReturnType<typeof useAnimation>;
|
|
11
|
+
/** A variant label or an explicit target — whatever `controls.start()` accepts. */
|
|
12
|
+
type AnimatedIconDefinition = Parameters<AnimatedIconControls["start"]>[0];
|
|
13
|
+
/** The per-call transition override `controls.start()` accepts as its 2nd argument. */
|
|
14
|
+
type AnimatedIconTransition = Parameters<AnimatedIconControls["start"]>[1];
|
|
15
|
+
/**
|
|
16
|
+
* Motion's own prop types, taken from a Motion element rather than restated, so
|
|
17
|
+
* a spec can never declare something Motion would reject. (`initial` is
|
|
18
|
+
* deliberately narrower than a start() definition: it takes no variant resolver.)
|
|
19
|
+
*/
|
|
20
|
+
type MotionElementProps = React.ComponentProps<typeof motion.svg>;
|
|
21
|
+
type AnimatedIconInitial = MotionElementProps["initial"];
|
|
22
|
+
type AnimatedIconTarget = MotionElementProps["animate"];
|
|
23
|
+
type AnimatedIconExit = MotionElementProps["exit"];
|
|
24
|
+
/**
|
|
25
|
+
* The root renders as either `svg` or `motion.svg`, so a style must satisfy
|
|
26
|
+
* both: plain CSS plus Motion's transform-origin shorthands.
|
|
27
|
+
*/
|
|
28
|
+
type AnimatedIconStyle = React.CSSProperties & NonNullable<MotionElementProps["style"]>;
|
|
29
|
+
/**
|
|
30
|
+
* The imperative handle every animated icon exposes on its ref — drive the
|
|
31
|
+
* animation programmatically instead of (or in addition to) hover/focus.
|
|
32
|
+
*/
|
|
33
|
+
interface AnimatedIconHandle {
|
|
34
|
+
startAnimation: () => void;
|
|
35
|
+
stopAnimation: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The choreography context handed to a spec's `start`/`stop`. Every timing
|
|
39
|
+
* primitive an icon may need is here, so an icon module never touches React.
|
|
40
|
+
*/
|
|
41
|
+
interface AnimatedIconChoreography {
|
|
42
|
+
/**
|
|
43
|
+
* Look up a control group by name; no argument gives the primary group. A
|
|
44
|
+
* function rather than a record so a group is never `possibly undefined` at
|
|
45
|
+
* the call site — the factory creates exactly the groups the spec declares.
|
|
46
|
+
*/
|
|
47
|
+
control: (group?: string) => AnimatedIconControls;
|
|
48
|
+
/**
|
|
49
|
+
* The live `(prefers-reduced-motion: reduce)` preference, with an explicit
|
|
50
|
+
* `<MotionConfig reducedMotion>` override applied.
|
|
51
|
+
*/
|
|
52
|
+
shouldReduceMotion: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Play a definition. A no-op that also halts the control when reduced motion
|
|
55
|
+
* is requested. Never rejects — an interrupted animation resolves.
|
|
56
|
+
*/
|
|
57
|
+
run: (control: AnimatedIconControls, definition: AnimatedIconDefinition, transition?: AnimatedIconTransition) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Return to a resting definition. Under reduced motion the target is applied
|
|
60
|
+
* instantly instead of being animated to.
|
|
61
|
+
*/
|
|
62
|
+
reset: (control: AnimatedIconControls, definition: AnimatedIconDefinition, transition?: AnimatedIconTransition) => Promise<void>;
|
|
63
|
+
/** Halt a control and snap it to a definition, with no animation, ever. */
|
|
64
|
+
set: (control: AnimatedIconControls, definition: AnimatedIconDefinition) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Schedule deferred work. Every pending task is cancelled when the animation
|
|
67
|
+
* stops and when the icon unmounts, so an icon never leaks a timer.
|
|
68
|
+
*/
|
|
69
|
+
after: (delayMs: number, task: () => void) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Per-instance scratch for choreography that needs to remember something
|
|
72
|
+
* between calls — a re-entrancy latch, say. Persists for the icon's lifetime.
|
|
73
|
+
*/
|
|
74
|
+
flags: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
/** Every SVG element an icon may draw, plus its Motion counterpart. */
|
|
77
|
+
declare const TAGS: {
|
|
78
|
+
readonly circle: "circle";
|
|
79
|
+
readonly defs: "defs";
|
|
80
|
+
readonly ellipse: "ellipse";
|
|
81
|
+
readonly g: "g";
|
|
82
|
+
readonly line: "line";
|
|
83
|
+
readonly path: "path";
|
|
84
|
+
readonly pattern: "pattern";
|
|
85
|
+
readonly polygon: "polygon";
|
|
86
|
+
readonly polyline: "polyline";
|
|
87
|
+
readonly rect: "rect";
|
|
88
|
+
readonly text: "text";
|
|
89
|
+
readonly "motion.circle": motion_react.ForwardRefComponent<SVGCircleElement, motion_react.SVGMotionProps<SVGCircleElement>>;
|
|
90
|
+
readonly "motion.ellipse": motion_react.ForwardRefComponent<SVGEllipseElement, motion_react.SVGMotionProps<SVGEllipseElement>>;
|
|
91
|
+
readonly "motion.g": motion_react.ForwardRefComponent<SVGGElement, motion_react.SVGMotionProps<SVGGElement>>;
|
|
92
|
+
readonly "motion.line": motion_react.ForwardRefComponent<SVGLineElement, motion_react.SVGMotionProps<SVGLineElement>>;
|
|
93
|
+
readonly "motion.path": motion_react.ForwardRefComponent<SVGPathElement, motion_react.SVGMotionProps<SVGPathElement>>;
|
|
94
|
+
readonly "motion.pattern": motion_react.ForwardRefComponent<SVGPatternElement, motion_react.SVGMotionProps<SVGPatternElement>>;
|
|
95
|
+
readonly "motion.polygon": motion_react.ForwardRefComponent<SVGPolygonElement, motion_react.SVGMotionProps<SVGPolygonElement>>;
|
|
96
|
+
readonly "motion.polyline": motion_react.ForwardRefComponent<SVGPolylineElement, motion_react.SVGMotionProps<SVGPolylineElement>>;
|
|
97
|
+
readonly "motion.rect": motion_react.ForwardRefComponent<SVGRectElement, motion_react.SVGMotionProps<SVGRectElement>>;
|
|
98
|
+
readonly "motion.text": motion_react.ForwardRefComponent<SVGTextElement, motion_react.SVGMotionProps<SVGTextElement>>;
|
|
99
|
+
};
|
|
100
|
+
type AnimatedIconTag = keyof typeof TAGS;
|
|
101
|
+
/**
|
|
102
|
+
* A single drawn node. Static SVG attributes sit flat alongside the spec keys,
|
|
103
|
+
* so one element is one line; {@link ANIMATED_ICON_RESERVED_KEYS} is the set the
|
|
104
|
+
* factory consumes rather than forwarding to the DOM.
|
|
105
|
+
*/
|
|
106
|
+
interface AnimatedIconNodeBase {
|
|
107
|
+
tag: AnimatedIconTag;
|
|
108
|
+
/** Motion's style type, which adds transform-origin shorthands to CSS. */
|
|
109
|
+
style?: AnimatedIconStyle;
|
|
110
|
+
className?: string;
|
|
111
|
+
variants?: Variants;
|
|
112
|
+
initial?: AnimatedIconInitial;
|
|
113
|
+
/**
|
|
114
|
+
* A literal animation target. When omitted, a `motion.*` node is driven by
|
|
115
|
+
* its control group unless `inherit` says otherwise.
|
|
116
|
+
*/
|
|
117
|
+
animate?: AnimatedIconTarget;
|
|
118
|
+
exit?: AnimatedIconExit;
|
|
119
|
+
transition?: Transition;
|
|
120
|
+
/** Passed to a variant resolver — an index, a delay, or a small offset. */
|
|
121
|
+
custom?: unknown;
|
|
122
|
+
/** Control group driving this node. Defaults to `default`. */
|
|
123
|
+
group?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Bind no control: the node takes its state from Motion's variant propagation
|
|
126
|
+
* down the tree, from a presence mount, or from nothing at all.
|
|
127
|
+
*/
|
|
128
|
+
inherit?: boolean;
|
|
129
|
+
children?: AnimatedIconChild[];
|
|
130
|
+
/** Text content, for the one icon that draws a glyph. */
|
|
131
|
+
text?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A node plus its flat static SVG attributes. The intersection (rather than an
|
|
135
|
+
* index signature on the interface) keeps every declared key precisely typed.
|
|
136
|
+
*/
|
|
137
|
+
type AnimatedIconNode = AnimatedIconNodeBase & {
|
|
138
|
+
[attribute: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
/** A bare string is a static `<path d="…"/>` — the commonest node by far. */
|
|
141
|
+
type AnimatedIconChild = string | AnimatedIconNode;
|
|
142
|
+
/** Spec keys the factory consumes; everything else is an SVG attribute. */
|
|
143
|
+
declare const ANIMATED_ICON_RESERVED_KEYS: Set<string>;
|
|
144
|
+
/**
|
|
145
|
+
* A mount/unmount swap: `active` nodes are mounted while the animation runs,
|
|
146
|
+
* `rest` nodes while it does not, with Motion's exit animations in between.
|
|
147
|
+
*/
|
|
148
|
+
interface AnimatedIconPresence {
|
|
149
|
+
tag: "presence";
|
|
150
|
+
active: AnimatedIconChild[];
|
|
151
|
+
rest: AnimatedIconChild[];
|
|
152
|
+
}
|
|
153
|
+
/** The root `<svg>`. Only deviations from the lucide defaults need stating. */
|
|
154
|
+
interface AnimatedIconRoot extends Omit<AnimatedIconNodeBase, "tag" | "children"> {
|
|
155
|
+
tag?: "svg" | "motion.svg";
|
|
156
|
+
viewBox?: string;
|
|
157
|
+
fill?: string;
|
|
158
|
+
stroke?: string;
|
|
159
|
+
strokeWidth?: string | number;
|
|
160
|
+
strokeLinecap?: "round" | "butt" | "square";
|
|
161
|
+
strokeLinejoin?: "round" | "miter" | "bevel";
|
|
162
|
+
overflow?: string;
|
|
163
|
+
}
|
|
164
|
+
/** The complete description of one animated icon. */
|
|
165
|
+
interface AnimatedIconSpec {
|
|
166
|
+
/** The component's `displayName`, e.g. `BellIcon`. */
|
|
167
|
+
name: string;
|
|
168
|
+
/** Root `<svg>` overrides and, when the whole icon animates, its motion props. */
|
|
169
|
+
svg?: AnimatedIconRoot;
|
|
170
|
+
/** The drawn tree, in paint order. */
|
|
171
|
+
elements: (AnimatedIconChild | AnimatedIconPresence)[];
|
|
172
|
+
/** Extra control groups beyond `default`, in a stable order. */
|
|
173
|
+
groups?: readonly string[];
|
|
174
|
+
/** Non-default play choreography. Defaults to `run(default, "animate")`. */
|
|
175
|
+
start?: (choreography: AnimatedIconChoreography) => void | Promise<void>;
|
|
176
|
+
/** Non-default rest choreography. Defaults to `reset(default, "normal")`. */
|
|
177
|
+
stop?: (choreography: AnimatedIconChoreography) => void | Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
interface AnimatedIconOwnProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "ref"> {
|
|
180
|
+
/** Any CSS length. Defaults to the `--icon-default` role token. */
|
|
181
|
+
size?: number | string;
|
|
182
|
+
ref?: React.Ref<AnimatedIconHandle>;
|
|
183
|
+
}
|
|
184
|
+
/** The component shape `createAnimatedIcon` returns. */
|
|
185
|
+
type AnimatedIconComponentType = ((props: AnimatedIconOwnProps) => React.JSX.Element) & {
|
|
186
|
+
displayName: string;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* `createAnimatedIcon` — the single controller behind every mirrored
|
|
190
|
+
* `lucide-animated` icon. The factory owns the animation controls, the
|
|
191
|
+
* reduced-motion contract, the multi-input trigger rules, the imperative
|
|
192
|
+
* handle, and the host element; an icon module owns only its geometry and,
|
|
193
|
+
* where upstream choreography is not the default play/rest pair, its
|
|
194
|
+
* `start`/`stop`.
|
|
195
|
+
*
|
|
196
|
+
* Trigger rules, unchanged from the per-icon controllers they replace:
|
|
197
|
+
* hover plays on fine pointers, a pointer-down plays on touch, focus plays and
|
|
198
|
+
* blur rests, and every trigger is suppressed once a consumer attaches a ref
|
|
199
|
+
* (the icon is then under imperative control).
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* export const BellIcon = createAnimatedIcon({
|
|
203
|
+
* name: "BellIcon",
|
|
204
|
+
* svg: { tag: "motion.svg", variants: SVG_VARIANTS },
|
|
205
|
+
* elements: [{ tag: "path", attrs: { d: "M6 8a6 6 0 0 1 12 0…" } }],
|
|
206
|
+
* });
|
|
207
|
+
*/
|
|
208
|
+
declare function createAnimatedIcon(spec: AnimatedIconSpec): AnimatedIconComponentType;
|
|
209
|
+
|
|
210
|
+
export { ANIMATED_ICON_RESERVED_KEYS, type AnimatedIconChild, type AnimatedIconChoreography, type AnimatedIconComponentType, type AnimatedIconControls, type AnimatedIconDefinition, type AnimatedIconExit, type AnimatedIconHandle, type AnimatedIconInitial, type AnimatedIconNode, type AnimatedIconOwnProps, type AnimatedIconPresence, type AnimatedIconRoot, type AnimatedIconSpec, type AnimatedIconStyle, type AnimatedIconTag, type AnimatedIconTarget, type AnimatedIconTransition, createAnimatedIcon };
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as motion_react from 'motion/react';
|
|
2
|
+
import { motion, Variants, Transition, useAnimation } from 'motion/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Motion's imperative controls. `motion` does not export a public name for this
|
|
7
|
+
* type (`LegacyAnimationControls` lives in `motion-dom` and is not re-exported),
|
|
8
|
+
* so it is derived from the hook that produces it.
|
|
9
|
+
*/
|
|
10
|
+
type AnimatedIconControls = ReturnType<typeof useAnimation>;
|
|
11
|
+
/** A variant label or an explicit target — whatever `controls.start()` accepts. */
|
|
12
|
+
type AnimatedIconDefinition = Parameters<AnimatedIconControls["start"]>[0];
|
|
13
|
+
/** The per-call transition override `controls.start()` accepts as its 2nd argument. */
|
|
14
|
+
type AnimatedIconTransition = Parameters<AnimatedIconControls["start"]>[1];
|
|
15
|
+
/**
|
|
16
|
+
* Motion's own prop types, taken from a Motion element rather than restated, so
|
|
17
|
+
* a spec can never declare something Motion would reject. (`initial` is
|
|
18
|
+
* deliberately narrower than a start() definition: it takes no variant resolver.)
|
|
19
|
+
*/
|
|
20
|
+
type MotionElementProps = React.ComponentProps<typeof motion.svg>;
|
|
21
|
+
type AnimatedIconInitial = MotionElementProps["initial"];
|
|
22
|
+
type AnimatedIconTarget = MotionElementProps["animate"];
|
|
23
|
+
type AnimatedIconExit = MotionElementProps["exit"];
|
|
24
|
+
/**
|
|
25
|
+
* The root renders as either `svg` or `motion.svg`, so a style must satisfy
|
|
26
|
+
* both: plain CSS plus Motion's transform-origin shorthands.
|
|
27
|
+
*/
|
|
28
|
+
type AnimatedIconStyle = React.CSSProperties & NonNullable<MotionElementProps["style"]>;
|
|
29
|
+
/**
|
|
30
|
+
* The imperative handle every animated icon exposes on its ref — drive the
|
|
31
|
+
* animation programmatically instead of (or in addition to) hover/focus.
|
|
32
|
+
*/
|
|
33
|
+
interface AnimatedIconHandle {
|
|
34
|
+
startAnimation: () => void;
|
|
35
|
+
stopAnimation: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The choreography context handed to a spec's `start`/`stop`. Every timing
|
|
39
|
+
* primitive an icon may need is here, so an icon module never touches React.
|
|
40
|
+
*/
|
|
41
|
+
interface AnimatedIconChoreography {
|
|
42
|
+
/**
|
|
43
|
+
* Look up a control group by name; no argument gives the primary group. A
|
|
44
|
+
* function rather than a record so a group is never `possibly undefined` at
|
|
45
|
+
* the call site — the factory creates exactly the groups the spec declares.
|
|
46
|
+
*/
|
|
47
|
+
control: (group?: string) => AnimatedIconControls;
|
|
48
|
+
/**
|
|
49
|
+
* The live `(prefers-reduced-motion: reduce)` preference, with an explicit
|
|
50
|
+
* `<MotionConfig reducedMotion>` override applied.
|
|
51
|
+
*/
|
|
52
|
+
shouldReduceMotion: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Play a definition. A no-op that also halts the control when reduced motion
|
|
55
|
+
* is requested. Never rejects — an interrupted animation resolves.
|
|
56
|
+
*/
|
|
57
|
+
run: (control: AnimatedIconControls, definition: AnimatedIconDefinition, transition?: AnimatedIconTransition) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Return to a resting definition. Under reduced motion the target is applied
|
|
60
|
+
* instantly instead of being animated to.
|
|
61
|
+
*/
|
|
62
|
+
reset: (control: AnimatedIconControls, definition: AnimatedIconDefinition, transition?: AnimatedIconTransition) => Promise<void>;
|
|
63
|
+
/** Halt a control and snap it to a definition, with no animation, ever. */
|
|
64
|
+
set: (control: AnimatedIconControls, definition: AnimatedIconDefinition) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Schedule deferred work. Every pending task is cancelled when the animation
|
|
67
|
+
* stops and when the icon unmounts, so an icon never leaks a timer.
|
|
68
|
+
*/
|
|
69
|
+
after: (delayMs: number, task: () => void) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Per-instance scratch for choreography that needs to remember something
|
|
72
|
+
* between calls — a re-entrancy latch, say. Persists for the icon's lifetime.
|
|
73
|
+
*/
|
|
74
|
+
flags: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
/** Every SVG element an icon may draw, plus its Motion counterpart. */
|
|
77
|
+
declare const TAGS: {
|
|
78
|
+
readonly circle: "circle";
|
|
79
|
+
readonly defs: "defs";
|
|
80
|
+
readonly ellipse: "ellipse";
|
|
81
|
+
readonly g: "g";
|
|
82
|
+
readonly line: "line";
|
|
83
|
+
readonly path: "path";
|
|
84
|
+
readonly pattern: "pattern";
|
|
85
|
+
readonly polygon: "polygon";
|
|
86
|
+
readonly polyline: "polyline";
|
|
87
|
+
readonly rect: "rect";
|
|
88
|
+
readonly text: "text";
|
|
89
|
+
readonly "motion.circle": motion_react.ForwardRefComponent<SVGCircleElement, motion_react.SVGMotionProps<SVGCircleElement>>;
|
|
90
|
+
readonly "motion.ellipse": motion_react.ForwardRefComponent<SVGEllipseElement, motion_react.SVGMotionProps<SVGEllipseElement>>;
|
|
91
|
+
readonly "motion.g": motion_react.ForwardRefComponent<SVGGElement, motion_react.SVGMotionProps<SVGGElement>>;
|
|
92
|
+
readonly "motion.line": motion_react.ForwardRefComponent<SVGLineElement, motion_react.SVGMotionProps<SVGLineElement>>;
|
|
93
|
+
readonly "motion.path": motion_react.ForwardRefComponent<SVGPathElement, motion_react.SVGMotionProps<SVGPathElement>>;
|
|
94
|
+
readonly "motion.pattern": motion_react.ForwardRefComponent<SVGPatternElement, motion_react.SVGMotionProps<SVGPatternElement>>;
|
|
95
|
+
readonly "motion.polygon": motion_react.ForwardRefComponent<SVGPolygonElement, motion_react.SVGMotionProps<SVGPolygonElement>>;
|
|
96
|
+
readonly "motion.polyline": motion_react.ForwardRefComponent<SVGPolylineElement, motion_react.SVGMotionProps<SVGPolylineElement>>;
|
|
97
|
+
readonly "motion.rect": motion_react.ForwardRefComponent<SVGRectElement, motion_react.SVGMotionProps<SVGRectElement>>;
|
|
98
|
+
readonly "motion.text": motion_react.ForwardRefComponent<SVGTextElement, motion_react.SVGMotionProps<SVGTextElement>>;
|
|
99
|
+
};
|
|
100
|
+
type AnimatedIconTag = keyof typeof TAGS;
|
|
101
|
+
/**
|
|
102
|
+
* A single drawn node. Static SVG attributes sit flat alongside the spec keys,
|
|
103
|
+
* so one element is one line; {@link ANIMATED_ICON_RESERVED_KEYS} is the set the
|
|
104
|
+
* factory consumes rather than forwarding to the DOM.
|
|
105
|
+
*/
|
|
106
|
+
interface AnimatedIconNodeBase {
|
|
107
|
+
tag: AnimatedIconTag;
|
|
108
|
+
/** Motion's style type, which adds transform-origin shorthands to CSS. */
|
|
109
|
+
style?: AnimatedIconStyle;
|
|
110
|
+
className?: string;
|
|
111
|
+
variants?: Variants;
|
|
112
|
+
initial?: AnimatedIconInitial;
|
|
113
|
+
/**
|
|
114
|
+
* A literal animation target. When omitted, a `motion.*` node is driven by
|
|
115
|
+
* its control group unless `inherit` says otherwise.
|
|
116
|
+
*/
|
|
117
|
+
animate?: AnimatedIconTarget;
|
|
118
|
+
exit?: AnimatedIconExit;
|
|
119
|
+
transition?: Transition;
|
|
120
|
+
/** Passed to a variant resolver — an index, a delay, or a small offset. */
|
|
121
|
+
custom?: unknown;
|
|
122
|
+
/** Control group driving this node. Defaults to `default`. */
|
|
123
|
+
group?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Bind no control: the node takes its state from Motion's variant propagation
|
|
126
|
+
* down the tree, from a presence mount, or from nothing at all.
|
|
127
|
+
*/
|
|
128
|
+
inherit?: boolean;
|
|
129
|
+
children?: AnimatedIconChild[];
|
|
130
|
+
/** Text content, for the one icon that draws a glyph. */
|
|
131
|
+
text?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A node plus its flat static SVG attributes. The intersection (rather than an
|
|
135
|
+
* index signature on the interface) keeps every declared key precisely typed.
|
|
136
|
+
*/
|
|
137
|
+
type AnimatedIconNode = AnimatedIconNodeBase & {
|
|
138
|
+
[attribute: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
/** A bare string is a static `<path d="…"/>` — the commonest node by far. */
|
|
141
|
+
type AnimatedIconChild = string | AnimatedIconNode;
|
|
142
|
+
/** Spec keys the factory consumes; everything else is an SVG attribute. */
|
|
143
|
+
declare const ANIMATED_ICON_RESERVED_KEYS: Set<string>;
|
|
144
|
+
/**
|
|
145
|
+
* A mount/unmount swap: `active` nodes are mounted while the animation runs,
|
|
146
|
+
* `rest` nodes while it does not, with Motion's exit animations in between.
|
|
147
|
+
*/
|
|
148
|
+
interface AnimatedIconPresence {
|
|
149
|
+
tag: "presence";
|
|
150
|
+
active: AnimatedIconChild[];
|
|
151
|
+
rest: AnimatedIconChild[];
|
|
152
|
+
}
|
|
153
|
+
/** The root `<svg>`. Only deviations from the lucide defaults need stating. */
|
|
154
|
+
interface AnimatedIconRoot extends Omit<AnimatedIconNodeBase, "tag" | "children"> {
|
|
155
|
+
tag?: "svg" | "motion.svg";
|
|
156
|
+
viewBox?: string;
|
|
157
|
+
fill?: string;
|
|
158
|
+
stroke?: string;
|
|
159
|
+
strokeWidth?: string | number;
|
|
160
|
+
strokeLinecap?: "round" | "butt" | "square";
|
|
161
|
+
strokeLinejoin?: "round" | "miter" | "bevel";
|
|
162
|
+
overflow?: string;
|
|
163
|
+
}
|
|
164
|
+
/** The complete description of one animated icon. */
|
|
165
|
+
interface AnimatedIconSpec {
|
|
166
|
+
/** The component's `displayName`, e.g. `BellIcon`. */
|
|
167
|
+
name: string;
|
|
168
|
+
/** Root `<svg>` overrides and, when the whole icon animates, its motion props. */
|
|
169
|
+
svg?: AnimatedIconRoot;
|
|
170
|
+
/** The drawn tree, in paint order. */
|
|
171
|
+
elements: (AnimatedIconChild | AnimatedIconPresence)[];
|
|
172
|
+
/** Extra control groups beyond `default`, in a stable order. */
|
|
173
|
+
groups?: readonly string[];
|
|
174
|
+
/** Non-default play choreography. Defaults to `run(default, "animate")`. */
|
|
175
|
+
start?: (choreography: AnimatedIconChoreography) => void | Promise<void>;
|
|
176
|
+
/** Non-default rest choreography. Defaults to `reset(default, "normal")`. */
|
|
177
|
+
stop?: (choreography: AnimatedIconChoreography) => void | Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
interface AnimatedIconOwnProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "ref"> {
|
|
180
|
+
/** Any CSS length. Defaults to the `--icon-default` role token. */
|
|
181
|
+
size?: number | string;
|
|
182
|
+
ref?: React.Ref<AnimatedIconHandle>;
|
|
183
|
+
}
|
|
184
|
+
/** The component shape `createAnimatedIcon` returns. */
|
|
185
|
+
type AnimatedIconComponentType = ((props: AnimatedIconOwnProps) => React.JSX.Element) & {
|
|
186
|
+
displayName: string;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* `createAnimatedIcon` — the single controller behind every mirrored
|
|
190
|
+
* `lucide-animated` icon. The factory owns the animation controls, the
|
|
191
|
+
* reduced-motion contract, the multi-input trigger rules, the imperative
|
|
192
|
+
* handle, and the host element; an icon module owns only its geometry and,
|
|
193
|
+
* where upstream choreography is not the default play/rest pair, its
|
|
194
|
+
* `start`/`stop`.
|
|
195
|
+
*
|
|
196
|
+
* Trigger rules, unchanged from the per-icon controllers they replace:
|
|
197
|
+
* hover plays on fine pointers, a pointer-down plays on touch, focus plays and
|
|
198
|
+
* blur rests, and every trigger is suppressed once a consumer attaches a ref
|
|
199
|
+
* (the icon is then under imperative control).
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* export const BellIcon = createAnimatedIcon({
|
|
203
|
+
* name: "BellIcon",
|
|
204
|
+
* svg: { tag: "motion.svg", variants: SVG_VARIANTS },
|
|
205
|
+
* elements: [{ tag: "path", attrs: { d: "M6 8a6 6 0 0 1 12 0…" } }],
|
|
206
|
+
* });
|
|
207
|
+
*/
|
|
208
|
+
declare function createAnimatedIcon(spec: AnimatedIconSpec): AnimatedIconComponentType;
|
|
209
|
+
|
|
210
|
+
export { ANIMATED_ICON_RESERVED_KEYS, type AnimatedIconChild, type AnimatedIconChoreography, type AnimatedIconComponentType, type AnimatedIconControls, type AnimatedIconDefinition, type AnimatedIconExit, type AnimatedIconHandle, type AnimatedIconInitial, type AnimatedIconNode, type AnimatedIconOwnProps, type AnimatedIconPresence, type AnimatedIconRoot, type AnimatedIconSpec, type AnimatedIconStyle, type AnimatedIconTag, type AnimatedIconTarget, type AnimatedIconTransition, createAnimatedIcon };
|