@bug-on/m3-expressive 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +31 -7
- package/dist/assets/material-symbols-cdn.css +17 -23
- package/dist/buttons.js +129 -35
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +129 -35
- package/dist/buttons.mjs.map +1 -1
- package/dist/{core-COvZHQ_k.d.ts → core-Cckt8qEm.d.ts} +10 -4
- package/dist/{core-CRkixy1y.d.mts → core-DDfG4pym.d.mts} +10 -4
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +6 -5
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +6 -5
- package/dist/core.mjs.map +1 -1
- package/dist/fading-blur-mask--uZbBKLj.d.mts +77 -0
- package/dist/fading-blur-mask--uZbBKLj.d.ts +77 -0
- package/dist/feedback.js +1 -1
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +1 -1
- package/dist/feedback.mjs.map +1 -1
- package/dist/forms.d.mts +2 -2
- package/dist/forms.d.ts +2 -2
- package/dist/forms.js +17 -7
- package/dist/forms.js.map +1 -1
- package/dist/forms.mjs +17 -7
- package/dist/forms.mjs.map +1 -1
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +988 -309
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +984 -310
- package/dist/index.mjs.map +1 -1
- package/dist/layout.d.mts +5 -3
- package/dist/layout.d.ts +5 -3
- package/dist/layout.js +61 -6
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +61 -7
- package/dist/layout.mjs.map +1 -1
- package/dist/material-symbols-cdn.css +17 -23
- package/dist/{md3-expressive-shapes-CPcfl_Hf.d.mts → md3-expressive-shapes-wk_98LJh.d.mts} +20 -1
- package/dist/{md3-expressive-shapes-CPcfl_Hf.d.ts → md3-expressive-shapes-wk_98LJh.d.ts} +20 -1
- package/dist/navigation.d.mts +26 -84
- package/dist/navigation.d.ts +26 -84
- package/dist/navigation.js +95 -29
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +95 -29
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.d.mts +4 -2
- package/dist/overlays.d.ts +4 -2
- package/dist/overlays.js +85 -44
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +85 -44
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.d.mts +12 -0
- package/dist/pickers.d.ts +12 -0
- package/dist/pickers.js +186 -120
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +186 -120
- package/dist/pickers.mjs.map +1 -1
- package/dist/shapes.d.mts +141 -15
- package/dist/shapes.d.ts +141 -15
- package/dist/shapes.js +618 -126
- package/dist/shapes.js.map +1 -1
- package/dist/shapes.mjs +614 -127
- package/dist/shapes.mjs.map +1 -1
- package/dist/{side-sheet-modal-64FGhDxL.d.mts → side-sheet-modal-BycxrabB.d.mts} +70 -0
- package/dist/{side-sheet-modal-Bd5Qqvp9.d.ts → side-sheet-modal-Cw4vemKx.d.ts} +70 -0
- package/dist/{text-field-4OlT9o8s.d.mts → text-field-B1fLh5Sh.d.mts} +22 -3
- package/dist/{text-field-DARNdj14.d.ts → text-field-C0VQLp8Y.d.ts} +22 -3
- package/dist/{typography-339RV6v7.d.mts → typography-CKTjvlZ4.d.mts} +25 -0
- package/dist/{typography-339RV6v7.d.ts → typography-CKTjvlZ4.d.ts} +25 -0
- package/dist/typography.css +1 -1
- package/llms-full.txt +24 -13
- package/llms.txt +11 -6
- package/package.json +3 -3
package/dist/shapes.d.mts
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
import { R as RoundedPolygon, a as CornerRounding, b as Cubic, e as MutableCubic
|
|
2
|
-
export { A as ANGLE_EPSILON, C as CornerFeature, D as DISTANCE_EPSILON, E as EdgeFeature, F as FLOAT_PI, c as Feature, d as MD3Shapes, P as Point, f as PointTransformer, U as UNROUNDED, g as addPoints, h as clockwise, i as convex, j as cornerFeature, k as cornerRounding, l as directionVector, m as distance, n as distanceSquared, o as dividePoint, p as dotProduct, q as edgeFeature, r as
|
|
1
|
+
import { M as MD3ShapeName, R as RoundedPolygon, a as CornerRounding, b as Cubic, e as MutableCubic } from './md3-expressive-shapes-wk_98LJh.mjs';
|
|
2
|
+
export { A as ANGLE_EPSILON, C as CornerFeature, D as DISTANCE_EPSILON, E as EdgeFeature, F as FLOAT_PI, c as Feature, d as MD3Shapes, P as Point, f as PointTransformer, U as UNROUNDED, g as addPoints, h as clockwise, i as convex, j as cornerFeature, k as cornerRounding, l as directionVector, m as distance, n as distanceSquared, o as dividePoint, p as dotProduct, q as edgeFeature, r as formatCoordinate, s as getDirection, t as getDistance, u as getDistanceSquared, v as interpolate, w as lerpPoint, x as point, y as positiveModulo, z as radialToCartesian, B as rotate90, G as scalePoint, H as square, I as subtractPoints, J as transformFeature, K as transformPoint } from './md3-expressive-shapes-wk_98LJh.mjs';
|
|
3
3
|
import { ReactNode, CSSProperties } from 'react';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Material Design 3 Expressive — Shape Pairings & Families.
|
|
7
|
+
*
|
|
8
|
+
* Defines natural, expressive bidirectional morph pairings for all 35 MD3 shapes.
|
|
9
|
+
* Organized by design families:
|
|
10
|
+
* - Organic & Floral
|
|
11
|
+
* - Starburst & Explosive
|
|
12
|
+
* - Clover, Gem & Diamond
|
|
13
|
+
* - Cookies & Geometric Multi-sided
|
|
14
|
+
* - Rounded & Architectural
|
|
15
|
+
* - Polygonal & Directional
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Curated bidirectional morph pairings for MD3 Expressive shapes.
|
|
20
|
+
* Each shape is paired with a harmonious companion shape within its design family.
|
|
21
|
+
*/
|
|
22
|
+
declare const MD3_SHAPE_PAIRINGS: Readonly<Record<MD3ShapeName, MD3ShapeName>>;
|
|
23
|
+
/**
|
|
24
|
+
* Shape families grouping shapes by structural and expressive traits.
|
|
25
|
+
*/
|
|
26
|
+
declare const MD3_SHAPE_FAMILIES: {
|
|
27
|
+
readonly organic: readonly ["circle", "flower", "sunny", "verySunny", "bun", "clamshell", "puffy"];
|
|
28
|
+
readonly starburst: readonly ["burst", "softBurst", "boom", "softBoom", "cookie12Sided"];
|
|
29
|
+
readonly cloverAndGems: readonly ["diamond", "puffyDiamond", "clover4Leaf", "clover8Leaf", "gem", "heart"];
|
|
30
|
+
readonly cookiesAndPolygons: readonly ["cookie4Sided", "cookie6Sided", "cookie7Sided", "cookie9Sided", "square"];
|
|
31
|
+
readonly roundedContainers: readonly ["pill", "oval", "arch", "semiCircle", "slanted"];
|
|
32
|
+
readonly directionalAndPixel: readonly ["triangle", "arrow", "pentagon", "fan", "ghostish", "pixelTriangle", "pixelCircle"];
|
|
33
|
+
};
|
|
34
|
+
type MD3ShapeFamily = keyof typeof MD3_SHAPE_FAMILIES;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the recommended morph target shape for a given shape.
|
|
37
|
+
* If a custom RoundedPolygon is passed without a name match, defaults to "circle".
|
|
38
|
+
*
|
|
39
|
+
* @param shape - Shape name or RoundedPolygon instance
|
|
40
|
+
* @returns The recommended companion MD3 shape name
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* getRecommendedMorphShape("flower"); // "sunny"
|
|
44
|
+
* getRecommendedMorphShape("burst"); // "softBurst"
|
|
45
|
+
*/
|
|
46
|
+
declare function getRecommendedMorphShape(shape: MD3ShapeName | RoundedPolygon): MD3ShapeName;
|
|
47
|
+
|
|
5
48
|
/**
|
|
6
49
|
* MD3 Corner Radius Token Scale.
|
|
7
50
|
* Ported from MD3 spec: https://m3.material.io/styles/shape/corner-radius-scale
|
|
@@ -171,6 +214,8 @@ interface MeasuredFeature {
|
|
|
171
214
|
readonly progress: number;
|
|
172
215
|
/** Whether this corner is convex */
|
|
173
216
|
readonly convex: boolean;
|
|
217
|
+
/** Polar angle in radians [-PI, PI] from polygon center to feature midpoint */
|
|
218
|
+
readonly angle: number;
|
|
174
219
|
}
|
|
175
220
|
/**
|
|
176
221
|
* A list of MeasuredCubics covering the full outline of a polygon.
|
|
@@ -209,12 +254,10 @@ declare class MeasuredPolygon {
|
|
|
209
254
|
|
|
210
255
|
/**
|
|
211
256
|
* Creates a DoubleMapper that maps progress values between two polygons
|
|
212
|
-
* based on matching their
|
|
257
|
+
* based on matching their features by optimal cyclic alignment.
|
|
213
258
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* 2. Match each corner in polygon1 to the closest corner of the same type in polygon2
|
|
217
|
-
* 3. Build a piecewise-linear bidirectional mapper
|
|
259
|
+
* Finds the cyclic phase shift that minimizes both perimeter distance
|
|
260
|
+
* and spatial angular difference between features of polygon 1 and polygon 2.
|
|
218
261
|
*
|
|
219
262
|
* @param features1 - Measured features from polygon 1
|
|
220
263
|
* @param features2 - Measured features from polygon 2
|
|
@@ -264,13 +307,30 @@ declare class Morph {
|
|
|
264
307
|
* Returns the interpolated shape at the given progress as a list of Cubics.
|
|
265
308
|
*
|
|
266
309
|
* Note: This allocates a new list. For performance-critical animation loops,
|
|
267
|
-
* use {@link forEachCubic} instead.
|
|
310
|
+
* use {@link toSvgPath} or {@link forEachCubic} instead.
|
|
268
311
|
*
|
|
269
312
|
* @param progress - Value in [0, 1]. 0 = start shape, 1 = end shape.
|
|
270
313
|
* Values outside [0, 1] produce exaggerated shapes (useful for bounce/overshoot).
|
|
271
314
|
* @returns List of interpolated Cubic curves forming the morphed shape
|
|
272
315
|
*/
|
|
273
316
|
asCubics(progress: number): Cubic[];
|
|
317
|
+
/**
|
|
318
|
+
* Returns an SVG path data string for the morphed shape at the given progress.
|
|
319
|
+
* Directly evaluates coordinates without allocating intermediate Cubic objects.
|
|
320
|
+
*
|
|
321
|
+
* @param progress - Value in [0, 1]
|
|
322
|
+
* @param width - Target pixel width (default: 1)
|
|
323
|
+
* @param height - Target pixel height (default: 1)
|
|
324
|
+
*/
|
|
325
|
+
toSvgPath(progress: number, width?: number, height?: number): string;
|
|
326
|
+
/**
|
|
327
|
+
* Returns a CSS clip-path value for the morphed shape at the given progress.
|
|
328
|
+
*
|
|
329
|
+
* @param progress - Value in [0, 1]
|
|
330
|
+
* @param width - Element width in pixels
|
|
331
|
+
* @param height - Element height in pixels
|
|
332
|
+
*/
|
|
333
|
+
toClipPath(progress: number, width: number, height: number): string;
|
|
274
334
|
/**
|
|
275
335
|
* Iterates over the morphed cubics without allocating new Cubic instances.
|
|
276
336
|
* Reuses a single MutableCubic for each callback invocation.
|
|
@@ -408,9 +468,10 @@ interface ShapeMediaProps {
|
|
|
408
468
|
shape: ShapeRef;
|
|
409
469
|
/**
|
|
410
470
|
* The target shape to morph to (optional).
|
|
471
|
+
* If "auto", picks the recommended MD3 shape pairing.
|
|
411
472
|
* When not provided, no morphing animation occurs.
|
|
412
473
|
*/
|
|
413
|
-
morphTo?: ShapeRef;
|
|
474
|
+
morphTo?: ShapeRef | "auto";
|
|
414
475
|
/** Which interaction triggers the morph (default: "hover"). */
|
|
415
476
|
morphOn?: MorphTrigger;
|
|
416
477
|
/** Animation options. */
|
|
@@ -441,8 +502,8 @@ interface ShapeMediaProps {
|
|
|
441
502
|
interface ShapeIconProps {
|
|
442
503
|
/** The base shape. */
|
|
443
504
|
shape: ShapeRef;
|
|
444
|
-
/** Shape to morph to on hover. */
|
|
445
|
-
morphTo?: ShapeRef;
|
|
505
|
+
/** Shape to morph to on hover (or "auto" for recommended pairing). */
|
|
506
|
+
morphTo?: ShapeRef | "auto";
|
|
446
507
|
/** Size in pixels (width = height). Default: 48. */
|
|
447
508
|
size?: number;
|
|
448
509
|
/** Icon content. */
|
|
@@ -478,8 +539,52 @@ interface ShapeSvgProps {
|
|
|
478
539
|
"aria-label"?: string;
|
|
479
540
|
/** Morph progress [0, 1] — set to animate between shape and morphTo. */
|
|
480
541
|
progress?: number;
|
|
481
|
-
/** Target shape for morphed SVG rendering. */
|
|
482
|
-
morphTo?: ShapeRef;
|
|
542
|
+
/** Target shape for morphed SVG rendering (or "auto" for recommended pairing). */
|
|
543
|
+
morphTo?: ShapeRef | "auto";
|
|
544
|
+
}
|
|
545
|
+
/** Options for useShapeSequenceMorph hook. */
|
|
546
|
+
interface UseShapeSequenceMorphOptions {
|
|
547
|
+
/** Array of shapes to morph through in sequence. */
|
|
548
|
+
shapes: ShapeRef[];
|
|
549
|
+
/** Duration per morph in seconds (default: 0.6). */
|
|
550
|
+
duration?: number;
|
|
551
|
+
/** Interval between morph steps in seconds when autoplay is enabled (default: 2.0). */
|
|
552
|
+
interval?: number;
|
|
553
|
+
/** Whether to automatically cycle through shapes (default: false). */
|
|
554
|
+
autoplay?: boolean;
|
|
555
|
+
/** Whether to loop back to the first shape after reaching the end (default: true). */
|
|
556
|
+
loop?: boolean;
|
|
557
|
+
/** Custom animation options. */
|
|
558
|
+
morphOptions?: ShapeMorphOptions;
|
|
559
|
+
/** Output clip-path width in pixels. */
|
|
560
|
+
width: number;
|
|
561
|
+
/** Output clip-path height in pixels. */
|
|
562
|
+
height: number;
|
|
563
|
+
/** Whether the sequence animation is disabled. */
|
|
564
|
+
disabled?: boolean;
|
|
565
|
+
}
|
|
566
|
+
/** Return value of useShapeSequenceMorph hook. */
|
|
567
|
+
interface UseShapeSequenceMorphResult {
|
|
568
|
+
/** CSS clip-path string for the current interpolated frame. */
|
|
569
|
+
clipPath: string;
|
|
570
|
+
/** Index of current base shape in the shapes array. */
|
|
571
|
+
currentIndex: number;
|
|
572
|
+
/** Index of next target shape. */
|
|
573
|
+
nextIndex: number;
|
|
574
|
+
/** Current morph progress between currentIndex and nextIndex [0, 1]. */
|
|
575
|
+
progress: number;
|
|
576
|
+
/** Whether autoplay is currently active. */
|
|
577
|
+
isPlaying: boolean;
|
|
578
|
+
/** Advance to the next shape in the sequence. */
|
|
579
|
+
next: () => void;
|
|
580
|
+
/** Go back to the previous shape in the sequence. */
|
|
581
|
+
prev: () => void;
|
|
582
|
+
/** Jump directly to a specific shape index. */
|
|
583
|
+
goTo: (index: number) => void;
|
|
584
|
+
/** Start autoplay cycling. */
|
|
585
|
+
play: () => void;
|
|
586
|
+
/** Pause autoplay cycling. */
|
|
587
|
+
pause: () => void;
|
|
483
588
|
}
|
|
484
589
|
|
|
485
590
|
/**
|
|
@@ -608,7 +713,7 @@ declare function ShapeSvg({ shape, morphTo, progress, width, height, fill, strok
|
|
|
608
713
|
|
|
609
714
|
interface UseShapeMorphOptions {
|
|
610
715
|
shape: ShapeRef;
|
|
611
|
-
morphTo?: ShapeRef;
|
|
716
|
+
morphTo?: ShapeRef | "auto";
|
|
612
717
|
morphOn?: MorphTrigger;
|
|
613
718
|
morphOptions?: ShapeMorphOptions;
|
|
614
719
|
scrollProgress?: number;
|
|
@@ -621,4 +726,25 @@ interface UseShapeMorphOptions {
|
|
|
621
726
|
*/
|
|
622
727
|
declare function useShapeMorph({ shape, morphTo, morphOn, morphOptions, scrollProgress, width, height, disabled, }: UseShapeMorphOptions): UseShapeMorphResult;
|
|
623
728
|
|
|
624
|
-
|
|
729
|
+
/**
|
|
730
|
+
* useShapeSequenceMorph — React hook for animating through a sequence of shapes.
|
|
731
|
+
*
|
|
732
|
+
* Smoothly morphs through an array of MD3 Expressive shapes, supporting
|
|
733
|
+
* autoplay, manual step-by-step navigation, and looping.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* const { clipPath, next, prev, isPlaying } = useShapeSequenceMorph({
|
|
737
|
+
* shapes: ["circle", "flower", "sunny", "burst"],
|
|
738
|
+
* autoplay: true,
|
|
739
|
+
* interval: 2.5,
|
|
740
|
+
* duration: 0.6,
|
|
741
|
+
* width: 200,
|
|
742
|
+
* height: 200,
|
|
743
|
+
* });
|
|
744
|
+
*
|
|
745
|
+
* return <div style={{ clipPath }}>...</div>;
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
declare function useShapeSequenceMorph({ shapes, duration, interval, autoplay, loop, morphOptions, width, height, disabled, }: UseShapeSequenceMorphOptions): UseShapeSequenceMorphResult;
|
|
749
|
+
|
|
750
|
+
export { CornerRounding, Cubic, type CubicPair, type DoubleMapper, MD3CornerRadius, type MD3CornerRadiusToken, type MD3ShapeFamily, MD3ShapeName, MD3_SHAPE_FAMILIES, MD3_SHAPE_PAIRINGS, type MeasuredCubic, type MeasuredFeature, MeasuredPolygon, Morph, type MorphTrigger, MutableCubic, RoundedPolygon, ShapeIcon, type ShapeIconProps, ShapeMedia, type ShapeMediaProps, ShapeMediaServer, type ShapeMorphOptions, type ShapeRef, ShapeSvg, type ShapeSvgProps, type UseShapeMorphResult, type UseShapeSequenceMorphOptions, type UseShapeSequenceMorphResult, circle, createDoubleMapper, featureMapper, getRecommendedMorphShape, interpolatePath, pill, pillStar, rectangle, star, toClipPath, toSvgPath, useShapeMorph, useShapeSequenceMorph };
|
package/dist/shapes.d.ts
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
import { R as RoundedPolygon, a as CornerRounding, b as Cubic, e as MutableCubic
|
|
2
|
-
export { A as ANGLE_EPSILON, C as CornerFeature, D as DISTANCE_EPSILON, E as EdgeFeature, F as FLOAT_PI, c as Feature, d as MD3Shapes, P as Point, f as PointTransformer, U as UNROUNDED, g as addPoints, h as clockwise, i as convex, j as cornerFeature, k as cornerRounding, l as directionVector, m as distance, n as distanceSquared, o as dividePoint, p as dotProduct, q as edgeFeature, r as
|
|
1
|
+
import { M as MD3ShapeName, R as RoundedPolygon, a as CornerRounding, b as Cubic, e as MutableCubic } from './md3-expressive-shapes-wk_98LJh.js';
|
|
2
|
+
export { A as ANGLE_EPSILON, C as CornerFeature, D as DISTANCE_EPSILON, E as EdgeFeature, F as FLOAT_PI, c as Feature, d as MD3Shapes, P as Point, f as PointTransformer, U as UNROUNDED, g as addPoints, h as clockwise, i as convex, j as cornerFeature, k as cornerRounding, l as directionVector, m as distance, n as distanceSquared, o as dividePoint, p as dotProduct, q as edgeFeature, r as formatCoordinate, s as getDirection, t as getDistance, u as getDistanceSquared, v as interpolate, w as lerpPoint, x as point, y as positiveModulo, z as radialToCartesian, B as rotate90, G as scalePoint, H as square, I as subtractPoints, J as transformFeature, K as transformPoint } from './md3-expressive-shapes-wk_98LJh.js';
|
|
3
3
|
import { ReactNode, CSSProperties } from 'react';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Material Design 3 Expressive — Shape Pairings & Families.
|
|
7
|
+
*
|
|
8
|
+
* Defines natural, expressive bidirectional morph pairings for all 35 MD3 shapes.
|
|
9
|
+
* Organized by design families:
|
|
10
|
+
* - Organic & Floral
|
|
11
|
+
* - Starburst & Explosive
|
|
12
|
+
* - Clover, Gem & Diamond
|
|
13
|
+
* - Cookies & Geometric Multi-sided
|
|
14
|
+
* - Rounded & Architectural
|
|
15
|
+
* - Polygonal & Directional
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Curated bidirectional morph pairings for MD3 Expressive shapes.
|
|
20
|
+
* Each shape is paired with a harmonious companion shape within its design family.
|
|
21
|
+
*/
|
|
22
|
+
declare const MD3_SHAPE_PAIRINGS: Readonly<Record<MD3ShapeName, MD3ShapeName>>;
|
|
23
|
+
/**
|
|
24
|
+
* Shape families grouping shapes by structural and expressive traits.
|
|
25
|
+
*/
|
|
26
|
+
declare const MD3_SHAPE_FAMILIES: {
|
|
27
|
+
readonly organic: readonly ["circle", "flower", "sunny", "verySunny", "bun", "clamshell", "puffy"];
|
|
28
|
+
readonly starburst: readonly ["burst", "softBurst", "boom", "softBoom", "cookie12Sided"];
|
|
29
|
+
readonly cloverAndGems: readonly ["diamond", "puffyDiamond", "clover4Leaf", "clover8Leaf", "gem", "heart"];
|
|
30
|
+
readonly cookiesAndPolygons: readonly ["cookie4Sided", "cookie6Sided", "cookie7Sided", "cookie9Sided", "square"];
|
|
31
|
+
readonly roundedContainers: readonly ["pill", "oval", "arch", "semiCircle", "slanted"];
|
|
32
|
+
readonly directionalAndPixel: readonly ["triangle", "arrow", "pentagon", "fan", "ghostish", "pixelTriangle", "pixelCircle"];
|
|
33
|
+
};
|
|
34
|
+
type MD3ShapeFamily = keyof typeof MD3_SHAPE_FAMILIES;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the recommended morph target shape for a given shape.
|
|
37
|
+
* If a custom RoundedPolygon is passed without a name match, defaults to "circle".
|
|
38
|
+
*
|
|
39
|
+
* @param shape - Shape name or RoundedPolygon instance
|
|
40
|
+
* @returns The recommended companion MD3 shape name
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* getRecommendedMorphShape("flower"); // "sunny"
|
|
44
|
+
* getRecommendedMorphShape("burst"); // "softBurst"
|
|
45
|
+
*/
|
|
46
|
+
declare function getRecommendedMorphShape(shape: MD3ShapeName | RoundedPolygon): MD3ShapeName;
|
|
47
|
+
|
|
5
48
|
/**
|
|
6
49
|
* MD3 Corner Radius Token Scale.
|
|
7
50
|
* Ported from MD3 spec: https://m3.material.io/styles/shape/corner-radius-scale
|
|
@@ -171,6 +214,8 @@ interface MeasuredFeature {
|
|
|
171
214
|
readonly progress: number;
|
|
172
215
|
/** Whether this corner is convex */
|
|
173
216
|
readonly convex: boolean;
|
|
217
|
+
/** Polar angle in radians [-PI, PI] from polygon center to feature midpoint */
|
|
218
|
+
readonly angle: number;
|
|
174
219
|
}
|
|
175
220
|
/**
|
|
176
221
|
* A list of MeasuredCubics covering the full outline of a polygon.
|
|
@@ -209,12 +254,10 @@ declare class MeasuredPolygon {
|
|
|
209
254
|
|
|
210
255
|
/**
|
|
211
256
|
* Creates a DoubleMapper that maps progress values between two polygons
|
|
212
|
-
* based on matching their
|
|
257
|
+
* based on matching their features by optimal cyclic alignment.
|
|
213
258
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* 2. Match each corner in polygon1 to the closest corner of the same type in polygon2
|
|
217
|
-
* 3. Build a piecewise-linear bidirectional mapper
|
|
259
|
+
* Finds the cyclic phase shift that minimizes both perimeter distance
|
|
260
|
+
* and spatial angular difference between features of polygon 1 and polygon 2.
|
|
218
261
|
*
|
|
219
262
|
* @param features1 - Measured features from polygon 1
|
|
220
263
|
* @param features2 - Measured features from polygon 2
|
|
@@ -264,13 +307,30 @@ declare class Morph {
|
|
|
264
307
|
* Returns the interpolated shape at the given progress as a list of Cubics.
|
|
265
308
|
*
|
|
266
309
|
* Note: This allocates a new list. For performance-critical animation loops,
|
|
267
|
-
* use {@link forEachCubic} instead.
|
|
310
|
+
* use {@link toSvgPath} or {@link forEachCubic} instead.
|
|
268
311
|
*
|
|
269
312
|
* @param progress - Value in [0, 1]. 0 = start shape, 1 = end shape.
|
|
270
313
|
* Values outside [0, 1] produce exaggerated shapes (useful for bounce/overshoot).
|
|
271
314
|
* @returns List of interpolated Cubic curves forming the morphed shape
|
|
272
315
|
*/
|
|
273
316
|
asCubics(progress: number): Cubic[];
|
|
317
|
+
/**
|
|
318
|
+
* Returns an SVG path data string for the morphed shape at the given progress.
|
|
319
|
+
* Directly evaluates coordinates without allocating intermediate Cubic objects.
|
|
320
|
+
*
|
|
321
|
+
* @param progress - Value in [0, 1]
|
|
322
|
+
* @param width - Target pixel width (default: 1)
|
|
323
|
+
* @param height - Target pixel height (default: 1)
|
|
324
|
+
*/
|
|
325
|
+
toSvgPath(progress: number, width?: number, height?: number): string;
|
|
326
|
+
/**
|
|
327
|
+
* Returns a CSS clip-path value for the morphed shape at the given progress.
|
|
328
|
+
*
|
|
329
|
+
* @param progress - Value in [0, 1]
|
|
330
|
+
* @param width - Element width in pixels
|
|
331
|
+
* @param height - Element height in pixels
|
|
332
|
+
*/
|
|
333
|
+
toClipPath(progress: number, width: number, height: number): string;
|
|
274
334
|
/**
|
|
275
335
|
* Iterates over the morphed cubics without allocating new Cubic instances.
|
|
276
336
|
* Reuses a single MutableCubic for each callback invocation.
|
|
@@ -408,9 +468,10 @@ interface ShapeMediaProps {
|
|
|
408
468
|
shape: ShapeRef;
|
|
409
469
|
/**
|
|
410
470
|
* The target shape to morph to (optional).
|
|
471
|
+
* If "auto", picks the recommended MD3 shape pairing.
|
|
411
472
|
* When not provided, no morphing animation occurs.
|
|
412
473
|
*/
|
|
413
|
-
morphTo?: ShapeRef;
|
|
474
|
+
morphTo?: ShapeRef | "auto";
|
|
414
475
|
/** Which interaction triggers the morph (default: "hover"). */
|
|
415
476
|
morphOn?: MorphTrigger;
|
|
416
477
|
/** Animation options. */
|
|
@@ -441,8 +502,8 @@ interface ShapeMediaProps {
|
|
|
441
502
|
interface ShapeIconProps {
|
|
442
503
|
/** The base shape. */
|
|
443
504
|
shape: ShapeRef;
|
|
444
|
-
/** Shape to morph to on hover. */
|
|
445
|
-
morphTo?: ShapeRef;
|
|
505
|
+
/** Shape to morph to on hover (or "auto" for recommended pairing). */
|
|
506
|
+
morphTo?: ShapeRef | "auto";
|
|
446
507
|
/** Size in pixels (width = height). Default: 48. */
|
|
447
508
|
size?: number;
|
|
448
509
|
/** Icon content. */
|
|
@@ -478,8 +539,52 @@ interface ShapeSvgProps {
|
|
|
478
539
|
"aria-label"?: string;
|
|
479
540
|
/** Morph progress [0, 1] — set to animate between shape and morphTo. */
|
|
480
541
|
progress?: number;
|
|
481
|
-
/** Target shape for morphed SVG rendering. */
|
|
482
|
-
morphTo?: ShapeRef;
|
|
542
|
+
/** Target shape for morphed SVG rendering (or "auto" for recommended pairing). */
|
|
543
|
+
morphTo?: ShapeRef | "auto";
|
|
544
|
+
}
|
|
545
|
+
/** Options for useShapeSequenceMorph hook. */
|
|
546
|
+
interface UseShapeSequenceMorphOptions {
|
|
547
|
+
/** Array of shapes to morph through in sequence. */
|
|
548
|
+
shapes: ShapeRef[];
|
|
549
|
+
/** Duration per morph in seconds (default: 0.6). */
|
|
550
|
+
duration?: number;
|
|
551
|
+
/** Interval between morph steps in seconds when autoplay is enabled (default: 2.0). */
|
|
552
|
+
interval?: number;
|
|
553
|
+
/** Whether to automatically cycle through shapes (default: false). */
|
|
554
|
+
autoplay?: boolean;
|
|
555
|
+
/** Whether to loop back to the first shape after reaching the end (default: true). */
|
|
556
|
+
loop?: boolean;
|
|
557
|
+
/** Custom animation options. */
|
|
558
|
+
morphOptions?: ShapeMorphOptions;
|
|
559
|
+
/** Output clip-path width in pixels. */
|
|
560
|
+
width: number;
|
|
561
|
+
/** Output clip-path height in pixels. */
|
|
562
|
+
height: number;
|
|
563
|
+
/** Whether the sequence animation is disabled. */
|
|
564
|
+
disabled?: boolean;
|
|
565
|
+
}
|
|
566
|
+
/** Return value of useShapeSequenceMorph hook. */
|
|
567
|
+
interface UseShapeSequenceMorphResult {
|
|
568
|
+
/** CSS clip-path string for the current interpolated frame. */
|
|
569
|
+
clipPath: string;
|
|
570
|
+
/** Index of current base shape in the shapes array. */
|
|
571
|
+
currentIndex: number;
|
|
572
|
+
/** Index of next target shape. */
|
|
573
|
+
nextIndex: number;
|
|
574
|
+
/** Current morph progress between currentIndex and nextIndex [0, 1]. */
|
|
575
|
+
progress: number;
|
|
576
|
+
/** Whether autoplay is currently active. */
|
|
577
|
+
isPlaying: boolean;
|
|
578
|
+
/** Advance to the next shape in the sequence. */
|
|
579
|
+
next: () => void;
|
|
580
|
+
/** Go back to the previous shape in the sequence. */
|
|
581
|
+
prev: () => void;
|
|
582
|
+
/** Jump directly to a specific shape index. */
|
|
583
|
+
goTo: (index: number) => void;
|
|
584
|
+
/** Start autoplay cycling. */
|
|
585
|
+
play: () => void;
|
|
586
|
+
/** Pause autoplay cycling. */
|
|
587
|
+
pause: () => void;
|
|
483
588
|
}
|
|
484
589
|
|
|
485
590
|
/**
|
|
@@ -608,7 +713,7 @@ declare function ShapeSvg({ shape, morphTo, progress, width, height, fill, strok
|
|
|
608
713
|
|
|
609
714
|
interface UseShapeMorphOptions {
|
|
610
715
|
shape: ShapeRef;
|
|
611
|
-
morphTo?: ShapeRef;
|
|
716
|
+
morphTo?: ShapeRef | "auto";
|
|
612
717
|
morphOn?: MorphTrigger;
|
|
613
718
|
morphOptions?: ShapeMorphOptions;
|
|
614
719
|
scrollProgress?: number;
|
|
@@ -621,4 +726,25 @@ interface UseShapeMorphOptions {
|
|
|
621
726
|
*/
|
|
622
727
|
declare function useShapeMorph({ shape, morphTo, morphOn, morphOptions, scrollProgress, width, height, disabled, }: UseShapeMorphOptions): UseShapeMorphResult;
|
|
623
728
|
|
|
624
|
-
|
|
729
|
+
/**
|
|
730
|
+
* useShapeSequenceMorph — React hook for animating through a sequence of shapes.
|
|
731
|
+
*
|
|
732
|
+
* Smoothly morphs through an array of MD3 Expressive shapes, supporting
|
|
733
|
+
* autoplay, manual step-by-step navigation, and looping.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* const { clipPath, next, prev, isPlaying } = useShapeSequenceMorph({
|
|
737
|
+
* shapes: ["circle", "flower", "sunny", "burst"],
|
|
738
|
+
* autoplay: true,
|
|
739
|
+
* interval: 2.5,
|
|
740
|
+
* duration: 0.6,
|
|
741
|
+
* width: 200,
|
|
742
|
+
* height: 200,
|
|
743
|
+
* });
|
|
744
|
+
*
|
|
745
|
+
* return <div style={{ clipPath }}>...</div>;
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
declare function useShapeSequenceMorph({ shapes, duration, interval, autoplay, loop, morphOptions, width, height, disabled, }: UseShapeSequenceMorphOptions): UseShapeSequenceMorphResult;
|
|
749
|
+
|
|
750
|
+
export { CornerRounding, Cubic, type CubicPair, type DoubleMapper, MD3CornerRadius, type MD3CornerRadiusToken, type MD3ShapeFamily, MD3ShapeName, MD3_SHAPE_FAMILIES, MD3_SHAPE_PAIRINGS, type MeasuredCubic, type MeasuredFeature, MeasuredPolygon, Morph, type MorphTrigger, MutableCubic, RoundedPolygon, ShapeIcon, type ShapeIconProps, ShapeMedia, type ShapeMediaProps, ShapeMediaServer, type ShapeMorphOptions, type ShapeRef, ShapeSvg, type ShapeSvgProps, type UseShapeMorphResult, type UseShapeSequenceMorphOptions, type UseShapeSequenceMorphResult, circle, createDoubleMapper, featureMapper, getRecommendedMorphShape, interpolatePath, pill, pillStar, rectangle, star, toClipPath, toSvgPath, useShapeMorph, useShapeSequenceMorph };
|