@idealyst/theme 1.2.98 → 1.2.100

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/theme",
3
- "version": "1.2.98",
3
+ "version": "1.2.100",
4
4
  "description": "Theming system for Idealyst Framework",
5
5
  "readme": "README.md",
6
6
  "main": "src/index.ts",
@@ -63,7 +63,7 @@
63
63
  "publish:npm": "npm publish"
64
64
  },
65
65
  "dependencies": {
66
- "@idealyst/tooling": "^1.2.98"
66
+ "@idealyst/tooling": "^1.2.100"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react-native-unistyles": ">=3.0.0"
@@ -35,6 +35,7 @@ export type ComponentName =
35
35
  | 'Divider'
36
36
  | 'DropZone'
37
37
  | 'FilePickerButton'
38
+ | 'Grid'
38
39
  | 'Icon'
39
40
  | 'IconButton'
40
41
  | 'Image'
@@ -26,6 +26,29 @@ function getScreenWidth(): number {
26
26
  return Dimensions.get('window').width;
27
27
  }
28
28
 
29
+ /**
30
+ * Get breakpoints from UnistylesRuntime, falling back to the current theme's
31
+ * breakpoints if the runtime doesn't expose them (Unistyles v3 web).
32
+ */
33
+ function getBreakpointsFromRuntime(): BreakpointsRecord {
34
+ const runtimeBps = UnistylesRuntime.breakpoints as BreakpointsRecord;
35
+ if (runtimeBps && Object.keys(runtimeBps).length > 0) {
36
+ return runtimeBps;
37
+ }
38
+
39
+ // Fallback: read breakpoints from the active theme
40
+ try {
41
+ const theme = UnistylesRuntime.getTheme();
42
+ if (theme && (theme as any).breakpoints && Object.keys((theme as any).breakpoints).length > 0) {
43
+ return (theme as any).breakpoints as BreakpointsRecord;
44
+ }
45
+ } catch {
46
+ // getTheme may throw if no theme is configured
47
+ }
48
+
49
+ return {} as BreakpointsRecord;
50
+ }
51
+
29
52
  /**
30
53
  * Calculate the current breakpoint from screen width.
31
54
  */
@@ -49,7 +72,7 @@ function calculateBreakpoint(
49
72
  * Returns both the current breakpoint and the screen width.
50
73
  */
51
74
  function useBreakpointChange(): { breakpoint: Breakpoint | undefined; screenWidth: number } {
52
- const breakpoints = UnistylesRuntime.breakpoints as BreakpointsRecord;
75
+ const breakpoints = getBreakpointsFromRuntime();
53
76
 
54
77
  const [state, setState] = useState(() => {
55
78
  const width = getScreenWidth();
@@ -62,7 +85,8 @@ function useBreakpointChange(): { breakpoint: Breakpoint | undefined; screenWidt
62
85
  useEffect(() => {
63
86
  const handleResize = () => {
64
87
  const newWidth = getScreenWidth();
65
- const newBreakpoint = calculateBreakpoint(newWidth, breakpoints);
88
+ const bps = getBreakpointsFromRuntime();
89
+ const newBreakpoint = calculateBreakpoint(newWidth, bps);
66
90
 
67
91
  // Only update state if breakpoint changed
68
92
  setState(prev => {
@@ -178,7 +202,7 @@ export function useResponsiveStyle(
178
202
  ): ViewStyle & TextStyle & ImageStyle {
179
203
  // Only re-render when breakpoint changes, not on every pixel
180
204
  const { breakpoint, screenWidth } = useBreakpointChange();
181
- const breakpoints = UnistylesRuntime.breakpoints as BreakpointsRecord;
205
+ const breakpoints = getBreakpointsFromRuntime();
182
206
 
183
207
  // Sort breakpoints by value descending for cascade lookup
184
208
  const sortedBps = useMemo(() =>
@@ -255,7 +279,7 @@ export function useBreakpoint(): Breakpoint | undefined {
255
279
  */
256
280
  export function useBreakpointUp(targetBreakpoint: Breakpoint): boolean {
257
281
  const { screenWidth } = useBreakpointChange();
258
- const breakpoints = UnistylesRuntime.breakpoints as BreakpointsRecord;
282
+ const breakpoints = getBreakpointsFromRuntime();
259
283
  return screenWidth >= breakpoints[targetBreakpoint];
260
284
  }
261
285