glacia-native 0.5.1 → 0.5.2
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 +29 -4
- package/README.md +27 -0
- package/lib/module/Bars.js +10 -9
- package/lib/module/Button.js +11 -8
- package/lib/module/Card.js +2 -2
- package/lib/module/Dialog.js +16 -17
- package/lib/module/Display.js +8 -7
- package/lib/module/Feedback.js +24 -15
- package/lib/module/Form.js +29 -33
- package/lib/module/Forms2.js +38 -21
- package/lib/module/Glass.js +2 -2
- package/lib/module/Input.js +12 -10
- package/lib/module/Message.js +11 -15
- package/lib/module/Overlays.js +22 -6
- package/lib/module/Pickers.js +16 -16
- package/lib/module/SegmentedControl.js +19 -10
- package/lib/module/Slider.js +18 -9
- package/lib/module/Switch.js +21 -9
- package/lib/module/TabBar.js +18 -12
- package/lib/module/Table.js +4 -3
- package/lib/module/Tabs.js +3 -2
- package/lib/module/ai.js +18 -15
- package/lib/module/charts/BarChart.js +11 -3
- package/lib/module/internal/GlassView.js +2 -2
- package/lib/module/internal/blur.js +78 -0
- package/lib/module/internal/fallback.js +110 -20
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/primitives.js +1 -0
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +34 -2
- package/lib/typescript/Message.d.ts +5 -9
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/internal/GlassView.d.ts +13 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +27 -2
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/primitives.d.ts +2 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +36 -0
- package/package.json +12 -3
- package/src/Bars.tsx +12 -2
- package/src/Button.tsx +16 -9
- package/src/Card.tsx +2 -2
- package/src/Dialog.tsx +37 -26
- package/src/Display.tsx +8 -5
- package/src/Feedback.tsx +36 -13
- package/src/Form.tsx +60 -40
- package/src/Forms2.tsx +65 -24
- package/src/Glass.tsx +4 -0
- package/src/Input.tsx +15 -11
- package/src/Message.tsx +15 -16
- package/src/Overlays.tsx +25 -6
- package/src/Pickers.tsx +11 -6
- package/src/SegmentedControl.tsx +33 -9
- package/src/Slider.tsx +19 -10
- package/src/Switch.tsx +24 -10
- package/src/TabBar.tsx +33 -12
- package/src/Table.tsx +4 -3
- package/src/Tabs.tsx +5 -0
- package/src/ai.tsx +28 -20
- package/src/charts/BarChart.tsx +41 -3
- package/src/index.ts +1 -0
- package/src/internal/GlassView.tsx +17 -0
- package/src/internal/blur.ts +90 -0
- package/src/internal/fallback.tsx +158 -20
- package/src/internal/glow.tsx +62 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/primitives.ts +3 -0
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +34 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
MIT License with Anti-Plagiarism & Brand Protection Terms
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026
|
|
3
|
+
Copyright (c) 2026 Binyam Feyissa. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,8 +9,28 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
1. COPYRIGHT & ATTRIBUTION:
|
|
13
|
+
The above copyright notice, this permission notice, and the third-party
|
|
14
|
+
attribution notices below shall be included in all copies or substantial
|
|
15
|
+
portions of the Software.
|
|
16
|
+
|
|
17
|
+
2. ACCEPTABLE USE & ANTI-PLAGIARISM RESTRICTIONS:
|
|
18
|
+
You are granted full permission to use, customize, and integrate the Software
|
|
19
|
+
in your own commercial, private, open-source, or enterprise end-user software,
|
|
20
|
+
websites, web applications, and mobile applications ("Applications").
|
|
21
|
+
|
|
22
|
+
However, the following are strictly prohibited:
|
|
23
|
+
a) You may NOT republish, re-upload, rebrand, or redistribute this repository,
|
|
24
|
+
source code, component registry, or design token suite as a competing standalone
|
|
25
|
+
UI component library, design system kit, template product, or under an alternate
|
|
26
|
+
package name on public registries (including npm, PyPI, GitHub, or any other registry).
|
|
27
|
+
b) You may NOT misrepresent yourself as the creator or original author of Glacia,
|
|
28
|
+
or remove or alter the original author attributions.
|
|
29
|
+
|
|
30
|
+
3. TRADEMARKS & BRAND ASSETS:
|
|
31
|
+
This license does not grant permission to use the trade names, trademarks,
|
|
32
|
+
service marks, product names, logos, or brand marks of "Glacia" or "Binyam Feyissa"
|
|
33
|
+
in connection with derivative works, forks, or any competing distributions.
|
|
14
34
|
|
|
15
35
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
36
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
@@ -19,3 +39,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
39
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
40
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
41
|
SOFTWARE.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
Attribution and Third-Party Acknowledgements:
|
|
46
|
+
- React Native glass effect architecture powered by @callstack/liquid-glass (MIT License): https://github.com/callstack/liquid-glass
|
package/README.md
CHANGED
|
@@ -147,6 +147,33 @@ const styles = StyleSheet.create({
|
|
|
147
147
|
|
|
148
148
|
---
|
|
149
149
|
|
|
150
|
+
## The fallback material
|
|
151
|
+
|
|
152
|
+
On iOS 26+ every glass surface is Apple's `UIGlassEffect`. On iOS below 26, on
|
|
153
|
+
Android and in Expo Go, the fallback renders the same design in layers, so it
|
|
154
|
+
reads as glass rather than as a translucent rectangle:
|
|
155
|
+
|
|
156
|
+
1. **Backdrop blur** — a real native blur view, when one is installed:
|
|
157
|
+
`expo-blur` (Expo apps) or `@react-native-community/blur` (bare React Native).
|
|
158
|
+
Both are optional peer dependencies; without either, the surface degrades to
|
|
159
|
+
tint + rim + edge + shadow instead of failing.
|
|
160
|
+
2. **Tint** — the `glass` token (or your `tintColor`, or 0.35 alpha for `clear`).
|
|
161
|
+
3. **Rim light** — a gradient stroke painted on the edge, brightest along the
|
|
162
|
+
top, so rounded corners read as lit curves.
|
|
163
|
+
4. **Top highlight** — a soft white falloff just inside the top edge.
|
|
164
|
+
5. **Edge** — the 0.5px hairline in the `edge` token.
|
|
165
|
+
6. **Drop shadow** — the surface lifts off the page behind it.
|
|
166
|
+
|
|
167
|
+
`Glass` accepts two optional props for this branch: `surface` picks one of the
|
|
168
|
+
web's six lenses (`"panel"`, `"control"`, `"field"`, `"overlay"`, `"hint"`,
|
|
169
|
+
`"rail"`), and `pressed` fades the specular press glow in. Neither is forwarded
|
|
170
|
+
to Apple's view — on iOS 26 the real material replaces the whole stack.
|
|
171
|
+
|
|
172
|
+
Reduce Transparency is honoured exactly as before: the layered material is
|
|
173
|
+
replaced by one solid colour.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
150
177
|
## Optical Diagnostics
|
|
151
178
|
|
|
152
179
|
You can check whether the running device supports Apple's native `UIGlassEffect` at runtime:
|
package/lib/module/Bars.js
CHANGED
|
@@ -26,7 +26,7 @@ exports.SearchBar = (0, react_1.forwardRef)(function SearchBar({ value: valuePro
|
|
|
26
26
|
onChangeText?.(next);
|
|
27
27
|
};
|
|
28
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: {
|
|
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", surface: "field", isDark: isDark, style: {
|
|
30
30
|
flex: 1,
|
|
31
31
|
flexDirection: "row",
|
|
32
32
|
alignItems: "center",
|
|
@@ -66,6 +66,7 @@ exports.Chip = (0, react_1.forwardRef)(function Chip({ label, icon, onClose, onP
|
|
|
66
66
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
67
67
|
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
68
68
|
const [internalSelected, setInternalSelected] = (0, react_1.useState)(defaultSelected);
|
|
69
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
69
70
|
const selected = selectedProp !== undefined ? selectedProp : internalSelected;
|
|
70
71
|
const selectable = selectedProp !== undefined || onSelectedChange !== undefined || defaultSelected;
|
|
71
72
|
const handlePress = () => {
|
|
@@ -79,16 +80,16 @@ exports.Chip = (0, react_1.forwardRef)(function Chip({ label, icon, onClose, onP
|
|
|
79
80
|
}
|
|
80
81
|
onPress?.();
|
|
81
82
|
};
|
|
82
|
-
const pill = ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, tintColor: selected ? theme.glassActive : undefined, interactive: !disabled, style: {
|
|
83
|
+
const pill = ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", surface: "control", pressed: held, isDark: isDark, tintColor: selected ? theme.glassActive : undefined, interactive: !disabled, style: {
|
|
83
84
|
flexDirection: "row",
|
|
84
85
|
alignItems: "center",
|
|
85
86
|
gap: 6,
|
|
86
|
-
height:
|
|
87
|
+
height: 34,
|
|
87
88
|
paddingHorizontal: 12,
|
|
88
89
|
borderRadius: tokens_1.radii.pill,
|
|
89
90
|
opacity: disabled ? 0.38 : 1,
|
|
90
91
|
...style,
|
|
91
|
-
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize:
|
|
92
|
+
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 14, 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
93
|
if (!onPress && !selectable) {
|
|
93
94
|
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: label, ...props, children: pill }));
|
|
94
95
|
}
|
|
@@ -111,7 +112,7 @@ exports.FAB = (0, react_1.forwardRef)(function FAB({ onPress, accessibilityLabel
|
|
|
111
112
|
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
113
|
alignSelf: "flex-start",
|
|
113
114
|
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
|
+
}), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "clear", surface: "control", interactive: !disabled, isDark: isDark, style: {
|
|
115
116
|
height: dimension,
|
|
116
117
|
width: extended ? undefined : dimension,
|
|
117
118
|
minWidth: dimension,
|
|
@@ -136,7 +137,7 @@ exports.IconButton = (0, react_1.forwardRef)(function IconButton({ accessibility
|
|
|
136
137
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
137
138
|
const { View, Pressable } = (0, primitives_1.primitives)();
|
|
138
139
|
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
|
+
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", surface: "control", interactive: !disabled && variant !== "ghost", isDark: isDark, style: {
|
|
140
141
|
width: dimension,
|
|
141
142
|
height: dimension,
|
|
142
143
|
borderRadius: dimension / 2,
|
|
@@ -171,7 +172,7 @@ exports.AppBar = (0, react_1.forwardRef)(function AppBar({ title, subtitle, lead
|
|
|
171
172
|
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
172
173
|
const actionCount = actions?.length ?? 0;
|
|
173
174
|
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));
|
|
174
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: {
|
|
175
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", isDark: isDark, testID: testID, style: {
|
|
175
176
|
borderRadius: 0,
|
|
176
177
|
borderTopWidth: 0,
|
|
177
178
|
borderLeftWidth: 0,
|
|
@@ -247,7 +248,7 @@ exports.FABGroup = (0, react_1.forwardRef)(function FABGroup({ actions, icon, cl
|
|
|
247
248
|
const pill = ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: () => {
|
|
248
249
|
setOpen(false);
|
|
249
250
|
action.onPress();
|
|
250
|
-
}, style: { flexDirection: "row", alignItems: "center", gap: 8 }, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: { borderRadius: tokens_1.radii.pill, paddingHorizontal: 12, paddingVertical: 7 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, numberOfLines: 1, children: action.label }) }), (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: {
|
|
251
|
+
}, style: { flexDirection: "row", alignItems: "center", gap: 8 }, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "control", isDark: isDark, style: { borderRadius: tokens_1.radii.pill, paddingHorizontal: 12, paddingVertical: 7 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, numberOfLines: 1, children: action.label }) }), (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "control", isDark: isDark, style: {
|
|
251
252
|
width: mini,
|
|
252
253
|
height: mini,
|
|
253
254
|
borderRadius: mini / 2,
|
|
@@ -259,7 +260,7 @@ exports.FABGroup = (0, react_1.forwardRef)(function FABGroup({ actions, icon, cl
|
|
|
259
260
|
}
|
|
260
261
|
return ((0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ translateY }], opacity }, children: pill }, `${action.label}-${index}`));
|
|
261
262
|
})
|
|
262
|
-
: null, (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { expanded: open }, onPress: () => setOpen(!open), children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "clear", interactive: true, isDark: isDark, style: {
|
|
263
|
+
: null, (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { expanded: open }, onPress: () => setOpen(!open), children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "clear", surface: "control", interactive: true, isDark: isDark, style: {
|
|
263
264
|
width: dimension,
|
|
264
265
|
height: dimension,
|
|
265
266
|
borderRadius: dimension / 2,
|
package/lib/module/Button.js
CHANGED
|
@@ -7,10 +7,12 @@ const Glass_1 = require("./Glass");
|
|
|
7
7
|
const tokens_1 = require("./internal/tokens");
|
|
8
8
|
const primitives_1 = require("./internal/primitives");
|
|
9
9
|
const motion_1 = require("./internal/motion");
|
|
10
|
+
// The web control scale: 28 / 34 / 44, one horizontal padding and one type
|
|
11
|
+
// size for every button, and the inherited 400 weight rather than a 500.
|
|
10
12
|
const sizeHeights = {
|
|
11
|
-
sm:
|
|
12
|
-
md:
|
|
13
|
-
lg:
|
|
13
|
+
sm: 28,
|
|
14
|
+
md: 34,
|
|
15
|
+
lg: 44,
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
18
|
* A pressable button on Glacia's glass.
|
|
@@ -23,6 +25,7 @@ exports.Button = (0, react_1.forwardRef)(function Button({ variant = "glass", si
|
|
|
23
25
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
24
26
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
25
27
|
const { Pressable, View, Text } = (0, primitives_1.primitives)();
|
|
28
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
26
29
|
const height = sizeHeights[size];
|
|
27
30
|
const buttonStyle = {
|
|
28
31
|
height,
|
|
@@ -30,7 +33,7 @@ exports.Button = (0, react_1.forwardRef)(function Button({ variant = "glass", si
|
|
|
30
33
|
flexDirection: "row",
|
|
31
34
|
alignItems: "center",
|
|
32
35
|
justifyContent: "center",
|
|
33
|
-
paddingHorizontal:
|
|
36
|
+
paddingHorizontal: 14,
|
|
34
37
|
opacity: disabled ? 0.38 : 1,
|
|
35
38
|
backgroundColor: variant === "filled"
|
|
36
39
|
? tint || themeColors.fill
|
|
@@ -40,11 +43,11 @@ exports.Button = (0, react_1.forwardRef)(function Button({ variant = "glass", si
|
|
|
40
43
|
...style,
|
|
41
44
|
};
|
|
42
45
|
const textStyle = {
|
|
43
|
-
color: variant === "filled" ?
|
|
44
|
-
fontSize:
|
|
45
|
-
fontWeight: "
|
|
46
|
+
color: variant === "filled" ? themeColors.onTint : tint || themeColors.foreground,
|
|
47
|
+
fontSize: 14,
|
|
48
|
+
fontWeight: "400",
|
|
46
49
|
};
|
|
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 ?
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { disabled }, disabled: disabled, onPress: disabled ? undefined : onPress, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: ({ pressed }) => ({ opacity: pressed && !disabled ? 0.85 : 1 }), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", surface: "control", pressed: held && !disabled, interactive: !disabled, isDark: isDark, style: buttonStyle, children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { marginRight: children ? 7 : 0 }, children: icon }) : null, typeof children === "string" ? (
|
|
48
51
|
// A string label is text: it needs Text to inherit font and colour.
|
|
49
52
|
(0, jsx_runtime_1.jsx)(Text, { style: textStyle, numberOfLines: 1, children: children })) : (children)] }) }));
|
|
50
53
|
});
|
package/lib/module/Card.js
CHANGED
|
@@ -19,10 +19,10 @@ const motion_1 = require("./internal/motion");
|
|
|
19
19
|
exports.Card = (0, react_1.forwardRef)(function Card({ effect = "regular", style, children, isDark: isDarkProp, testID, ...props }, ref) {
|
|
20
20
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
21
21
|
const cardStyle = {
|
|
22
|
-
padding:
|
|
22
|
+
padding: 24,
|
|
23
23
|
borderRadius: tokens_1.radii.lg,
|
|
24
24
|
flexDirection: "column",
|
|
25
|
-
gap:
|
|
25
|
+
gap: 16,
|
|
26
26
|
...style,
|
|
27
27
|
};
|
|
28
28
|
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: effect, isDark: isDark, style: cardStyle, testID: testID, ...props, children: children }));
|
package/lib/module/Dialog.js
CHANGED
|
@@ -55,14 +55,16 @@ function Dialog({ open: controlledOpen, onOpenChange, title, description, childr
|
|
|
55
55
|
justifyContent: "center",
|
|
56
56
|
padding: 24,
|
|
57
57
|
backgroundColor: "rgba(0, 0, 0, 0.45)",
|
|
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.
|
|
60
|
-
borderWidth: 1,
|
|
61
|
-
borderColor: theme.edge,
|
|
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", surface: "overlay", isDark: isDark, testID: testID, style: {
|
|
59
|
+
borderRadius: tokens_1.radii.xl,
|
|
62
60
|
padding: 20,
|
|
63
61
|
gap: 8,
|
|
62
|
+
// The web overlay shadow: the panel has to float above the scrim.
|
|
63
|
+
shadowOpacity: 0.12,
|
|
64
|
+
shadowRadius: 50,
|
|
65
|
+
shadowOffset: { width: 0, height: 20 },
|
|
64
66
|
...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:
|
|
67
|
+
}, 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: 14, color: theme.muted, lineHeight: 20 }, children: description })), children, footer && (0, jsx_runtime_1.jsx)(View, { style: { marginTop: 12, gap: 8 }, children: footer })] }) }) }) }));
|
|
66
68
|
}
|
|
67
69
|
/** Opens the dialog without the caller tracking state. */
|
|
68
70
|
function DialogTrigger({ label, children, ...dialogProps }) {
|
|
@@ -124,16 +126,13 @@ function ActionSheet({ open: controlledOpen, onOpenChange, title, message, optio
|
|
|
124
126
|
setUncontrolled(false);
|
|
125
127
|
onOpenChange?.(false);
|
|
126
128
|
};
|
|
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.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}, children: (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
136
|
-
fontSize: 16,
|
|
137
|
-
color: option.destructive ? theme.destructive : theme.foreground,
|
|
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 }) }) })] }) }) }));
|
|
129
|
+
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: [(title || message) && ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, style: { borderRadius: tokens_1.radii.lg }, children: (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) => ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, style: { borderRadius: tokens_1.radii.pill }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: option.label, onPress: () => {
|
|
130
|
+
option.onPress?.();
|
|
131
|
+
close();
|
|
132
|
+
}, style: { minHeight: 44, paddingVertical: 12, paddingHorizontal: 20, alignItems: "center", justifyContent: "center" }, children: (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
133
|
+
fontSize: 17,
|
|
134
|
+
// The web's iOS-style action sheet: every row is the tint
|
|
135
|
+
// colour, and only a destructive one is red.
|
|
136
|
+
color: option.destructive ? theme.destructive : theme.fill,
|
|
137
|
+
}, children: option.label }) }) }, option.label))), (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, style: { borderRadius: tokens_1.radii.pill }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: cancelLabel, onPress: close, style: { minHeight: 44, paddingVertical: 12, alignItems: "center", justifyContent: "center" }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: cancelLabel }) }) })] }) }) }));
|
|
139
138
|
}
|
package/lib/module/Display.js
CHANGED
|
@@ -34,7 +34,7 @@ exports.Avatar = (0, react_1.forwardRef)(function Avatar({ source, name, size =
|
|
|
34
34
|
const initials = name ? initialsOf(name) : "";
|
|
35
35
|
const statusColor = status === "online" ? theme.on : status === "busy" ? theme.destructive : theme.muted;
|
|
36
36
|
const dot = Math.max(8, Math.round(dimension * 0.26));
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessible: true, accessibilityRole: "image", accessibilityLabel: name ? `Avatar of ${name}` : "Avatar", style: { width: dimension, height: dimension, ...style }, ...props, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: {
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessible: true, accessibilityRole: "image", accessibilityLabel: name ? `Avatar of ${name}` : "Avatar", style: { width: dimension, height: dimension, ...style }, ...props, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "panel", isDark: isDark, style: {
|
|
38
38
|
width: dimension,
|
|
39
39
|
height: dimension,
|
|
40
40
|
borderRadius: dimension / 2,
|
|
@@ -76,17 +76,18 @@ exports.Badge = (0, react_1.forwardRef)(function Badge({ children, tone = "fill"
|
|
|
76
76
|
? theme.muted
|
|
77
77
|
: theme.fill;
|
|
78
78
|
const isDot = children == null;
|
|
79
|
-
|
|
79
|
+
// The web badge is 24 tall with 10 of horizontal padding and 12/500 type.
|
|
80
|
+
const height = isDot ? 10 : 24;
|
|
80
81
|
const badge = ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: isDot ? undefined : String(children), style: {
|
|
81
82
|
minWidth: height,
|
|
82
83
|
height,
|
|
83
84
|
borderRadius: height / 2,
|
|
84
|
-
paddingHorizontal: isDot ? 0 :
|
|
85
|
+
paddingHorizontal: isDot ? 0 : 10,
|
|
85
86
|
alignItems: "center",
|
|
86
87
|
justifyContent: "center",
|
|
87
88
|
backgroundColor: background,
|
|
88
89
|
...style,
|
|
89
|
-
}, ...props, children: !isDot && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize:
|
|
90
|
+
}, ...props, children: !isDot && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "500", color: theme.onTint }, numberOfLines: 1, children: children })) }));
|
|
90
91
|
if (overlay === undefined)
|
|
91
92
|
return badge;
|
|
92
93
|
// Overlaid: the badge floats at the top-right of whatever it decorates, which
|
|
@@ -104,8 +105,8 @@ exports.Separator = (0, react_1.forwardRef)(function Separator({ orientation = "
|
|
|
104
105
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
105
106
|
const { View } = (0, primitives_1.primitives)();
|
|
106
107
|
const separatorStyle = orientation === "horizontal"
|
|
107
|
-
? { height:
|
|
108
|
-
: { width:
|
|
108
|
+
? { height: 1, alignSelf: "stretch", marginLeft: inset, backgroundColor: theme.separator }
|
|
109
|
+
: { width: 1, alignSelf: "stretch", backgroundColor: theme.separator };
|
|
109
110
|
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "none", style: { ...separatorStyle, ...style }, ...props }));
|
|
110
111
|
});
|
|
111
112
|
/**
|
|
@@ -225,7 +226,7 @@ exports.Progress = (0, react_1.forwardRef)(function Progress({ value, variant =
|
|
|
225
226
|
justifyContent: "center",
|
|
226
227
|
}, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, children: `${Math.round(clamped)}%` }) })] }));
|
|
227
228
|
}
|
|
228
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: {
|
|
229
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", isDark: isDark, style: {
|
|
229
230
|
height: 8,
|
|
230
231
|
borderRadius: tokens_1.radii.pill,
|
|
231
232
|
overflow: "hidden",
|
package/lib/module/Feedback.js
CHANGED
|
@@ -8,6 +8,7 @@ const Display_1 = require("./Display");
|
|
|
8
8
|
const tokens_1 = require("./internal/tokens");
|
|
9
9
|
const primitives_1 = require("./internal/primitives");
|
|
10
10
|
const motion_1 = require("./internal/motion");
|
|
11
|
+
const lens_1 = require("./internal/lens");
|
|
11
12
|
const haptics_1 = require("./internal/haptics");
|
|
12
13
|
/**
|
|
13
14
|
* A transient message on a glass pill.
|
|
@@ -44,16 +45,21 @@ exports.Toast = (0, react_1.forwardRef)(function Toast({ visible: visibleProp, d
|
|
|
44
45
|
if (!visible)
|
|
45
46
|
return null;
|
|
46
47
|
const accent = tone === "neutral" ? theme.foreground : (0, tokens_1.toneColor)(theme, tone);
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, pointerEvents: "box-none", style: { alignItems: "center", ...style }, ...props, children: (0, jsx_runtime_1.jsx)(Entrance, { animated: animated, rise: rise, fade: fade, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: {
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, pointerEvents: "box-none", style: { alignItems: "center", ...style }, ...props, children: (0, jsx_runtime_1.jsx)(Entrance, { animated: animated, rise: rise, fade: fade, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, style: {
|
|
48
49
|
flexDirection: "row",
|
|
49
50
|
alignItems: "center",
|
|
50
51
|
gap: 10,
|
|
51
|
-
paddingVertical:
|
|
52
|
-
paddingHorizontal:
|
|
53
|
-
borderRadius: tokens_1.radii.
|
|
54
|
-
maxWidth:
|
|
52
|
+
paddingVertical: 12,
|
|
53
|
+
paddingHorizontal: 16,
|
|
54
|
+
borderRadius: tokens_1.radii.lg,
|
|
55
|
+
maxWidth: 400,
|
|
56
|
+
minWidth: 280,
|
|
57
|
+
// A toast floats above everything; without a shadow it is a label.
|
|
58
|
+
shadowOpacity: 0.12,
|
|
59
|
+
shadowRadius: 30,
|
|
60
|
+
shadowOffset: { width: 0, height: 10 },
|
|
55
61
|
borderColor: tone === "neutral" ? theme.edge : accent,
|
|
56
|
-
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", accessibilityLiveRegion: "polite", style: { fontSize:
|
|
62
|
+
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", accessibilityLiveRegion: "polite", style: { fontSize: 13, color: theme.foreground, flexShrink: 1 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { paddingHorizontal: 4 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: "600", color: theme.fill }, children: action.label }) }))] }) }) }));
|
|
57
63
|
});
|
|
58
64
|
/**
|
|
59
65
|
* Applies the toast's entrance motion around the pill.
|
|
@@ -171,7 +177,7 @@ exports.Banner = (0, react_1.forwardRef)(function Banner({ title, message, tone
|
|
|
171
177
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
172
178
|
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
173
179
|
const accent = (0, tokens_1.toneColor)(theme, tone);
|
|
174
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.md, borderColor: accent, ...style }, ...props, children: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "flex-start", gap: 10, padding: 12 }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { paddingTop: 1 }, children: icon }) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [title && ((0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 14, fontWeight: "600", color: theme.foreground }, children: title })), (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { alignSelf: "flex-start", paddingTop: 6 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, fontWeight: "600", color: accent }, children: action.label }) }))] }), onDismiss && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss", onPress: onDismiss, hitSlop: 8, style: { padding: 2 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, color: theme.muted }, children: "\u00D7" }) }))] }) }));
|
|
180
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "overlay", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.md, borderColor: accent, ...style }, ...props, children: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "flex-start", gap: 10, padding: 12 }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { paddingTop: 1 }, children: icon }) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [title && ((0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 14, fontWeight: "600", color: theme.foreground }, children: title })), (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { alignSelf: "flex-start", paddingTop: 6 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, fontWeight: "600", color: accent }, children: action.label }) }))] }), onDismiss && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss", onPress: onDismiss, hitSlop: 8, style: { padding: 2 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, color: theme.muted }, children: "\u00D7" }) }))] }) }));
|
|
175
181
|
});
|
|
176
182
|
/**
|
|
177
183
|
* Tracks which row of a List is open, so opening one closes the rest.
|
|
@@ -289,14 +295,16 @@ exports.ListItem = (0, react_1.forwardRef)(function ListItem({ leading, title, d
|
|
|
289
295
|
const rowStyle = {
|
|
290
296
|
flexDirection: "row",
|
|
291
297
|
alignItems: "center",
|
|
292
|
-
minHeight:
|
|
298
|
+
minHeight: 44,
|
|
293
299
|
paddingVertical: 10,
|
|
294
|
-
paddingHorizontal:
|
|
295
|
-
|
|
300
|
+
paddingHorizontal: 16,
|
|
301
|
+
// The selected row is a lens painted behind the content, not a flat wash.
|
|
302
|
+
backgroundColor: "transparent",
|
|
296
303
|
opacity: disabled ? 0.38 : 1,
|
|
297
304
|
...style,
|
|
298
305
|
};
|
|
299
|
-
const
|
|
306
|
+
const lens = selected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: 8, isDark: isDark, style: (0, lens_1.rowLensStyle)(8), testID: testID ? `${testID}-lens` : undefined })) : null;
|
|
307
|
+
const rowInner = !interactive ? ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "text", accessibilityState: { disabled }, style: rowStyle, children: [lens, content] })) : ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: description ? `${title}, ${description}` : title, accessibilityState: { selected, disabled }, disabled: disabled, onPress: guardPress(onPress), style: ({ pressed }) => ({ ...rowStyle, opacity: pressed ? 0.7 : rowStyle.opacity }), children: [lens, content] }));
|
|
300
308
|
if (!canSwipe) {
|
|
301
309
|
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: { overflow: "hidden" }, ...props, children: rowInner }));
|
|
302
310
|
}
|
|
@@ -340,7 +348,7 @@ exports.List = (0, react_1.forwardRef)(function List({ children, inset = false,
|
|
|
340
348
|
if (!inset) {
|
|
341
349
|
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: style, ...props, children: body }));
|
|
342
350
|
}
|
|
343
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.
|
|
351
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "panel", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.lg, ...style }, ...props, children: body }));
|
|
344
352
|
});
|
|
345
353
|
exports.ListSection = (0, react_1.forwardRef)(function ListSection({ header, children, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
346
354
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
@@ -352,7 +360,8 @@ exports.ListSection = (0, react_1.forwardRef)(function ListSection({ header, chi
|
|
|
352
360
|
letterSpacing: 0.4,
|
|
353
361
|
textTransform: "uppercase",
|
|
354
362
|
color: theme.muted,
|
|
355
|
-
paddingHorizontal:
|
|
363
|
+
paddingHorizontal: 16,
|
|
364
|
+
paddingVertical: 5,
|
|
356
365
|
}, children: header })) : null, (0, jsx_runtime_1.jsx)(exports.List, { inset: true, isDark: isDark, children: children })] }));
|
|
357
366
|
});
|
|
358
367
|
/**
|
|
@@ -379,8 +388,8 @@ exports.Accordion = (0, react_1.forwardRef)(function Accordion({ sections, multi
|
|
|
379
388
|
setInternalOpen(next);
|
|
380
389
|
onOpenSectionsChange?.(next);
|
|
381
390
|
};
|
|
382
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.
|
|
391
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "panel", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.stack, ...style }, ...props, children: sections.map((section, index) => {
|
|
383
392
|
const expanded = open.includes(section.value);
|
|
384
|
-
return ((0, jsx_runtime_1.jsxs)(View, { children: [index > 0 ? (0, jsx_runtime_1.jsx)(Display_1.Separator, { isDark: isDark }) : null, (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: section.title, accessibilityState: { expanded }, onPress: () => toggle(section.value), style: { paddingVertical:
|
|
393
|
+
return ((0, jsx_runtime_1.jsxs)(View, { children: [index > 0 ? (0, jsx_runtime_1.jsx)(Display_1.Separator, { isDark: isDark }) : null, (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: section.title, accessibilityState: { expanded }, onPress: () => toggle(section.value), style: { paddingVertical: 16, paddingHorizontal: 20, flexDirection: "row", alignItems: "center" }, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [(0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, fontWeight: "500", color: theme.foreground }, children: section.title }), section.description ? ((0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, color: theme.muted }, children: section.description })) : null] }), (0, jsx_runtime_1.jsx)(RNText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { fontSize: 13, color: theme.muted, marginLeft: 8 }, children: expanded ? "\u2303" : "\u2304" })] }), expanded ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20, paddingBottom: 16 }, children: section.content })) : null] }, section.value));
|
|
385
394
|
}) }));
|
|
386
395
|
});
|
package/lib/module/Form.js
CHANGED
|
@@ -7,9 +7,11 @@ exports.RadioGroup = RadioGroup;
|
|
|
7
7
|
exports.Select = Select;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
+
const Glass_1 = require("./Glass");
|
|
10
11
|
const tokens_1 = require("./internal/tokens");
|
|
11
12
|
const primitives_1 = require("./internal/primitives");
|
|
12
13
|
const motion_1 = require("./internal/motion");
|
|
14
|
+
const lens_1 = require("./internal/lens");
|
|
13
15
|
/** The text above a control. */
|
|
14
16
|
exports.Label = (0, react_1.forwardRef)(function Label({ children, required = false, disabled = false, nativeID, isDark: isDarkProp, style }, ref) {
|
|
15
17
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
@@ -17,7 +19,7 @@ exports.Label = (0, react_1.forwardRef)(function Label({ children, required = fa
|
|
|
17
19
|
const { Text } = (0, primitives_1.primitives)();
|
|
18
20
|
return ((0, jsx_runtime_1.jsxs)(Text, { ref: ref, nativeID: nativeID, accessibilityRole: "text", style: {
|
|
19
21
|
fontSize: 13,
|
|
20
|
-
fontWeight: "
|
|
22
|
+
fontWeight: "500",
|
|
21
23
|
color: disabled ? theme.muted : theme.foreground,
|
|
22
24
|
opacity: disabled ? 0.6 : 1,
|
|
23
25
|
...style,
|
|
@@ -32,8 +34,8 @@ function Field({ label, description, error, required = false, disabled = false,
|
|
|
32
34
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
33
35
|
const { View, Text } = (0, primitives_1.primitives)();
|
|
34
36
|
const message = error ?? description;
|
|
35
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: { gap:
|
|
36
|
-
fontSize:
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)(View, { style: { gap: 7, ...style }, children: [label && ((0, jsx_runtime_1.jsx)(exports.Label, { required: required, disabled: disabled, isDark: isDark, children: label })), children, message && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: error ? "alert" : "text", style: {
|
|
38
|
+
fontSize: 12,
|
|
37
39
|
color: error ? theme.destructive : theme.muted,
|
|
38
40
|
}, children: message }))] }));
|
|
39
41
|
}
|
|
@@ -60,19 +62,17 @@ function Checkbox({ checked: checkedProp, defaultChecked = false, onCheckedChang
|
|
|
60
62
|
gap: 10,
|
|
61
63
|
opacity: disabled ? 0.45 : 1,
|
|
62
64
|
...style,
|
|
63
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
65
|
+
}, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "control", isDark: isDark, style: {
|
|
64
66
|
width: 20,
|
|
65
67
|
height: 20,
|
|
66
68
|
borderRadius: 6,
|
|
67
|
-
|
|
68
|
-
borderColor: theme.edge,
|
|
69
|
-
backgroundColor: filled ? theme.fill : "transparent",
|
|
69
|
+
backgroundColor: filled ? theme.fill : undefined,
|
|
70
70
|
alignItems: "center",
|
|
71
71
|
justifyContent: "center",
|
|
72
72
|
marginTop: 1,
|
|
73
|
-
}, children: indeterminate ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 10, height: 2, borderRadius: 1, backgroundColor:
|
|
73
|
+
}, children: indeterminate ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 10, height: 2, borderRadius: 1, backgroundColor: theme.onTint } })) : checked ? (
|
|
74
74
|
// A glyph rather than an icon dependency: one text node, no package.
|
|
75
|
-
(0, jsx_runtime_1.jsx)(Text, { style: { color:
|
|
75
|
+
(0, jsx_runtime_1.jsx)(Text, { style: { color: theme.onTint, 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: 12, color: theme.muted, marginTop: 2 }, children: description }))] }))] }));
|
|
76
76
|
}
|
|
77
77
|
/** One choice from a small, always-visible set. */
|
|
78
78
|
function RadioGroup({ value: valueProp, defaultValue, onValueChange, options, horizontal = false, disabled = false, isDark: isDarkProp, style, testID, }) {
|
|
@@ -101,14 +101,15 @@ function RadioGroup({ value: valueProp, defaultValue, onValueChange, options, ho
|
|
|
101
101
|
alignItems: "flex-start",
|
|
102
102
|
gap: 9,
|
|
103
103
|
opacity: isDisabled ? 0.45 : 1,
|
|
104
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
104
|
+
}, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "control", isDark: isDark, style: {
|
|
105
105
|
width: 20,
|
|
106
106
|
height: 20,
|
|
107
107
|
borderRadius: 10,
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
backgroundColor: isSelected ? theme.fill : undefined,
|
|
109
|
+
alignItems: "center",
|
|
110
|
+
justifyContent: "center",
|
|
110
111
|
marginTop: 1,
|
|
111
|
-
} }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }), option.description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize:
|
|
112
|
+
}, children: isSelected ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 8, height: 8, borderRadius: 4, backgroundColor: theme.onTint } })) : null }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }), option.description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginTop: 2 }, children: option.description }))] })] }, option.value));
|
|
112
113
|
}) }));
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
@@ -132,33 +133,28 @@ function Select({ value: valueProp, defaultValue, onValueChange, options, placeh
|
|
|
132
133
|
onValueChange?.(next);
|
|
133
134
|
};
|
|
134
135
|
const selected = options.find((option) => option.value === value);
|
|
135
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
borderWidth: 1,
|
|
143
|
-
borderColor: theme.edge,
|
|
144
|
-
backgroundColor: theme.glass,
|
|
145
|
-
opacity: disabled ? 0.5 : 1,
|
|
146
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 15, color: selected ? theme.foreground : theme.muted }, children: selected?.label ?? placeholder }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: open ? "▲" : "▼" })] }), open && ((0, jsx_runtime_1.jsx)(View, { style: {
|
|
136
|
+
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsx)(Pressable, { testID: testID, accessibilityRole: "button", accessibilityState: { expanded: open, disabled }, accessibilityLabel: selected?.label ?? placeholder, disabled: disabled, onPress: () => setOpen(!open), style: { opacity: disabled ? 0.5 : 1 }, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
|
|
137
|
+
minHeight: 34,
|
|
138
|
+
flexDirection: "row",
|
|
139
|
+
alignItems: "center",
|
|
140
|
+
justifyContent: "space-between",
|
|
141
|
+
paddingHorizontal: 14,
|
|
142
|
+
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 15, color: selected ? theme.foreground : theme.muted }, children: selected?.label ?? placeholder }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: open ? "▲" : "▼" })] }) }), open && ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "overlay", isDark: isDark, style: {
|
|
147
143
|
marginTop: 6,
|
|
148
144
|
borderRadius: tokens_1.radii.md,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
overflow: "hidden",
|
|
145
|
+
shadowOpacity: 0.12,
|
|
146
|
+
shadowRadius: 30,
|
|
147
|
+
shadowOffset: { width: 0, height: 10 },
|
|
153
148
|
}, children: options.map((option) => {
|
|
154
149
|
const isSelected = option.value === value;
|
|
155
|
-
return ((0, jsx_runtime_1.
|
|
150
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isSelected }, accessibilityLabel: option.label, onPress: () => {
|
|
156
151
|
choose(option.value);
|
|
157
152
|
setOpen(false);
|
|
158
153
|
}, style: {
|
|
159
|
-
|
|
154
|
+
minHeight: 32,
|
|
160
155
|
paddingHorizontal: 12,
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
borderRadius: 10,
|
|
157
|
+
backgroundColor: "transparent",
|
|
158
|
+
}, children: [isSelected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: 10, isDark: isDark, style: lens_1.lensFill })) : null, (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label })] }, option.value));
|
|
163
159
|
}) }))] }));
|
|
164
160
|
}
|