glacia-native 0.5.0 → 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 +103 -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 +86 -8
- package/lib/module/Feedback.js +244 -21
- package/lib/module/Form.js +29 -33
- package/lib/module/Forms2.js +257 -13
- package/lib/module/Glass.js +2 -2
- package/lib/module/Input.js +12 -10
- package/lib/module/Message.js +84 -0
- package/lib/module/Overlays.js +195 -17
- package/lib/module/Pickers.js +16 -16
- package/lib/module/SegmentedControl.js +24 -11
- package/lib/module/Slider.js +24 -10
- package/lib/module/Switch.js +25 -10
- package/lib/module/TabBar.js +23 -13
- package/lib/module/Table.js +4 -3
- package/lib/module/Tabs.js +3 -2
- package/lib/module/ai.js +26 -18
- package/lib/module/charts/BarChart.js +11 -3
- package/lib/module/index.js +23 -2
- package/lib/module/internal/GlassContainer.js +54 -0
- package/lib/module/internal/GlassView.js +10 -2
- package/lib/module/internal/a11y.js +94 -0
- package/lib/module/internal/blur.js +78 -0
- package/lib/module/internal/fallback.js +120 -19
- package/lib/module/internal/glass-routing.js +7 -0
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/haptics.js +54 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/motion.js +10 -1
- package/lib/module/internal/primitives.js +70 -4
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +80 -2
- package/lib/typescript/Bars.d.ts +67 -0
- package/lib/typescript/Display.d.ts +59 -0
- package/lib/typescript/Feedback.d.ts +58 -0
- package/lib/typescript/Forms2.d.ts +81 -0
- package/lib/typescript/Message.d.ts +67 -0
- package/lib/typescript/Overlays.d.ts +41 -0
- package/lib/typescript/SegmentedControl.d.ts +2 -0
- package/lib/typescript/Slider.d.ts +2 -0
- package/lib/typescript/Switch.d.ts +2 -0
- package/lib/typescript/TabBar.d.ts +2 -0
- package/lib/typescript/index.d.ts +9 -6
- package/lib/typescript/internal/GlassContainer.d.ts +37 -0
- package/lib/typescript/internal/GlassView.d.ts +21 -0
- package/lib/typescript/internal/a11y.d.ts +19 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +32 -2
- package/lib/typescript/internal/glass-routing.d.ts +10 -0
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/haptics.d.ts +7 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/motion.d.ts +4 -0
- package/lib/typescript/internal/primitives.d.ts +23 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +89 -0
- package/package.json +12 -3
- package/src/Bars.tsx +239 -2
- package/src/Button.tsx +16 -9
- package/src/Card.tsx +2 -2
- package/src/Dialog.tsx +37 -26
- package/src/Display.tsx +237 -6
- package/src/Feedback.tsx +448 -35
- package/src/Form.tsx +60 -40
- package/src/Forms2.tsx +455 -8
- package/src/Glass.tsx +4 -0
- package/src/Input.tsx +15 -11
- package/src/Message.tsx +218 -0
- package/src/Overlays.tsx +269 -39
- package/src/Pickers.tsx +11 -6
- package/src/SegmentedControl.tsx +39 -9
- package/src/Slider.tsx +26 -10
- package/src/Switch.tsx +29 -10
- package/src/TabBar.tsx +39 -12
- package/src/Table.tsx +4 -3
- package/src/Tabs.tsx +5 -0
- package/src/ai.tsx +37 -23
- package/src/charts/BarChart.tsx +41 -3
- package/src/index.ts +43 -1
- package/src/internal/GlassContainer.tsx +82 -0
- package/src/internal/GlassView.tsx +25 -0
- package/src/internal/a11y.ts +105 -0
- package/src/internal/blur.ts +90 -0
- package/src/internal/fallback.tsx +170 -15
- package/src/internal/glass-routing.ts +17 -0
- package/src/internal/glow.tsx +62 -0
- package/src/internal/haptics.ts +59 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/motion.ts +10 -1
- package/src/internal/primitives.ts +83 -4
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +82 -1
package/lib/module/Forms2.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = void 0;
|
|
3
|
+
exports.Combobox = exports.ColorPicker = exports.DEFAULT_PALETTE = exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = void 0;
|
|
4
|
+
exports.hexToRgb = hexToRgb;
|
|
5
|
+
exports.hueGradientColors = hueGradientColors;
|
|
6
|
+
exports.rgbToHex = rgbToHex;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
6
9
|
const Glass_1 = require("./Glass");
|
|
7
10
|
const tokens_1 = require("./internal/tokens");
|
|
8
11
|
const primitives_1 = require("./internal/primitives");
|
|
9
12
|
const motion_1 = require("./internal/motion");
|
|
13
|
+
const lens_1 = require("./internal/lens");
|
|
10
14
|
/**
|
|
11
15
|
* Minus / value / plus.
|
|
12
16
|
*
|
|
@@ -30,21 +34,22 @@ exports.Stepper = (0, react_1.forwardRef)(function Stepper({ value: valueProp, d
|
|
|
30
34
|
};
|
|
31
35
|
const atMin = value <= min;
|
|
32
36
|
const atMax = value >= max;
|
|
33
|
-
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:
|
|
34
|
-
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) => {
|
|
35
39
|
const delta = event?.nativeEvent?.actionName === "increment" ? step : -step;
|
|
36
40
|
apply(value + delta);
|
|
37
41
|
}, style: {
|
|
38
42
|
flexDirection: "row",
|
|
39
43
|
alignItems: "center",
|
|
40
44
|
alignSelf: "flex-start",
|
|
45
|
+
height: 34,
|
|
41
46
|
borderRadius: tokens_1.radii.pill,
|
|
42
47
|
paddingHorizontal: 2,
|
|
43
48
|
opacity: disabled ? 0.38 : 1,
|
|
44
49
|
...style,
|
|
45
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)] }));
|
|
46
51
|
});
|
|
47
|
-
const toggleSizes = { sm: 30, md:
|
|
52
|
+
const toggleSizes = { sm: 30, md: 34, lg: 44 };
|
|
48
53
|
/**
|
|
49
54
|
* A button that stays pressed.
|
|
50
55
|
*
|
|
@@ -60,6 +65,7 @@ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp,
|
|
|
60
65
|
const controlled = pressedProp !== undefined ? pressedProp : selected;
|
|
61
66
|
const [internal, setInternal] = (0, react_1.useState)(defaultPressed);
|
|
62
67
|
const isPressed = controlled !== undefined ? controlled : internal;
|
|
68
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
63
69
|
const dimension = toggleSizes[size];
|
|
64
70
|
const handlePress = () => {
|
|
65
71
|
const next = !isPressed;
|
|
@@ -67,7 +73,7 @@ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp,
|
|
|
67
73
|
setInternal(next);
|
|
68
74
|
onPressedChange?.(next);
|
|
69
75
|
};
|
|
70
|
-
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: {
|
|
71
77
|
height: dimension,
|
|
72
78
|
borderRadius: tokens_1.radii.pill,
|
|
73
79
|
paddingHorizontal: icon && !children ? 0 : 12,
|
|
@@ -79,7 +85,7 @@ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp,
|
|
|
79
85
|
backgroundColor: variant === "ghost" ? "transparent" : undefined,
|
|
80
86
|
...style,
|
|
81
87
|
}, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, typeof children === "string" ? ((0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: {
|
|
82
|
-
fontSize: size === "sm" ? 12 : size === "lg" ? 15 :
|
|
88
|
+
fontSize: size === "sm" ? 12 : size === "lg" ? 15 : 14,
|
|
83
89
|
fontWeight: isPressed ? "600" : "500",
|
|
84
90
|
color: isPressed ? theme.foreground : theme.muted,
|
|
85
91
|
}, children: children })) : (children)] }) }));
|
|
@@ -114,13 +120,19 @@ exports.ToggleGroup = (0, react_1.forwardRef)(function ToggleGroup({ items, mult
|
|
|
114
120
|
onValueChange?.(next);
|
|
115
121
|
};
|
|
116
122
|
const height = size === "sm" ? 30 : size === "lg" ? 42 : 36;
|
|
117
|
-
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: {
|
|
118
124
|
flexDirection: "row",
|
|
119
125
|
alignItems: "center",
|
|
120
126
|
alignSelf: "flex-start",
|
|
121
127
|
padding: 3,
|
|
122
128
|
gap: 3,
|
|
123
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 },
|
|
124
136
|
...style,
|
|
125
137
|
}, ...props, children: items.map((item) => {
|
|
126
138
|
const on = isOn(item.value);
|
|
@@ -132,10 +144,8 @@ exports.ToggleGroup = (0, react_1.forwardRef)(function ToggleGroup({ items, mult
|
|
|
132
144
|
alignItems: "center",
|
|
133
145
|
justifyContent: "center",
|
|
134
146
|
gap: 6,
|
|
135
|
-
backgroundColor:
|
|
136
|
-
|
|
137
|
-
borderColor: theme.edge,
|
|
138
|
-
}, 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));
|
|
139
149
|
}) }));
|
|
140
150
|
});
|
|
141
151
|
/**
|
|
@@ -165,7 +175,7 @@ exports.InputOTP = (0, react_1.forwardRef)(function InputOTP({ value: valueProp,
|
|
|
165
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) => {
|
|
166
176
|
const char = value[index] ?? "";
|
|
167
177
|
const isActive = index === focusedIndex && !disabled;
|
|
168
|
-
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: {
|
|
169
179
|
width: 44,
|
|
170
180
|
height: 52,
|
|
171
181
|
borderRadius: tokens_1.radii.md,
|
|
@@ -212,7 +222,7 @@ exports.ButtonGroup = (0, react_1.forwardRef)(function ButtonGroup({ items, size
|
|
|
212
222
|
onItemPress?.(item, index);
|
|
213
223
|
}, style: ({ pressed }) => ({
|
|
214
224
|
opacity: item.disabled ? 0.38 : pressed ? 0.85 : 1,
|
|
215
|
-
}), 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: {
|
|
216
226
|
height,
|
|
217
227
|
paddingHorizontal: 18,
|
|
218
228
|
justifyContent: "center",
|
|
@@ -225,3 +235,237 @@ exports.ButtonGroup = (0, react_1.forwardRef)(function ButtonGroup({ items, size
|
|
|
225
235
|
}, children: (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: size === "sm" ? 13 : 14, fontWeight: "500", color: theme.foreground }, children: item.label }) }) }, `${item.label}-${index}`));
|
|
226
236
|
}) }));
|
|
227
237
|
});
|
|
238
|
+
/**
|
|
239
|
+
* A colour picker built from Glacia's own parts — no native widget.
|
|
240
|
+
*
|
|
241
|
+
* The palette is a grid of swatches from the caller's colours; the custom row
|
|
242
|
+
* is a hue track drawn as an SVG gradient (the resolver's shapes, so it works
|
|
243
|
+
* wherever the charts work) driven by the same Slider mechanics as the rest of
|
|
244
|
+
* the library: a drag along the track picks a hue, and a second track saturates
|
|
245
|
+
* it. The value is a hex string.
|
|
246
|
+
*
|
|
247
|
+
* The default palette is a small set of iOS-conventional colours, in case a
|
|
248
|
+
* caller wants a picker with no colour knowledge of its own.
|
|
249
|
+
*/
|
|
250
|
+
exports.DEFAULT_PALETTE = tokens_1.palette.default;
|
|
251
|
+
/** Parses a hex colour into its red, green and blue channels. */
|
|
252
|
+
function hexToRgb(hex) {
|
|
253
|
+
const match = /^#?([0-9a-f]{6})$/i.exec(hex.trim());
|
|
254
|
+
if (!match)
|
|
255
|
+
return null;
|
|
256
|
+
const raw = match[1];
|
|
257
|
+
return {
|
|
258
|
+
r: parseInt(raw.slice(0, 2), 16),
|
|
259
|
+
g: parseInt(raw.slice(2, 4), 16),
|
|
260
|
+
b: parseInt(raw.slice(4, 6), 16),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** Builds a hue gradient's colours, sweeping red → orange → … → red. */
|
|
264
|
+
function hueGradientColors() {
|
|
265
|
+
const stops = 12;
|
|
266
|
+
return Array.from({ length: stops }, (_u, i) => {
|
|
267
|
+
const angle = (i / stops) * 360;
|
|
268
|
+
const c = hslToRgb(angle, 1, 0.5);
|
|
269
|
+
return `#${c.r.toString(16).padStart(2, "0")}${c.g.toString(16).padStart(2, "0")}${c.b.toString(16).padStart(2, "0")}`;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/** Converts an HSL triple (h 0–360, s/l 0–1) to an RGB hex string. */
|
|
273
|
+
function hslToRgb(h, s, l) {
|
|
274
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
275
|
+
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
|
|
276
|
+
const m = l - c / 2;
|
|
277
|
+
let r = 0, g = 0, b = 0;
|
|
278
|
+
if (h < 60) {
|
|
279
|
+
r = c;
|
|
280
|
+
g = x;
|
|
281
|
+
}
|
|
282
|
+
else if (h < 120) {
|
|
283
|
+
r = x;
|
|
284
|
+
g = c;
|
|
285
|
+
}
|
|
286
|
+
else if (h < 180) {
|
|
287
|
+
g = c;
|
|
288
|
+
b = x;
|
|
289
|
+
}
|
|
290
|
+
else if (h < 240) {
|
|
291
|
+
g = x;
|
|
292
|
+
b = c;
|
|
293
|
+
}
|
|
294
|
+
else if (h < 300) {
|
|
295
|
+
r = x;
|
|
296
|
+
b = c;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
r = c;
|
|
300
|
+
b = x;
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
r: Math.round((r + m) * 255),
|
|
304
|
+
g: Math.round((g + m) * 255),
|
|
305
|
+
b: Math.round((b + m) * 255),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** Converts an RGB triple to a hex string. */
|
|
309
|
+
function rgbToHex(r, g, b) {
|
|
310
|
+
const clamp = (n) => Math.max(0, Math.min(255, Math.round(n)));
|
|
311
|
+
return `#${clamp(r).toString(16).padStart(2, "0")}${clamp(g).toString(16).padStart(2, "0")}${clamp(b).toString(16).padStart(2, "0")}`;
|
|
312
|
+
}
|
|
313
|
+
exports.ColorPicker = (0, react_1.forwardRef)(function ColorPicker({ colors: palette, value, defaultValue, onChange, size = "md", columns = 6, allowCustom = true, disabled = false, accessibilityLabel = "Color", style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
314
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
315
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
316
|
+
const { View, Pressable, Text: RNText, PanResponder, Svg, Rect, Defs, LinearGradient, Stop } = (0, primitives_1.primitives)();
|
|
317
|
+
const swatches = palette && palette.length > 0 ? palette : exports.DEFAULT_PALETTE;
|
|
318
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue ?? swatches[0] ?? tokens_1.palette.fallback);
|
|
319
|
+
const activeColor = value !== undefined ? value : internalValue;
|
|
320
|
+
const setColor = (next) => {
|
|
321
|
+
if (disabled)
|
|
322
|
+
return;
|
|
323
|
+
if (value === undefined)
|
|
324
|
+
setInternalValue(next);
|
|
325
|
+
onChange?.(next);
|
|
326
|
+
};
|
|
327
|
+
// The custom row's two tracks: hue on the top, saturation on the bottom.
|
|
328
|
+
// Both are driven by PanResponder like the library's Slider — a press or a
|
|
329
|
+
// drag along a track reports the colour at that position.
|
|
330
|
+
const trackRef = (0, react_1.useRef)(0);
|
|
331
|
+
const swatchSize = tokens_1.controlSizes.swatch[size];
|
|
332
|
+
const hueColor = (h) => {
|
|
333
|
+
const c = hslToRgb(h, 1, 0.5);
|
|
334
|
+
return rgbToHex(c.r, c.g, c.b);
|
|
335
|
+
};
|
|
336
|
+
const colorAtFraction = (fraction, hue) => {
|
|
337
|
+
const sat = Math.max(0, Math.min(1, fraction));
|
|
338
|
+
const c = hslToRgb(hue, sat, 0.5);
|
|
339
|
+
return rgbToHex(c.r, c.g, c.b);
|
|
340
|
+
};
|
|
341
|
+
const hue = hexToRgb(activeColor) ? hueOf(activeColor) : 0;
|
|
342
|
+
const hueResponder = makeTrackResponder((fraction) => {
|
|
343
|
+
setColor(hueColor(fraction * 360));
|
|
344
|
+
}, PanResponder, trackRef);
|
|
345
|
+
const satResponder = makeTrackResponder((fraction) => {
|
|
346
|
+
setColor(colorAtFraction(fraction, hue));
|
|
347
|
+
}, PanResponder, trackRef);
|
|
348
|
+
const hueGradient = hueGradientColors();
|
|
349
|
+
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessibilityRole: "adjustable", accessibilityLabel: accessibilityLabel, accessibilityValue: { text: activeColor }, style: { gap: 12, opacity: disabled ? 0.38 : 1, ...style }, ...props, children: [(0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 8 }, children: swatches.map((swatch, index) => {
|
|
350
|
+
const selected = swatch.toLowerCase() === activeColor.toLowerCase();
|
|
351
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${swatch} color`, accessibilityState: { selected }, disabled: disabled, onPress: () => setColor(swatch), style: {
|
|
352
|
+
width: swatchSize,
|
|
353
|
+
height: swatchSize,
|
|
354
|
+
borderRadius: swatchSize / 2,
|
|
355
|
+
backgroundColor: swatch,
|
|
356
|
+
borderWidth: selected ? 2 : 0.5,
|
|
357
|
+
borderColor: selected ? theme.fill : theme.separator,
|
|
358
|
+
} }, `${swatch}-${index}`));
|
|
359
|
+
}) }), allowCustom ? ((0, jsx_runtime_1.jsxs)(View, { style: { gap: 8 }, children: [(0, jsx_runtime_1.jsx)(View, { style: { height: tokens_1.controlSizes.picker.track, borderRadius: tokens_1.radii.md, overflow: "hidden" }, ...(hueResponder ? hueResponder.panHandlers : {}), children: (0, jsx_runtime_1.jsxs)(Svg, { width: "100%", height: "100%", children: [(0, jsx_runtime_1.jsx)(Defs, { children: (0, jsx_runtime_1.jsx)(LinearGradient, { id: "hueGradient", x1: "0", y1: "0", x2: "1", y2: "0", children: hueGradient.map((color, i) => ((0, jsx_runtime_1.jsx)(Stop, { offset: i / (hueGradient.length - 1), stopColor: color }, i))) }) }), (0, jsx_runtime_1.jsx)(Rect, { x: "0", y: "0", width: "100%", height: "100%", fill: "url(#hueGradient)" })] }) }), (0, jsx_runtime_1.jsx)(View, { style: { height: tokens_1.controlSizes.picker.track, borderRadius: tokens_1.radii.md, overflow: "hidden" }, ...(satResponder ? satResponder.panHandlers : {}), children: (0, jsx_runtime_1.jsxs)(Svg, { width: "100%", height: "100%", children: [(0, jsx_runtime_1.jsx)(Defs, { children: (0, jsx_runtime_1.jsxs)(LinearGradient, { id: "satGradient", x1: "0", y1: "0", x2: "1", y2: "0", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: theme.neutralTop }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: hueColor(hue) })] }) }), (0, jsx_runtime_1.jsx)(Rect, { x: "0", y: "0", width: "100%", height: "100%", fill: "url(#satGradient)" })] }) }), (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 12, color: theme.muted }, children: activeColor })] })) : null] }));
|
|
360
|
+
});
|
|
361
|
+
/** The hue (0–360) of a hex colour. */
|
|
362
|
+
function hueOf(hex) {
|
|
363
|
+
const rgb = hexToRgb(hex);
|
|
364
|
+
if (!rgb)
|
|
365
|
+
return 0;
|
|
366
|
+
const { r, g, b } = rgb;
|
|
367
|
+
const max = Math.max(r, g, b) / 255;
|
|
368
|
+
const min = Math.min(r, g, b) / 255;
|
|
369
|
+
const delta = max - min;
|
|
370
|
+
if (delta === 0)
|
|
371
|
+
return 0;
|
|
372
|
+
let h = 0;
|
|
373
|
+
if (max === r / 255)
|
|
374
|
+
h = ((g / 255 - b / 255) / delta) % 6;
|
|
375
|
+
else if (max === g / 255)
|
|
376
|
+
h = (b / 255 - r / 255) / delta + 2;
|
|
377
|
+
else
|
|
378
|
+
h = (r / 255 - g / 255) / delta + 4;
|
|
379
|
+
const degrees = h * 60;
|
|
380
|
+
return degrees < 0 ? degrees + 360 : degrees;
|
|
381
|
+
}
|
|
382
|
+
/** Builds a PanResponder that reports the fraction (0–1) across a track. */
|
|
383
|
+
function makeTrackResponder(onFraction, PanResponder, trackRef) {
|
|
384
|
+
if (!PanResponder?.create)
|
|
385
|
+
return null;
|
|
386
|
+
return PanResponder.create({
|
|
387
|
+
onStartShouldSetPanResponder: () => true,
|
|
388
|
+
onMoveShouldSetPanResponder: () => true,
|
|
389
|
+
onPanResponderGrant: (event) => {
|
|
390
|
+
const fraction = fractionAt(event, 100);
|
|
391
|
+
if (fraction !== null)
|
|
392
|
+
onFraction(fraction);
|
|
393
|
+
},
|
|
394
|
+
onPanResponderMove: (event) => {
|
|
395
|
+
const fraction = fractionAt(event, 100);
|
|
396
|
+
if (fraction !== null)
|
|
397
|
+
onFraction(fraction);
|
|
398
|
+
},
|
|
399
|
+
onPanResponderTerminationRequest: () => false,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
/** The fraction of the track under a touch, from the touch's X. */
|
|
403
|
+
function fractionAt(event, fallbackWidth) {
|
|
404
|
+
const x = event?.nativeEvent?.locationX;
|
|
405
|
+
const width = event?.nativeEvent?.layoutMeasurement?.width ?? fallbackWidth;
|
|
406
|
+
if (typeof x !== "number" || typeof width !== "number" || width <= 0)
|
|
407
|
+
return null;
|
|
408
|
+
return Math.max(0, Math.min(1, x / width));
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* A type-to-search select.
|
|
412
|
+
*
|
|
413
|
+
* The Input patterns (real TextInput, themed placeholder, `value`/`defaultValue`)
|
|
414
|
+
* open a Menu-style glass dropdown whose list filters as the user types — every
|
|
415
|
+
* keystroke re-filters the options, so the visible set genuinely shrinks, never
|
|
416
|
+
* a list that stays put and pretends to search.
|
|
417
|
+
*
|
|
418
|
+
* The filter is a case-insensitive substring match on label and description. An
|
|
419
|
+
* empty result shows an explicit empty row, so the user sees a search that found
|
|
420
|
+
* nothing rather than a list that silently went blank. The dropdown stays open
|
|
421
|
+
* until an option is picked or the field loses focus.
|
|
422
|
+
*/
|
|
423
|
+
exports.Combobox = (0, react_1.forwardRef)(function Combobox({ options, value, defaultValue, onChange, label, placeholder = "Search…", disabled = false, onEmpty, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
424
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
425
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
426
|
+
const { View, TextInput, Text: RNText, Pressable } = (0, primitives_1.primitives)();
|
|
427
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue ?? "");
|
|
428
|
+
const [query, setQuery] = (0, react_1.useState)("");
|
|
429
|
+
const selected = value !== undefined ? value : internalValue;
|
|
430
|
+
const selectedLabel = (options ?? []).find((option) => option.value === selected)?.label ?? "";
|
|
431
|
+
const setValue = (next) => {
|
|
432
|
+
if (disabled)
|
|
433
|
+
return;
|
|
434
|
+
if (value === undefined)
|
|
435
|
+
setInternalValue(next);
|
|
436
|
+
onChange?.(next);
|
|
437
|
+
};
|
|
438
|
+
// Filter as the user types.
|
|
439
|
+
// An option list that has not loaded yet is empty, not a crash: a combobox
|
|
440
|
+
// is frequently rendered before its options arrive.
|
|
441
|
+
const available = options ?? [];
|
|
442
|
+
const needle = query.trim().toLowerCase();
|
|
443
|
+
const matches = needle.length === 0
|
|
444
|
+
? available
|
|
445
|
+
: available.filter((option) => option.label.toLowerCase().includes(needle) ||
|
|
446
|
+
(option.description ?? "").toLowerCase().includes(needle));
|
|
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,
|
|
458
|
+
borderRadius: tokens_1.radii.md,
|
|
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) => {
|
|
465
|
+
const isSelected = option.value === selected;
|
|
466
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: option.label, accessibilityState: { selected: isSelected }, onPress: () => {
|
|
467
|
+
setValue(option.value);
|
|
468
|
+
setQuery("");
|
|
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}`));
|
|
470
|
+
})) })) : null] }));
|
|
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.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Message = exports.MessageAttachment = exports.MessageBubble = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Display_1 = require("./Display");
|
|
7
|
+
const Glass_1 = require("./Glass");
|
|
8
|
+
const tokens_1 = require("./internal/tokens");
|
|
9
|
+
const primitives_1 = require("./internal/primitives");
|
|
10
|
+
const motion_1 = require("./internal/motion");
|
|
11
|
+
/**
|
|
12
|
+
* One message's bubble.
|
|
13
|
+
*
|
|
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.
|
|
19
|
+
*/
|
|
20
|
+
exports.MessageBubble = (0, react_1.forwardRef)(function MessageBubble({ outgoing = false, children, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
21
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
22
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
23
|
+
const { View } = (0, primitives_1.primitives)();
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, testID: testID, surface: "panel", isDark: isDark, tintColor: outgoing ? theme.glassActive : undefined, style: {
|
|
25
|
+
alignSelf: outgoing ? "flex-end" : "flex-start",
|
|
26
|
+
maxWidth: "82%",
|
|
27
|
+
paddingHorizontal: 14,
|
|
28
|
+
paddingVertical: 10,
|
|
29
|
+
borderRadius: tokens_1.radii.lg,
|
|
30
|
+
...style,
|
|
31
|
+
}, ...props, children: children }));
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* A file chip for a message.
|
|
35
|
+
*
|
|
36
|
+
* A flat, bordered chip rather than a glass one, for the same reason the
|
|
37
|
+
* bubbles are flat: it sits inside a bubble or beside one, and glass inside
|
|
38
|
+
* glass is never allowed. The size is a caller-formatted string — byte
|
|
39
|
+
* formatting belongs to the app's locale, not to a component library.
|
|
40
|
+
*/
|
|
41
|
+
exports.MessageAttachment = (0, react_1.forwardRef)(function MessageAttachment({ name, size, icon, onPress, disabled = false, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
42
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
43
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
44
|
+
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
45
|
+
const body = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { marginRight: 8 }, children: icon }) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flexShrink: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { numberOfLines: 1, style: { fontSize: 14, color: theme.foreground }, children: name }), size ? ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: size })) : null] })] }));
|
|
46
|
+
const chipStyle = {
|
|
47
|
+
flexDirection: "row",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
paddingHorizontal: 12,
|
|
50
|
+
paddingVertical: 8,
|
|
51
|
+
borderRadius: tokens_1.radii.md,
|
|
52
|
+
backgroundColor: theme.wash,
|
|
53
|
+
borderWidth: 0.5,
|
|
54
|
+
borderColor: theme.separator,
|
|
55
|
+
opacity: disabled ? 0.38 : 1,
|
|
56
|
+
...style,
|
|
57
|
+
};
|
|
58
|
+
if (!onPress) {
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: size ? `${name}, ${size}` : name, style: chipStyle, ...props, children: body }));
|
|
60
|
+
}
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: size ? `${name}, ${size}` : name, accessibilityState: { disabled }, disabled: disabled, onPress: onPress, style: chipStyle, ...props, children: body }));
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* A whole message: who sent it, when, and what they said.
|
|
65
|
+
*
|
|
66
|
+
* The row every chat screen builds by hand — an avatar, a name and time line,
|
|
67
|
+
* and the content under it. Grouping it means the alignment, spacing and
|
|
68
|
+
* accessibility grouping are decided once: the row is announced as a single
|
|
69
|
+
* message (name, time, content) rather than as three unrelated pieces of text.
|
|
70
|
+
*/
|
|
71
|
+
exports.Message = (0, react_1.forwardRef)(function Message({ name, time, avatar = false, outgoing = false, children, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
72
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
73
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
74
|
+
const { View, Text } = (0, primitives_1.primitives)();
|
|
75
|
+
const meta = [name, time].filter(Boolean).join(", ");
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: meta || undefined, style: {
|
|
77
|
+
flexDirection: outgoing ? "row-reverse" : "row",
|
|
78
|
+
alignItems: "flex-end",
|
|
79
|
+
gap: 8,
|
|
80
|
+
paddingHorizontal: 4,
|
|
81
|
+
paddingVertical: 4,
|
|
82
|
+
...style,
|
|
83
|
+
}, ...props, children: [avatar ? ((0, jsx_runtime_1.jsx)(Display_1.Avatar, { name: name ?? "", size: "sm", isDark: isDark })) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flexShrink: 1, alignItems: outgoing ? "flex-end" : "flex-start", gap: 2 }, children: [name || time ? ((0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "center", gap: 6 }, children: [name ? ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "600", color: theme.foreground }, children: name })) : null, time ? (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: time }) : null] })) : null, children] })] }));
|
|
84
|
+
});
|