glacia-native 0.0.0-stage → 0.3.1

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.
Files changed (39) hide show
  1. package/LICENSE +27 -0
  2. package/lib/module/Button.js +37 -0
  3. package/lib/module/Card.js +60 -0
  4. package/lib/module/Glass.js +9 -0
  5. package/lib/module/SegmentedControl.js +46 -0
  6. package/lib/module/Slider.js +49 -0
  7. package/lib/module/Switch.js +42 -0
  8. package/lib/module/TabBar.js +47 -0
  9. package/lib/module/Tabs.js +59 -0
  10. package/lib/module/index.js +31 -0
  11. package/lib/module/internal/GlassView.js +30 -0
  12. package/lib/module/internal/fallback.js +23 -0
  13. package/lib/module/internal/tokens.js +36 -0
  14. package/lib/typescript/Button.d.ts +14 -0
  15. package/lib/typescript/Card.d.ts +31 -0
  16. package/lib/typescript/Glass.d.ts +5 -0
  17. package/lib/typescript/SegmentedControl.d.ts +9 -0
  18. package/lib/typescript/Slider.d.ts +13 -0
  19. package/lib/typescript/Switch.d.ts +10 -0
  20. package/lib/typescript/TabBar.d.ts +15 -0
  21. package/lib/typescript/Tabs.d.ts +28 -0
  22. package/lib/typescript/index.d.ts +10 -0
  23. package/lib/typescript/internal/GlassView.d.ts +15 -0
  24. package/lib/typescript/internal/fallback.d.ts +9 -0
  25. package/lib/typescript/internal/tokens.d.ts +44 -0
  26. package/package.json +41 -3
  27. package/src/Button.tsx +87 -0
  28. package/src/Card.tsx +120 -0
  29. package/src/Glass.tsx +24 -0
  30. package/src/SegmentedControl.tsx +79 -0
  31. package/src/Slider.tsx +97 -0
  32. package/src/Switch.tsx +80 -0
  33. package/src/TabBar.tsx +87 -0
  34. package/src/Tabs.tsx +108 -0
  35. package/src/index.ts +22 -0
  36. package/src/internal/GlassView.tsx +71 -0
  37. package/src/internal/fallback.tsx +46 -0
  38. package/src/internal/tokens.ts +36 -0
  39. package/README.md +0 -3
package/src/TabBar.tsx ADDED
@@ -0,0 +1,87 @@
1
+ import { useState, forwardRef, type ReactNode } from "react";
2
+ import { Glass } from "./Glass";
3
+ import { colors, radii } from "./internal/tokens";
4
+
5
+ export interface TabBarItem {
6
+ id: string;
7
+ label: string;
8
+ icon?: ReactNode;
9
+ }
10
+
11
+ export interface TabBarProps {
12
+ items: TabBarItem[];
13
+ activeId?: string;
14
+ defaultActiveId?: string;
15
+ onTabChange?: (id: string) => void;
16
+ style?: any;
17
+ isDark?: boolean;
18
+ }
19
+
20
+ export const TabBar = forwardRef<any, TabBarProps>(function TabBar(
21
+ {
22
+ items,
23
+ activeId: activeProp,
24
+ defaultActiveId,
25
+ onTabChange,
26
+ style,
27
+ isDark = false,
28
+ ...props
29
+ },
30
+ ref,
31
+ ) {
32
+ const [internalId, setInternalId] = useState(defaultActiveId || items[0]?.id || "");
33
+ const activeId = activeProp !== undefined ? activeProp : internalId;
34
+ const themeColors = isDark ? colors.dark : colors.light;
35
+
36
+ const handleSelect = (id: string) => {
37
+ if (activeProp === undefined) {
38
+ setInternalId(id);
39
+ }
40
+ onTabChange?.(id);
41
+ };
42
+
43
+ const barStyle = {
44
+ position: "relative" as const,
45
+ display: "flex" as const,
46
+ flexDirection: "row" as const,
47
+ alignItems: "center" as const,
48
+ justifyContent: "space-around" as const,
49
+ height: 52,
50
+ paddingHorizontal: 8,
51
+ borderRadius: radii.xl,
52
+ ...style,
53
+ };
54
+
55
+ return (
56
+ <Glass ref={ref} effect="regular" style={barStyle} {...props}>
57
+ {items.map((tab) => {
58
+ const isActive = tab.id === activeId;
59
+ return (
60
+ <button
61
+ key={tab.id}
62
+ type="button"
63
+ onClick={() => handleSelect(tab.id)}
64
+ style={{
65
+ flex: 1,
66
+ display: "flex",
67
+ flexDirection: "column",
68
+ alignItems: "center",
69
+ justifyContent: "center",
70
+ gap: 2,
71
+ padding: "4px 8px",
72
+ border: 0,
73
+ background: "transparent",
74
+ color: isActive ? themeColors.fill : themeColors.muted,
75
+ fontSize: 11,
76
+ fontWeight: isActive ? 600 : 500,
77
+ cursor: "pointer",
78
+ }}
79
+ >
80
+ {tab.icon && <span style={{ fontSize: 18 }}>{tab.icon}</span>}
81
+ <span>{tab.label}</span>
82
+ </button>
83
+ );
84
+ })}
85
+ </Glass>
86
+ );
87
+ });
package/src/Tabs.tsx ADDED
@@ -0,0 +1,108 @@
1
+ import { useState, forwardRef, type ReactNode } from "react";
2
+ import { Glass } from "./Glass";
3
+ import { colors, radii } from "./internal/tokens";
4
+
5
+ export interface TabItem {
6
+ /** Stable identifier for the tab. */
7
+ id: string;
8
+ /** What the tab reads. */
9
+ label: string;
10
+ /** An optional icon element drawn before the label. */
11
+ icon?: ReactNode;
12
+ }
13
+
14
+ export interface TabsProps {
15
+ items: TabItem[];
16
+ /** The active tab's `id`. Leave undefined and the component keeps it itself. */
17
+ activeId?: string;
18
+ defaultActiveId?: string;
19
+ onTabChange?: (id: string) => void;
20
+ style?: any;
21
+ isDark?: boolean;
22
+ }
23
+
24
+ /**
25
+ * A row of tabs on a glass rail, in the reference implementation's style: the
26
+ * selected tab is a lifted inner pane rather than a flat highlight.
27
+ *
28
+ * Follows the same conventions as the other native components — no browser
29
+ * APIs and no CSS — so it renders on iOS and Android. On iOS 26 the rail is
30
+ * real glass through `@callstack/liquid-glass`; elsewhere it is a translucent
31
+ * tint of the same shape with no layout shift.
32
+ */
33
+ export const Tabs = forwardRef<any, TabsProps>(function Tabs(
34
+ {
35
+ items,
36
+ activeId: activeProp,
37
+ defaultActiveId,
38
+ onTabChange,
39
+ style,
40
+ isDark = false,
41
+ ...props
42
+ },
43
+ ref,
44
+ ) {
45
+ const [internalId, setInternalId] = useState(defaultActiveId || items[0]?.id || "");
46
+ const activeId = activeProp !== undefined ? activeProp : internalId;
47
+ const themeColors = isDark ? colors.dark : colors.light;
48
+
49
+ const handleSelect = (id: string) => {
50
+ if (activeProp === undefined) setInternalId(id);
51
+ onTabChange?.(id);
52
+ };
53
+
54
+ return (
55
+ <Glass
56
+ ref={ref}
57
+ effect="regular"
58
+ style={{
59
+ display: "flex",
60
+ flexDirection: "row",
61
+ alignItems: "center",
62
+ gap: 2,
63
+ padding: 4,
64
+ borderRadius: radii.pill,
65
+ ...style,
66
+ }}
67
+ {...props}
68
+ >
69
+ {items.map((tab) => {
70
+ const isActive = tab.id === activeId;
71
+ return (
72
+ <button
73
+ key={tab.id}
74
+ type="button"
75
+ onClick={() => handleSelect(tab.id)}
76
+ aria-selected={isActive}
77
+ role="tab"
78
+ style={{
79
+ flex: 1,
80
+ display: "flex",
81
+ flexDirection: "row",
82
+ alignItems: "center",
83
+ justifyContent: "center",
84
+ gap: 6,
85
+ padding: "8px 12px",
86
+ border: 0,
87
+ borderRadius: radii.pill,
88
+ // The selection is a lens, not a fill: a lifted pane on the rail.
89
+ background: isActive
90
+ ? isDark
91
+ ? "rgba(255,255,255,0.16)"
92
+ : "rgba(255,255,255,0.72)"
93
+ : "transparent",
94
+ color: isActive ? themeColors.foreground : themeColors.muted,
95
+ fontSize: 13,
96
+ fontWeight: isActive ? 600 : 500,
97
+ cursor: "pointer",
98
+ whiteSpace: "nowrap",
99
+ }}
100
+ >
101
+ {tab.icon && <span style={{ fontSize: 14 }}>{tab.icon}</span>}
102
+ <span>{tab.label}</span>
103
+ </button>
104
+ );
105
+ })}
106
+ </Glass>
107
+ );
108
+ });
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ export { Glass, type GlassProps } from "./Glass";
2
+ export { Button, type ButtonProps } from "./Button";
3
+ export { Switch, type SwitchProps } from "./Switch";
4
+ export { Slider, type SliderProps } from "./Slider";
5
+ export {
6
+ SegmentedControl,
7
+ type SegmentedControlProps,
8
+ } from "./SegmentedControl";
9
+ export { TabBar, type TabBarProps, type TabBarItem } from "./TabBar";
10
+ export { Tabs, type TabsProps, type TabItem } from "./Tabs";
11
+ export {
12
+ Card,
13
+ CardHeader,
14
+ CardTitle,
15
+ CardDescription,
16
+ CardContent,
17
+ CardBody,
18
+ CardFooter,
19
+ type CardProps,
20
+ } from "./Card";
21
+ export { isGlassSupported } from "./internal/GlassView";
22
+ export { colors, radii, springs } from "./internal/tokens";
@@ -0,0 +1,71 @@
1
+ import { forwardRef, type ReactNode } from "react";
2
+ import { FallbackGlassView } from "./fallback";
3
+
4
+ declare const require: any;
5
+
6
+ export interface NativeGlassProps {
7
+ effect?: "clear" | "regular" | "none";
8
+ tintColor?: string;
9
+ interactive?: boolean;
10
+ style?: any;
11
+ children?: ReactNode;
12
+ }
13
+
14
+ let LiquidGlassViewComponent: any = null;
15
+ let supported = false;
16
+
17
+ try {
18
+ const liquidGlass = require("@callstack/liquid-glass");
19
+ if (liquidGlass && liquidGlass.LiquidGlassView) {
20
+ LiquidGlassViewComponent = liquidGlass.LiquidGlassView;
21
+ supported = Boolean(liquidGlass.isLiquidGlassSupported);
22
+ }
23
+ } catch {
24
+ supported = false;
25
+ }
26
+
27
+ export const isGlassSupported = supported;
28
+
29
+ /**
30
+ * Platform Glass View:
31
+ * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
32
+ * - iOS < 26 / Android / Expo Go / Fallback: Smooth translucent tint View with identical layout
33
+ */
34
+ export const GlassView = forwardRef<any, NativeGlassProps>(function GlassView(
35
+ {
36
+ effect = "regular",
37
+ tintColor,
38
+ interactive = false,
39
+ style,
40
+ children,
41
+ ...props
42
+ },
43
+ ref,
44
+ ) {
45
+ if (isGlassSupported && LiquidGlassViewComponent) {
46
+ return (
47
+ <LiquidGlassViewComponent
48
+ ref={ref}
49
+ effect={effect}
50
+ tintColor={tintColor}
51
+ interactive={interactive}
52
+ style={style}
53
+ {...props}
54
+ >
55
+ {children}
56
+ </LiquidGlassViewComponent>
57
+ );
58
+ }
59
+
60
+ return (
61
+ <FallbackGlassView
62
+ ref={ref}
63
+ effect={effect}
64
+ tintColor={tintColor}
65
+ style={style}
66
+ {...props}
67
+ >
68
+ {children}
69
+ </FallbackGlassView>
70
+ );
71
+ });
@@ -0,0 +1,46 @@
1
+ import { forwardRef, type ReactNode } from "react";
2
+ import { colors, radii } from "./tokens";
3
+
4
+ export interface FallbackGlassProps {
5
+ effect?: "clear" | "regular" | "none";
6
+ tintColor?: string;
7
+ style?: any;
8
+ children?: ReactNode;
9
+ isDark?: boolean;
10
+ }
11
+
12
+ export const FallbackGlassView = forwardRef<any, FallbackGlassProps>(function FallbackGlassView(
13
+ {
14
+ effect = "regular",
15
+ tintColor,
16
+ style,
17
+ children,
18
+ isDark = false,
19
+ ...props
20
+ },
21
+ ref,
22
+ ) {
23
+ const themeColors = isDark ? colors.dark : colors.light;
24
+
25
+ const bg =
26
+ effect === "none"
27
+ ? "transparent"
28
+ : effect === "clear"
29
+ ? "rgba(255, 255, 255, 0.25)"
30
+ : tintColor || themeColors.glass;
31
+
32
+ const containerStyle = {
33
+ backgroundColor: bg,
34
+ borderColor: themeColors.edge,
35
+ borderWidth: 0.5,
36
+ borderRadius: radii.md,
37
+ overflow: "hidden" as const,
38
+ ...style,
39
+ };
40
+
41
+ return (
42
+ <div ref={ref} style={containerStyle} {...props}>
43
+ {children}
44
+ </div>
45
+ );
46
+ });
@@ -0,0 +1,36 @@
1
+ import { radii as tokenRadii, springs as tokenSprings, colors as tokenColors } from "glacia-tokens";
2
+
3
+ export const radii = {
4
+ sm: tokenRadii.sm.number,
5
+ md: tokenRadii.md.number,
6
+ lg: tokenRadii.lg.number,
7
+ xl: tokenRadii.xl.number,
8
+ pill: tokenRadii.pill.number,
9
+ };
10
+
11
+ export const springs = {
12
+ gentle: tokenSprings.gentle,
13
+ snappy: tokenSprings.snappy,
14
+ bouncy: tokenSprings.bouncy,
15
+ };
16
+
17
+ export const colors = {
18
+ light: {
19
+ foreground: "#000000E0",
20
+ muted: "#3C3C4399",
21
+ glass: "rgba(255, 255, 255, 0.6)",
22
+ glassActive: "rgba(236, 236, 240, 0.85)",
23
+ edge: "rgba(0, 0, 0, 0.08)",
24
+ fill: "#0088FF",
25
+ destructive: "#FF3B30",
26
+ },
27
+ dark: {
28
+ foreground: "#FFFFFF",
29
+ muted: "#EBEBF599",
30
+ glass: "rgba(40, 40, 40, 0.62)",
31
+ glassActive: "rgba(70, 70, 70, 0.62)",
32
+ edge: "rgba(255, 255, 255, 0.08)",
33
+ fill: "#0091FF",
34
+ destructive: "#FF4245",
35
+ },
36
+ };
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.