glacia-native 0.3.5 → 0.4.0
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/lib/module/Button.js +15 -2
- package/lib/module/Card.js +29 -14
- package/lib/module/Dialog.js +43 -32
- package/lib/module/Form.js +51 -12
- package/lib/module/Glass.js +11 -2
- package/lib/module/Input.js +19 -7
- package/lib/module/SegmentedControl.js +65 -21
- package/lib/module/Slider.js +121 -25
- package/lib/module/Switch.js +33 -15
- package/lib/module/TabBar.js +63 -25
- package/lib/module/Table.js +24 -6
- package/lib/module/Tabs.js +55 -33
- package/lib/module/ai.js +49 -20
- package/lib/module/charts/BarChart.js +4 -2
- package/lib/module/charts/FunnelChart.js +4 -2
- package/lib/module/charts/HeatmapChart.js +4 -2
- package/lib/module/charts/LineChart.js +4 -2
- package/lib/module/charts/PlotChart.js +11 -3
- package/lib/module/charts/RadarChart.js +4 -2
- package/lib/module/charts/RingChart.js +4 -2
- package/lib/module/charts/ScatterChart.js +20 -3
- package/lib/module/charts/WaterfallChart.js +12 -3
- package/lib/module/charts/advanced.js +12 -6
- package/lib/module/charts/extra.js +6 -3
- package/lib/module/internal/GlassView.js +17 -19
- package/lib/module/internal/fallback.js +14 -3
- package/lib/module/internal/glass-routing.js +56 -0
- package/lib/module/internal/motion.js +55 -0
- package/lib/module/internal/primitives.js +408 -0
- package/lib/typescript/Button.d.ts +11 -1
- package/lib/typescript/Card.d.ts +20 -8
- package/lib/typescript/Dialog.d.ts +19 -6
- package/lib/typescript/Form.d.ts +27 -11
- package/lib/typescript/Glass.d.ts +9 -0
- package/lib/typescript/Input.d.ts +11 -1
- package/lib/typescript/SegmentedControl.d.ts +11 -1
- package/lib/typescript/Slider.d.ts +13 -1
- package/lib/typescript/Switch.d.ts +12 -1
- package/lib/typescript/TabBar.d.ts +13 -1
- package/lib/typescript/Table.d.ts +14 -5
- package/lib/typescript/Tabs.d.ts +8 -5
- package/lib/typescript/ai.d.ts +12 -9
- package/lib/typescript/charts/BarChart.d.ts +1 -1
- package/lib/typescript/charts/FunnelChart.d.ts +1 -1
- package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
- package/lib/typescript/charts/LineChart.d.ts +1 -1
- package/lib/typescript/charts/PlotChart.d.ts +1 -1
- package/lib/typescript/charts/RadarChart.d.ts +1 -1
- package/lib/typescript/charts/RingChart.d.ts +1 -1
- package/lib/typescript/charts/ScatterChart.d.ts +1 -1
- package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
- package/lib/typescript/charts/advanced.d.ts +5 -5
- package/lib/typescript/charts/extra.d.ts +2 -2
- package/lib/typescript/internal/GlassView.d.ts +11 -3
- package/lib/typescript/internal/fallback.d.ts +10 -1
- package/lib/typescript/internal/glass-routing.d.ts +30 -0
- package/lib/typescript/internal/motion.d.ts +19 -0
- package/lib/typescript/internal/primitives.d.ts +41 -0
- package/package.json +2 -2
- package/src/Button.tsx +47 -22
- package/src/Card.tsx +52 -31
- package/src/Dialog.tsx +99 -64
- package/src/Form.tsx +90 -25
- package/src/Glass.tsx +24 -1
- package/src/Input.tsx +33 -12
- package/src/SegmentedControl.tsx +104 -32
- package/src/Slider.tsx +151 -47
- package/src/Switch.tsx +56 -32
- package/src/TabBar.tsx +100 -30
- package/src/Table.tsx +38 -14
- package/src/Tabs.tsx +85 -32
- package/src/ai.tsx +77 -31
- package/src/charts/BarChart.tsx +4 -2
- package/src/charts/FunnelChart.tsx +4 -2
- package/src/charts/HeatmapChart.tsx +4 -2
- package/src/charts/LineChart.tsx +4 -2
- package/src/charts/PlotChart.tsx +23 -3
- package/src/charts/RadarChart.tsx +4 -2
- package/src/charts/RingChart.tsx +4 -2
- package/src/charts/ScatterChart.tsx +24 -3
- package/src/charts/WaterfallChart.tsx +21 -3
- package/src/charts/advanced.tsx +12 -6
- package/src/charts/extra.tsx +6 -3
- package/src/internal/GlassView.tsx +31 -21
- package/src/internal/fallback.tsx +23 -8
- package/src/internal/glass-routing.ts +68 -0
- package/src/internal/motion.ts +60 -0
- package/src/internal/primitives.ts +477 -0
- package/lib/module/charts/primitives.js +0 -212
- package/lib/typescript/charts/primitives.d.ts +0 -23
- package/src/charts/primitives.ts +0 -262
package/lib/module/Button.js
CHANGED
|
@@ -5,13 +5,24 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Glass_1 = require("./Glass");
|
|
7
7
|
const tokens_1 = require("./internal/tokens");
|
|
8
|
+
const primitives_1 = require("./internal/primitives");
|
|
9
|
+
const motion_1 = require("./internal/motion");
|
|
8
10
|
const sizeHeights = {
|
|
9
11
|
sm: 32,
|
|
10
12
|
md: 40,
|
|
11
13
|
lg: 48,
|
|
12
14
|
};
|
|
13
|
-
|
|
15
|
+
/**
|
|
16
|
+
* A pressable button on Glacia's glass.
|
|
17
|
+
*
|
|
18
|
+
* The root is a Pressable so it gets the platform's own press semantics
|
|
19
|
+
* (focus, screen-reader activation, pressed feedback) while the material —
|
|
20
|
+
* Apple's glass on iOS 26+, Glacia's tint elsewhere — comes from `Glass`.
|
|
21
|
+
*/
|
|
22
|
+
exports.Button = (0, react_1.forwardRef)(function Button({ variant = "glass", size = "md", disabled = false, onPress, accessibilityLabel, icon, children, style, tint, isDark: isDarkProp, testID, ...props }, ref) {
|
|
23
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
14
24
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
25
|
+
const { Pressable, View, Text } = (0, primitives_1.primitives)();
|
|
15
26
|
const height = sizeHeights[size];
|
|
16
27
|
const buttonStyle = {
|
|
17
28
|
height,
|
|
@@ -33,5 +44,7 @@ exports.Button = (0, react_1.forwardRef)(function Button({ variant = "glass", si
|
|
|
33
44
|
fontSize: size === "sm" ? 13 : size === "lg" ? 16 : 14,
|
|
34
45
|
fontWeight: "500",
|
|
35
46
|
};
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { disabled }, disabled: disabled, onPress: disabled ? undefined : onPress, style: ({ pressed }) => ({ opacity: pressed && !disabled ? 0.85 : 1 }), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", interactive: !disabled, isDark: isDark, style: buttonStyle, children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { marginRight: children ? 8 : 0 }, children: icon }) : null, typeof children === "string" ? (
|
|
48
|
+
// A string label is text: it needs Text to inherit font and colour.
|
|
49
|
+
(0, jsx_runtime_1.jsx)(Text, { style: textStyle, numberOfLines: 1, children: children })) : (children)] }) }));
|
|
37
50
|
});
|
package/lib/module/Card.js
CHANGED
|
@@ -10,46 +10,61 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
10
10
|
const react_1 = require("react");
|
|
11
11
|
const Glass_1 = require("./Glass");
|
|
12
12
|
const tokens_1 = require("./internal/tokens");
|
|
13
|
-
|
|
13
|
+
const primitives_1 = require("./internal/primitives");
|
|
14
|
+
const motion_1 = require("./internal/motion");
|
|
15
|
+
/**
|
|
16
|
+
* A content panel on Glacia's glass: Apple's material on iOS 26+, Glacia's
|
|
17
|
+
* tint elsewhere. The padding, radius and stacking are ours on every platform.
|
|
18
|
+
*/
|
|
19
|
+
exports.Card = (0, react_1.forwardRef)(function Card({ effect = "regular", style, children, isDark: isDarkProp, testID, ...props }, ref) {
|
|
20
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
14
21
|
const cardStyle = {
|
|
15
22
|
padding: 20,
|
|
16
23
|
borderRadius: tokens_1.radii.lg,
|
|
17
|
-
display: "flex",
|
|
18
24
|
flexDirection: "column",
|
|
19
25
|
gap: 12,
|
|
20
26
|
...style,
|
|
21
27
|
};
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: effect, style: cardStyle, ...props, children: children }));
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: effect, isDark: isDark, style: cardStyle, testID: testID, ...props, children: children }));
|
|
23
29
|
});
|
|
30
|
+
/** The block holding a card's title and description. */
|
|
24
31
|
function CardHeader({ style, children, ...props }) {
|
|
25
|
-
|
|
32
|
+
const { View } = (0, primitives_1.primitives)();
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "column", gap: 4, ...style }, ...props, children: children }));
|
|
26
34
|
}
|
|
27
|
-
|
|
35
|
+
/** A card's heading, announced as a heading by screen readers. */
|
|
36
|
+
function CardTitle({ style, children, isDark: isDarkProp, ...props }) {
|
|
37
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
28
38
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
const { Text } = (0, primitives_1.primitives)();
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "heading", style: {
|
|
31
41
|
fontSize: 18,
|
|
32
|
-
fontWeight: 600,
|
|
42
|
+
fontWeight: "600",
|
|
33
43
|
color: themeColors.foreground,
|
|
34
44
|
...style,
|
|
35
45
|
}, ...props, children: children }));
|
|
36
46
|
}
|
|
37
|
-
|
|
47
|
+
/** Supporting text under a card's title. */
|
|
48
|
+
function CardDescription({ style, children, isDark: isDarkProp, ...props }) {
|
|
49
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
38
50
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
const { Text } = (0, primitives_1.primitives)();
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(Text, { style: {
|
|
41
53
|
fontSize: 13,
|
|
42
54
|
color: themeColors.muted,
|
|
43
55
|
...style,
|
|
44
56
|
}, ...props, children: children }));
|
|
45
57
|
}
|
|
58
|
+
/** The card's body. */
|
|
46
59
|
function CardContent({ style, children, ...props }) {
|
|
47
|
-
|
|
60
|
+
const { View } = (0, primitives_1.primitives)();
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "column", gap: 8, ...style }, ...props, children: children }));
|
|
48
62
|
}
|
|
49
63
|
exports.CardBody = CardContent;
|
|
64
|
+
/** The card's action row. */
|
|
50
65
|
function CardFooter({ style, children, ...props }) {
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
const { View } = (0, primitives_1.primitives)();
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)(View, { style: {
|
|
53
68
|
flexDirection: "row",
|
|
54
69
|
alignItems: "center",
|
|
55
70
|
justifyContent: "flex-end",
|
package/lib/module/Dialog.js
CHANGED
|
@@ -7,17 +7,26 @@ exports.ActionSheet = ActionSheet;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const tokens_1 = require("./internal/tokens");
|
|
10
|
-
const primitives_1 = require("./
|
|
10
|
+
const primitives_1 = require("./internal/primitives");
|
|
11
|
+
const motion_1 = require("./internal/motion");
|
|
12
|
+
const Glass_1 = require("./Glass");
|
|
11
13
|
const Button_1 = require("./Button");
|
|
12
14
|
/**
|
|
13
|
-
* A centred modal
|
|
15
|
+
* A centred modal panel above a dimmed backdrop.
|
|
16
|
+
*
|
|
17
|
+
* The panel is a glass surface, so it is Apple's real Liquid Glass on iOS 26+
|
|
18
|
+
* and Glacia's translucent tint elsewhere; the text sits on it with the
|
|
19
|
+
* theme's foreground colour, so contrast holds either way.
|
|
14
20
|
*
|
|
15
21
|
* React Native has no built-in focus trap, so this component covers what the
|
|
16
22
|
* platform can actually do: `Modal` blocks touches behind it, Android's back
|
|
17
23
|
* button routes to `onOpenChange(false)`, and the heading is marked as such so
|
|
18
24
|
* screen readers announce the dialog as it appears.
|
|
25
|
+
*
|
|
26
|
+
* To open a dialog from a button, use `DialogTrigger`.
|
|
19
27
|
*/
|
|
20
|
-
function Dialog({ open: controlledOpen, onOpenChange, title, description, children, footer, dismissOnBackdropPress = true, isDark
|
|
28
|
+
function Dialog({ open: controlledOpen, onOpenChange, title, description, children, footer, dismissOnBackdropPress = true, isDark: isDarkProp, style, testID, }) {
|
|
29
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
21
30
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
31
|
const { View, Text, Pressable, Modal, getBackHandler } = (0, primitives_1.primitives)();
|
|
23
32
|
const [uncontrolled, setUncontrolled] = (0, react_1.useState)(false);
|
|
@@ -46,17 +55,14 @@ function Dialog({ open: controlledOpen, onOpenChange, title, description, childr
|
|
|
46
55
|
justifyContent: "center",
|
|
47
56
|
padding: 24,
|
|
48
57
|
backgroundColor: "rgba(0, 0, 0, 0.45)",
|
|
49
|
-
}, children: (0, jsx_runtime_1.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
gap: 8,
|
|
58
|
-
...style,
|
|
59
|
-
}, children: [title && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "heading", style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: description })), children, footer && (0, jsx_runtime_1.jsx)(View, { style: { marginTop: 12, gap: 8 }, children: footer })] }) }) }));
|
|
58
|
+
}, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { width: "100%", maxWidth: 380 }, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
|
|
59
|
+
borderRadius: tokens_1.radii.lg,
|
|
60
|
+
borderWidth: 1,
|
|
61
|
+
borderColor: theme.edge,
|
|
62
|
+
padding: 20,
|
|
63
|
+
gap: 8,
|
|
64
|
+
...style,
|
|
65
|
+
}, children: [title && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "heading", style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: description })), children, footer && (0, jsx_runtime_1.jsx)(View, { style: { marginTop: 12, gap: 8 }, children: footer })] }) }) }) }));
|
|
60
66
|
}
|
|
61
67
|
/** Opens the dialog without the caller tracking state. */
|
|
62
68
|
function DialogTrigger({ label, children, ...dialogProps }) {
|
|
@@ -70,7 +76,8 @@ function DialogTrigger({ label, children, ...dialogProps }) {
|
|
|
70
76
|
* should require a real answer, so the only ways out are the two buttons or the
|
|
71
77
|
* Android back button, which counts as cancel.
|
|
72
78
|
*/
|
|
73
|
-
function AlertDialog({ open: controlledOpen, onOpenChange, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", destructive = false, onConfirm, onCancel, isDark
|
|
79
|
+
function AlertDialog({ open: controlledOpen, onOpenChange, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", destructive = false, onConfirm, onCancel, isDark: isDarkProp, testID, }) {
|
|
80
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
74
81
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
75
82
|
const { View } = (0, primitives_1.primitives)();
|
|
76
83
|
const [uncontrolled, setUncontrolled] = (0, react_1.useState)(false);
|
|
@@ -80,10 +87,20 @@ function AlertDialog({ open: controlledOpen, onOpenChange, title, description, c
|
|
|
80
87
|
setUncontrolled(next);
|
|
81
88
|
onOpenChange?.(next);
|
|
82
89
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const cancel = () => {
|
|
91
|
+
onCancel?.();
|
|
92
|
+
close(false);
|
|
93
|
+
};
|
|
94
|
+
return ((0, jsx_runtime_1.jsx)(Dialog, { open: open, testID: testID,
|
|
95
|
+
// Android's back button routes here as a dismissal, and a dismissal of a
|
|
96
|
+
// confirmation question is a cancellation, so onCancel fires too.
|
|
97
|
+
onOpenChange: (next) => {
|
|
98
|
+
if (!next) {
|
|
99
|
+
cancel();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
close(true);
|
|
103
|
+
}, title: title, description: description, dismissOnBackdropPress: false, isDark: isDark, footer: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", gap: 8, justifyContent: "flex-end" }, children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { accessibilityLabel: cancelLabel, variant: "ghost", onPress: cancel, children: cancelLabel }), (0, jsx_runtime_1.jsx)(Button_1.Button, { accessibilityLabel: confirmLabel, variant: "filled", tint: destructive ? theme.destructive : undefined, onPress: () => {
|
|
87
104
|
onConfirm?.();
|
|
88
105
|
close(false);
|
|
89
106
|
}, children: confirmLabel })] }) }));
|
|
@@ -94,9 +111,12 @@ function AlertDialog({ open: controlledOpen, onOpenChange, title, description, c
|
|
|
94
111
|
* Anchored to the bottom because that is where a thumb reaches, and it keeps a
|
|
95
112
|
* separate Cancel row so a mis-tap is always reversible.
|
|
96
113
|
*/
|
|
97
|
-
function ActionSheet({ open: controlledOpen, onOpenChange, title, message, options, cancelLabel = "Cancel", isDark
|
|
114
|
+
function ActionSheet({ open: controlledOpen, onOpenChange, title, message, options, cancelLabel = "Cancel", isDark: isDarkProp, testID, }) {
|
|
115
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
98
116
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
99
|
-
|
|
117
|
+
// Android's back button is handled by Modal's onRequestClose, so no
|
|
118
|
+
// BackHandler subscription is needed here.
|
|
119
|
+
const { View, Text, Pressable, Modal } = (0, primitives_1.primitives)();
|
|
100
120
|
const [uncontrolled, setUncontrolled] = (0, react_1.useState)(false);
|
|
101
121
|
const open = controlledOpen ?? uncontrolled;
|
|
102
122
|
const close = () => {
|
|
@@ -104,11 +124,7 @@ function ActionSheet({ open: controlledOpen, onOpenChange, title, message, optio
|
|
|
104
124
|
setUncontrolled(false);
|
|
105
125
|
onOpenChange?.(false);
|
|
106
126
|
};
|
|
107
|
-
return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "slide", onRequestClose: close, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss actions", onPress: close, style: { flex: 1, justifyContent: "flex-end", backgroundColor: "rgba(0,0,0,0.4)" }, children: (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { padding: 10, gap: 8 }, children: [(0, jsx_runtime_1.jsxs)(View, { style: {
|
|
108
|
-
borderRadius: tokens_1.radii.lg,
|
|
109
|
-
overflow: "hidden",
|
|
110
|
-
backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
|
|
111
|
-
}, children: [(title || message) && ((0, jsx_runtime_1.jsxs)(View, { style: { paddingVertical: 12, paddingHorizontal: 16, alignItems: "center" }, children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, children: title })), message && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginTop: 4, textAlign: "center" }, children: message }))] })), options.map((option, index) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: option.label, onPress: () => {
|
|
127
|
+
return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "slide", onRequestClose: close, testID: testID, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss actions", onPress: close, style: { flex: 1, justifyContent: "flex-end", backgroundColor: "rgba(0,0,0,0.4)" }, children: (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { padding: 10, gap: 8 }, children: [(0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: { borderRadius: tokens_1.radii.lg, overflow: "hidden" }, children: [(title || message) && ((0, jsx_runtime_1.jsxs)(View, { style: { paddingVertical: 12, paddingHorizontal: 16, alignItems: "center" }, children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, children: title })), message && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginTop: 4, textAlign: "center" }, children: message }))] })), options.map((option, index) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: option.label, onPress: () => {
|
|
112
128
|
option.onPress?.();
|
|
113
129
|
close();
|
|
114
130
|
}, style: {
|
|
@@ -119,10 +135,5 @@ function ActionSheet({ open: controlledOpen, onOpenChange, title, message, optio
|
|
|
119
135
|
}, children: (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
120
136
|
fontSize: 16,
|
|
121
137
|
color: option.destructive ? theme.destructive : theme.foreground,
|
|
122
|
-
}, children: option.label }) }, option.label)))] }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: cancelLabel, onPress: close, style: {
|
|
123
|
-
paddingVertical: 14,
|
|
124
|
-
alignItems: "center",
|
|
125
|
-
borderRadius: tokens_1.radii.lg,
|
|
126
|
-
backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
|
|
127
|
-
}, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 16, fontWeight: "600", color: theme.foreground }, children: cancelLabel }) })] }) }) }));
|
|
138
|
+
}, children: option.label }) }, option.label)))] }), (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: { borderRadius: tokens_1.radii.lg }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: cancelLabel, onPress: close, style: { paddingVertical: 14, alignItems: "center" }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 16, fontWeight: "600", color: theme.foreground }, children: cancelLabel }) }) })] }) }) }));
|
|
128
139
|
}
|
package/lib/module/Form.js
CHANGED
|
@@ -8,12 +8,14 @@ exports.Select = Select;
|
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const tokens_1 = require("./internal/tokens");
|
|
11
|
-
const primitives_1 = require("./
|
|
11
|
+
const primitives_1 = require("./internal/primitives");
|
|
12
|
+
const motion_1 = require("./internal/motion");
|
|
12
13
|
/** The text above a control. */
|
|
13
|
-
exports.Label = (0, react_1.forwardRef)(function Label({ children, required = false, disabled = false,
|
|
14
|
+
exports.Label = (0, react_1.forwardRef)(function Label({ children, required = false, disabled = false, nativeID, isDark: isDarkProp, style }, ref) {
|
|
15
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
14
16
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
15
17
|
const { Text } = (0, primitives_1.primitives)();
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)(Text, { ref: ref, nativeID:
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(Text, { ref: ref, nativeID: nativeID, accessibilityRole: "text", style: {
|
|
17
19
|
fontSize: 13,
|
|
18
20
|
fontWeight: "600",
|
|
19
21
|
color: disabled ? theme.muted : theme.foreground,
|
|
@@ -25,7 +27,8 @@ exports.Label = (0, react_1.forwardRef)(function Label({ children, required = fa
|
|
|
25
27
|
* Label, control and message stacked in the order assistive tech announces
|
|
26
28
|
* them, so a caller never has to place these three by hand.
|
|
27
29
|
*/
|
|
28
|
-
function Field({ label, description, error, required = false, disabled = false, isDark
|
|
30
|
+
function Field({ label, description, error, required = false, disabled = false, isDark: isDarkProp, children, style, }) {
|
|
31
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
29
32
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
30
33
|
const { View, Text } = (0, primitives_1.primitives)();
|
|
31
34
|
const message = error ?? description;
|
|
@@ -35,11 +38,23 @@ function Field({ label, description, error, required = false, disabled = false,
|
|
|
35
38
|
}, children: message }))] }));
|
|
36
39
|
}
|
|
37
40
|
/** A tick box for a single boolean, with an optional label and description. */
|
|
38
|
-
function Checkbox({ checked = false, onCheckedChange, label, description, indeterminate = false, disabled = false, isDark
|
|
41
|
+
function Checkbox({ checked: checkedProp, defaultChecked = false, onCheckedChange, label, description, indeterminate = false, disabled = false, isDark: isDarkProp, style, testID, }) {
|
|
42
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
39
43
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
40
44
|
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
45
|
+
// Controlled when `checked` is given, otherwise the box owns its state.
|
|
46
|
+
const [internalChecked, setInternalChecked] = (0, react_1.useState)(defaultChecked);
|
|
47
|
+
const checked = checkedProp !== undefined ? checkedProp : internalChecked;
|
|
48
|
+
const toggle = () => {
|
|
49
|
+
if (disabled)
|
|
50
|
+
return;
|
|
51
|
+
const next = !checked;
|
|
52
|
+
if (checkedProp === undefined)
|
|
53
|
+
setInternalChecked(next);
|
|
54
|
+
onCheckedChange?.(next);
|
|
55
|
+
};
|
|
41
56
|
const filled = checked || indeterminate;
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "checkbox", accessibilityState: { checked, disabled }, accessibilityLabel: label, disabled: disabled, onPress:
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { testID: testID, accessibilityRole: "checkbox", accessibilityState: { checked, disabled }, accessibilityLabel: label, disabled: disabled, onPress: toggle, style: {
|
|
43
58
|
flexDirection: "row",
|
|
44
59
|
alignItems: "flex-start",
|
|
45
60
|
gap: 10,
|
|
@@ -60,13 +75,28 @@ function Checkbox({ checked = false, onCheckedChange, label, description, indete
|
|
|
60
75
|
(0, jsx_runtime_1.jsx)(Text, { style: { color: "#fff", fontSize: 12, fontWeight: "700", lineHeight: 14 }, children: "\u2713" })) : null }), (label || description) && ((0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [label && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground, fontWeight: "500" }, children: label })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: description }))] }))] }));
|
|
61
76
|
}
|
|
62
77
|
/** One choice from a small, always-visible set. */
|
|
63
|
-
function RadioGroup({ value, onValueChange, options, horizontal = false, disabled = false, isDark
|
|
78
|
+
function RadioGroup({ value: valueProp, defaultValue, onValueChange, options, horizontal = false, disabled = false, isDark: isDarkProp, style, testID, }) {
|
|
79
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
64
80
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
65
81
|
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
66
|
-
|
|
82
|
+
// Controlled when `value` is given, otherwise the group owns its selection.
|
|
83
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue);
|
|
84
|
+
const value = valueProp !== undefined ? valueProp : internalValue;
|
|
85
|
+
const select = (next, isDisabled) => {
|
|
86
|
+
if (isDisabled)
|
|
87
|
+
return;
|
|
88
|
+
if (valueProp === undefined)
|
|
89
|
+
setInternalValue(next);
|
|
90
|
+
onValueChange?.(next);
|
|
91
|
+
};
|
|
92
|
+
return ((0, jsx_runtime_1.jsx)(View, { testID: testID, accessibilityRole: "radiogroup", style: {
|
|
93
|
+
gap: horizontal ? 14 : 10,
|
|
94
|
+
flexDirection: horizontal ? "row" : "column",
|
|
95
|
+
...style,
|
|
96
|
+
}, children: options.map((option) => {
|
|
67
97
|
const isSelected = option.value === value;
|
|
68
98
|
const isDisabled = disabled || option.disabled;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "radio", accessibilityState: { checked: isSelected, disabled: isDisabled }, accessibilityLabel: option.label, disabled: isDisabled, onPress: () =>
|
|
99
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "radio", accessibilityState: { checked: isSelected, disabled: isDisabled }, accessibilityLabel: option.label, disabled: isDisabled, onPress: () => select(option.value, isDisabled), style: {
|
|
70
100
|
flexDirection: "row",
|
|
71
101
|
alignItems: "flex-start",
|
|
72
102
|
gap: 9,
|
|
@@ -88,12 +118,21 @@ function RadioGroup({ value, onValueChange, options, horizontal = false, disable
|
|
|
88
118
|
* list opens inline: predictable across platforms and reachable without a
|
|
89
119
|
* modal. A long list scrolls naturally with the page.
|
|
90
120
|
*/
|
|
91
|
-
function Select({ value, onValueChange, options, placeholder = "Select an option", disabled = false, isDark
|
|
121
|
+
function Select({ value: valueProp, defaultValue, onValueChange, options, placeholder = "Select an option", disabled = false, isDark: isDarkProp, style, testID, }) {
|
|
122
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
92
123
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
93
124
|
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
94
125
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
126
|
+
// Controlled when `value` is given, otherwise the select owns its choice.
|
|
127
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue);
|
|
128
|
+
const value = valueProp !== undefined ? valueProp : internalValue;
|
|
129
|
+
const choose = (next) => {
|
|
130
|
+
if (valueProp === undefined)
|
|
131
|
+
setInternalValue(next);
|
|
132
|
+
onValueChange?.(next);
|
|
133
|
+
};
|
|
95
134
|
const selected = options.find((option) => option.value === value);
|
|
96
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { expanded: open, disabled }, accessibilityLabel: selected?.label ?? placeholder, disabled: disabled, onPress: () => setOpen(!open), style: {
|
|
135
|
+
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Pressable, { testID: testID, accessibilityRole: "button", accessibilityState: { expanded: open, disabled }, accessibilityLabel: selected?.label ?? placeholder, disabled: disabled, onPress: () => setOpen(!open), style: {
|
|
97
136
|
minHeight: 42,
|
|
98
137
|
flexDirection: "row",
|
|
99
138
|
alignItems: "center",
|
|
@@ -114,7 +153,7 @@ function Select({ value, onValueChange, options, placeholder = "Select an option
|
|
|
114
153
|
}, children: options.map((option) => {
|
|
115
154
|
const isSelected = option.value === value;
|
|
116
155
|
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isSelected }, accessibilityLabel: option.label, onPress: () => {
|
|
117
|
-
|
|
156
|
+
choose(option.value);
|
|
118
157
|
setOpen(false);
|
|
119
158
|
}, style: {
|
|
120
159
|
paddingVertical: 10,
|
package/lib/module/Glass.js
CHANGED
|
@@ -4,6 +4,15 @@ exports.Glass = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const GlassView_1 = require("./internal/GlassView");
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const motion_1 = require("./internal/motion");
|
|
8
|
+
/**
|
|
9
|
+
* A glass surface.
|
|
10
|
+
*
|
|
11
|
+
* Routes through the package's single switch: Apple's real `UIGlassEffect` on
|
|
12
|
+
* iOS 26+, Glacia's translucent fallback of identical shape on older iOS and
|
|
13
|
+
* Android. `testID` is passed to whichever surface renders.
|
|
14
|
+
*/
|
|
15
|
+
exports.Glass = (0, react_1.forwardRef)(function Glass({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
|
|
16
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(GlassView_1.GlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, isDark: isDark, style: style, ...props, children: children }));
|
|
9
18
|
});
|
package/lib/module/Input.js
CHANGED
|
@@ -4,7 +4,8 @@ exports.Textarea = exports.Input = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const tokens_1 = require("./internal/tokens");
|
|
7
|
-
const primitives_1 = require("./
|
|
7
|
+
const primitives_1 = require("./internal/primitives");
|
|
8
|
+
const motion_1 = require("./internal/motion");
|
|
8
9
|
const heights = { sm: 34, md: 42, lg: 50 };
|
|
9
10
|
const fontSizes = { sm: 14, md: 15, lg: 16 };
|
|
10
11
|
/**
|
|
@@ -13,20 +14,32 @@ const fontSizes = { sm: 14, md: 15, lg: 16 };
|
|
|
13
14
|
* The native TextInput has no placeholder styling prop, so the placeholder is
|
|
14
15
|
* drawn as a sibling Text: that keeps its colour tied to the theme instead of
|
|
15
16
|
* the OS default, which changes between iOS versions.
|
|
17
|
+
*
|
|
18
|
+
* The field works controlled (`value` + `onChangeText`) or uncontrolled (no
|
|
19
|
+
* `value` prop). In uncontrolled use it tracks its own text so the themed
|
|
20
|
+
* placeholder disappears as soon as the user types; without that state the
|
|
21
|
+
* overlay would sit on top of the typed text until the parent re-rendered.
|
|
16
22
|
*/
|
|
17
|
-
exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, placeholder, invalid = false, disabled = false, secureTextEntry = false, keyboardType = "default", autoCapitalize, autoCorrect, multiline = false, minLines = 3, size = "md", accessibilityLabel, returnKeyType, onSubmitEditing, prefix, suffix, isDark
|
|
23
|
+
exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, placeholder, invalid = false, disabled = false, secureTextEntry = false, keyboardType = "default", autoCapitalize, autoCorrect, multiline = false, minLines = 3, size = "md", accessibilityLabel, returnKeyType, onSubmitEditing, defaultValue, prefix, suffix, isDark: isDarkProp, style, testID, maxLength, editable, onFocus, onBlur, }, ref) {
|
|
24
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
18
25
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
19
26
|
const { View, Text, TextInput } = (0, primitives_1.primitives)();
|
|
27
|
+
// Uncontrolled support: with no `value` prop the field owns its text.
|
|
28
|
+
const [internalText, setInternalText] = (0, react_1.useState)(defaultValue ?? "");
|
|
29
|
+
const text = value !== undefined ? value : internalText;
|
|
30
|
+
const handleChangeText = (next) => {
|
|
31
|
+
if (value === undefined)
|
|
32
|
+
setInternalText(next);
|
|
33
|
+
onChangeText?.(next);
|
|
34
|
+
};
|
|
20
35
|
const isEditable = editable !== undefined ? editable : !disabled;
|
|
21
|
-
const showPlaceholder = !
|
|
36
|
+
const showPlaceholder = !text && Boolean(placeholder);
|
|
22
37
|
const fieldStyle = {
|
|
23
38
|
flex: 1,
|
|
24
39
|
paddingVertical: height_padding(size),
|
|
25
40
|
paddingHorizontal: 0,
|
|
26
41
|
fontSize: fontSizes[size],
|
|
27
42
|
color: theme.foreground,
|
|
28
|
-
// RN draws its own underline on Android; the border is ours.
|
|
29
|
-
outlineStyle: "none",
|
|
30
43
|
};
|
|
31
44
|
return ((0, jsx_runtime_1.jsxs)(View, { style: {
|
|
32
45
|
flexDirection: "row",
|
|
@@ -46,8 +59,7 @@ exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, pl
|
|
|
46
59
|
top: multiline ? 0 : undefined,
|
|
47
60
|
fontSize: fontSizes[size],
|
|
48
61
|
color: theme.muted,
|
|
49
|
-
|
|
50
|
-
}, numberOfLines: 1, children: placeholder })), (0, jsx_runtime_1.jsx)(TextInput, { ref: ref, value: value, onChangeText: onChangeText, editable: isEditable, secureTextEntry: secureTextEntry, keyboardType: keyboardType, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, multiline: multiline, numberOfLines: multiline ? minLines : undefined, maxLength: maxLength, returnKeyType: returnKeyType, onSubmitEditing: onSubmitEditing, onFocus: onFocus, onBlur: onBlur, accessibilityLabel: accessibilityLabel ?? placeholder, accessibilityState: { disabled: !isEditable }, style: fieldStyle })] }), suffix] }));
|
|
62
|
+
}, pointerEvents: "none", numberOfLines: 1, children: placeholder })), (0, jsx_runtime_1.jsx)(TextInput, { ref: ref, testID: testID, value: text, onChangeText: handleChangeText, editable: isEditable, secureTextEntry: secureTextEntry, keyboardType: keyboardType, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, multiline: multiline, numberOfLines: multiline ? minLines : undefined, maxLength: maxLength, returnKeyType: returnKeyType, onSubmitEditing: onSubmitEditing, onFocus: onFocus, onBlur: onBlur, accessibilityLabel: accessibilityLabel ?? placeholder, accessibilityState: { disabled: !isEditable }, style: fieldStyle })] }), suffix] }));
|
|
51
63
|
});
|
|
52
64
|
/** Vertical padding tuned per size so the text sits optically centred. */
|
|
53
65
|
function height_padding(size) {
|
|
@@ -5,42 +5,86 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Glass_1 = require("./Glass");
|
|
7
7
|
const tokens_1 = require("./internal/tokens");
|
|
8
|
-
|
|
8
|
+
const primitives_1 = require("./internal/primitives");
|
|
9
|
+
const motion_1 = require("./internal/motion");
|
|
10
|
+
const SEGMENT_HEIGHT = 30;
|
|
11
|
+
/**
|
|
12
|
+
* A row of mutually exclusive segments on one glass container.
|
|
13
|
+
*
|
|
14
|
+
* The selected segment is marked by a pill that slides on the springs token.
|
|
15
|
+
* The pill's colours come from the theme tokens, so it reads correctly in both
|
|
16
|
+
* light and dark instead of assuming a white-on-light palette.
|
|
17
|
+
*/
|
|
18
|
+
exports.SegmentedControl = (0, react_1.forwardRef)(function SegmentedControl({ values, selectedIndex: selectedProp, defaultIndex = 0, onValueChange, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
19
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
20
|
+
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
21
|
+
const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
|
|
9
22
|
const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultIndex);
|
|
10
23
|
const activeIndex = selectedProp !== undefined ? selectedProp : internalIndex;
|
|
11
|
-
const
|
|
24
|
+
const safeIndex = Math.min(Math.max(activeIndex, 0), Math.max(values.length - 1, 0));
|
|
25
|
+
// The pill slides between equal-width segments, so a ratio is enough: 0 is
|
|
26
|
+
// the first segment, values.length - 1 the last.
|
|
27
|
+
const { value: slide, animated } = (0, motion_1.useSpring)(safeIndex, "snappy");
|
|
12
28
|
const handleSelect = (index) => {
|
|
13
|
-
if (selectedProp === undefined)
|
|
29
|
+
if (selectedProp === undefined)
|
|
14
30
|
setInternalIndex(index);
|
|
15
|
-
}
|
|
16
31
|
const val = values[index];
|
|
17
|
-
if (val !== undefined)
|
|
32
|
+
if (val !== undefined)
|
|
18
33
|
onValueChange?.(val, index);
|
|
19
|
-
}
|
|
20
34
|
};
|
|
35
|
+
const count = Math.max(values.length, 1);
|
|
36
|
+
const pillWidth = `${100 / count}%`;
|
|
21
37
|
const containerStyle = {
|
|
22
38
|
position: "relative",
|
|
23
|
-
display: "inline-flex",
|
|
24
39
|
flexDirection: "row",
|
|
25
40
|
alignItems: "center",
|
|
41
|
+
alignSelf: "flex-start",
|
|
26
42
|
padding: 2,
|
|
27
43
|
borderRadius: tokens_1.radii.md,
|
|
28
44
|
backgroundColor: "rgba(118, 118, 128, 0.12)",
|
|
29
45
|
...style,
|
|
30
46
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
const pillTranslate = animated
|
|
48
|
+
? slide.interpolate({
|
|
49
|
+
inputRange: [0, Math.max(count - 1, 1)],
|
|
50
|
+
// One segment's worth per step, measured against the pill's own width.
|
|
51
|
+
outputRange: ["0%", `${((count - 1) * 100) / count}%`],
|
|
52
|
+
})
|
|
53
|
+
: `${(safeIndex * 100) / count}%`;
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: containerStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { style: {
|
|
55
|
+
position: "absolute",
|
|
56
|
+
top: 2,
|
|
57
|
+
left: 2,
|
|
58
|
+
width: pillWidth,
|
|
59
|
+
height: SEGMENT_HEIGHT,
|
|
60
|
+
borderRadius: tokens_1.radii.sm,
|
|
61
|
+
backgroundColor: themeColors.glassActive,
|
|
62
|
+
borderWidth: 0.5,
|
|
63
|
+
borderColor: themeColors.edge,
|
|
64
|
+
transform: [{ translateX: pillTranslate }],
|
|
65
|
+
}, pointerEvents: "none" })) : ((0, jsx_runtime_1.jsx)(View, { style: {
|
|
66
|
+
position: "absolute",
|
|
67
|
+
top: 2,
|
|
68
|
+
left: `${2 + (safeIndex * 100) / count}%`,
|
|
69
|
+
width: pillWidth,
|
|
70
|
+
height: SEGMENT_HEIGHT,
|
|
35
71
|
borderRadius: tokens_1.radii.sm,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
72
|
+
backgroundColor: themeColors.glassActive,
|
|
73
|
+
borderWidth: 0.5,
|
|
74
|
+
borderColor: themeColors.edge,
|
|
75
|
+
}, pointerEvents: "none" })), values.map((label, idx) => {
|
|
76
|
+
const isSelected = idx === safeIndex;
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "tab", accessibilityLabel: label, accessibilityState: { selected: isSelected }, onPress: () => handleSelect(idx), style: {
|
|
78
|
+
flex: 1,
|
|
79
|
+
height: SEGMENT_HEIGHT,
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
justifyContent: "center",
|
|
82
|
+
paddingHorizontal: 16,
|
|
83
|
+
borderRadius: tokens_1.radii.sm,
|
|
84
|
+
}, children: (0, jsx_runtime_1.jsx)(Text, { numberOfLines: 1, style: {
|
|
85
|
+
fontSize: 13,
|
|
86
|
+
fontWeight: isSelected ? "600" : "500",
|
|
87
|
+
color: isSelected ? themeColors.foreground : themeColors.muted,
|
|
88
|
+
}, children: label }) }, label));
|
|
89
|
+
})] }));
|
|
46
90
|
});
|