onejs-react 0.1.16 → 0.1.17

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": "onejs-react",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "React 19 renderer for OneJS (Unity UI Toolkit)",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -11,6 +11,8 @@ import type {
11
11
  ScrollViewProps,
12
12
  ImageProps,
13
13
  ListViewProps,
14
+ FrostedGlassProps,
15
+ FrostedGlassIntrinsicProps,
14
16
  VisualElement,
15
17
  TextElement,
16
18
  LabelElement,
@@ -20,6 +22,7 @@ import type {
20
22
  SliderElement,
21
23
  ScrollViewElement,
22
24
  ImageElement,
25
+ FrostedGlassElement,
23
26
  } from './types';
24
27
 
25
28
  declare const CS: any
@@ -95,6 +98,7 @@ declare module 'react/jsx-runtime' {
95
98
  'ojs-scrollview': WithRef<ScrollViewProps, ScrollViewElement>;
96
99
  'ojs-image': WithRef<ImageProps, ImageElement>;
97
100
  'ojs-listview': WithRef<ListViewProps, VisualElement>;
101
+ 'ojs-frostedglass': WithRef<FrostedGlassIntrinsicProps, FrostedGlassElement>;
98
102
  }
99
103
  }
100
104
  }
@@ -113,6 +117,7 @@ declare module 'react' {
113
117
  'ojs-scrollview': WithRef<ScrollViewProps, ScrollViewElement>;
114
118
  'ojs-image': WithRef<ImageProps, ImageElement>;
115
119
  'ojs-listview': WithRef<ListViewProps, VisualElement>;
120
+ 'ojs-frostedglass': WithRef<FrostedGlassIntrinsicProps, FrostedGlassElement>;
116
121
  }
117
122
  }
118
123
  }
@@ -174,6 +179,17 @@ export const ListView = forwardRef<VisualElement, ListViewProps>((props, ref) =>
174
179
  });
175
180
  ListView.displayName = 'ListView';
176
181
 
182
+ export const FrostedGlass = forwardRef<FrostedGlassElement, FrostedGlassProps>(({ blur, tint, ...rest }, ref) => {
183
+ const parsedTint = useMemo(() => {
184
+ if (!tint) return new CS.UnityEngine.Color(1, 1, 1, 0.15)
185
+ const m = tint.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+))?\s*\)/)
186
+ if (m) return new CS.UnityEngine.Color(+m[1] / 255, +m[2] / 255, +m[3] / 255, m[4] != null ? +m[4] : 1)
187
+ return new CS.UnityEngine.Color(1, 1, 1, 0.15)
188
+ }, [tint])
189
+ return <ojs-frostedglass ref={ref} blurRadius={blur ?? 10} tintColor={parsedTint} {...rest} />;
190
+ });
191
+ FrostedGlass.displayName = 'FrostedGlass';
192
+
177
193
  /**
178
194
  * Create a typed React component for a registered custom element.
179
195
  * Use with `registerElement()` to add custom C# VisualElement types to React.
@@ -60,6 +60,7 @@ declare const CS: {
60
60
  };
61
61
  ScaleMode: CSEnum;
62
62
  Rect: new (...args: any[]) => any;
63
+ Color: new (r: number, g: number, b: number, a: number) => any;
63
64
  };
64
65
  OneJS: {
65
66
  GPU: {
@@ -68,6 +69,7 @@ declare const CS: {
68
69
  SetElementBackgroundFromObject: (element: CSObject, obj: CSObject) => void;
69
70
  ClearElementBackgroundImage: (element: CSObject) => void;
70
71
  };
72
+ FrostedGlassElement: new () => CSObject;
71
73
  };
72
74
  };
73
75
  };
@@ -173,6 +175,7 @@ const TYPE_MAP: Record<string, () => CSObject> = {
173
175
  'ojs-scrollview': () => new CS.UnityEngine.UIElements.ScrollView(),
174
176
  'ojs-image': () => new CS.UnityEngine.UIElements.Image(),
175
177
  'ojs-listview': () => new CS.UnityEngine.UIElements.ListView(),
178
+ 'ojs-frostedglass': () => new CS.OneJS.GPU.FrostedGlassElement(),
176
179
  };
177
180
 
178
181
  // Built-in types with specific prop handling in applyComponentProps
@@ -800,6 +803,10 @@ function applyComponentProps(element: CSObject, type: string, props: Record<stri
800
803
  applyScrollViewProps(element as CSScrollView, props);
801
804
  } else if (type === 'ojs-listview') {
802
805
  applyListViewProps(element as CSListView, props);
806
+ } else if (type === 'ojs-frostedglass') {
807
+ const el = element as any;
808
+ if (props.blurRadius !== undefined) el.BlurRadius = props.blurRadius;
809
+ if (props.tintColor !== undefined) el.TintColor = props.tintColor;
803
810
  }
804
811
  }
805
812
 
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export {
10
10
  ScrollView,
11
11
  Image,
12
12
  ListView,
13
+ FrostedGlass,
13
14
  clearImageCache,
14
15
  createComponent,
15
16
  } from './components';
@@ -83,6 +84,7 @@ export type {
83
84
  ScrollViewProps,
84
85
  ImageProps,
85
86
  ListViewProps,
87
+ FrostedGlassProps,
86
88
  // Container type for render()
87
89
  RenderContainer,
88
90
  // Element types for refs
@@ -95,6 +97,7 @@ export type {
95
97
  SliderElement,
96
98
  ScrollViewElement,
97
99
  ImageElement,
100
+ FrostedGlassElement,
98
101
  // Vector drawing types
99
102
  Vector2,
100
103
  Color,
package/src/types.ts CHANGED
@@ -674,6 +674,24 @@ export interface ImageElement extends VisualElement {
674
674
 
675
675
  // ListView uses Unity's virtualization callbacks directly
676
676
  // This is intentionally imperative - ListView manages its own element recycling
677
+ export interface FrostedGlassProps extends BaseProps {
678
+ /** Blur radius in screen pixels. Higher = more blurry. Default: 10. */
679
+ blur?: number;
680
+ /** Tint color overlaid on the blurred background (CSS color string). */
681
+ tint?: string;
682
+ }
683
+
684
+ /** Internal props for the ojs-frostedglass intrinsic element */
685
+ export interface FrostedGlassIntrinsicProps extends BaseProps {
686
+ blurRadius?: number;
687
+ tintColor?: any;
688
+ }
689
+
690
+ export interface FrostedGlassElement extends VisualElement {
691
+ blurRadius: number;
692
+ tintColor: any;
693
+ }
694
+
677
695
  export interface ListViewProps extends BaseProps {
678
696
  // Data source - the array of items to display
679
697
  itemsSource: unknown[];