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/lib/module/Forms2.js
CHANGED
|
@@ -10,6 +10,7 @@ const Glass_1 = require("./Glass");
|
|
|
10
10
|
const tokens_1 = require("./internal/tokens");
|
|
11
11
|
const primitives_1 = require("./internal/primitives");
|
|
12
12
|
const motion_1 = require("./internal/motion");
|
|
13
|
+
const lens_1 = require("./internal/lens");
|
|
13
14
|
/**
|
|
14
15
|
* Minus / value / plus.
|
|
15
16
|
*
|
|
@@ -33,21 +34,22 @@ exports.Stepper = (0, react_1.forwardRef)(function Stepper({ value: valueProp, d
|
|
|
33
34
|
};
|
|
34
35
|
const atMin = value <= min;
|
|
35
36
|
const atMax = value >= max;
|
|
36
|
-
const stepButton = (label, sign, action, blocked) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { disabled: disabled || blocked }, disabled: disabled || blocked, onPress: action, style: { width:
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, accessibilityRole: "adjustable", accessibilityLabel: accessibilityLabel, accessibilityValue: { min, max, now: value }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
|
|
37
|
+
const stepButton = (label, sign, action, blocked) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { disabled: disabled || blocked }, disabled: disabled || blocked, onPress: action, style: { width: 46, height: 34, alignItems: "center", justifyContent: "center", opacity: disabled || blocked ? 0.38 : 1 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 17, fontWeight: "500", color: theme.foreground, lineHeight: 20 }, children: sign }) }));
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "control", isDark: isDark, testID: testID, accessibilityRole: "adjustable", accessibilityLabel: accessibilityLabel, accessibilityValue: { min, max, now: value }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
|
|
38
39
|
const delta = event?.nativeEvent?.actionName === "increment" ? step : -step;
|
|
39
40
|
apply(value + delta);
|
|
40
41
|
}, style: {
|
|
41
42
|
flexDirection: "row",
|
|
42
43
|
alignItems: "center",
|
|
43
44
|
alignSelf: "flex-start",
|
|
45
|
+
height: 34,
|
|
44
46
|
borderRadius: tokens_1.radii.pill,
|
|
45
47
|
paddingHorizontal: 2,
|
|
46
48
|
opacity: disabled ? 0.38 : 1,
|
|
47
49
|
...style,
|
|
48
50
|
}, ...props, children: [stepButton(`Decrease ${accessibilityLabel}`, "\u2212", () => apply(value - step), atMin), (0, jsx_runtime_1.jsx)(View, { style: { minWidth: 44, alignItems: "center", justifyContent: "center" }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 16, fontWeight: "600", color: theme.foreground }, numberOfLines: 1, children: formatValue ? formatValue(value) : String(value) }) }), stepButton(`Increase ${accessibilityLabel}`, "+", () => apply(value + step), atMax)] }));
|
|
49
51
|
});
|
|
50
|
-
const toggleSizes = { sm: 30, md:
|
|
52
|
+
const toggleSizes = { sm: 30, md: 34, lg: 44 };
|
|
51
53
|
/**
|
|
52
54
|
* A button that stays pressed.
|
|
53
55
|
*
|
|
@@ -63,6 +65,7 @@ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp,
|
|
|
63
65
|
const controlled = pressedProp !== undefined ? pressedProp : selected;
|
|
64
66
|
const [internal, setInternal] = (0, react_1.useState)(defaultPressed);
|
|
65
67
|
const isPressed = controlled !== undefined ? controlled : internal;
|
|
68
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
66
69
|
const dimension = toggleSizes[size];
|
|
67
70
|
const handlePress = () => {
|
|
68
71
|
const next = !isPressed;
|
|
@@ -70,7 +73,7 @@ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp,
|
|
|
70
73
|
setInternal(next);
|
|
71
74
|
onPressedChange?.(next);
|
|
72
75
|
};
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: accessibilityLabel ?? (typeof children === "string" ? children : undefined), accessibilityState: { selected: isPressed, disabled }, disabled: disabled, onPress: handlePress, style: ({ pressed }) => ({ alignSelf: "flex-start", opacity: disabled ? 0.38 : pressed ? 0.8 : 1 }), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", interactive: !disabled && variant !== "ghost", isDark: isDark, tintColor: isPressed && variant !== "ghost" ? theme.glassActive : undefined, style: {
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: accessibilityLabel ?? (typeof children === "string" ? children : undefined), accessibilityState: { selected: isPressed, disabled }, disabled: disabled, onPress: handlePress, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: ({ pressed }) => ({ alignSelf: "flex-start", opacity: disabled ? 0.38 : pressed ? 0.8 : 1 }), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", surface: "control", pressed: held, interactive: !disabled && variant !== "ghost", isDark: isDark, tintColor: isPressed && variant !== "ghost" ? theme.glassActive : undefined, style: {
|
|
74
77
|
height: dimension,
|
|
75
78
|
borderRadius: tokens_1.radii.pill,
|
|
76
79
|
paddingHorizontal: icon && !children ? 0 : 12,
|
|
@@ -82,7 +85,7 @@ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp,
|
|
|
82
85
|
backgroundColor: variant === "ghost" ? "transparent" : undefined,
|
|
83
86
|
...style,
|
|
84
87
|
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, typeof children === "string" ? ((0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: {
|
|
85
|
-
fontSize: size === "sm" ? 12 : size === "lg" ? 15 :
|
|
88
|
+
fontSize: size === "sm" ? 12 : size === "lg" ? 15 : 14,
|
|
86
89
|
fontWeight: isPressed ? "600" : "500",
|
|
87
90
|
color: isPressed ? theme.foreground : theme.muted,
|
|
88
91
|
}, children: children })) : (children)] }) }));
|
|
@@ -117,13 +120,19 @@ exports.ToggleGroup = (0, react_1.forwardRef)(function ToggleGroup({ items, mult
|
|
|
117
120
|
onValueChange?.(next);
|
|
118
121
|
};
|
|
119
122
|
const height = size === "sm" ? 30 : size === "lg" ? 42 : 36;
|
|
120
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, accessibilityRole: "radiogroup", accessibilityLabel: accessibilityLabel, style: {
|
|
123
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "control", isDark: isDark, testID: testID, accessibilityRole: "radiogroup", accessibilityLabel: accessibilityLabel, style: {
|
|
121
124
|
flexDirection: "row",
|
|
122
125
|
alignItems: "center",
|
|
123
126
|
alignSelf: "flex-start",
|
|
124
127
|
padding: 3,
|
|
125
128
|
gap: 3,
|
|
126
129
|
borderRadius: tokens_1.radii.pill,
|
|
130
|
+
// The web makes the group's own surface near-solid for legibility; the
|
|
131
|
+
// selected item is the glass lens on top of it.
|
|
132
|
+
backgroundColor: theme.surface,
|
|
133
|
+
shadowOpacity: 0.08,
|
|
134
|
+
shadowRadius: 8,
|
|
135
|
+
shadowOffset: { width: 0, height: 2 },
|
|
127
136
|
...style,
|
|
128
137
|
}, ...props, children: items.map((item) => {
|
|
129
138
|
const on = isOn(item.value);
|
|
@@ -135,10 +144,8 @@ exports.ToggleGroup = (0, react_1.forwardRef)(function ToggleGroup({ items, mult
|
|
|
135
144
|
alignItems: "center",
|
|
136
145
|
justifyContent: "center",
|
|
137
146
|
gap: 6,
|
|
138
|
-
backgroundColor:
|
|
139
|
-
|
|
140
|
-
borderColor: theme.edge,
|
|
141
|
-
}, children: [item.icon ? (0, jsx_runtime_1.jsx)(View, { children: item.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 13, fontWeight: on ? "600" : "500", color: on ? theme.foreground : theme.muted }, children: item.label })] }) }, item.value));
|
|
147
|
+
backgroundColor: "transparent",
|
|
148
|
+
}, children: [on ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.pill, isDark: isDark, style: lens_1.lensFill }) : null, item.icon ? (0, jsx_runtime_1.jsx)(View, { children: item.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 13, fontWeight: on ? "600" : "500", color: on ? theme.foreground : theme.muted }, children: item.label })] }) }, item.value));
|
|
142
149
|
}) }));
|
|
143
150
|
});
|
|
144
151
|
/**
|
|
@@ -168,7 +175,7 @@ exports.InputOTP = (0, react_1.forwardRef)(function InputOTP({ value: valueProp,
|
|
|
168
175
|
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: [{ flexDirection: "row", alignItems: "center", gap: 8, alignSelf: "flex-start" }, style], ...props, children: [Array.from({ length }, (_, index) => {
|
|
169
176
|
const char = value[index] ?? "";
|
|
170
177
|
const isActive = index === focusedIndex && !disabled;
|
|
171
|
-
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, tintColor: isActive ? theme.glassActive : undefined, style: {
|
|
178
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "field", isDark: isDark, tintColor: isActive ? theme.glassActive : undefined, style: {
|
|
172
179
|
width: 44,
|
|
173
180
|
height: 52,
|
|
174
181
|
borderRadius: tokens_1.radii.md,
|
|
@@ -215,7 +222,7 @@ exports.ButtonGroup = (0, react_1.forwardRef)(function ButtonGroup({ items, size
|
|
|
215
222
|
onItemPress?.(item, index);
|
|
216
223
|
}, style: ({ pressed }) => ({
|
|
217
224
|
opacity: item.disabled ? 0.38 : pressed ? 0.85 : 1,
|
|
218
|
-
}), children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", interactive: !item.disabled, isDark: isDark, style: {
|
|
225
|
+
}), children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "control", interactive: !item.disabled, isDark: isDark, style: {
|
|
219
226
|
height,
|
|
220
227
|
paddingHorizontal: 18,
|
|
221
228
|
justifyContent: "center",
|
|
@@ -437,18 +444,28 @@ exports.Combobox = (0, react_1.forwardRef)(function Combobox({ options, value, d
|
|
|
437
444
|
? available
|
|
438
445
|
: available.filter((option) => option.label.toLowerCase().includes(needle) ||
|
|
439
446
|
(option.description ?? "").toLowerCase().includes(needle));
|
|
440
|
-
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: { ...style }, children: [(0, jsx_runtime_1.jsx)(
|
|
447
|
+
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: { ...style }, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
|
|
448
|
+
minHeight: 34,
|
|
449
|
+
paddingHorizontal: 14,
|
|
450
|
+
justifyContent: "center",
|
|
451
|
+
opacity: disabled ? 0.5 : 1,
|
|
452
|
+
}, children: (0, jsx_runtime_1.jsx)(TextInput, { value: query, onChangeText: (text) => setQuery(text), placeholder: placeholder, accessibilityLabel: label ?? placeholder, accessibilityState: { disabled }, editable: !disabled, style: {
|
|
453
|
+
paddingVertical: 8,
|
|
454
|
+
fontSize: 15,
|
|
455
|
+
color: theme.foreground,
|
|
456
|
+
} }) }), query.length > 0 ? ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "overlay", isDark: isDark, style: {
|
|
457
|
+
marginTop: 6,
|
|
441
458
|
borderRadius: tokens_1.radii.md,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
459
|
+
// The web dropdown floats on its own shadow rather than sitting
|
|
460
|
+
// flush on the page.
|
|
461
|
+
shadowOpacity: 0.4,
|
|
462
|
+
shadowRadius: 32,
|
|
463
|
+
shadowOffset: { width: 0, height: 12 },
|
|
464
|
+
}, children: matches.length === 0 ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 12, paddingVertical: 10 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, color: theme.muted }, children: "No matches" }) })) : (matches.map((option, index) => {
|
|
448
465
|
const isSelected = option.value === selected;
|
|
449
|
-
return ((0, jsx_runtime_1.
|
|
466
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: option.label, accessibilityState: { selected: isSelected }, onPress: () => {
|
|
450
467
|
setValue(option.value);
|
|
451
468
|
setQuery("");
|
|
452
|
-
}, style: { flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 10, backgroundColor: isSelected ?
|
|
469
|
+
}, style: { flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 10, backgroundColor: "transparent" }, children: [isSelected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: 8, isDark: isDark, style: lens_1.lensFill })) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, color: theme.foreground }, children: option.label }), option.description ? ((0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 12, color: theme.muted }, numberOfLines: 1, children: option.description })) : null] })] }, `${option.value}-${index}`));
|
|
453
470
|
})) })) : null] }));
|
|
454
471
|
});
|
package/lib/module/Glass.js
CHANGED
|
@@ -12,7 +12,7 @@ const motion_1 = require("./internal/motion");
|
|
|
12
12
|
* iOS 26+, Glacia's translucent fallback of identical shape on older iOS and
|
|
13
13
|
* Android. `testID` is passed to whichever surface renders.
|
|
14
14
|
*/
|
|
15
|
-
exports.Glass = (0, react_1.forwardRef)(function Glass({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
|
|
15
|
+
exports.Glass = (0, react_1.forwardRef)(function Glass({ effect = "regular", tintColor, interactive = false, surface, pressed, testID, style, children, isDark: isDarkProp, ...props }, ref) {
|
|
16
16
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(GlassView_1.GlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, isDark: isDark, style: style, ...props, children: children }));
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(GlassView_1.GlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, surface: surface, pressed: pressed, testID: testID, isDark: isDark, style: style, ...props, children: children }));
|
|
18
18
|
});
|
package/lib/module/Input.js
CHANGED
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Textarea = exports.Input = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const Glass_1 = require("./Glass");
|
|
6
7
|
const tokens_1 = require("./internal/tokens");
|
|
7
8
|
const primitives_1 = require("./internal/primitives");
|
|
8
9
|
const motion_1 = require("./internal/motion");
|
|
9
|
-
const heights = { sm:
|
|
10
|
+
const heights = { sm: 28, md: 34, lg: 44 };
|
|
10
11
|
const fontSizes = { sm: 14, md: 15, lg: 16 };
|
|
11
12
|
/**
|
|
12
13
|
* A single-line or multiline text field.
|
|
@@ -36,21 +37,22 @@ exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, pl
|
|
|
36
37
|
const showPlaceholder = !text && Boolean(placeholder);
|
|
37
38
|
const fieldStyle = {
|
|
38
39
|
flex: 1,
|
|
39
|
-
paddingVertical: height_padding(size),
|
|
40
|
+
paddingVertical: multiline ? 0 : height_padding(size),
|
|
40
41
|
paddingHorizontal: 0,
|
|
41
42
|
fontSize: fontSizes[size],
|
|
42
43
|
color: theme.foreground,
|
|
43
44
|
};
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
|
|
45
46
|
flexDirection: "row",
|
|
46
47
|
alignItems: multiline ? "flex-start" : "center",
|
|
47
48
|
gap: 8,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
// Fields are pills on the web; a multi-line field relaxes to the
|
|
50
|
+
// stack radius (18) because a pill around wrapped text reads wrong.
|
|
51
|
+
borderRadius: multiline ? 18 : tokens_1.radii.pill,
|
|
52
|
+
minHeight: multiline ? 84 : heights[size],
|
|
53
|
+
paddingHorizontal: 14,
|
|
54
|
+
paddingVertical: multiline ? 10 : 0,
|
|
55
|
+
borderColor: invalid ? theme.destructive : undefined,
|
|
54
56
|
opacity: disabled ? 0.5 : 1,
|
|
55
57
|
...style,
|
|
56
58
|
}, children: [prefix, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, justifyContent: "center" }, children: [showPlaceholder && ((0, jsx_runtime_1.jsx)(Text, { style: {
|
|
@@ -63,7 +65,7 @@ exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, pl
|
|
|
63
65
|
});
|
|
64
66
|
/** Vertical padding tuned per size so the text sits optically centred. */
|
|
65
67
|
function height_padding(size) {
|
|
66
|
-
return size === "sm" ?
|
|
68
|
+
return size === "sm" ? 4 : size === "lg" ? 10 : 7;
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* A multi-line field.
|
package/lib/module/Message.js
CHANGED
|
@@ -4,33 +4,29 @@ exports.Message = exports.MessageAttachment = exports.MessageBubble = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Display_1 = require("./Display");
|
|
7
|
+
const Glass_1 = require("./Glass");
|
|
7
8
|
const tokens_1 = require("./internal/tokens");
|
|
8
9
|
const primitives_1 = require("./internal/primitives");
|
|
9
10
|
const motion_1 = require("./internal/motion");
|
|
10
11
|
/**
|
|
11
12
|
* One message's bubble.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Incoming messages take the theme's wash; outgoing take `glassActive`, the
|
|
20
|
-
* same tint the library uses for any selected surface, so a transcript reads
|
|
21
|
-
* consistently with the rest of Glacia.
|
|
14
|
+
* The bubble is a glass surface like the rest of the library (panel profile),
|
|
15
|
+
* so it carries the same blurred backdrop, lit rim and shadow as a card. The
|
|
16
|
+
* outgoing direction is tinted with `glassActive` — the theme's selected
|
|
17
|
+
* tint — and the incoming one uses the plain glass token, which is what keeps
|
|
18
|
+
* the two directions distinguishable without a second material.
|
|
22
19
|
*/
|
|
23
20
|
exports.MessageBubble = (0, react_1.forwardRef)(function MessageBubble({ outgoing = false, children, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
24
21
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
25
22
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
26
23
|
const { View } = (0, primitives_1.primitives)();
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, testID: testID, surface: "panel", isDark: isDark, tintColor: outgoing ? theme.glassActive : undefined, style: {
|
|
28
25
|
alignSelf: outgoing ? "flex-end" : "flex-start",
|
|
29
26
|
maxWidth: "82%",
|
|
30
|
-
paddingHorizontal:
|
|
31
|
-
paddingVertical:
|
|
27
|
+
paddingHorizontal: 14,
|
|
28
|
+
paddingVertical: 10,
|
|
32
29
|
borderRadius: tokens_1.radii.lg,
|
|
33
|
-
backgroundColor: outgoing ? theme.glassActive : theme.wash,
|
|
34
30
|
...style,
|
|
35
31
|
}, ...props, children: children }));
|
|
36
32
|
});
|
|
@@ -50,8 +46,8 @@ exports.MessageAttachment = (0, react_1.forwardRef)(function MessageAttachment({
|
|
|
50
46
|
const chipStyle = {
|
|
51
47
|
flexDirection: "row",
|
|
52
48
|
alignItems: "center",
|
|
53
|
-
paddingHorizontal:
|
|
54
|
-
paddingVertical:
|
|
49
|
+
paddingHorizontal: 12,
|
|
50
|
+
paddingVertical: 8,
|
|
55
51
|
borderRadius: tokens_1.radii.md,
|
|
56
52
|
backgroundColor: theme.wash,
|
|
57
53
|
borderWidth: 0.5,
|
package/lib/module/Overlays.js
CHANGED
|
@@ -69,10 +69,21 @@ exports.Menu = (0, react_1.forwardRef)(function Menu({ trigger, items, open: ope
|
|
|
69
69
|
useBackDismiss(open, dismiss);
|
|
70
70
|
const { value: enter, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "snappy");
|
|
71
71
|
const scale = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0.96, 1] }) : 1;
|
|
72
|
-
const popover = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID ? `${testID}-popover` : undefined, style: {
|
|
72
|
+
const popover = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, testID: testID ? `${testID}-popover` : undefined, style: {
|
|
73
|
+
width,
|
|
74
|
+
borderRadius: tokens_1.radii.lg,
|
|
75
|
+
paddingVertical: 4,
|
|
76
|
+
// The web menu is deliberately near-solid so its labels stay legible
|
|
77
|
+
// over any backdrop, and it floats on a real shadow.
|
|
78
|
+
backgroundColor: theme.surface,
|
|
79
|
+
shadowOpacity: 0.12,
|
|
80
|
+
shadowRadius: 40,
|
|
81
|
+
shadowOffset: { width: 0, height: 12 },
|
|
82
|
+
...style,
|
|
83
|
+
}, children: items.map((item, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: item.accessibilityLabel ?? item.label, accessibilityState: { disabled: item.disabled }, disabled: item.disabled, onPress: () => {
|
|
73
84
|
setOpen(false);
|
|
74
85
|
item.onPress();
|
|
75
|
-
}, style: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical:
|
|
86
|
+
}, style: { flexDirection: "row", alignItems: "center", gap: 10, minHeight: 40, paddingVertical: 8, paddingHorizontal: 12, opacity: item.disabled ? 0.38 : 1 }, children: [item.icon ? (0, jsx_runtime_1.jsx)(View, { children: item.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 15, color: item.destructive ? theme.destructive : theme.foreground }, children: item.label })] }, `${item.label}-${index}`))) }));
|
|
76
87
|
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, style: { alignSelf: "flex-start" }, ...props, children: [(0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { expanded: open }, onPress: () => setOpen(!open), children: trigger }), (0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close menu", onPress: dismiss, style: { flex: 1, backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", justifyContent: "center", padding: 24 }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, children: animated ? ((0, jsx_runtime_1.jsx)(AnimatedScale, { scale: scale, children: popover })) : (popover) }) }) }) })] }));
|
|
77
88
|
});
|
|
78
89
|
/** Wraps a popover in the entrance scale, which must land on an Animated.View. */
|
|
@@ -234,18 +245,23 @@ function SheetRise({ translateY, children }) {
|
|
|
234
245
|
function SheetPanel({ title, footer, showHandle, isDark, testID, style, height, children, }) {
|
|
235
246
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
236
247
|
const { View, Text: RNText } = (0, primitives_1.primitives)();
|
|
237
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
|
|
248
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, testID: testID, style: {
|
|
238
249
|
borderTopLeftRadius: tokens_1.radii.xl,
|
|
239
250
|
borderTopRightRadius: tokens_1.radii.xl,
|
|
240
251
|
borderBottomLeftRadius: 0,
|
|
241
252
|
borderBottomRightRadius: 0,
|
|
242
|
-
paddingBottom:
|
|
253
|
+
paddingBottom: 24,
|
|
254
|
+
// The web sheet carries a deep, soft shadow so it reads as a layer
|
|
255
|
+
// above the page rather than a rectangle painted on it.
|
|
256
|
+
shadowOpacity: 0.5,
|
|
257
|
+
shadowRadius: 40,
|
|
258
|
+
shadowOffset: { width: 0, height: 0 },
|
|
243
259
|
// A snap point fixes the height; without one the panel is natural.
|
|
244
260
|
...(height != null ? { height } : { maxHeight: 560 }),
|
|
245
261
|
...style,
|
|
246
262
|
}, children: [showHandle ? ((0, jsx_runtime_1.jsx)(View, { style: { alignItems: "center", paddingTop: 8, paddingBottom: 4 }, children: (0, jsx_runtime_1.jsx)(View, { accessibilityElementsHidden: true,
|
|
247
263
|
// A capsule: the radius is half the handle's own height.
|
|
248
|
-
style: { width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator } }) })) : null, title ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal:
|
|
264
|
+
style: { width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator } }) })) : null, title ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 24, paddingVertical: 10 }, children: (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title }) })) : null, (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 24 }, children: children }), footer ? (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 24, paddingTop: 12, gap: 8 }, children: footer }) : null] }));
|
|
249
265
|
}
|
|
250
266
|
/**
|
|
251
267
|
* A side navigation drawer.
|
|
@@ -310,7 +326,7 @@ exports.Drawer = (0, react_1.forwardRef)(function Drawer({ open: openProp, defau
|
|
|
310
326
|
// (side or width) changes.
|
|
311
327
|
}, [draggable, PanResponder, side, width, haptics, dismiss]);
|
|
312
328
|
const translateX = drag !== 0 ? (side === "left" ? -drag : drag) : animated ? slideIn : 0;
|
|
313
|
-
const panel = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
|
|
329
|
+
const panel = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, testID: testID, style: {
|
|
314
330
|
width,
|
|
315
331
|
height: "100%",
|
|
316
332
|
borderRadius: 0,
|
package/lib/module/Pickers.js
CHANGED
|
@@ -13,6 +13,7 @@ const Overlays_1 = require("./Overlays");
|
|
|
13
13
|
const tokens_1 = require("./internal/tokens");
|
|
14
14
|
const primitives_1 = require("./internal/primitives");
|
|
15
15
|
const motion_1 = require("./internal/motion");
|
|
16
|
+
const lens_1 = require("./internal/lens");
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
17
18
|
// Date helpers
|
|
18
19
|
//
|
|
@@ -99,21 +100,22 @@ exports.Calendar = (0, react_1.forwardRef)(function Calendar({ value, onChange,
|
|
|
99
100
|
const selected = sameDay(cell.date, value);
|
|
100
101
|
const isToday = sameDay(cell.date, today);
|
|
101
102
|
const disabled = isDisabled(cell.date);
|
|
102
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", paddingVertical: 2 }, children: (0, jsx_runtime_1.
|
|
103
|
+
return ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", paddingVertical: 2 }, children: (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: cell.date.toDateString(), accessibilityState: { selected, disabled }, disabled: disabled, onPress: () => onChange?.(startOfDay(cell.date)), style: {
|
|
103
104
|
width: cellSize,
|
|
104
105
|
height: cellSize,
|
|
105
106
|
borderRadius: cellSize / 2,
|
|
106
107
|
alignItems: "center",
|
|
107
108
|
justifyContent: "center",
|
|
108
|
-
backgroundColor:
|
|
109
|
-
|
|
109
|
+
backgroundColor: "transparent",
|
|
110
|
+
// Today is ringed; the selection is a lens on top of it.
|
|
111
|
+
borderWidth: isToday && !selected ? 0.5 : 0,
|
|
110
112
|
borderColor: isToday && !selected ? theme.fill : theme.edge,
|
|
111
113
|
opacity: disabled ? 0.28 : cell.outside ? 0.45 : 1,
|
|
112
|
-
}, children: (0, jsx_runtime_1.jsx)(RNText, { style: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
}, children: [selected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: cellSize / 2, isDark: isDark, style: lens_1.lensFill })) : null, (0, jsx_runtime_1.jsx)(RNText, { style: {
|
|
115
|
+
fontSize: 14,
|
|
116
|
+
fontWeight: selected ? "600" : "400",
|
|
117
|
+
color: selected ? theme.foreground : theme.foreground,
|
|
118
|
+
}, children: String(cell.date.getDate()) })] }) }, cell.key));
|
|
117
119
|
}) }, row)))] }));
|
|
118
120
|
});
|
|
119
121
|
/**
|
|
@@ -201,7 +203,7 @@ exports.TimePicker = (0, react_1.forwardRef)(function TimePicker({ open: openPro
|
|
|
201
203
|
setHour(picked % 12 === 0 ? (isPm ? 12 : 0) : isPm ? picked + 12 : picked);
|
|
202
204
|
}, "Hour"), (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 22, color: theme.muted }, children: ":" }), column(minutes, minute, setMinute, "Minute"), use12Hour && ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, gap: 6 }, children: ["AM", "PM"].map((label) => {
|
|
203
205
|
const active = label === "PM" ? isPm : !isPm;
|
|
204
|
-
return ((0, jsx_runtime_1.
|
|
206
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { selected: active }, onPress: () => {
|
|
205
207
|
const nextPm = label === "PM";
|
|
206
208
|
if (nextPm === isPm)
|
|
207
209
|
return;
|
|
@@ -211,10 +213,8 @@ exports.TimePicker = (0, react_1.forwardRef)(function TimePicker({ open: openPro
|
|
|
211
213
|
borderRadius: tokens_1.radii.sm,
|
|
212
214
|
alignItems: "center",
|
|
213
215
|
justifyContent: "center",
|
|
214
|
-
backgroundColor:
|
|
215
|
-
|
|
216
|
-
borderColor: active ? theme.edge : "transparent",
|
|
217
|
-
}, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: active ? "600" : "500", color: active ? theme.foreground : theme.muted }, children: label }) }, label));
|
|
216
|
+
backgroundColor: "transparent",
|
|
217
|
+
}, children: [active ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.sm, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: active ? "600" : "500", color: active ? theme.foreground : theme.muted }, children: label })] }, label));
|
|
218
218
|
}) }))] }) }));
|
|
219
219
|
});
|
|
220
220
|
/** One scrollable column of the time drums. */
|
|
@@ -225,13 +225,13 @@ function ScrollColumn({ items, selected, onPick, isDark, pad, }) {
|
|
|
225
225
|
const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
226
226
|
const rows = items.map((item) => {
|
|
227
227
|
const active = item === selected;
|
|
228
|
-
return ((0, jsx_runtime_1.
|
|
228
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: String(item).padStart(pad, "0"), accessibilityState: { selected: active }, onPress: () => onPick(item), style: {
|
|
229
229
|
height: 34,
|
|
230
230
|
alignItems: "center",
|
|
231
231
|
justifyContent: "center",
|
|
232
232
|
borderRadius: tokens_1.radii.sm,
|
|
233
|
-
backgroundColor:
|
|
234
|
-
}, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 17, fontWeight: active ? "600" : "400", color: active ? theme.foreground : theme.muted }, children: String(item).padStart(pad, "0") }) }, item));
|
|
233
|
+
backgroundColor: "transparent",
|
|
234
|
+
}, children: [active ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.sm, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 17, fontWeight: active ? "600" : "400", color: active ? theme.foreground : theme.muted }, children: String(item).padStart(pad, "0") })] }, item));
|
|
235
235
|
});
|
|
236
236
|
if (!ScrollView) {
|
|
237
237
|
// Off-device: no ScrollView, so the column is clipped to its height rather
|
|
@@ -8,7 +8,10 @@ const tokens_1 = require("./internal/tokens");
|
|
|
8
8
|
const primitives_1 = require("./internal/primitives");
|
|
9
9
|
const motion_1 = require("./internal/motion");
|
|
10
10
|
const haptics_1 = require("./internal/haptics");
|
|
11
|
-
const
|
|
11
|
+
const lens_1 = require("./internal/lens");
|
|
12
|
+
// The web segment is 32 high inside a 2pt inset, on a pill container, with the
|
|
13
|
+
// selected pill itself a pill: 500/400 weights, not a bold selected label.
|
|
14
|
+
const SEGMENT_HEIGHT = 32;
|
|
12
15
|
/**
|
|
13
16
|
* A row of mutually exclusive segments on one glass container.
|
|
14
17
|
*
|
|
@@ -21,6 +24,7 @@ exports.SegmentedControl = (0, react_1.forwardRef)(function SegmentedControl({ v
|
|
|
21
24
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
25
|
const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
|
|
23
26
|
const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultIndex);
|
|
27
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
24
28
|
const activeIndex = selectedProp !== undefined ? selectedProp : internalIndex;
|
|
25
29
|
const safeIndex = Math.min(Math.max(activeIndex, 0), Math.max(values.length - 1, 0));
|
|
26
30
|
// The pill slides between equal-width segments, so a ratio is enough: 0 is
|
|
@@ -44,8 +48,10 @@ exports.SegmentedControl = (0, react_1.forwardRef)(function SegmentedControl({ v
|
|
|
44
48
|
alignItems: "center",
|
|
45
49
|
alignSelf: "flex-start",
|
|
46
50
|
padding: 2,
|
|
47
|
-
borderRadius: tokens_1.radii.
|
|
48
|
-
|
|
51
|
+
borderRadius: tokens_1.radii.pill,
|
|
52
|
+
// The web lays the segment track tint over glass; the fallback paints the
|
|
53
|
+
// same tint as the flat track the web sees through the glass.
|
|
54
|
+
backgroundColor: themeColors.fieldWash,
|
|
49
55
|
...style,
|
|
50
56
|
};
|
|
51
57
|
const pillTranslate = animated
|
|
@@ -55,30 +61,33 @@ exports.SegmentedControl = (0, react_1.forwardRef)(function SegmentedControl({ v
|
|
|
55
61
|
outputRange: ["0%", `${((count - 1) * 100) / count}%`],
|
|
56
62
|
})
|
|
57
63
|
: `${(safeIndex * 100) / count}%`;
|
|
58
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: containerStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { style: {
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", pressed: held, isDark: isDark, style: containerStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { style: {
|
|
59
65
|
position: "absolute",
|
|
60
66
|
top: 2,
|
|
61
67
|
left: 2,
|
|
62
68
|
width: pillWidth,
|
|
63
69
|
height: SEGMENT_HEIGHT,
|
|
64
|
-
borderRadius: tokens_1.radii.
|
|
70
|
+
borderRadius: tokens_1.radii.pill,
|
|
65
71
|
backgroundColor: themeColors.glassActive,
|
|
66
72
|
borderWidth: 0.5,
|
|
67
73
|
borderColor: themeColors.edge,
|
|
74
|
+
// The thumb is a lens: lifted off the rail, with its own rim.
|
|
75
|
+
...(0, lens_1.lensShadow)(isDark),
|
|
68
76
|
transform: [{ translateX: pillTranslate }],
|
|
69
|
-
}, pointerEvents: "none" })) : ((0, jsx_runtime_1.jsx)(View, { style: {
|
|
77
|
+
}, pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(lens_1.LensRim, { radius: tokens_1.radii.pill, isDark: isDark }) })) : ((0, jsx_runtime_1.jsx)(View, { style: {
|
|
70
78
|
position: "absolute",
|
|
71
79
|
top: 2,
|
|
72
80
|
left: `${2 + (safeIndex * 100) / count}%`,
|
|
73
81
|
width: pillWidth,
|
|
74
82
|
height: SEGMENT_HEIGHT,
|
|
75
|
-
borderRadius: tokens_1.radii.
|
|
83
|
+
borderRadius: tokens_1.radii.pill,
|
|
76
84
|
backgroundColor: themeColors.glassActive,
|
|
77
85
|
borderWidth: 0.5,
|
|
78
86
|
borderColor: themeColors.edge,
|
|
79
|
-
|
|
87
|
+
...(0, lens_1.lensShadow)(isDark),
|
|
88
|
+
}, pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(lens_1.LensRim, { radius: tokens_1.radii.pill, isDark: isDark }) })), values.map((label, idx) => {
|
|
80
89
|
const isSelected = idx === safeIndex;
|
|
81
|
-
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "tab", accessibilityLabel: label, accessibilityState: { selected: isSelected }, onPress: () => handleSelect(idx), style: {
|
|
90
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "tab", accessibilityLabel: label, accessibilityState: { selected: isSelected }, onPress: () => handleSelect(idx), onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: {
|
|
82
91
|
flex: 1,
|
|
83
92
|
height: SEGMENT_HEIGHT,
|
|
84
93
|
alignItems: "center",
|
|
@@ -87,7 +96,7 @@ exports.SegmentedControl = (0, react_1.forwardRef)(function SegmentedControl({ v
|
|
|
87
96
|
borderRadius: tokens_1.radii.sm,
|
|
88
97
|
}, children: (0, jsx_runtime_1.jsx)(Text, { numberOfLines: 1, style: {
|
|
89
98
|
fontSize: 13,
|
|
90
|
-
fontWeight: isSelected ? "
|
|
99
|
+
fontWeight: isSelected ? "500" : "400",
|
|
91
100
|
color: isSelected ? themeColors.foreground : themeColors.muted,
|
|
92
101
|
}, children: label }) }, label));
|
|
93
102
|
})] }));
|
package/lib/module/Slider.js
CHANGED
|
@@ -9,8 +9,10 @@ const tokens_1 = require("./internal/tokens");
|
|
|
9
9
|
const primitives_2 = require("./internal/primitives");
|
|
10
10
|
const motion_1 = require("./internal/motion");
|
|
11
11
|
const haptics_1 = require("./internal/haptics");
|
|
12
|
-
|
|
13
|
-
const
|
|
12
|
+
// The web slider: a 6pt track and a glass-lens thumb rather than a small dot.
|
|
13
|
+
const TRACK_HEIGHT = 6;
|
|
14
|
+
const THUMB_WIDTH = 36;
|
|
15
|
+
const THUMB_HEIGHT = 24;
|
|
14
16
|
const CONTAINER_HEIGHT = 40;
|
|
15
17
|
/** Rounds `value` onto the nearest step from `min`, clamped to the range. */
|
|
16
18
|
function quantize(value, min, max, step) {
|
|
@@ -118,15 +120,22 @@ exports.Slider = (0, react_1.forwardRef)(function Slider({ value: valueProp, def
|
|
|
118
120
|
};
|
|
119
121
|
const thumbStyle = {
|
|
120
122
|
position: "absolute",
|
|
121
|
-
top: (CONTAINER_HEIGHT -
|
|
123
|
+
top: (CONTAINER_HEIGHT - THUMB_HEIGHT) / 2,
|
|
122
124
|
left: `${Math.min(100, Math.max(0, percentage))}%`,
|
|
123
|
-
width:
|
|
124
|
-
height:
|
|
125
|
-
marginLeft: -
|
|
126
|
-
borderRadius:
|
|
127
|
-
backgroundColor:
|
|
125
|
+
width: THUMB_WIDTH,
|
|
126
|
+
height: THUMB_HEIGHT,
|
|
127
|
+
marginLeft: -THUMB_WIDTH / 2,
|
|
128
|
+
borderRadius: THUMB_HEIGHT / 2,
|
|
129
|
+
backgroundColor: themeColors.onTint,
|
|
128
130
|
borderWidth: 0.5,
|
|
129
|
-
borderColor:
|
|
131
|
+
borderColor: themeColors.edge,
|
|
132
|
+
// The same lens shadow stack the Switch thumb carries: the web thumb is a
|
|
133
|
+
// lens with real depth, not a white dot painted on the track.
|
|
134
|
+
shadowColor: tokens_1.material.shadowColor,
|
|
135
|
+
shadowOpacity: 0.2,
|
|
136
|
+
shadowRadius: 8,
|
|
137
|
+
shadowOffset: { width: 0, height: 3 },
|
|
138
|
+
elevation: 3,
|
|
130
139
|
};
|
|
131
140
|
return ((0, jsx_runtime_1.jsxs)(Pressable, { testID: testID, accessibilityRole: "adjustable", accessibilityLabel: accessibilityLabel, accessibilityState: { disabled }, accessibilityValue: { min, max, now: value }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
|
|
132
141
|
if (event?.nativeEvent?.actionName === "increment")
|
package/lib/module/Switch.js
CHANGED
|
@@ -8,9 +8,12 @@ const tokens_1 = require("./internal/tokens");
|
|
|
8
8
|
const primitives_1 = require("./internal/primitives");
|
|
9
9
|
const motion_1 = require("./internal/motion");
|
|
10
10
|
const haptics_1 = require("./internal/haptics");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// The web switch's geometry: a 60 x 25 track with a 21pt thumb, which the web
|
|
12
|
+
// draws at 160 x 67 and scales down by 0.375. The thumb is a lens, not a dot:
|
|
13
|
+
// it carries the same shadow stack as the slider's.
|
|
14
|
+
const TRACK_WIDTH = 60;
|
|
15
|
+
const TRACK_HEIGHT = 25;
|
|
16
|
+
const THUMB = 21;
|
|
14
17
|
const TRAVEL = TRACK_WIDTH - THUMB - 4;
|
|
15
18
|
/**
|
|
16
19
|
* An on/off switch.
|
|
@@ -25,6 +28,7 @@ exports.Switch = (0, react_1.forwardRef)(function Switch({ checked: checkedProp,
|
|
|
25
28
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
26
29
|
const { View, Pressable, Animated } = (0, primitives_1.primitives)();
|
|
27
30
|
const [internalChecked, setInternalChecked] = (0, react_1.useState)(defaultChecked);
|
|
31
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
28
32
|
const isChecked = checkedProp !== undefined ? checkedProp : internalChecked;
|
|
29
33
|
// The thumb's travel is a single number animated on the springs token.
|
|
30
34
|
const { value: offset, animated } = (0, motion_1.useSpring)(isChecked ? TRAVEL : 0, "snappy");
|
|
@@ -52,12 +56,20 @@ exports.Switch = (0, react_1.forwardRef)(function Switch({ checked: checkedProp,
|
|
|
52
56
|
width: THUMB,
|
|
53
57
|
height: THUMB,
|
|
54
58
|
borderRadius: THUMB / 2,
|
|
55
|
-
backgroundColor:
|
|
56
|
-
// A hairline edge instead of a drop shadow: RN shadows need per-platform
|
|
57
|
-
// props, and the edge reads correctly on a translucent track.
|
|
59
|
+
backgroundColor: themeColors.onTint,
|
|
58
60
|
borderWidth: 0.5,
|
|
59
|
-
borderColor:
|
|
60
|
-
|
|
61
|
+
borderColor: themeColors.edge,
|
|
62
|
+
// The lens's lift: a soft shadow under the thumb, and a slight growth
|
|
63
|
+
// while it is held, matching the web thumb.
|
|
64
|
+
shadowColor: tokens_1.material.shadowColor,
|
|
65
|
+
shadowOpacity: 0.2,
|
|
66
|
+
shadowRadius: 8,
|
|
67
|
+
shadowOffset: { width: 0, height: 3 },
|
|
68
|
+
elevation: 3,
|
|
69
|
+
transform: [
|
|
70
|
+
{ translateX: animated ? offset : isChecked ? TRAVEL : 0 },
|
|
71
|
+
{ scale: held ? 1.06 : 1 },
|
|
72
|
+
],
|
|
61
73
|
};
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "switch", accessibilityLabel: accessibilityLabel, accessibilityState: { checked: isChecked, disabled }, disabled: disabled, onPress: toggle, style: { alignSelf: "flex-start" }, ...props, children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: trackStyle, children: animated ? (0, jsx_runtime_1.jsx)(Animated.View, { style: thumbStyle }) : (0, jsx_runtime_1.jsx)(View, { style: thumbStyle }) }) }));
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "switch", accessibilityLabel: accessibilityLabel, accessibilityState: { checked: isChecked, disabled }, disabled: disabled, onPress: toggle, onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: { alignSelf: "flex-start" }, ...props, children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "control", isDark: isDark, style: trackStyle, children: animated ? (0, jsx_runtime_1.jsx)(Animated.View, { style: thumbStyle }) : (0, jsx_runtime_1.jsx)(View, { style: thumbStyle }) }) }));
|
|
63
75
|
});
|