glacia-native 0.3.5 → 0.5.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/Bars.js +176 -0
- package/lib/module/Button.js +15 -2
- package/lib/module/Card.js +29 -14
- package/lib/module/Carousel.js +103 -0
- package/lib/module/Dialog.js +43 -32
- package/lib/module/Display.js +240 -0
- package/lib/module/Feedback.js +172 -0
- package/lib/module/Form.js +51 -12
- package/lib/module/Forms2.js +227 -0
- package/lib/module/Glass.js +11 -2
- package/lib/module/Input.js +19 -7
- package/lib/module/Overlays.js +166 -0
- package/lib/module/Pickers.js +243 -0
- 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/Text.js +37 -0
- 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/index.js +58 -1
- package/lib/module/internal/GlassView.js +31 -17
- 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 +413 -0
- package/lib/module/internal/tokens.js +55 -1
- package/lib/typescript/Bars.d.ts +121 -0
- package/lib/typescript/Button.d.ts +11 -1
- package/lib/typescript/Card.d.ts +20 -8
- package/lib/typescript/Carousel.d.ts +47 -0
- package/lib/typescript/Dialog.d.ts +19 -6
- package/lib/typescript/Display.d.ts +119 -0
- package/lib/typescript/Feedback.d.ts +138 -0
- package/lib/typescript/Form.d.ts +27 -11
- package/lib/typescript/Forms2.d.ts +128 -0
- package/lib/typescript/Glass.d.ts +10 -1
- package/lib/typescript/Input.d.ts +11 -1
- package/lib/typescript/Overlays.d.ts +105 -0
- package/lib/typescript/Pickers.d.ts +105 -0
- 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/Text.d.ts +28 -0
- 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/index.d.ts +9 -1
- package/lib/typescript/internal/GlassView.d.ts +21 -4
- 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/lib/typescript/internal/tokens.d.ts +61 -0
- package/package.json +2 -2
- package/src/Bars.tsx +570 -0
- package/src/Button.tsx +47 -22
- package/src/Card.tsx +52 -31
- package/src/Carousel.tsx +233 -0
- package/src/Dialog.tsx +99 -64
- package/src/Display.tsx +550 -0
- package/src/Feedback.tsx +579 -0
- package/src/Form.tsx +90 -25
- package/src/Forms2.tsx +608 -0
- package/src/Glass.tsx +24 -1
- package/src/Input.tsx +33 -12
- package/src/Overlays.tsx +474 -0
- package/src/Pickers.tsx +590 -0
- 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/Text.tsx +83 -0
- 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/index.ts +101 -1
- package/src/internal/GlassView.tsx +51 -19
- 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 +482 -0
- package/src/internal/tokens.ts +62 -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
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppBar = exports.IconButton = exports.FAB = exports.Chip = exports.SearchBar = 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 primitives_1 = require("./internal/primitives");
|
|
9
|
+
const motion_1 = require("./internal/motion");
|
|
10
|
+
/**
|
|
11
|
+
* A search field for a bar or a screen header.
|
|
12
|
+
*
|
|
13
|
+
* Distinct from NativeAIInput: that is an AI composer with send semantics, this
|
|
14
|
+
* is ordinary app search — magnifier, themed placeholder, and a clear button
|
|
15
|
+
* once there is something to clear.
|
|
16
|
+
*/
|
|
17
|
+
exports.SearchBar = (0, react_1.forwardRef)(function SearchBar({ value: valueProp, defaultValue = "", onChangeText, onSubmit, placeholder = "Search", showCancel = false, onCancel, accessibilityLabel = "Search", style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
18
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
19
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
20
|
+
const { View, Text: RNText, TextInput, Pressable } = (0, primitives_1.primitives)();
|
|
21
|
+
const [internal, setInternal] = (0, react_1.useState)(defaultValue);
|
|
22
|
+
const value = valueProp !== undefined ? valueProp : internal;
|
|
23
|
+
const handleChange = (next) => {
|
|
24
|
+
if (valueProp === undefined)
|
|
25
|
+
setInternal(next);
|
|
26
|
+
onChangeText?.(next);
|
|
27
|
+
};
|
|
28
|
+
const clear = () => handleChange("");
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: [{ flexDirection: "row", alignItems: "center", gap: 8 }, style], ...props, children: [(0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: {
|
|
30
|
+
flex: 1,
|
|
31
|
+
flexDirection: "row",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
gap: 8,
|
|
34
|
+
height: 36,
|
|
35
|
+
borderRadius: tokens_1.radii.pill,
|
|
36
|
+
paddingHorizontal: 12,
|
|
37
|
+
}, children: [(0, jsx_runtime_1.jsx)(RNText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { fontSize: 14, color: theme.muted }, children: "\u2315" }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, justifyContent: "center" }, children: [!value && placeholder ? (
|
|
38
|
+
// Themed placeholder: the OS default colour ignores the theme.
|
|
39
|
+
(0, jsx_runtime_1.jsx)(RNText, { pointerEvents: "none", numberOfLines: 1, style: { position: "absolute", left: 0, fontSize: 15, color: theme.muted }, children: placeholder })) : null, (0, jsx_runtime_1.jsx)(TextInput, { accessibilityRole: "search", accessibilityLabel: accessibilityLabel, value: value, onChangeText: handleChange, onSubmitEditing: () => onSubmit?.(value), returnKeyType: "search", autoCorrect: false, placeholder: "", style: {
|
|
40
|
+
fontSize: 15,
|
|
41
|
+
paddingVertical: 4,
|
|
42
|
+
color: theme.foreground,
|
|
43
|
+
// Transparent: the themed placeholder above provides the hint.
|
|
44
|
+
backgroundColor: "transparent",
|
|
45
|
+
} })] }), value.length > 0 && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Clear search", onPress: clear, hitSlop: 8, children: (0, jsx_runtime_1.jsx)(View, { style: {
|
|
46
|
+
width: 16,
|
|
47
|
+
height: 16,
|
|
48
|
+
// A circle from its own size: half the 16pt box.
|
|
49
|
+
borderRadius: 16 / 2,
|
|
50
|
+
backgroundColor: theme.separator,
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
justifyContent: "center",
|
|
53
|
+
}, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 10, color: theme.muted }, children: "\u00D7" }) }) }))] }), showCancel && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Cancel", onPress: () => {
|
|
54
|
+
clear();
|
|
55
|
+
onCancel?.();
|
|
56
|
+
}, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, color: theme.fill }, children: "Cancel" }) }))] }));
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* A filter or tag pill.
|
|
60
|
+
*
|
|
61
|
+
* Selected state is a glass pill tinted with `glassActive` — the same selected
|
|
62
|
+
* treatment SegmentedControl and TabBar use, rather than a new colour.
|
|
63
|
+
*/
|
|
64
|
+
exports.Chip = (0, react_1.forwardRef)(function Chip({ label, icon, onClose, onPress, selected: selectedProp, defaultSelected = false, onSelectedChange, disabled = false, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
65
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
66
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
67
|
+
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
68
|
+
const [internalSelected, setInternalSelected] = (0, react_1.useState)(defaultSelected);
|
|
69
|
+
const selected = selectedProp !== undefined ? selectedProp : internalSelected;
|
|
70
|
+
const selectable = selectedProp !== undefined || onSelectedChange !== undefined || defaultSelected;
|
|
71
|
+
const handlePress = () => {
|
|
72
|
+
if (disabled)
|
|
73
|
+
return;
|
|
74
|
+
if (selectable) {
|
|
75
|
+
const next = !selected;
|
|
76
|
+
if (selectedProp === undefined)
|
|
77
|
+
setInternalSelected(next);
|
|
78
|
+
onSelectedChange?.(next);
|
|
79
|
+
}
|
|
80
|
+
onPress?.();
|
|
81
|
+
};
|
|
82
|
+
const pill = ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, tintColor: selected ? theme.glassActive : undefined, interactive: !disabled, style: {
|
|
83
|
+
flexDirection: "row",
|
|
84
|
+
alignItems: "center",
|
|
85
|
+
gap: 6,
|
|
86
|
+
height: 30,
|
|
87
|
+
paddingHorizontal: 12,
|
|
88
|
+
borderRadius: tokens_1.radii.pill,
|
|
89
|
+
opacity: disabled ? 0.38 : 1,
|
|
90
|
+
...style,
|
|
91
|
+
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 13, fontWeight: selected ? "600" : "500", color: selected ? theme.foreground : theme.muted }, children: label }), onClose && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `Remove ${label}`, onPress: onClose, hitSlop: 8, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 11, color: theme.muted }, children: "\u00D7" }) }))] }));
|
|
92
|
+
if (!onPress && !selectable) {
|
|
93
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: label, ...props, children: pill }));
|
|
94
|
+
}
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { selected: selectable ? selected : undefined, disabled }, disabled: disabled, onPress: handlePress, ...props, children: pill }));
|
|
96
|
+
});
|
|
97
|
+
const fabSizes = { md: 56, lg: 64 };
|
|
98
|
+
/**
|
|
99
|
+
* The floating action button.
|
|
100
|
+
*
|
|
101
|
+
* The flagship glass circle of the library: a round `Glass` with `interactive`
|
|
102
|
+
* so the material itself responds to touch. The caller positions it; the
|
|
103
|
+
* component does not assume an edge.
|
|
104
|
+
*/
|
|
105
|
+
exports.FAB = (0, react_1.forwardRef)(function FAB({ onPress, accessibilityLabel, icon, label, size = "md", disabled = false, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
106
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
107
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
108
|
+
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
109
|
+
const dimension = fabSizes[size];
|
|
110
|
+
const extended = Boolean(label);
|
|
111
|
+
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 }) => ({
|
|
112
|
+
alignSelf: "flex-start",
|
|
113
|
+
opacity: disabled ? 0.38 : pressed ? 0.85 : 1,
|
|
114
|
+
}), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "clear", interactive: !disabled, isDark: isDark, style: {
|
|
115
|
+
height: dimension,
|
|
116
|
+
width: extended ? undefined : dimension,
|
|
117
|
+
minWidth: dimension,
|
|
118
|
+
borderRadius: extended ? dimension / 2 : dimension / 2,
|
|
119
|
+
paddingHorizontal: extended ? 20 : 0,
|
|
120
|
+
flexDirection: "row",
|
|
121
|
+
alignItems: "center",
|
|
122
|
+
justifyContent: "center",
|
|
123
|
+
gap: 8,
|
|
124
|
+
...style,
|
|
125
|
+
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, label ? ((0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, fontWeight: "600", color: theme.foreground }, numberOfLines: 1, children: label })) : null] }) }));
|
|
126
|
+
});
|
|
127
|
+
const iconButtonSizes = { sm: 28, md: 36, lg: 44 };
|
|
128
|
+
/**
|
|
129
|
+
* An icon-only button on glass.
|
|
130
|
+
*
|
|
131
|
+
* Button takes an icon alongside a label; this is the icon-only form, which
|
|
132
|
+
* every kit ships for toolbars and bar actions.
|
|
133
|
+
*/
|
|
134
|
+
exports.IconButton = (0, react_1.forwardRef)(function IconButton({ accessibilityLabel, onPress, icon, size = "md", variant = "glass", disabled = false, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
135
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
136
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
137
|
+
const { View, Pressable } = (0, primitives_1.primitives)();
|
|
138
|
+
const dimension = iconButtonSizes[size];
|
|
139
|
+
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: disabled ? 0.38 : pressed ? 0.8 : 1 }), ...props, children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", interactive: !disabled && variant !== "ghost", isDark: isDark, style: {
|
|
140
|
+
width: dimension,
|
|
141
|
+
height: dimension,
|
|
142
|
+
borderRadius: dimension / 2,
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "center",
|
|
145
|
+
backgroundColor: variant === "ghost" ? "transparent" : undefined,
|
|
146
|
+
...style,
|
|
147
|
+
}, children: (0, jsx_runtime_1.jsx)(View, { style: { width: dimension * 0.5, height: dimension * 0.5, alignItems: "center", justifyContent: "center" }, children: icon }) }) }));
|
|
148
|
+
});
|
|
149
|
+
/**
|
|
150
|
+
* The top bar.
|
|
151
|
+
*
|
|
152
|
+
* A glass bar across the top of the screen with a leading action, a title and
|
|
153
|
+
* trailing actions — the counterpart to the existing bottom TabBar.
|
|
154
|
+
*/
|
|
155
|
+
exports.AppBar = (0, react_1.forwardRef)(function AppBar({ title, subtitle, leading, actions, topInset = 0, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
156
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
157
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
158
|
+
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
159
|
+
const actionCount = actions?.length ?? 0;
|
|
160
|
+
const renderAction = (action, key) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.accessibilityLabel, accessibilityState: { disabled: action.disabled }, disabled: action.disabled, onPress: action.disabled ? undefined : action.onPress, hitSlop: 6, style: { padding: 6, opacity: action.disabled ? 0.38 : 1 }, children: action.icon }, key));
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: {
|
|
162
|
+
borderRadius: 0,
|
|
163
|
+
borderTopWidth: 0,
|
|
164
|
+
borderLeftWidth: 0,
|
|
165
|
+
borderRightWidth: 0,
|
|
166
|
+
...style,
|
|
167
|
+
}, ...props, children: (0, jsx_runtime_1.jsxs)(View, { style: {
|
|
168
|
+
paddingTop: topInset,
|
|
169
|
+
paddingHorizontal: 8,
|
|
170
|
+
paddingBottom: 8,
|
|
171
|
+
flexDirection: "row",
|
|
172
|
+
alignItems: "center",
|
|
173
|
+
gap: 4,
|
|
174
|
+
minHeight: 44 + topInset,
|
|
175
|
+
}, children: [leading ? renderAction(leading, "leading") : (0, jsx_runtime_1.jsx)(View, { style: { width: 8 } }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, paddingHorizontal: 4 }, children: [(0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "header", numberOfLines: 1, style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title }), subtitle ? ((0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 12, color: theme.muted }, children: subtitle })) : null] }), actions && actionCount > 0 ? ((0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row", alignItems: "center" }, children: actions.map((action, index) => renderAction(action, `action-${index}`)) })) : null] }) }));
|
|
176
|
+
});
|
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",
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageControl = exports.Carousel = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const tokens_1 = require("./internal/tokens");
|
|
7
|
+
const primitives_1 = require("./internal/primitives");
|
|
8
|
+
const motion_1 = require("./internal/motion");
|
|
9
|
+
/**
|
|
10
|
+
* A horizontally paging swiper.
|
|
11
|
+
*
|
|
12
|
+
* It rides the resolver's ScrollView with `pagingEnabled`, so the paging feel is
|
|
13
|
+
* the platform's own and the pages are plain content the caller supplies. The
|
|
14
|
+
* active page is derived from the scroll offset, which is also what reports
|
|
15
|
+
* `onIndexChange`.
|
|
16
|
+
*/
|
|
17
|
+
exports.Carousel = (0, react_1.forwardRef)(function Carousel({ slides, index: indexProp, defaultIndex = 0, onIndexChange, gap = 0, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
18
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
19
|
+
const { getScrollView } = (0, primitives_1.primitives)();
|
|
20
|
+
const ScrollView = getScrollView();
|
|
21
|
+
const { View } = (0, primitives_1.primitives)();
|
|
22
|
+
const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultIndex);
|
|
23
|
+
const index = indexProp !== undefined ? indexProp : internalIndex;
|
|
24
|
+
const viewportWidth = (0, react_1.useRef)(0);
|
|
25
|
+
const scrollRef = (0, react_1.useRef)(null);
|
|
26
|
+
// Derives the page from the offset rather than trusting a counter, so a
|
|
27
|
+
// fast swipe that skips pages still reports the page it landed on.
|
|
28
|
+
const handleScroll = (event) => {
|
|
29
|
+
const { contentOffset, layoutMeasurement } = event?.nativeEvent ?? {};
|
|
30
|
+
const width = layoutMeasurement?.width || viewportWidth.current;
|
|
31
|
+
if (!width || !contentOffset)
|
|
32
|
+
return;
|
|
33
|
+
const next = Math.round(contentOffset.x / width);
|
|
34
|
+
const clamped = Math.min(Math.max(next, 0), Math.max(slides.length - 1, 0));
|
|
35
|
+
if (clamped !== index) {
|
|
36
|
+
if (indexProp === undefined)
|
|
37
|
+
setInternalIndex(clamped);
|
|
38
|
+
onIndexChange?.(clamped);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const pages = slides.map((slide, i) => ((0, jsx_runtime_1.jsx)(View, { style: { width: viewportWidth.current || "100%", paddingRight: gap }, children: slide }, i)));
|
|
42
|
+
// Off-device there is no ScrollView; the pages still render in a row so the
|
|
43
|
+
// component mounts, and the tests drive `handleScroll` through onScroll.
|
|
44
|
+
if (!ScrollView) {
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: [{ flexDirection: "row", overflow: "hidden" }, style], ...props, children: pages }));
|
|
46
|
+
}
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, onLayout: (event) => {
|
|
48
|
+
viewportWidth.current = event?.nativeEvent?.layout?.width ?? 0;
|
|
49
|
+
}, style: style, ...props, children: (0, jsx_runtime_1.jsx)(ScrollView, { ref: scrollRef, horizontal: true, pagingEnabled: gap === 0, showsHorizontalScrollIndicator: false, onScroll: handleScroll, scrollEventThrottle: 16, accessibilityRole: "adjustable", accessibilityLabel: "Carousel", accessibilityValue: { min: 0, max: Math.max(slides.length - 1, 0), now: index }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
|
|
50
|
+
const step = event?.nativeEvent?.actionName === "increment" ? 1 : -1;
|
|
51
|
+
const next = Math.min(Math.max(index + step, 0), Math.max(slides.length - 1, 0));
|
|
52
|
+
if (next === index)
|
|
53
|
+
return;
|
|
54
|
+
if (indexProp === undefined)
|
|
55
|
+
setInternalIndex(next);
|
|
56
|
+
onIndexChange?.(next);
|
|
57
|
+
}, children: pages }) }));
|
|
58
|
+
});
|
|
59
|
+
const DOT = 7;
|
|
60
|
+
const ACTIVE_DOT = 18;
|
|
61
|
+
/**
|
|
62
|
+
* The page dots.
|
|
63
|
+
*
|
|
64
|
+
* The active dot elongates and the others stay narrow, which is how iOS reads
|
|
65
|
+
* "you are here". The width change runs on the springs token through Animated.
|
|
66
|
+
*/
|
|
67
|
+
exports.PageControl = (0, react_1.forwardRef)(function PageControl({ count, activeIndex: activeProp, defaultActiveIndex = 0, onChange, tint, hidesForSinglePage = false, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
68
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
69
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
70
|
+
const { View, Pressable } = (0, primitives_1.primitives)();
|
|
71
|
+
const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultActiveIndex);
|
|
72
|
+
const active = activeProp !== undefined ? activeProp : internalIndex;
|
|
73
|
+
if (hidesForSinglePage && count <= 1)
|
|
74
|
+
return null;
|
|
75
|
+
// The accent tints the active dot; the resting dots sit on `glassActive` so
|
|
76
|
+
// selection reads the same way it does in SegmentedControl and TabBar.
|
|
77
|
+
const accent = tint ?? theme.fill;
|
|
78
|
+
const resting = theme.glassActive;
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "tablist", style: [{ flexDirection: "row", alignItems: "center", gap: 6, alignSelf: "center" }, style], ...props, children: Array.from({ length: Math.max(count, 0) }, (_, index) => {
|
|
80
|
+
const isActive = index === active;
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "tab", accessibilityLabel: `Page ${index + 1} of ${count}`, accessibilityState: { selected: isActive }, onPress: () => {
|
|
82
|
+
if (activeProp === undefined)
|
|
83
|
+
setInternalIndex(index);
|
|
84
|
+
onChange?.(index);
|
|
85
|
+
}, hitSlop: 8, children: (0, jsx_runtime_1.jsx)(Dot, { active: isActive, accent: accent, muted: resting }) }, index));
|
|
86
|
+
}) }));
|
|
87
|
+
});
|
|
88
|
+
/** One dot, whose width springs between the resting and active lengths. */
|
|
89
|
+
function Dot({ active, accent, muted }) {
|
|
90
|
+
const { Animated, View } = (0, primitives_1.primitives)();
|
|
91
|
+
const { value: progress, animated } = (0, motion_1.useSpring)(active ? 1 : 0, "snappy");
|
|
92
|
+
const width = animated
|
|
93
|
+
? progress.interpolate({ inputRange: [0, 1], outputRange: [DOT, ACTIVE_DOT] })
|
|
94
|
+
: active
|
|
95
|
+
? ACTIVE_DOT
|
|
96
|
+
: DOT;
|
|
97
|
+
const style = {
|
|
98
|
+
height: DOT,
|
|
99
|
+
borderRadius: DOT / 2,
|
|
100
|
+
backgroundColor: active ? accent : muted,
|
|
101
|
+
};
|
|
102
|
+
return animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { style: { ...style, width } })) : ((0, jsx_runtime_1.jsx)(View, { style: { ...style, width: width } }));
|
|
103
|
+
}
|
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
|
}
|