fancy-ui-react 0.3.0 → 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/README.md +52 -19
- package/dist/components/animated-beam/AnimatedBeam.d.ts +47 -11
- package/dist/components/animated-beam/AnimatedBeam.js +293 -118
- package/dist/components/animated-tooltip/AnimatedTooltip.d.ts +10 -1
- package/dist/components/animated-tooltip/AnimatedTooltip.js +170 -101
- package/dist/components/bento-grid/BentoFrame.d.ts +16 -0
- package/dist/components/bento-grid/BentoFrame.js +28 -0
- package/dist/components/bento-grid/BentoGrid.d.ts +5 -1
- package/dist/components/bento-grid/BentoGrid.js +71 -2
- package/dist/components/bento-grid/BentoGridCard.js +34 -26
- package/dist/components/bento-grid/BentoGridItem.js +10 -10
- package/dist/components/border-beam/BorderBeam.d.ts +55 -10
- package/dist/components/border-beam/BorderBeam.js +93 -16
- package/dist/components/compare/Compare.d.ts +32 -8
- package/dist/components/compare/Compare.js +213 -95
- package/dist/components/container-scroll/ContainerScroll.d.ts +26 -4
- package/dist/components/container-scroll/ContainerScroll.js +88 -49
- package/dist/components/dock/Dock.d.ts +10 -7
- package/dist/components/dock/Dock.js +76 -31
- package/dist/components/dock/DockIcon.d.ts +14 -3
- package/dist/components/dock/DockIcon.js +23 -19
- package/dist/components/dock/DockSeparator.d.ts +4 -1
- package/dist/components/dock/DockSeparator.js +5 -2
- package/dist/components/dock/types.d.ts +13 -6
- package/dist/components/dropdown-menu/menu-shared.d.ts +11 -8
- package/dist/components/editorial-engine/engine.js +1 -14
- package/dist/components/fireworks-hdr/webgl2-renderer.js +0 -19
- package/dist/components/fireworks-hdr/webgpu-renderer.js +3 -22
- package/dist/components/flip-card/FlipCard.d.ts +42 -1
- package/dist/components/flip-card/FlipCard.js +178 -25
- package/dist/components/flip-card/index.d.ts +1 -1
- package/dist/components/fluid-cursor/FluidCursor.js +5 -4
- package/dist/components/fluid-cursor/dev.d.ts +1 -0
- package/dist/components/fluid-cursor/dev.js +8 -0
- package/dist/components/fluid-cursor/fluid-shared.d.ts +0 -2
- package/dist/components/fluid-cursor/fluid-shared.js +0 -2
- package/dist/components/fluid-cursor/webgpu-engine.js +10 -24
- package/dist/components/glow-border/GlowBorder.d.ts +41 -1
- package/dist/components/glow-border/GlowBorder.js +96 -16
- package/dist/components/glow-border/index.d.ts +2 -2
- package/dist/components/gradient-button/GradientButton.d.ts +10 -5
- package/dist/components/gradient-button/GradientButton.js +25 -18
- package/dist/components/image-trail-cursor/ImageTrailCursor.js +1 -0
- package/dist/components/image-trail-cursor/trail-variants.d.ts +37 -1
- package/dist/components/image-trail-cursor/trail-variants.js +331 -8
- package/dist/components/interactive-hover-button/InteractiveHoverButton.js +30 -35
- package/dist/components/marquee/Marquee.d.ts +7 -3
- package/dist/components/marquee/Marquee.js +134 -2
- package/dist/components/marquee/ReviewCard.d.ts +2 -1
- package/dist/components/marquee/ReviewCard.js +20 -9
- package/dist/components/meteors/Meteors.d.ts +32 -10
- package/dist/components/meteors/Meteors.js +53 -20
- package/dist/components/mosaic-glow/mosaic-glow-core.d.ts +98 -10
- package/dist/components/neon-border/NeonBorder.d.ts +24 -5
- package/dist/components/neon-border/NeonBorder.js +37 -7
- package/dist/components/pagination/Pagination.js +220 -82
- package/dist/components/rainbow-button/RainbowButton.js +13 -5
- package/dist/components/ripple-button/RippleButton.d.ts +20 -1
- package/dist/components/ripple-button/RippleButton.js +44 -21
- package/dist/components/shimmer-button/ShimmerButton.d.ts +5 -5
- package/dist/components/shimmer-button/ShimmerButton.js +17 -19
- package/dist/components/smooth-cursor/SmoothCursor.d.ts +13 -9
- package/dist/components/smooth-cursor/SmoothCursor.js +114 -163
- package/dist/components/smooth-cursor/smooth-cursor-core.d.ts +85 -0
- package/dist/components/smooth-cursor/smooth-cursor-core.js +327 -0
- package/dist/components/stepper/Step.js +32 -19
- package/dist/components/stepper/Stepper.js +18 -2
- package/dist/components/stepper/types.d.ts +13 -0
- package/dist/components/timeline/Timeline.d.ts +8 -1
- package/dist/components/timeline/Timeline.js +165 -76
- package/dist/index.js +2 -1
- package/dist/internals/markdown.d.ts +5 -0
- package/dist/internals/motion/haptics.d.ts +0 -4
- package/dist/internals/motion/presence-core.d.ts +59 -0
- package/dist/internals/motion/presence-core.js +162 -0
- package/dist/internals/motion/presence.d.ts +2 -4
- package/dist/internals/motion/presence.js +1 -156
- package/dist/internals/motion/raf.d.ts +1 -1
- package/dist/internals/motion/stagger.d.ts +3 -4
- package/dist/internals/motion/tokens.js +4 -0
- package/dist/internals/motion/transitions.d.ts +17 -17
- package/dist/internals/motion/types.d.ts +6 -7
- package/dist/internals/relative-time.d.ts +1 -1
- package/dist/styles.css +3470 -203
- package/package.json +18 -2
- package/dist/components/fireworks-hdr/webgpu-types.d.ts +0 -159
|
@@ -3,162 +3,7 @@ import { useState } from "react";
|
|
|
3
3
|
import { useConstant, useIsomorphicLayoutEffect } from "../dom/ssr.js";
|
|
4
4
|
import { useEventCallback } from "../dom/use-event-callback.js";
|
|
5
5
|
import { useLiveRef } from "../dom/use-live-ref.js";
|
|
6
|
-
import {
|
|
7
|
-
const DEFAULT_KEY = "default";
|
|
8
|
-
function createPresenceCore(deps) {
|
|
9
|
-
const slots = /* @__PURE__ */ new Map();
|
|
10
|
-
let leg = null;
|
|
11
|
-
let starting = false;
|
|
12
|
-
let inertApplied = false;
|
|
13
|
-
let firstRun = true;
|
|
14
|
-
function ensureSlot(key) {
|
|
15
|
-
const existing = slots.get(key);
|
|
16
|
-
if (existing) return existing;
|
|
17
|
-
const slot = {
|
|
18
|
-
node: null,
|
|
19
|
-
buildSpec: null,
|
|
20
|
-
run: void 0,
|
|
21
|
-
legTo: null,
|
|
22
|
-
finished: false,
|
|
23
|
-
pendingLeg: null,
|
|
24
|
-
// Block body, never a concise arrow: React 19 reads a returned value
|
|
25
|
-
// as a cleanup function (convention C-3).
|
|
26
|
-
ref: (node) => {
|
|
27
|
-
if (node) {
|
|
28
|
-
slot.node = node;
|
|
29
|
-
const pending = slot.pendingLeg;
|
|
30
|
-
slot.pendingLeg = null;
|
|
31
|
-
if (pending !== null && leg === pending) startSlot(slot, pending);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
slot.pendingLeg = leg !== null && !slot.finished ? leg : null;
|
|
35
|
-
slot.run?.abort();
|
|
36
|
-
slot.run = void 0;
|
|
37
|
-
slot.node = null;
|
|
38
|
-
slot.legTo = null;
|
|
39
|
-
slot.finished = false;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
slots.set(key, slot);
|
|
43
|
-
return slot;
|
|
44
|
-
}
|
|
45
|
-
function register(a, b, c) {
|
|
46
|
-
const keyed = typeof a === "string";
|
|
47
|
-
const slot = ensureSlot(keyed ? a : DEFAULT_KEY);
|
|
48
|
-
const transition = keyed ? b : a;
|
|
49
|
-
const params = keyed ? c : b;
|
|
50
|
-
slot.buildSpec = (node, entering) => {
|
|
51
|
-
const resolved = typeof params === "function" ? params(entering) : params;
|
|
52
|
-
return transition(node, resolved, { direction: entering ? "in" : "out" });
|
|
53
|
-
};
|
|
54
|
-
return slot.ref;
|
|
55
|
-
}
|
|
56
|
-
function startSlot(slot, to) {
|
|
57
|
-
const node = slot.node;
|
|
58
|
-
const buildSpec = slot.buildSpec;
|
|
59
|
-
if (!node || !buildSpec) return;
|
|
60
|
-
const counterpart = slot.run;
|
|
61
|
-
slot.legTo = to;
|
|
62
|
-
slot.finished = false;
|
|
63
|
-
slot.run = void 0;
|
|
64
|
-
const handle = { current: void 0 };
|
|
65
|
-
const run = runTransition(node, buildSpec(node, to === 1), to, counterpart, () => {
|
|
66
|
-
slot.finished = true;
|
|
67
|
-
if (to === 1) {
|
|
68
|
-
handle.current?.abort();
|
|
69
|
-
slot.run = void 0;
|
|
70
|
-
}
|
|
71
|
-
settle(to);
|
|
72
|
-
});
|
|
73
|
-
handle.current = run;
|
|
74
|
-
if (!slot.finished) slot.run = run;
|
|
75
|
-
}
|
|
76
|
-
function startLegs(to) {
|
|
77
|
-
starting = true;
|
|
78
|
-
try {
|
|
79
|
-
for (const slot of slots.values()) {
|
|
80
|
-
if (!slot.node) continue;
|
|
81
|
-
if (slot.legTo === to) continue;
|
|
82
|
-
startSlot(slot, to);
|
|
83
|
-
}
|
|
84
|
-
} finally {
|
|
85
|
-
starting = false;
|
|
86
|
-
}
|
|
87
|
-
settle(to);
|
|
88
|
-
}
|
|
89
|
-
function settle(to) {
|
|
90
|
-
if (starting) return;
|
|
91
|
-
if (leg !== to) return;
|
|
92
|
-
for (const slot of slots.values()) {
|
|
93
|
-
if (!slot.node) continue;
|
|
94
|
-
if (slot.legTo !== to || !slot.finished) return;
|
|
95
|
-
}
|
|
96
|
-
leg = null;
|
|
97
|
-
if (to === 1) {
|
|
98
|
-
deps.setState("open");
|
|
99
|
-
deps.onEnterEnd();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
deps.setMounted(false);
|
|
103
|
-
deps.setState("open");
|
|
104
|
-
deps.onExitEnd();
|
|
105
|
-
}
|
|
106
|
-
function beginEnter() {
|
|
107
|
-
leg = 1;
|
|
108
|
-
if (inertApplied) {
|
|
109
|
-
inertApplied = false;
|
|
110
|
-
for (const slot of slots.values()) {
|
|
111
|
-
slot.node?.toggleAttribute("inert", false);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
deps.setState("opening");
|
|
115
|
-
deps.onEnterStart();
|
|
116
|
-
}
|
|
117
|
-
function beginExit() {
|
|
118
|
-
leg = 0;
|
|
119
|
-
deps.onExitStart();
|
|
120
|
-
deps.setState("closing");
|
|
121
|
-
if (deps.inertRef.current) {
|
|
122
|
-
inertApplied = true;
|
|
123
|
-
for (const slot of slots.values()) {
|
|
124
|
-
slot.node?.toggleAttribute("inert", true);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function sync(open, mounted, appear) {
|
|
129
|
-
const first = firstRun;
|
|
130
|
-
firstRun = false;
|
|
131
|
-
if (open) {
|
|
132
|
-
if (!mounted) {
|
|
133
|
-
beginEnter();
|
|
134
|
-
deps.setMounted(true);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (first && !appear) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (leg !== 1) beginEnter();
|
|
141
|
-
startLegs(1);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (!mounted) return;
|
|
145
|
-
if (leg !== 0) beginExit();
|
|
146
|
-
startLegs(0);
|
|
147
|
-
}
|
|
148
|
-
function teardown() {
|
|
149
|
-
for (const slot of slots.values()) {
|
|
150
|
-
slot.run?.abort();
|
|
151
|
-
slot.run = void 0;
|
|
152
|
-
slot.legTo = null;
|
|
153
|
-
slot.finished = false;
|
|
154
|
-
slot.pendingLeg = null;
|
|
155
|
-
}
|
|
156
|
-
leg = null;
|
|
157
|
-
inertApplied = false;
|
|
158
|
-
firstRun = true;
|
|
159
|
-
}
|
|
160
|
-
return { register, sync, teardown };
|
|
161
|
-
}
|
|
6
|
+
import { createPresenceCore } from "./presence-core.js";
|
|
162
7
|
function usePresence(open, options = {}) {
|
|
163
8
|
const { appear = false, inert = true } = options;
|
|
164
9
|
const [mounted, setMounted] = useState(open);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Trailing-edge rAF throttle, generalized from the hand-rolled
|
|
3
3
|
* `if (id) cancelAnimationFrame(id); id = requestAnimationFrame(...)` pattern
|
|
4
|
-
* already duplicated in this
|
|
4
|
+
* already duplicated in this repo (GlowingEffect's pointer sampling). Magnetic
|
|
5
5
|
* (pointermove) and ScrollProgress (scroll/resize) both need "run at most
|
|
6
6
|
* once per frame, with the freshest data" — this is that primitive, pulled
|
|
7
7
|
* out once instead of re-hand-rolled a third and fourth time.
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
* so "stagger from the center" or "stagger from the last item" means the
|
|
5
5
|
* same thing everywhere in this family.
|
|
6
6
|
*
|
|
7
|
-
* Deliberately pure: no DOM, no timers, no side effects
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* — this file never schedules anything itself.
|
|
7
|
+
* Deliberately pure: no DOM, no timers, no side effects. A caller is expected
|
|
8
|
+
* to call this once per item and write the result into a CSS custom property
|
|
9
|
+
* or a transition `delay` param — this file never schedules anything itself.
|
|
11
10
|
*/
|
|
12
11
|
export type StaggerFrom = "first" | "last" | "center" | number;
|
|
13
12
|
/**
|
|
@@ -7,11 +7,15 @@ const DURATIONS = {
|
|
|
7
7
|
exit: 200,
|
|
8
8
|
entrance: 600
|
|
9
9
|
};
|
|
10
|
+
const EASINGS = {
|
|
11
|
+
out: "cubic-bezier(0.16, 1, 0.3, 1)"
|
|
12
|
+
};
|
|
10
13
|
const JS_EASINGS = { out: expoOut, in: expoIn };
|
|
11
14
|
const STAGGERS = { char: 15 };
|
|
12
15
|
const STAGGER_CAPS = { text: 200, item: 600 };
|
|
13
16
|
export {
|
|
14
17
|
DURATIONS,
|
|
18
|
+
EASINGS,
|
|
15
19
|
JS_EASINGS,
|
|
16
20
|
STAGGERS,
|
|
17
21
|
STAGGER_CAPS
|
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
*
|
|
6
6
|
* How the `easing` param actually reaches the screen is worth spelling out,
|
|
7
7
|
* because it is easy to assume `css(t, u)` needs to apply the curve itself:
|
|
8
|
-
* it does not.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* it does not. Whichever runtime plays the transition samples every keyframe
|
|
9
|
+
* as `t = t1 + delta * easing(i / n)` BEFORE `css(t, 1 - t)` is ever called —
|
|
10
|
+
* so the `t`/`u` a `css()` function receives are ALREADY eased, and the curve
|
|
11
|
+
* lives entirely in the sample POSITIONS rather than in a WAAPI `easing`
|
|
12
|
+
* option. `preset()` below does the same as the framework built-ins it
|
|
13
|
+
* mirrors: `easing` is resolved once and returned as-is on the spec; `cssFor`
|
|
14
|
+
* never touches it.
|
|
15
15
|
*/
|
|
16
16
|
import { type PresetName } from "./presets.js";
|
|
17
17
|
/**
|
|
18
18
|
* One transition's timing plus its per-frame CSS. Structurally identical to
|
|
19
|
-
* the
|
|
20
|
-
* so this
|
|
21
|
-
* omitted: nothing in this library uses it.
|
|
19
|
+
* the `TransitionConfig` a framework transition runtime consumes, declared
|
|
20
|
+
* locally so this shared core takes no dependency on any one framework's
|
|
21
|
+
* types. The `tick` field is omitted: nothing in this library uses it.
|
|
22
22
|
*/
|
|
23
23
|
export interface TransitionSpec {
|
|
24
24
|
delay: number;
|
|
@@ -31,7 +31,7 @@ export interface TransitionSpec {
|
|
|
31
31
|
}
|
|
32
32
|
export type TransitionDirection = "in" | "out" | "both";
|
|
33
33
|
/** A transition function's shape, preserved exactly — including the unused
|
|
34
|
-
* first parameter, so the
|
|
34
|
+
* first parameter, so the colocated test files transpose 1:1. */
|
|
35
35
|
export type TransitionFn<P = unknown> = (node: Element, params?: P, options?: {
|
|
36
36
|
direction: TransitionDirection;
|
|
37
37
|
}) => TransitionSpec;
|
|
@@ -46,12 +46,12 @@ export interface PresetParams {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Returns a transition function for the named preset, ready to hand to
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* guess at that asymmetry).
|
|
49
|
+
* whichever presence/transition mechanism the host framework provides.
|
|
50
|
+
* Resolution order for every param is caller-supplied `params` → this
|
|
51
|
+
* function's own defaults; `duration` defaults to `DURATIONS.base` and
|
|
52
|
+
* `distance` to 16px regardless of direction (a component that wants a
|
|
53
|
+
* shorter/half-distance EXIT, like Presence, passes those explicitly in its
|
|
54
|
+
* own `out`-side params — this factory does not guess at that asymmetry).
|
|
55
55
|
*
|
|
56
56
|
* `easing` is the one default that DOES read `options.direction`: with no
|
|
57
57
|
* explicit `params.easing`, an `"out"`-direction instance (an exit-only
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type-only aggregate of the shared unions component prop interfaces need to
|
|
3
|
-
* reference. Re-exported from the package barrel
|
|
4
|
-
* `export type
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the ten components' barrels).
|
|
3
|
+
* reference. Re-exported from the package barrel with a wholesale
|
|
4
|
+
* `export type *` (the barrel's edit, not this file's) so a component's own
|
|
5
|
+
* `<ComponentName>Props` can `import type` these from one place instead of
|
|
6
|
+
* reaching into individual foundation files — and, per the common contract,
|
|
7
|
+
* so a component's `index.ts` barrel never has to re-export a type itself
|
|
8
|
+
* (which would risk a name collision across the ten components' barrels).
|
|
10
9
|
*
|
|
11
10
|
* `verbatimModuleSyntax` (this package's tsconfig) means every line here is
|
|
12
11
|
* `export type` and compiles to nothing at runtime — this module has zero
|
|
@@ -8,7 +8,7 @@ export interface RelativeTimeOptions {
|
|
|
8
8
|
locale?: string;
|
|
9
9
|
/**
|
|
10
10
|
* Epoch ms to measure against. Defaults to `Date.now()`. A non-finite
|
|
11
|
-
* value (
|
|
11
|
+
* value (a shared clock's "not started yet" sentinel) yields `""`.
|
|
12
12
|
*/
|
|
13
13
|
now?: number;
|
|
14
14
|
/** Defaults to `"auto"`, which yields idiomatic words ("now", "yesterday"). */
|