@castui/cast-ui 4.8.0 → 4.10.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 +78 -1
- package/dist/components/Accordion/Accordion.js +4 -3
- package/dist/components/Backdrop/Backdrop.js +7 -8
- package/dist/components/BottomSheet/BottomSheet.js +12 -14
- package/dist/components/Drawer/Drawer.js +12 -14
- package/dist/components/Progress/Progress.js +5 -4
- package/dist/components/Skeleton/Skeleton.js +11 -13
- package/dist/components/SpeedDial/SpeedDial.js +3 -5
- package/dist/components/Spinner/Spinner.js +6 -5
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useBreakpoint.d.ts +22 -0
- package/dist/hooks/useBreakpoint.js +45 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +23 -2
- package/dist/theme/ThemeContext.d.ts +12 -1
- package/dist/theme/ThemeContext.js +5 -2
- package/dist/theme/applyCastTheme.d.ts +32 -2
- package/dist/theme/applyCastTheme.js +72 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +3 -1
- package/dist/theme/useMotion.d.ts +32 -0
- package/dist/theme/useMotion.js +55 -0
- package/dist/tokens/breakpoints.d.ts +57 -0
- package/dist/tokens/breakpoints.js +92 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +17 -1
- package/dist/tokens/motion.d.ts +196 -0
- package/dist/tokens/motion.js +175 -0
- package/package.json +2 -1
- package/skills/cast-ui-component/SKILL.md +834 -0
- package/skills/cast-ui-docs-site/SKILL.md +114 -0
- package/skills/cast-ui-usage/SKILL.md +587 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Motion tokens — the single source for animation timing across Cast UI.
|
|
4
|
+
*
|
|
5
|
+
* Two layers, mirroring the colour and spacing token system:
|
|
6
|
+
* Primitive raw durations, cubic-bezier easings, spring configs.
|
|
7
|
+
* Semantic named roles (transition / feedback / loop) that components read.
|
|
8
|
+
*
|
|
9
|
+
* Motion is constant across density and colour mode. Density changes spacing
|
|
10
|
+
* only. Easings are real cubic-beziers, so the same numbers map 1:1 to the
|
|
11
|
+
* `motion` variable collection in the Figma kit and to CSS.
|
|
12
|
+
*
|
|
13
|
+
* Components never read a raw number. They read a semantic role through
|
|
14
|
+
* useMotion(), for example motion.transition.standard or motion.loop.spin.
|
|
15
|
+
*
|
|
16
|
+
* Theming: a cast-theme.json can carry a `motion` block (exported by the
|
|
17
|
+
* cast-sync plugin from the kit's `motion` variable collection). ThemeProvider
|
|
18
|
+
* accepts those primitive-level overrides via its `motion` prop and
|
|
19
|
+
* `resolveMotion` rebuilds every semantic role from them, so a brand can
|
|
20
|
+
* re-tune timing with no code changes.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.motionTokens = exports.loop = exports.feedback = exports.transition = exports.spring = exports.easing = exports.easingBezier = exports.cycle = exports.duration = void 0;
|
|
24
|
+
exports.resolveMotion = resolveMotion;
|
|
25
|
+
const react_native_1 = require("react-native");
|
|
26
|
+
/** Primitive: transition durations in ms (state to state). */
|
|
27
|
+
exports.duration = {
|
|
28
|
+
instant: 100,
|
|
29
|
+
fast: 150,
|
|
30
|
+
base: 220,
|
|
31
|
+
slow: 320,
|
|
32
|
+
};
|
|
33
|
+
/** Primitive: loop cycle lengths in ms (continuous, not state to state). */
|
|
34
|
+
exports.cycle = {
|
|
35
|
+
pulse: 700,
|
|
36
|
+
spin: 800,
|
|
37
|
+
sweep: 1200,
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Primitive: easing control points as cubic-bezier [x1, y1, x2, y2].
|
|
41
|
+
* This is the design-side value. The `motion` collection in the Figma kit
|
|
42
|
+
* carries these exact numbers (easing/{name}/{x1,y1,x2,y2}).
|
|
43
|
+
*/
|
|
44
|
+
exports.easingBezier = {
|
|
45
|
+
standard: [0.4, 0, 0.2, 1],
|
|
46
|
+
entrance: [0, 0, 0.2, 1],
|
|
47
|
+
exit: [0.4, 0, 1, 1],
|
|
48
|
+
emphasized: [0.7, -0.4, 0.4, 1.4],
|
|
49
|
+
linear: [0, 0, 1, 1],
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Build a lazy easing function from bezier points. The Easing function is
|
|
53
|
+
* only created when an animation actually runs, so importing the tokens
|
|
54
|
+
* never touches the native Easing API. That keeps the library safe to
|
|
55
|
+
* import in any environment.
|
|
56
|
+
*/
|
|
57
|
+
function lazyEasing(points, linear) {
|
|
58
|
+
let fn = null;
|
|
59
|
+
return (value) => {
|
|
60
|
+
if (!fn) {
|
|
61
|
+
fn = linear ? react_native_1.Easing.linear : react_native_1.Easing.bezier(points[0], points[1], points[2], points[3]);
|
|
62
|
+
}
|
|
63
|
+
return fn(value);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function isLinear(points) {
|
|
67
|
+
return points[0] === 0 && points[1] === 0 && points[2] === 1 && points[3] === 1;
|
|
68
|
+
}
|
|
69
|
+
function buildEasings(beziers) {
|
|
70
|
+
return {
|
|
71
|
+
standard: lazyEasing(beziers.standard, isLinear(beziers.standard)),
|
|
72
|
+
entrance: lazyEasing(beziers.entrance, isLinear(beziers.entrance)),
|
|
73
|
+
exit: lazyEasing(beziers.exit, isLinear(beziers.exit)),
|
|
74
|
+
emphasized: lazyEasing(beziers.emphasized, isLinear(beziers.emphasized)),
|
|
75
|
+
linear: lazyEasing(beziers.linear, isLinear(beziers.linear)),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Primitive: easing as runtime functions (the code-side value). */
|
|
79
|
+
exports.easing = buildEasings(exports.easingBezier);
|
|
80
|
+
/** Primitive: spring configs for Animated.spring. */
|
|
81
|
+
exports.spring = {
|
|
82
|
+
/** Overlay surfaces sliding in (drawer, bottom sheet). */
|
|
83
|
+
overlay: { damping: 22, stiffness: 220, mass: 0.9 },
|
|
84
|
+
};
|
|
85
|
+
function buildRoles(p) {
|
|
86
|
+
return {
|
|
87
|
+
transition: {
|
|
88
|
+
/** General state-to-state fade or slide. Backdrops, overlay fades. */
|
|
89
|
+
standard: { duration: p.duration.base, easing: p.easing.standard },
|
|
90
|
+
/** Something appearing. Decelerates as it lands. */
|
|
91
|
+
enter: { duration: p.duration.fast, easing: p.easing.entrance },
|
|
92
|
+
/** Something leaving. Accelerates as it goes. */
|
|
93
|
+
exit: { duration: p.duration.fast, easing: p.easing.exit },
|
|
94
|
+
/** Expand or collapse. Accordion chevron, height reveals. */
|
|
95
|
+
expand: { duration: p.duration.fast, easing: p.easing.standard },
|
|
96
|
+
},
|
|
97
|
+
feedback: {
|
|
98
|
+
/** Press-down scale on a pressable (reserved for future use). */
|
|
99
|
+
press: { duration: p.duration.instant, easing: p.easing.standard, scale: p.press.scale },
|
|
100
|
+
/** Error shake, e.g. input rejection. amplitude in px (future use). */
|
|
101
|
+
shake: { duration: p.duration.base, easing: p.easing.standard, amplitude: p.shake.amplitude },
|
|
102
|
+
/** Pop-in for a check, badge, or toast (future use). */
|
|
103
|
+
pop: { duration: p.duration.fast, easing: p.easing.emphasized },
|
|
104
|
+
},
|
|
105
|
+
loop: {
|
|
106
|
+
/** Spinner rotation. */
|
|
107
|
+
spin: { duration: p.cycle.spin, easing: p.easing.linear },
|
|
108
|
+
/** Skeleton pulse. Fades opacity between from and to. */
|
|
109
|
+
pulse: { duration: p.cycle.pulse, easing: p.easing.standard, from: p.pulse.from, to: p.pulse.to },
|
|
110
|
+
/** Progress indeterminate sweep. */
|
|
111
|
+
indeterminate: { duration: p.cycle.sweep, easing: p.easing.standard },
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const defaultRoles = buildRoles({
|
|
116
|
+
duration: exports.duration,
|
|
117
|
+
cycle: exports.cycle,
|
|
118
|
+
easing: exports.easing,
|
|
119
|
+
press: { scale: 0.97 },
|
|
120
|
+
shake: { amplitude: 4 },
|
|
121
|
+
pulse: { from: 1, to: 0.5 },
|
|
122
|
+
});
|
|
123
|
+
exports.transition = defaultRoles.transition;
|
|
124
|
+
exports.feedback = defaultRoles.feedback;
|
|
125
|
+
exports.loop = defaultRoles.loop;
|
|
126
|
+
/** The full default motion token set, exposed on the theme as `theme.motion`. */
|
|
127
|
+
exports.motionTokens = {
|
|
128
|
+
duration: exports.duration,
|
|
129
|
+
cycle: exports.cycle,
|
|
130
|
+
easing: exports.easing,
|
|
131
|
+
easingBezier: exports.easingBezier,
|
|
132
|
+
spring: exports.spring,
|
|
133
|
+
transition: exports.transition,
|
|
134
|
+
feedback: exports.feedback,
|
|
135
|
+
loop: exports.loop,
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Resolve a full motion token set from primitive-level overrides.
|
|
139
|
+
* With no overrides this returns the shared default set (no allocation).
|
|
140
|
+
* Semantic roles are always rebuilt from the merged primitives, so a
|
|
141
|
+
* duration override flows into every role that uses it.
|
|
142
|
+
*/
|
|
143
|
+
function resolveMotion(overrides) {
|
|
144
|
+
if (!overrides)
|
|
145
|
+
return exports.motionTokens;
|
|
146
|
+
const mergedDuration = { ...exports.duration, ...(overrides.duration ?? {}) };
|
|
147
|
+
const mergedCycle = { ...exports.cycle, ...(overrides.cycle ?? {}) };
|
|
148
|
+
const mergedBezier = {
|
|
149
|
+
...exports.easingBezier,
|
|
150
|
+
...(overrides.easingBezier ?? {}),
|
|
151
|
+
};
|
|
152
|
+
const mergedEasing = overrides.easingBezier ? buildEasings(mergedBezier) : exports.easing;
|
|
153
|
+
const mergedSpring = {
|
|
154
|
+
overlay: { ...exports.spring.overlay, ...(overrides.spring?.overlay ?? {}) },
|
|
155
|
+
};
|
|
156
|
+
const roles = buildRoles({
|
|
157
|
+
duration: mergedDuration,
|
|
158
|
+
cycle: mergedCycle,
|
|
159
|
+
easing: mergedEasing,
|
|
160
|
+
press: { scale: overrides.feedback?.press?.scale ?? 0.97 },
|
|
161
|
+
shake: { amplitude: overrides.feedback?.shake?.amplitude ?? 4 },
|
|
162
|
+
pulse: {
|
|
163
|
+
from: overrides.loop?.pulse?.from ?? 1,
|
|
164
|
+
to: overrides.loop?.pulse?.to ?? 0.5,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
duration: mergedDuration,
|
|
169
|
+
cycle: mergedCycle,
|
|
170
|
+
easing: mergedEasing,
|
|
171
|
+
easingBezier: mergedBezier,
|
|
172
|
+
spring: mergedSpring,
|
|
173
|
+
...roles,
|
|
174
|
+
};
|
|
175
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@castui/cast-ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "A cross-platform design system for React Native (iOS, Android, Web) with multi-theme support.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"react-dom": "^19.2.4",
|
|
66
66
|
"react-native": "^0.84.0",
|
|
67
67
|
"react-native-web": "^0.21.2",
|
|
68
|
+
"remark-gfm": "^4.0.0",
|
|
68
69
|
"storybook": "^10.2.8",
|
|
69
70
|
"typescript": "^5.9.3"
|
|
70
71
|
},
|