@rootnative/core 0.0.0-alpha.2 → 0.0.0-alpha.20

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 CHANGED
@@ -1,3 +1,9 @@
1
+ <!--
2
+ Absolute URL, not a relative path: this README is the npm package page, and
3
+ npm does not resolve repository-relative image paths.
4
+ -->
5
+ <img src="https://raw.githubusercontent.com/rootnative/ui/main/assets/brand/rootnative-mark.png" alt="" width="88" height="88" />
6
+
1
7
  # @rootnative/core
2
8
 
3
9
  Design-system agnostic theme engine for [RootNative UI](https://github.com/rootnative/ui) — a React Native component library. Ships with Material Design 3 out of the box.
@@ -5,12 +11,18 @@ Design-system agnostic theme engine for [RootNative UI](https://github.com/rootn
5
11
  ## Install
6
12
 
7
13
  ```bash
8
- pnpm add @rootnative/core
14
+ pnpm add @rootnative/core @rootnative/inertia
9
15
  ```
10
16
 
11
- Peer dependencies: `react >=18`, `react-native >=0.72`
17
+ Peer dependencies: `react >=19.2.3`, `react-native >=0.83.0 <0.87.0`, `@rootnative/inertia >=0.0.10 <0.1.0`
18
+
19
+ `@rootnative/inertia` is required — every animation in the library runs on it.
20
+ npm and pnpm install required peers automatically; Yarn classic does not, so add
21
+ it by hand there.
12
22
 
13
- Optional: `@material/material-color-utilities >=0.4` — only needed for `createMaterialTheme`.
23
+ `createMaterialTheme` needs no extra install — its MD3 color engine
24
+ (`@material/material-color-utilities`) is bundled behind the
25
+ `@rootnative/core/create-theme` subpath.
14
26
 
15
27
  ## Quick start (Material Design 3)
16
28
 
@@ -86,7 +98,9 @@ const { lightTheme, darkTheme } = createMaterialTheme('#006A6A')
86
98
  <ThemeProvider theme={lightTheme}>{children}</ThemeProvider>
87
99
  ```
88
100
 
89
- Requires: `npm install @material/material-color-utilities`
101
+ No extra install is needed, and the subpath imports nothing from
102
+ `react-native`, so it also runs in plain Node — print a palette from a script
103
+ or check a theme in CI.
90
104
 
91
105
  ### applyRoundness(roundness)
92
106
 
@@ -112,20 +126,20 @@ material.defaultTopAppBarTokens
112
126
 
113
127
  ### Theme type hierarchy
114
128
 
115
- - `BaseTheme` — Generic base. Colors as `Record<string, string>`, typography as `Record<string, TextStyle>`, plus shape, spacing, stateLayer, elevation, motion.
116
- - `Theme` — MD3 theme. Extends `BaseTheme` with 69 color roles, 15 typography variants, optional `topAppBar` tokens. `MaterialTheme` is an identical alias — use it to disambiguate in multi-design-system codebases.
129
+ - `BaseTheme` — Generic base. Colors as `Record<string, string>`, typography as `Record<string, TypographyToken>`, plus shape, spacing, stateLayer, elevation, motion.
130
+ - `Theme` — MD3 theme. Extends `BaseTheme` with 49 color roles, 30 typography variants (15 base + 15 emphasized), optional `topAppBar` tokens. `MaterialTheme` is an identical alias — use it to disambiguate in multi-design-system codebases.
117
131
 
118
132
  ### Theme structure
119
133
 
120
134
  | Token group | Description |
121
135
  |-------------|-------------|
122
136
  | `colors` | Design-system specific color roles (`Record<string, string>`) |
123
- | `typography` | Type scale variants (`Record<string, TextStyle>`) |
124
- | `shape` | Corner radius tokens (none through full) |
137
+ | `typography` | Type scale variants (`Record<string, TypographyToken>`) |
138
+ | `shape` | `roundness` multiplier plus corner radius tokens (`cornerNone` through `cornerFull`) |
125
139
  | `spacing` | Spacing scale (xs, sm, md, lg, xl) |
126
- | `elevation` | Shadow levels 0–3 |
127
- | `stateLayer` | Opacity values for pressed, focused, hovered, disabled |
128
- | `motion` | Duration and easing tokens |
140
+ | `elevation` | Shadow levels `level0` through `level5` |
141
+ | `stateLayer` | Opacity values: `pressedOpacity`, `focusedOpacity`, `hoveredOpacity`, `draggedOpacity`, `disabledOpacity`, `disabledContainerOpacity` |
142
+ | `motion` | 16 `duration*`, 7 `easing*` and 6 `spring*` tokens |
129
143
 
130
144
  ### Custom MD3 theme
131
145
 
@@ -161,6 +175,14 @@ Returns a value based on the current breakpoint with cascade fallback.
161
175
  const columns = useBreakpointValue({ compact: 1, medium: 2, expanded: 4 })
162
176
  ```
163
177
 
178
+ ### useWindowDimensions()
179
+
180
+ Returns the window size, the same as the `react-native` hook, but safe in a static web export. Use it when a layout needs the raw width or height.
181
+
182
+ ```tsx
183
+ const { width } = useWindowDimensions()
184
+ ```
185
+
164
186
  ## Exports
165
187
 
166
188
  - `ThemeProvider` — Theme context provider (works with any design system, defaults to MD3)
@@ -172,9 +194,11 @@ const columns = useBreakpointValue({ compact: 1, medium: 2, expanded: 4 })
172
194
  - `material` — MD3 preset object (`lightTheme`, `darkTheme`, `defaultTopAppBarTokens`)
173
195
  - `useBreakpoint` / `breakpoints` — Current window size class
174
196
  - `useBreakpointValue` — Responsive values
197
+ - `useWindowDimensions` — Window size that is safe to hydrate from a static export
175
198
  - `lightTheme` / `darkTheme` — Built-in MD3 themes
176
199
  - `defaultTopAppBarTokens` — MD3 top app bar defaults
177
- - `BaseTheme`, `Theme`, `MaterialTheme`, `Colors`, `Typography`, `Shape`, `Spacing`, `Elevation`, `StateLayer`, `Motion`, `TopAppBarTokens`, `IconResolver`, `IconRenderProps`, `ThemeProviderProps`, `Breakpoint`, `BreakpointValues` — Types
200
+ - `motionTransitions` — The named-transition registry mounted by `ThemeProvider`
201
+ - `BaseTheme`, `Theme`, `MaterialTheme`, `Colors`, `Typography`, `TypographyToken`, `FontWeight`, `Shape`, `Spacing`, `Elevation`, `ElevationLevel`, `ShadowOffset`, `StateLayer`, `Motion`, `MotionSpring`, `TopAppBarTokens`, `IconResolver`, `IconRenderProps`, `IconSource`, `ThemeProviderProps`, `Breakpoint`, `BreakpointValues` — Types
178
202
 
179
203
  ## Docs
180
204
 
@@ -1,3 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/theme/topAppBar.ts
2
9
  var defaultTopAppBarTokens = {
3
10
  horizontalPadding: 4,
@@ -13,13 +20,31 @@ var defaultTopAppBarTokens = {
13
20
  };
14
21
 
15
22
  // src/theme/typography.ts
16
- import { Platform } from "react-native";
17
- var defaultFontFamily = Platform.select({
18
- android: "Roboto",
19
- ios: "System",
20
- web: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
21
- default: "System"
22
- });
23
+ var webFontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
24
+ function resolveDefaultFontFamily() {
25
+ var _a;
26
+ if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.EXPO_OS)) {
27
+ return process.env.EXPO_OS === "web" ? webFontFamily : "System";
28
+ }
29
+ try {
30
+ if (typeof __require === "function") {
31
+ const { Platform } = __require("react-native");
32
+ const selected = Platform.select({
33
+ android: "Roboto",
34
+ ios: "System",
35
+ web: webFontFamily,
36
+ default: "System"
37
+ });
38
+ if (selected) return selected;
39
+ }
40
+ } catch {
41
+ }
42
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
43
+ return "System";
44
+ }
45
+ return webFontFamily;
46
+ }
47
+ var defaultFontFamily = resolveDefaultFontFamily();
23
48
  var defaultTypography = {
24
49
  displayLarge: {
25
50
  fontFamily: defaultFontFamily,
@@ -125,6 +150,115 @@ var defaultTypography = {
125
150
  fontWeight: "500",
126
151
  lineHeight: 16,
127
152
  letterSpacing: 0.5
153
+ },
154
+ // MD3 Expressive emphasized styles — androidx TypeScaleTokens.kt v0_103.
155
+ // Same size/line-height as the base style, weight one step heavier
156
+ // (400→500, 500→700); displayLarge/titleMedium/bodyLarge/bodyMedium also
157
+ // adjust tracking per the Compose tokens.
158
+ displayLargeEmphasized: {
159
+ fontFamily: defaultFontFamily,
160
+ fontSize: 57,
161
+ fontWeight: "500",
162
+ lineHeight: 64,
163
+ letterSpacing: 0
164
+ },
165
+ displayMediumEmphasized: {
166
+ fontFamily: defaultFontFamily,
167
+ fontSize: 45,
168
+ fontWeight: "500",
169
+ lineHeight: 52,
170
+ letterSpacing: 0
171
+ },
172
+ displaySmallEmphasized: {
173
+ fontFamily: defaultFontFamily,
174
+ fontSize: 36,
175
+ fontWeight: "500",
176
+ lineHeight: 44,
177
+ letterSpacing: 0
178
+ },
179
+ headlineLargeEmphasized: {
180
+ fontFamily: defaultFontFamily,
181
+ fontSize: 32,
182
+ fontWeight: "500",
183
+ lineHeight: 40,
184
+ letterSpacing: 0
185
+ },
186
+ headlineMediumEmphasized: {
187
+ fontFamily: defaultFontFamily,
188
+ fontSize: 28,
189
+ fontWeight: "500",
190
+ lineHeight: 36,
191
+ letterSpacing: 0
192
+ },
193
+ headlineSmallEmphasized: {
194
+ fontFamily: defaultFontFamily,
195
+ fontSize: 24,
196
+ fontWeight: "500",
197
+ lineHeight: 32,
198
+ letterSpacing: 0
199
+ },
200
+ titleLargeEmphasized: {
201
+ fontFamily: defaultFontFamily,
202
+ fontSize: 22,
203
+ fontWeight: "500",
204
+ lineHeight: 28,
205
+ letterSpacing: 0
206
+ },
207
+ titleMediumEmphasized: {
208
+ fontFamily: defaultFontFamily,
209
+ fontSize: 16,
210
+ fontWeight: "700",
211
+ lineHeight: 24,
212
+ letterSpacing: 0.15
213
+ },
214
+ titleSmallEmphasized: {
215
+ fontFamily: defaultFontFamily,
216
+ fontSize: 14,
217
+ fontWeight: "700",
218
+ lineHeight: 20,
219
+ letterSpacing: 0.1
220
+ },
221
+ bodyLargeEmphasized: {
222
+ fontFamily: defaultFontFamily,
223
+ fontSize: 16,
224
+ fontWeight: "500",
225
+ lineHeight: 24,
226
+ letterSpacing: 0.15
227
+ },
228
+ bodyMediumEmphasized: {
229
+ fontFamily: defaultFontFamily,
230
+ fontSize: 14,
231
+ fontWeight: "500",
232
+ lineHeight: 20,
233
+ letterSpacing: 0.25
234
+ },
235
+ bodySmallEmphasized: {
236
+ fontFamily: defaultFontFamily,
237
+ fontSize: 12,
238
+ fontWeight: "500",
239
+ lineHeight: 16,
240
+ letterSpacing: 0.4
241
+ },
242
+ labelLargeEmphasized: {
243
+ fontFamily: defaultFontFamily,
244
+ fontSize: 14,
245
+ fontWeight: "700",
246
+ lineHeight: 20,
247
+ letterSpacing: 0.1
248
+ },
249
+ labelMediumEmphasized: {
250
+ fontFamily: defaultFontFamily,
251
+ fontSize: 12,
252
+ fontWeight: "700",
253
+ lineHeight: 16,
254
+ letterSpacing: 0.5
255
+ },
256
+ labelSmallEmphasized: {
257
+ fontFamily: defaultFontFamily,
258
+ fontSize: 11,
259
+ fontWeight: "700",
260
+ lineHeight: 16,
261
+ letterSpacing: 0.5
128
262
  }
129
263
  };
130
264
 
@@ -294,8 +428,14 @@ var lightTheme = {
294
428
  easingEmphasized: "cubic-bezier(0.2, 0, 0, 1)",
295
429
  easingEmphasizedAccelerate: "cubic-bezier(0.3, 0, 0.8, 0.15)",
296
430
  easingEmphasizedDecelerate: "cubic-bezier(0.05, 0.7, 0.1, 1)",
297
- springFastSpatial: { tension: 380, friction: 33, mass: 1 },
298
- springDefaultSpatial: { tension: 380, friction: 26, mass: 1 }
431
+ // MD3 Expressive scheme, androidx ExpressiveMotionTokens.kt v0_14_0.
432
+ // tension = Compose stiffness; friction = dampingRatio * 2 * sqrt(tension).
433
+ springFastSpatial: { tension: 800, friction: 33.94, mass: 1 },
434
+ springDefaultSpatial: { tension: 380, friction: 31.19, mass: 1 },
435
+ springSlowSpatial: { tension: 200, friction: 22.63, mass: 1 },
436
+ springFastEffects: { tension: 3800, friction: 123.29, mass: 1 },
437
+ springDefaultEffects: { tension: 1600, friction: 80, mass: 1 },
438
+ springSlowEffects: { tension: 800, friction: 56.57, mass: 1 }
299
439
  }
300
440
  };
301
441
 
@@ -1,4 +1,4 @@
1
- import { T as Theme } from '../types-xq2X5AuN.mjs';
1
+ import { T as Theme } from '../types-NiRbh4dM.mjs';
2
2
 
3
3
  /**
4
4
  * MD3 scheme variant. Each is a spec-defined recipe for deriving the palette