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.
- package/LICENSE +27 -0
- package/lib/module/Button.js +37 -0
- package/lib/module/Card.js +60 -0
- package/lib/module/Glass.js +9 -0
- package/lib/module/SegmentedControl.js +46 -0
- package/lib/module/Slider.js +49 -0
- package/lib/module/Switch.js +42 -0
- package/lib/module/TabBar.js +47 -0
- package/lib/module/Tabs.js +59 -0
- package/lib/module/index.js +31 -0
- package/lib/module/internal/GlassView.js +30 -0
- package/lib/module/internal/fallback.js +23 -0
- package/lib/module/internal/tokens.js +36 -0
- package/lib/typescript/Button.d.ts +14 -0
- package/lib/typescript/Card.d.ts +31 -0
- package/lib/typescript/Glass.d.ts +5 -0
- package/lib/typescript/SegmentedControl.d.ts +9 -0
- package/lib/typescript/Slider.d.ts +13 -0
- package/lib/typescript/Switch.d.ts +10 -0
- package/lib/typescript/TabBar.d.ts +15 -0
- package/lib/typescript/Tabs.d.ts +28 -0
- package/lib/typescript/index.d.ts +10 -0
- package/lib/typescript/internal/GlassView.d.ts +15 -0
- package/lib/typescript/internal/fallback.d.ts +9 -0
- package/lib/typescript/internal/tokens.d.ts +44 -0
- package/package.json +41 -3
- package/src/Button.tsx +87 -0
- package/src/Card.tsx +120 -0
- package/src/Glass.tsx +24 -0
- package/src/SegmentedControl.tsx +79 -0
- package/src/Slider.tsx +97 -0
- package/src/Switch.tsx +80 -0
- package/src/TabBar.tsx +87 -0
- package/src/Tabs.tsx +108 -0
- package/src/index.ts +22 -0
- package/src/internal/GlassView.tsx +71 -0
- package/src/internal/fallback.tsx +46 -0
- package/src/internal/tokens.ts +36 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Glacia Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Attribution and Third-Party Notices:
|
|
26
|
+
- Web glass engine based on Glisse by Kelvin Zhang (MIT): https://github.com/0kzh/glisse
|
|
27
|
+
- React Native glass powered by @callstack/liquid-glass (MIT): https://github.com/callstack/liquid-glass
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Button = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
7
|
+
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
const sizeHeights = {
|
|
9
|
+
sm: 32,
|
|
10
|
+
md: 40,
|
|
11
|
+
lg: 48,
|
|
12
|
+
};
|
|
13
|
+
exports.Button = (0, react_1.forwardRef)(function Button({ variant = "glass", size = "md", disabled = false, onPress, accessibilityLabel, icon, children, style, tint, isDark = false, ...props }, ref) {
|
|
14
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
15
|
+
const height = sizeHeights[size];
|
|
16
|
+
const buttonStyle = {
|
|
17
|
+
height,
|
|
18
|
+
borderRadius: height / 2,
|
|
19
|
+
flexDirection: "row",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
justifyContent: "center",
|
|
22
|
+
paddingHorizontal: size === "sm" ? 12 : size === "lg" ? 22 : 16,
|
|
23
|
+
opacity: disabled ? 0.38 : 1,
|
|
24
|
+
backgroundColor: variant === "filled"
|
|
25
|
+
? tint || themeColors.fill
|
|
26
|
+
: variant === "ghost"
|
|
27
|
+
? "transparent"
|
|
28
|
+
: undefined,
|
|
29
|
+
...style,
|
|
30
|
+
};
|
|
31
|
+
const textStyle = {
|
|
32
|
+
color: variant === "filled" ? "#FFFFFF" : tint || themeColors.foreground,
|
|
33
|
+
fontSize: size === "sm" ? 13 : size === "lg" ? 16 : 14,
|
|
34
|
+
fontWeight: "500",
|
|
35
|
+
};
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, role: "button", tabIndex: disabled ? -1 : 0, "aria-label": accessibilityLabel, "aria-disabled": disabled, onClick: disabled ? undefined : onPress, style: { display: "inline-block", cursor: disabled ? "default" : "pointer" }, ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", interactive: !disabled, style: buttonStyle, children: [icon && (0, jsx_runtime_1.jsx)("span", { style: { marginRight: children ? 8 : 0 }, children: icon }), typeof children === "string" ? (0, jsx_runtime_1.jsx)("span", { style: textStyle, children: children }) : children] }) }));
|
|
37
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CardBody = exports.Card = void 0;
|
|
4
|
+
exports.CardHeader = CardHeader;
|
|
5
|
+
exports.CardTitle = CardTitle;
|
|
6
|
+
exports.CardDescription = CardDescription;
|
|
7
|
+
exports.CardContent = CardContent;
|
|
8
|
+
exports.CardFooter = CardFooter;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const Glass_1 = require("./Glass");
|
|
12
|
+
const tokens_1 = require("./internal/tokens");
|
|
13
|
+
exports.Card = (0, react_1.forwardRef)(function Card({ effect = "regular", style, children, isDark = false, ...props }, ref) {
|
|
14
|
+
const cardStyle = {
|
|
15
|
+
padding: 20,
|
|
16
|
+
borderRadius: tokens_1.radii.lg,
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "column",
|
|
19
|
+
gap: 12,
|
|
20
|
+
...style,
|
|
21
|
+
};
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: effect, style: cardStyle, ...props, children: children }));
|
|
23
|
+
});
|
|
24
|
+
function CardHeader({ style, children, ...props }) {
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 4, ...style }, ...props, children: children }));
|
|
26
|
+
}
|
|
27
|
+
function CardTitle({ style, children, isDark = false, ...props }) {
|
|
28
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)("h3", { style: {
|
|
30
|
+
margin: 0,
|
|
31
|
+
fontSize: 18,
|
|
32
|
+
fontWeight: 600,
|
|
33
|
+
color: themeColors.foreground,
|
|
34
|
+
...style,
|
|
35
|
+
}, ...props, children: children }));
|
|
36
|
+
}
|
|
37
|
+
function CardDescription({ style, children, isDark = false, ...props }) {
|
|
38
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)("p", { style: {
|
|
40
|
+
margin: 0,
|
|
41
|
+
fontSize: 13,
|
|
42
|
+
color: themeColors.muted,
|
|
43
|
+
...style,
|
|
44
|
+
}, ...props, children: children }));
|
|
45
|
+
}
|
|
46
|
+
function CardContent({ style, children, ...props }) {
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8, ...style }, ...props, children: children }));
|
|
48
|
+
}
|
|
49
|
+
exports.CardBody = CardContent;
|
|
50
|
+
function CardFooter({ style, children, ...props }) {
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
52
|
+
display: "flex",
|
|
53
|
+
flexDirection: "row",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
justifyContent: "flex-end",
|
|
56
|
+
gap: 8,
|
|
57
|
+
paddingTop: 8,
|
|
58
|
+
...style,
|
|
59
|
+
}, ...props, children: children }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Glass = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const GlassView_1 = require("./internal/GlassView");
|
|
7
|
+
exports.Glass = (0, react_1.forwardRef)(function Glass({ effect = "regular", tintColor, interactive = false, style, children, ...props }, ref) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(GlassView_1.GlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, style: style, ...props, children: children }));
|
|
9
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SegmentedControl = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
7
|
+
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
exports.SegmentedControl = (0, react_1.forwardRef)(function SegmentedControl({ values, selectedIndex: selectedProp, defaultIndex = 0, onValueChange, style, isDark = false, ...props }, ref) {
|
|
9
|
+
const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultIndex);
|
|
10
|
+
const activeIndex = selectedProp !== undefined ? selectedProp : internalIndex;
|
|
11
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
12
|
+
const handleSelect = (index) => {
|
|
13
|
+
if (selectedProp === undefined) {
|
|
14
|
+
setInternalIndex(index);
|
|
15
|
+
}
|
|
16
|
+
const val = values[index];
|
|
17
|
+
if (val !== undefined) {
|
|
18
|
+
onValueChange?.(val, index);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const containerStyle = {
|
|
22
|
+
position: "relative",
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
flexDirection: "row",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
padding: 2,
|
|
27
|
+
borderRadius: tokens_1.radii.md,
|
|
28
|
+
backgroundColor: "rgba(118, 118, 128, 0.12)",
|
|
29
|
+
...style,
|
|
30
|
+
};
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", style: containerStyle, ...props, children: values.map((label, idx) => {
|
|
32
|
+
const isSelected = idx === activeIndex;
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => handleSelect(idx), style: {
|
|
34
|
+
padding: "6px 16px",
|
|
35
|
+
borderRadius: tokens_1.radii.sm,
|
|
36
|
+
border: 0,
|
|
37
|
+
backgroundColor: isSelected ? "#FFFFFF" : "transparent",
|
|
38
|
+
color: isSelected ? "#000000" : themeColors.muted,
|
|
39
|
+
boxShadow: isSelected ? "0 1px 3px rgba(0, 0, 0, 0.12)" : "none",
|
|
40
|
+
fontSize: 13,
|
|
41
|
+
fontWeight: 500,
|
|
42
|
+
cursor: "pointer",
|
|
43
|
+
transition: "all 150ms ease",
|
|
44
|
+
}, children: label }, label));
|
|
45
|
+
}) }));
|
|
46
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Slider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
7
|
+
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
exports.Slider = (0, react_1.forwardRef)(function Slider({ value: valueProp, defaultValue = 50, min = 0, max = 100, step = 1, onValueChange, disabled = false, accessibilityLabel, style, isDark = false, ...props }, ref) {
|
|
9
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue);
|
|
10
|
+
const value = valueProp !== undefined ? valueProp : internalValue;
|
|
11
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
12
|
+
const percentage = Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100));
|
|
13
|
+
const handleChange = (e) => {
|
|
14
|
+
const val = Number(e.target.value);
|
|
15
|
+
if (valueProp === undefined) {
|
|
16
|
+
setInternalValue(val);
|
|
17
|
+
}
|
|
18
|
+
onValueChange?.(val);
|
|
19
|
+
};
|
|
20
|
+
const containerStyle = {
|
|
21
|
+
position: "relative",
|
|
22
|
+
height: 40,
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
opacity: disabled ? 0.38 : 1,
|
|
25
|
+
...style,
|
|
26
|
+
};
|
|
27
|
+
const trackStyle = {
|
|
28
|
+
height: 8,
|
|
29
|
+
borderRadius: 4,
|
|
30
|
+
backgroundColor: "rgba(120, 120, 128, 0.2)",
|
|
31
|
+
overflow: "hidden",
|
|
32
|
+
width: "100%",
|
|
33
|
+
};
|
|
34
|
+
const fillStyle = {
|
|
35
|
+
height: "100%",
|
|
36
|
+
width: `${percentage}%`,
|
|
37
|
+
backgroundColor: themeColors.fill,
|
|
38
|
+
};
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, style: containerStyle, ...props, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", style: trackStyle, children: (0, jsx_runtime_1.jsx)("div", { style: fillStyle }) }), (0, jsx_runtime_1.jsx)("input", { type: "range", min: min, max: max, step: step, value: value, disabled: disabled, "aria-label": accessibilityLabel, onChange: handleChange, style: {
|
|
40
|
+
position: "absolute",
|
|
41
|
+
top: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
width: "100%",
|
|
44
|
+
height: "100%",
|
|
45
|
+
opacity: 0,
|
|
46
|
+
cursor: disabled ? "default" : "pointer",
|
|
47
|
+
margin: 0,
|
|
48
|
+
} })] }));
|
|
49
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Switch = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
7
|
+
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
exports.Switch = (0, react_1.forwardRef)(function Switch({ checked: checkedProp, defaultChecked = false, onCheckedChange, disabled = false, accessibilityLabel, style, isDark = false, ...props }, ref) {
|
|
9
|
+
const [internalChecked, setInternalChecked] = (0, react_1.useState)(defaultChecked);
|
|
10
|
+
const isChecked = checkedProp !== undefined ? checkedProp : internalChecked;
|
|
11
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
12
|
+
const toggle = () => {
|
|
13
|
+
if (disabled)
|
|
14
|
+
return;
|
|
15
|
+
const next = !isChecked;
|
|
16
|
+
if (checkedProp === undefined) {
|
|
17
|
+
setInternalChecked(next);
|
|
18
|
+
}
|
|
19
|
+
onCheckedChange?.(next);
|
|
20
|
+
};
|
|
21
|
+
const trackStyle = {
|
|
22
|
+
width: 51,
|
|
23
|
+
height: 31,
|
|
24
|
+
borderRadius: 15.5,
|
|
25
|
+
backgroundColor: isChecked ? themeColors.fill : "rgba(120, 120, 128, 0.16)",
|
|
26
|
+
padding: 2,
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
opacity: disabled ? 0.38 : 1,
|
|
29
|
+
transition: "background-color 200ms ease",
|
|
30
|
+
...style,
|
|
31
|
+
};
|
|
32
|
+
const thumbStyle = {
|
|
33
|
+
width: 27,
|
|
34
|
+
height: 27,
|
|
35
|
+
borderRadius: 13.5,
|
|
36
|
+
backgroundColor: "#FFFFFF",
|
|
37
|
+
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.2)",
|
|
38
|
+
transform: isChecked ? "translateX(20px)" : "translateX(0px)",
|
|
39
|
+
transition: "transform 200ms cubic-bezier(0.25, 0.1, 0.25, 1)",
|
|
40
|
+
};
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, role: "switch", "aria-checked": isChecked, "aria-label": accessibilityLabel, "aria-disabled": disabled, tabIndex: disabled ? -1 : 0, onClick: toggle, style: { display: "inline-block", cursor: disabled ? "default" : "pointer" }, ...props, children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", style: trackStyle, children: (0, jsx_runtime_1.jsx)("div", { style: thumbStyle }) }) }));
|
|
42
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TabBar = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
7
|
+
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: activeProp, defaultActiveId, onTabChange, style, isDark = false, ...props }, ref) {
|
|
9
|
+
const [internalId, setInternalId] = (0, react_1.useState)(defaultActiveId || items[0]?.id || "");
|
|
10
|
+
const activeId = activeProp !== undefined ? activeProp : internalId;
|
|
11
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
12
|
+
const handleSelect = (id) => {
|
|
13
|
+
if (activeProp === undefined) {
|
|
14
|
+
setInternalId(id);
|
|
15
|
+
}
|
|
16
|
+
onTabChange?.(id);
|
|
17
|
+
};
|
|
18
|
+
const barStyle = {
|
|
19
|
+
position: "relative",
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "space-around",
|
|
24
|
+
height: 52,
|
|
25
|
+
paddingHorizontal: 8,
|
|
26
|
+
borderRadius: tokens_1.radii.xl,
|
|
27
|
+
...style,
|
|
28
|
+
};
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", style: barStyle, ...props, children: items.map((tab) => {
|
|
30
|
+
const isActive = tab.id === activeId;
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => handleSelect(tab.id), style: {
|
|
32
|
+
flex: 1,
|
|
33
|
+
display: "flex",
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
justifyContent: "center",
|
|
37
|
+
gap: 2,
|
|
38
|
+
padding: "4px 8px",
|
|
39
|
+
border: 0,
|
|
40
|
+
background: "transparent",
|
|
41
|
+
color: isActive ? themeColors.fill : themeColors.muted,
|
|
42
|
+
fontSize: 11,
|
|
43
|
+
fontWeight: isActive ? 600 : 500,
|
|
44
|
+
cursor: "pointer",
|
|
45
|
+
}, children: [tab.icon && (0, jsx_runtime_1.jsx)("span", { style: { fontSize: 18 }, children: tab.icon }), (0, jsx_runtime_1.jsx)("span", { children: tab.label })] }, tab.id));
|
|
46
|
+
}) }));
|
|
47
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tabs = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
7
|
+
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
/**
|
|
9
|
+
* A row of tabs on a glass rail, in the reference implementation's style: the
|
|
10
|
+
* selected tab is a lifted inner pane rather than a flat highlight.
|
|
11
|
+
*
|
|
12
|
+
* Follows the same conventions as the other native components — no browser
|
|
13
|
+
* APIs and no CSS — so it renders on iOS and Android. On iOS 26 the rail is
|
|
14
|
+
* real glass through `@callstack/liquid-glass`; elsewhere it is a translucent
|
|
15
|
+
* tint of the same shape with no layout shift.
|
|
16
|
+
*/
|
|
17
|
+
exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activeProp, defaultActiveId, onTabChange, style, isDark = false, ...props }, ref) {
|
|
18
|
+
const [internalId, setInternalId] = (0, react_1.useState)(defaultActiveId || items[0]?.id || "");
|
|
19
|
+
const activeId = activeProp !== undefined ? activeProp : internalId;
|
|
20
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
21
|
+
const handleSelect = (id) => {
|
|
22
|
+
if (activeProp === undefined)
|
|
23
|
+
setInternalId(id);
|
|
24
|
+
onTabChange?.(id);
|
|
25
|
+
};
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", style: {
|
|
27
|
+
display: "flex",
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
gap: 2,
|
|
31
|
+
padding: 4,
|
|
32
|
+
borderRadius: tokens_1.radii.pill,
|
|
33
|
+
...style,
|
|
34
|
+
}, ...props, children: items.map((tab) => {
|
|
35
|
+
const isActive = tab.id === activeId;
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => handleSelect(tab.id), "aria-selected": isActive, role: "tab", style: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
display: "flex",
|
|
39
|
+
flexDirection: "row",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
justifyContent: "center",
|
|
42
|
+
gap: 6,
|
|
43
|
+
padding: "8px 12px",
|
|
44
|
+
border: 0,
|
|
45
|
+
borderRadius: tokens_1.radii.pill,
|
|
46
|
+
// The selection is a lens, not a fill: a lifted pane on the rail.
|
|
47
|
+
background: isActive
|
|
48
|
+
? isDark
|
|
49
|
+
? "rgba(255,255,255,0.16)"
|
|
50
|
+
: "rgba(255,255,255,0.72)"
|
|
51
|
+
: "transparent",
|
|
52
|
+
color: isActive ? themeColors.foreground : themeColors.muted,
|
|
53
|
+
fontSize: 13,
|
|
54
|
+
fontWeight: isActive ? 600 : 500,
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
whiteSpace: "nowrap",
|
|
57
|
+
}, children: [tab.icon && (0, jsx_runtime_1.jsx)("span", { style: { fontSize: 14 }, children: tab.icon }), (0, jsx_runtime_1.jsx)("span", { children: tab.label })] }, tab.id));
|
|
58
|
+
}) }));
|
|
59
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.springs = exports.radii = exports.colors = exports.isGlassSupported = exports.CardFooter = exports.CardBody = exports.CardContent = exports.CardDescription = exports.CardTitle = exports.CardHeader = exports.Card = exports.Tabs = exports.TabBar = exports.SegmentedControl = exports.Slider = exports.Switch = exports.Button = exports.Glass = void 0;
|
|
4
|
+
var Glass_1 = require("./Glass");
|
|
5
|
+
Object.defineProperty(exports, "Glass", { enumerable: true, get: function () { return Glass_1.Glass; } });
|
|
6
|
+
var Button_1 = require("./Button");
|
|
7
|
+
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
|
|
8
|
+
var Switch_1 = require("./Switch");
|
|
9
|
+
Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.Switch; } });
|
|
10
|
+
var Slider_1 = require("./Slider");
|
|
11
|
+
Object.defineProperty(exports, "Slider", { enumerable: true, get: function () { return Slider_1.Slider; } });
|
|
12
|
+
var SegmentedControl_1 = require("./SegmentedControl");
|
|
13
|
+
Object.defineProperty(exports, "SegmentedControl", { enumerable: true, get: function () { return SegmentedControl_1.SegmentedControl; } });
|
|
14
|
+
var TabBar_1 = require("./TabBar");
|
|
15
|
+
Object.defineProperty(exports, "TabBar", { enumerable: true, get: function () { return TabBar_1.TabBar; } });
|
|
16
|
+
var Tabs_1 = require("./Tabs");
|
|
17
|
+
Object.defineProperty(exports, "Tabs", { enumerable: true, get: function () { return Tabs_1.Tabs; } });
|
|
18
|
+
var Card_1 = require("./Card");
|
|
19
|
+
Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return Card_1.Card; } });
|
|
20
|
+
Object.defineProperty(exports, "CardHeader", { enumerable: true, get: function () { return Card_1.CardHeader; } });
|
|
21
|
+
Object.defineProperty(exports, "CardTitle", { enumerable: true, get: function () { return Card_1.CardTitle; } });
|
|
22
|
+
Object.defineProperty(exports, "CardDescription", { enumerable: true, get: function () { return Card_1.CardDescription; } });
|
|
23
|
+
Object.defineProperty(exports, "CardContent", { enumerable: true, get: function () { return Card_1.CardContent; } });
|
|
24
|
+
Object.defineProperty(exports, "CardBody", { enumerable: true, get: function () { return Card_1.CardBody; } });
|
|
25
|
+
Object.defineProperty(exports, "CardFooter", { enumerable: true, get: function () { return Card_1.CardFooter; } });
|
|
26
|
+
var GlassView_1 = require("./internal/GlassView");
|
|
27
|
+
Object.defineProperty(exports, "isGlassSupported", { enumerable: true, get: function () { return GlassView_1.isGlassSupported; } });
|
|
28
|
+
var tokens_1 = require("./internal/tokens");
|
|
29
|
+
Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return tokens_1.colors; } });
|
|
30
|
+
Object.defineProperty(exports, "radii", { enumerable: true, get: function () { return tokens_1.radii; } });
|
|
31
|
+
Object.defineProperty(exports, "springs", { enumerable: true, get: function () { return tokens_1.springs; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GlassView = exports.isGlassSupported = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const fallback_1 = require("./fallback");
|
|
7
|
+
let LiquidGlassViewComponent = null;
|
|
8
|
+
let supported = false;
|
|
9
|
+
try {
|
|
10
|
+
const liquidGlass = require("@callstack/liquid-glass");
|
|
11
|
+
if (liquidGlass && liquidGlass.LiquidGlassView) {
|
|
12
|
+
LiquidGlassViewComponent = liquidGlass.LiquidGlassView;
|
|
13
|
+
supported = Boolean(liquidGlass.isLiquidGlassSupported);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
supported = false;
|
|
18
|
+
}
|
|
19
|
+
exports.isGlassSupported = supported;
|
|
20
|
+
/**
|
|
21
|
+
* Platform Glass View:
|
|
22
|
+
* - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
|
|
23
|
+
* - iOS < 26 / Android / Expo Go / Fallback: Smooth translucent tint View with identical layout
|
|
24
|
+
*/
|
|
25
|
+
exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, style, children, ...props }, ref) {
|
|
26
|
+
if (exports.isGlassSupported && LiquidGlassViewComponent) {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(LiquidGlassViewComponent, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, style: style, ...props, children: children }));
|
|
28
|
+
}
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, style: style, ...props, children: children }));
|
|
30
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FallbackGlassView = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const tokens_1 = require("./tokens");
|
|
7
|
+
exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", tintColor, style, children, isDark = false, ...props }, ref) {
|
|
8
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
9
|
+
const bg = effect === "none"
|
|
10
|
+
? "transparent"
|
|
11
|
+
: effect === "clear"
|
|
12
|
+
? "rgba(255, 255, 255, 0.25)"
|
|
13
|
+
: tintColor || themeColors.glass;
|
|
14
|
+
const containerStyle = {
|
|
15
|
+
backgroundColor: bg,
|
|
16
|
+
borderColor: themeColors.edge,
|
|
17
|
+
borderWidth: 0.5,
|
|
18
|
+
borderRadius: tokens_1.radii.md,
|
|
19
|
+
overflow: "hidden",
|
|
20
|
+
...style,
|
|
21
|
+
};
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, style: containerStyle, ...props, children: children }));
|
|
23
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.colors = exports.springs = exports.radii = void 0;
|
|
4
|
+
const glacia_tokens_1 = require("glacia-tokens");
|
|
5
|
+
exports.radii = {
|
|
6
|
+
sm: glacia_tokens_1.radii.sm.number,
|
|
7
|
+
md: glacia_tokens_1.radii.md.number,
|
|
8
|
+
lg: glacia_tokens_1.radii.lg.number,
|
|
9
|
+
xl: glacia_tokens_1.radii.xl.number,
|
|
10
|
+
pill: glacia_tokens_1.radii.pill.number,
|
|
11
|
+
};
|
|
12
|
+
exports.springs = {
|
|
13
|
+
gentle: glacia_tokens_1.springs.gentle,
|
|
14
|
+
snappy: glacia_tokens_1.springs.snappy,
|
|
15
|
+
bouncy: glacia_tokens_1.springs.bouncy,
|
|
16
|
+
};
|
|
17
|
+
exports.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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface ButtonProps {
|
|
3
|
+
variant?: "glass" | "filled" | "ghost";
|
|
4
|
+
size?: "sm" | "md" | "lg";
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
onPress?: () => void;
|
|
7
|
+
accessibilityLabel: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
style?: any;
|
|
11
|
+
tint?: string;
|
|
12
|
+
isDark?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface CardProps {
|
|
3
|
+
effect?: "clear" | "regular" | "none";
|
|
4
|
+
style?: any;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
isDark?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const Card: import("react").ForwardRefExoticComponent<CardProps & import("react").RefAttributes<any>>;
|
|
9
|
+
export declare function CardHeader({ style, children, ...props }: {
|
|
10
|
+
style?: any;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
export declare function CardTitle({ style, children, isDark, ...props }: {
|
|
14
|
+
style?: any;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
isDark?: boolean;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
export declare function CardDescription({ style, children, isDark, ...props }: {
|
|
19
|
+
style?: any;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
isDark?: boolean;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
export declare function CardContent({ style, children, ...props }: {
|
|
24
|
+
style?: any;
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
}): import("react").JSX.Element;
|
|
27
|
+
export declare const CardBody: typeof CardContent;
|
|
28
|
+
export declare function CardFooter({ style, children, ...props }: {
|
|
29
|
+
style?: any;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SegmentedControlProps {
|
|
2
|
+
values: string[];
|
|
3
|
+
selectedIndex?: number;
|
|
4
|
+
defaultIndex?: number;
|
|
5
|
+
onValueChange?: (value: string, index: number) => void;
|
|
6
|
+
style?: any;
|
|
7
|
+
isDark?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const SegmentedControl: import("react").ForwardRefExoticComponent<SegmentedControlProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SliderProps {
|
|
2
|
+
value?: number;
|
|
3
|
+
defaultValue?: number;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
step?: number;
|
|
7
|
+
onValueChange?: (value: number) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
accessibilityLabel: string;
|
|
10
|
+
style?: any;
|
|
11
|
+
isDark?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const Slider: import("react").ForwardRefExoticComponent<SliderProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SwitchProps {
|
|
2
|
+
checked?: boolean;
|
|
3
|
+
defaultChecked?: boolean;
|
|
4
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
accessibilityLabel: string;
|
|
7
|
+
style?: any;
|
|
8
|
+
isDark?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface TabBarItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface TabBarProps {
|
|
8
|
+
items: TabBarItem[];
|
|
9
|
+
activeId?: string;
|
|
10
|
+
defaultActiveId?: string;
|
|
11
|
+
onTabChange?: (id: string) => void;
|
|
12
|
+
style?: any;
|
|
13
|
+
isDark?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const TabBar: import("react").ForwardRefExoticComponent<TabBarProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface TabItem {
|
|
3
|
+
/** Stable identifier for the tab. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** What the tab reads. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** An optional icon element drawn before the label. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface TabsProps {
|
|
11
|
+
items: TabItem[];
|
|
12
|
+
/** The active tab's `id`. Leave undefined and the component keeps it itself. */
|
|
13
|
+
activeId?: string;
|
|
14
|
+
defaultActiveId?: string;
|
|
15
|
+
onTabChange?: (id: string) => void;
|
|
16
|
+
style?: any;
|
|
17
|
+
isDark?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A row of tabs on a glass rail, in the reference implementation's style: the
|
|
21
|
+
* selected tab is a lifted inner pane rather than a flat highlight.
|
|
22
|
+
*
|
|
23
|
+
* Follows the same conventions as the other native components — no browser
|
|
24
|
+
* APIs and no CSS — so it renders on iOS and Android. On iOS 26 the rail is
|
|
25
|
+
* real glass through `@callstack/liquid-glass`; elsewhere it is a translucent
|
|
26
|
+
* tint of the same shape with no layout shift.
|
|
27
|
+
*/
|
|
28
|
+
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<any>>;
|