@expressive-ui/native 0.0.0-stage → 0.1.1

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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/dist/Button.d.ts +48 -0
  4. package/dist/Button.d.ts.map +1 -0
  5. package/dist/Button.js +122 -0
  6. package/dist/Button.js.map +1 -0
  7. package/dist/Carousel.d.ts +13 -0
  8. package/dist/Carousel.d.ts.map +1 -0
  9. package/dist/Carousel.js +52 -0
  10. package/dist/Carousel.js.map +1 -0
  11. package/dist/Chips.d.ts +35 -0
  12. package/dist/Chips.d.ts.map +1 -0
  13. package/dist/Chips.js +138 -0
  14. package/dist/Chips.js.map +1 -0
  15. package/dist/Dialogs.d.ts +42 -0
  16. package/dist/Dialogs.d.ts.map +1 -0
  17. package/dist/Dialogs.js +115 -0
  18. package/dist/Dialogs.js.map +1 -0
  19. package/dist/ExpressiveCard.d.ts +20 -0
  20. package/dist/ExpressiveCard.d.ts.map +1 -0
  21. package/dist/ExpressiveCard.js +71 -0
  22. package/dist/ExpressiveCard.js.map +1 -0
  23. package/dist/Fab.d.ts +16 -0
  24. package/dist/Fab.d.ts.map +1 -0
  25. package/dist/Fab.js +104 -0
  26. package/dist/Fab.js.map +1 -0
  27. package/dist/Fields.d.ts +90 -0
  28. package/dist/Fields.d.ts.map +1 -0
  29. package/dist/Fields.js +211 -0
  30. package/dist/Fields.js.map +1 -0
  31. package/dist/Grid.d.ts +8 -0
  32. package/dist/Grid.d.ts.map +1 -0
  33. package/dist/Grid.js +16 -0
  34. package/dist/Grid.js.map +1 -0
  35. package/dist/Inputs.d.ts +33 -0
  36. package/dist/Inputs.d.ts.map +1 -0
  37. package/dist/Inputs.js +172 -0
  38. package/dist/Inputs.js.map +1 -0
  39. package/dist/List.d.ts +20 -0
  40. package/dist/List.d.ts.map +1 -0
  41. package/dist/List.js +222 -0
  42. package/dist/List.js.map +1 -0
  43. package/dist/Menu.d.ts +26 -0
  44. package/dist/Menu.d.ts.map +1 -0
  45. package/dist/Menu.js +117 -0
  46. package/dist/Menu.js.map +1 -0
  47. package/dist/Navigation.d.ts +34 -0
  48. package/dist/Navigation.d.ts.map +1 -0
  49. package/dist/Navigation.js +80 -0
  50. package/dist/Navigation.js.map +1 -0
  51. package/dist/Pickers.d.ts +16 -0
  52. package/dist/Pickers.d.ts.map +1 -0
  53. package/dist/Pickers.js +100 -0
  54. package/dist/Pickers.js.map +1 -0
  55. package/dist/Progress.d.ts +20 -0
  56. package/dist/Progress.d.ts.map +1 -0
  57. package/dist/Progress.js +93 -0
  58. package/dist/Progress.js.map +1 -0
  59. package/dist/Search.d.ts +50 -0
  60. package/dist/Search.d.ts.map +1 -0
  61. package/dist/Search.js +121 -0
  62. package/dist/Search.js.map +1 -0
  63. package/dist/Sheets.d.ts +44 -0
  64. package/dist/Sheets.d.ts.map +1 -0
  65. package/dist/Sheets.js +128 -0
  66. package/dist/Sheets.js.map +1 -0
  67. package/dist/Toolbar.d.ts +13 -0
  68. package/dist/Toolbar.d.ts.map +1 -0
  69. package/dist/Toolbar.js +38 -0
  70. package/dist/Toolbar.js.map +1 -0
  71. package/dist/Transition.d.ts +34 -0
  72. package/dist/Transition.d.ts.map +1 -0
  73. package/dist/Transition.js +93 -0
  74. package/dist/Transition.js.map +1 -0
  75. package/dist/index.d.ts +21 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +21 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/primitives.d.ts +41 -0
  80. package/dist/primitives.d.ts.map +1 -0
  81. package/dist/primitives.js +55 -0
  82. package/dist/primitives.js.map +1 -0
  83. package/dist/theme.d.ts +57 -0
  84. package/dist/theme.d.ts.map +1 -0
  85. package/dist/theme.js +89 -0
  86. package/dist/theme.js.map +1 -0
  87. package/package.json +53 -4
  88. package/src/Button.tsx +347 -0
  89. package/src/Carousel.tsx +108 -0
  90. package/src/Chips.tsx +292 -0
  91. package/src/Dialogs.tsx +252 -0
  92. package/src/ExpressiveCard.tsx +205 -0
  93. package/src/Fab.tsx +187 -0
  94. package/src/Fields.tsx +556 -0
  95. package/src/Grid.tsx +29 -0
  96. package/src/Inputs.tsx +290 -0
  97. package/src/List.tsx +295 -0
  98. package/src/Menu.tsx +238 -0
  99. package/src/Navigation.tsx +198 -0
  100. package/src/Pickers.tsx +151 -0
  101. package/src/Progress.tsx +192 -0
  102. package/src/Search.tsx +351 -0
  103. package/src/Sheets.tsx +273 -0
  104. package/src/Toolbar.tsx +88 -0
  105. package/src/Transition.tsx +155 -0
  106. package/src/index.ts +20 -0
  107. package/src/primitives.tsx +110 -0
  108. package/src/theme.tsx +125 -0
package/src/Chips.tsx ADDED
@@ -0,0 +1,292 @@
1
+ import { useRef, useState, type ReactNode } from 'react';
2
+ import { Animated, Pressable, ScrollView, StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { CHIP_GROUP_DEFAULTS, type ChipData, type ChipGroupData } from '@expressive-ui/schema';
4
+ import { resolveBadge, resolveChip, resolveTabs, useInteraction, type BadgeTone, type ChipSpec, type RuntimeProps, type TabItem, type TabsVariant } from '@expressive-ui/core';
5
+ import { elevation, tokens } from '@expressive-ui/tokens';
6
+ import { Icon, T, withAlpha } from './primitives.js';
7
+ import { useExpressiveTheme, useSpringValue } from './theme.js';
8
+
9
+ // --- Badge ----------------------------------------------------------------------------------
10
+
11
+ export type BadgeProps = {
12
+ value?: number | string | true;
13
+ tone?: BadgeTone;
14
+ max?: number;
15
+ /** Elemento ancorado: o badge vai no canto superior direito. */
16
+ children?: ReactNode;
17
+ style?: StyleProp<ViewStyle>;
18
+ };
19
+
20
+ export function Badge({ value, tone = 'error', max, children, style }: BadgeProps) {
21
+ const { colors } = useExpressiveTheme();
22
+ const spec = resolveBadge({ value, tone, max });
23
+ const badge = spec ? (
24
+ <View
25
+ accessibilityLabel={spec.accessibilityLabel}
26
+ style={[
27
+ {
28
+ minWidth: spec.minWidth,
29
+ height: spec.size,
30
+ paddingHorizontal: spec.paddingX,
31
+ borderRadius: spec.size / 2,
32
+ backgroundColor: colors[spec.container],
33
+ alignItems: 'center',
34
+ justifyContent: 'center',
35
+ },
36
+ children ? (spec.text === null ? styles.dotAnchored : styles.badgeAnchored) : style,
37
+ ]}
38
+ >
39
+ {spec.text ? (
40
+ <T variant="labelSmall" emphasized color={spec.content} style={styles.badgeText}>
41
+ {spec.text}
42
+ </T>
43
+ ) : null}
44
+ </View>
45
+ ) : null;
46
+ if (!children) return badge;
47
+ return (
48
+ <View style={[styles.anchor, style]}>
49
+ {children}
50
+ {badge}
51
+ </View>
52
+ );
53
+ }
54
+
55
+ // --- Chip -----------------------------------------------------------------------------------
56
+
57
+ export type ChipProps = ChipData &
58
+ RuntimeProps & {
59
+ onPress?: () => void;
60
+ onRemove?: () => void;
61
+ style?: StyleProp<ViewStyle>;
62
+ };
63
+
64
+ function ChipLeading({ spec, tint }: { spec: ChipSpec; tint: string }) {
65
+ const { colors } = useExpressiveTheme();
66
+ const lead = spec.leading;
67
+ if (!lead) return null;
68
+ if (lead.kind === 'check') return <Icon name="check" size={spec.iconSize} tint={tint} />;
69
+ if (lead.kind === 'icon') return <Icon name={lead.name} size={spec.iconSize} tint={tint} filled={spec.kind === 'status'} />;
70
+ if (lead.kind === 'dot') return <View style={[styles.dot, { backgroundColor: colors[lead.color] }]} />;
71
+ return (
72
+ <View style={[styles.avatar, { backgroundColor: colors[lead.container] }]}>
73
+ <T variant="labelSmall" emphasized color={lead.content}>
74
+ {lead.initial}
75
+ </T>
76
+ </View>
77
+ );
78
+ }
79
+
80
+ /** Chip do M3 nas 5 variações; o filtro selecionado anima os cantos até a pílula (Chip do mobile-app-rhosse). */
81
+ export function Chip({ onPress, onRemove, onAction, index: _, children: __, style, ...data }: ChipProps) {
82
+ const { colors, mode } = useExpressiveTheme();
83
+ const spec = resolveChip(data);
84
+ const { state, handlers } = useInteraction(!spec.interactive);
85
+ const press = onPress ?? (data.action && onAction ? () => onAction(data.action!) : undefined);
86
+ const remove = onRemove ?? (data.removeAction && onAction ? () => onAction(data.removeAction!) : undefined);
87
+ const radius = useSpringValue(spec.selected ? spec.radius.selected : state.pressed ? spec.radius.pressed : spec.radius.rest, 'spatialDefault');
88
+ const layer = useSpringValue(state.pressed ? tokens.state.pressed : state.hovered ? tokens.state.hover : 0, 'effectsDefault');
89
+ const fg = withAlpha(colors[spec.content], spec.contentOpacity);
90
+ const iconTint = withAlpha(colors[spec.icon], spec.contentOpacity);
91
+
92
+ const body = (
93
+ <Animated.View
94
+ style={[
95
+ styles.chip,
96
+ {
97
+ height: spec.height,
98
+ paddingLeft: spec.paddingStart,
99
+ paddingRight: spec.paddingEnd,
100
+ gap: spec.gap,
101
+ borderRadius: radius,
102
+ borderWidth: spec.border ? 1 : 0,
103
+ borderColor: spec.border ? withAlpha(colors[spec.border], spec.containerOpacity) : undefined,
104
+ backgroundColor: spec.container ? withAlpha(colors[spec.container], spec.containerOpacity) : 'transparent',
105
+ boxShadow: elevation(mode, state.hovered ? spec.elevation.hover : spec.elevation.rest),
106
+ },
107
+ style,
108
+ ]}
109
+ >
110
+ {spec.interactive ? <Animated.View pointerEvents="none" style={[StyleSheet.absoluteFill, { backgroundColor: colors[spec.content], opacity: layer }]} /> : null}
111
+ <ChipLeading spec={spec} tint={iconTint} />
112
+ <T variant={spec.type} emphasized numberOfLines={1} style={{ color: fg }}>
113
+ {data.label}
114
+ </T>
115
+ {spec.count ? (
116
+ <View style={[styles.count, { backgroundColor: spec.selected ? fg : colors.surfaceContainerHighest }]}>
117
+ <T variant="labelSmall" emphasized style={{ color: spec.selected ? colors[spec.container ?? 'surface'] : colors.onSurfaceVariant }}>
118
+ {spec.count}
119
+ </T>
120
+ </View>
121
+ ) : null}
122
+ {spec.trailing === 'dropdown' ? <Icon name="arrow_drop_down" size={spec.iconSize} tint={iconTint} /> : null}
123
+ {spec.trailing === 'remove' ? (
124
+ <Pressable accessibilityRole="button" accessibilityLabel={data.removeAction?.label ?? `Remover ${data.label}`} disabled={spec.disabled} onPress={remove} hitSlop={12}>
125
+ <Icon name="close" size={spec.iconSize} tint={iconTint} />
126
+ </Pressable>
127
+ ) : null}
128
+ </Animated.View>
129
+ );
130
+
131
+ if (spec.kind === 'status') {
132
+ return (
133
+ <View accessible accessibilityLabel={spec.accessibilityLabel}>
134
+ {body}
135
+ </View>
136
+ );
137
+ }
138
+ return (
139
+ <Pressable
140
+ accessibilityRole="button"
141
+ accessibilityLabel={spec.accessibilityLabel}
142
+ accessibilityState={{ disabled: spec.disabled, selected: spec.kind === 'filter' || spec.kind === 'input' ? spec.selected : undefined }}
143
+ disabled={spec.disabled}
144
+ onPress={press}
145
+ hitSlop={{ top: (48 - spec.height) / 2, bottom: (48 - spec.height) / 2 }}
146
+ {...handlers}
147
+ >
148
+ {body}
149
+ </Pressable>
150
+ );
151
+ }
152
+
153
+ export type ChipGroupProps = ChipGroupData & RuntimeProps & { style?: StyleProp<ViewStyle> };
154
+
155
+ export function ChipGroup({ overflow = CHIP_GROUP_DEFAULTS.overflow, label, style, children }: ChipGroupProps) {
156
+ if (overflow === 'scroll') {
157
+ return (
158
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} accessibilityLabel={label} contentContainerStyle={styles.groupScroll} style={style}>
159
+ {children}
160
+ </ScrollView>
161
+ );
162
+ }
163
+ return (
164
+ <View accessibilityLabel={label} style={[styles.groupWrap, style]}>
165
+ {children}
166
+ </View>
167
+ );
168
+ }
169
+
170
+ // --- Tabs -----------------------------------------------------------------------------------
171
+
172
+ export type TabsProps<K extends string> = {
173
+ items: readonly TabItem<K>[];
174
+ value: K;
175
+ onChange?: (key: K) => void;
176
+ variant?: TabsVariant;
177
+ layout?: 'fixed' | 'scrollable';
178
+ style?: StyleProp<ViewStyle>;
179
+ };
180
+
181
+ /** PrimaryTabs do mobile-app-rhosse + abas secundárias; o indicador desliza com a mola spatial. */
182
+ export function Tabs<K extends string>({ items, value, onChange, variant = 'primary', layout = 'fixed', style }: TabsProps<K>) {
183
+ const { colors } = useExpressiveTheme();
184
+ const spec = resolveTabs(variant);
185
+ const withIcons = variant === 'primary' && items.some((item) => item.icon);
186
+ const height = withIcons ? spec.heightWithIcon : spec.height;
187
+ // Posição de cada aba e do seu conteúdo, para o indicador.
188
+ const frames = useRef<Record<string, { x: number; width: number; contentX: number; contentWidth: number }>>({});
189
+ const [, force] = useState(0);
190
+ const frame = frames.current[value];
191
+ const left = useSpringValue(frame ? (spec.indicatorFullWidth ? frame.x : frame.x + frame.contentX) : 0, 'spatialDefault');
192
+ const width = useSpringValue(frame ? (spec.indicatorFullWidth ? frame.width : frame.contentWidth) : 0, 'spatialDefault');
193
+
194
+ const tabs = items.map((item) => {
195
+ const active = item.key === value;
196
+ const color = colors[active ? spec.active : spec.inactive];
197
+ return (
198
+ <Pressable
199
+ key={item.key}
200
+ accessibilityRole="tab"
201
+ accessibilityLabel={item.label}
202
+ accessibilityState={{ selected: active, disabled: item.disabled }}
203
+ disabled={item.disabled}
204
+ onPress={() => onChange?.(item.key)}
205
+ onLayout={(e) => {
206
+ const { x, width: w } = e.nativeEvent.layout;
207
+ frames.current[item.key] = { ...(frames.current[item.key] ?? { contentX: 0, contentWidth: w }), x, width: w };
208
+ force((n) => n + 1);
209
+ }}
210
+ style={({ pressed }) => [
211
+ styles.tab,
212
+ { height, paddingHorizontal: spec.paddingX, opacity: item.disabled ? tokens.state.disabledContent : 1 },
213
+ layout === 'fixed' ? { flex: 1 } : { minWidth: spec.scrollableMinWidth },
214
+ pressed && { backgroundColor: withAlpha(color, tokens.state.pressed) },
215
+ ]}
216
+ >
217
+ <View
218
+ onLayout={(e) => {
219
+ const { x, width: w } = e.nativeEvent.layout;
220
+ frames.current[item.key] = { ...(frames.current[item.key] ?? { x: 0, width: w }), contentX: x, contentWidth: Math.max(24, w) };
221
+ force((n) => n + 1);
222
+ }}
223
+ style={[styles.tabContent, withIcons && item.icon ? styles.tabContentColumn : null]}
224
+ >
225
+ {item.icon ? (
226
+ <Badge value={item.badge}>
227
+ <Icon name={item.icon} tint={color} filled={active} />
228
+ </Badge>
229
+ ) : null}
230
+ <View style={styles.tabLabel}>
231
+ <T variant={spec.type} emphasized numberOfLines={1} style={{ color }}>
232
+ {item.label}
233
+ </T>
234
+ {!item.icon && item.badge !== undefined ? <Badge value={item.badge} /> : null}
235
+ </View>
236
+ </View>
237
+ </Pressable>
238
+ );
239
+ });
240
+
241
+ const indicator = frame ? (
242
+ <Animated.View
243
+ pointerEvents="none"
244
+ style={{
245
+ position: 'absolute',
246
+ bottom: 0,
247
+ left,
248
+ width,
249
+ height: spec.indicatorThickness,
250
+ borderTopLeftRadius: spec.indicatorRadius,
251
+ borderTopRightRadius: spec.indicatorRadius,
252
+ backgroundColor: colors[spec.indicator],
253
+ }}
254
+ />
255
+ ) : null;
256
+
257
+ const row = (
258
+ <View accessibilityRole="tablist" style={[styles.row, layout === 'fixed' && { flex: 1 }]}>
259
+ {tabs}
260
+ {indicator}
261
+ </View>
262
+ );
263
+ return (
264
+ <View style={[{ borderBottomWidth: 1, borderBottomColor: colors[spec.divider] }, style]}>
265
+ {layout === 'scrollable' ? (
266
+ <ScrollView horizontal showsHorizontalScrollIndicator={false}>
267
+ {row}
268
+ </ScrollView>
269
+ ) : (
270
+ row
271
+ )}
272
+ </View>
273
+ );
274
+ }
275
+
276
+ const styles = StyleSheet.create({
277
+ anchor: { alignSelf: 'flex-start' },
278
+ badgeAnchored: { position: 'absolute', top: -4, right: -8 },
279
+ dotAnchored: { position: 'absolute', top: 0, right: 0 },
280
+ badgeText: { fontSize: 11, lineHeight: 14 },
281
+ chip: { flexDirection: 'row', alignItems: 'center', overflow: 'hidden', alignSelf: 'flex-start' },
282
+ dot: { width: 8, height: 8, borderRadius: 4 },
283
+ avatar: { width: 24, height: 24, borderRadius: 12, alignItems: 'center', justifyContent: 'center' },
284
+ count: { minWidth: 18, height: 18, borderRadius: 9, paddingHorizontal: 5, alignItems: 'center', justifyContent: 'center' },
285
+ groupWrap: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
286
+ groupScroll: { gap: 8, paddingHorizontal: 2 },
287
+ row: { flexDirection: 'row' },
288
+ tab: { alignItems: 'center', justifyContent: 'center' },
289
+ tabContent: { flexDirection: 'row', alignItems: 'center', gap: 8 },
290
+ tabContentColumn: { flexDirection: 'column', gap: 2 },
291
+ tabLabel: { flexDirection: 'row', alignItems: 'center', gap: 6 },
292
+ });
@@ -0,0 +1,252 @@
1
+ import { useEffect, useState, type ReactNode } from 'react';
2
+ import { Alert, Animated, Modal, Pressable, ScrollView, StyleSheet, useWindowDimensions, View, type AlertButton, type AlertOptions, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { orderDialogActions, resolveDialog, resolveFullScreenDialog, type DialogAction } from '@expressive-ui/core';
4
+ import { tokens } from '@expressive-ui/tokens';
5
+ import { Button } from './Button.js';
6
+ import { Icon, T, withAlpha } from './primitives.js';
7
+ import { useExpressiveTheme, usePresence } from './theme.js';
8
+
9
+ export type { DialogAction };
10
+
11
+ function DialogButtons({ actions, onClose }: { actions: readonly DialogAction[]; onClose?: () => void }) {
12
+ return (
13
+ <View style={styles.actions}>
14
+ {orderDialogActions(actions).map((action) => (
15
+ <Button
16
+ key={action.label}
17
+ action={{ id: action.label, label: action.label }}
18
+ variant={action.variant ?? 'text'}
19
+ destructive={action.tone === 'danger'}
20
+ disabled={action.disabled}
21
+ onPress={() => (action.onPress ? action.onPress() : action.tone === 'cancel' ? onClose?.() : undefined)}
22
+ />
23
+ ))}
24
+ </View>
25
+ );
26
+ }
27
+
28
+ // --- Dialog básico --------------------------------------------------------------------------
29
+
30
+ export type DialogProps = {
31
+ open: boolean;
32
+ onClose?: () => void;
33
+ /** false: só as ações fecham (botão voltar do Android e scrim não fecham). */
34
+ dismissible?: boolean;
35
+ icon?: string;
36
+ headline?: string;
37
+ supportingText?: string;
38
+ children?: ReactNode;
39
+ dividers?: boolean;
40
+ actions?: readonly DialogAction[];
41
+ style?: StyleProp<ViewStyle>;
42
+ };
43
+
44
+ /** Dialog básico do M3, a partir do Dialog do mobile-app-rhosse: cantos de 28, ícone, ações de texto à direita. */
45
+ export function Dialog({ open, onClose, dismissible = true, icon, headline, supportingText, children, dividers = false, actions = [], style }: DialogProps) {
46
+ const { labels } = useExpressiveTheme();
47
+ const { colors, mode } = useExpressiveTheme();
48
+ const { height } = useWindowDimensions();
49
+ const spec = resolveDialog();
50
+ const { progress, opacity, mounted } = usePresence(open);
51
+ const dismiss = dismissible ? onClose : undefined;
52
+ if (!mounted) return null;
53
+ return (
54
+ <Modal visible transparent animationType="none" onRequestClose={dismiss ?? (() => {})} statusBarTranslucent>
55
+ <View style={styles.center}>
56
+ <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: withAlpha(colors[spec.scrim.color], spec.scrim.opacity), opacity }]}>
57
+ <Pressable accessibilityRole={dismiss ? 'button' : undefined} accessibilityLabel={dismiss ? labels.close : undefined} style={StyleSheet.absoluteFill} onPress={dismiss} />
58
+ </Animated.View>
59
+ <Animated.View
60
+ accessibilityViewIsModal
61
+ accessibilityRole={dismissible ? undefined : 'alert'}
62
+ style={[
63
+ {
64
+ width: '100%',
65
+ maxWidth: spec.maxWidth,
66
+ maxHeight: height * spec.maxHeight,
67
+ padding: spec.padding,
68
+ gap: spec.gap,
69
+ borderRadius: spec.radius,
70
+ backgroundColor: colors[spec.container],
71
+ boxShadow: tokens.elevation[mode][spec.elevation],
72
+ opacity,
73
+ transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.85, 1] }) }],
74
+ },
75
+ style,
76
+ ]}
77
+ >
78
+ {icon ? (
79
+ <View style={{ alignItems: 'center' }}>
80
+ <Icon name={icon} size={spec.icon.size} color={spec.icon.color} />
81
+ </View>
82
+ ) : null}
83
+ {headline ? (
84
+ <T variant={spec.headline.type} color={spec.headline.color} accessibilityRole="header" style={{ textAlign: icon ? 'center' : 'left' }}>
85
+ {headline}
86
+ </T>
87
+ ) : null}
88
+ {supportingText ? (
89
+ <T variant={spec.supporting.type} color={spec.supporting.color}>
90
+ {supportingText}
91
+ </T>
92
+ ) : null}
93
+ {children ? (
94
+ <ScrollView
95
+ style={[styles.content, dividers && { borderTopWidth: 1, borderBottomWidth: 1, borderColor: colors[spec.divider] }]}
96
+ contentContainerStyle={dividers ? { paddingVertical: 8 } : undefined}
97
+ >
98
+ {children}
99
+ </ScrollView>
100
+ ) : null}
101
+ {actions.length ? <DialogButtons actions={actions} onClose={onClose} /> : null}
102
+ </Animated.View>
103
+ </View>
104
+ </Modal>
105
+ );
106
+ }
107
+
108
+ // --- Full-screen dialog ---------------------------------------------------------------------
109
+
110
+ export type FullScreenDialogProps = {
111
+ open: boolean;
112
+ onClose: () => void;
113
+ title: string;
114
+ action?: { label: string; onPress: () => void; disabled?: boolean };
115
+ divider?: boolean;
116
+ /** Área segura superior (ex.: useSafeAreaInsets().top). */
117
+ topInset?: number;
118
+ children?: ReactNode;
119
+ style?: StyleProp<ViewStyle>;
120
+ };
121
+
122
+ /** Tela cheia em janelas compactas; a partir de 600dp vira dialog centralizado (tablets). */
123
+ export function FullScreenDialog({ open, onClose, title, action, divider = false, topInset = 0, children, style }: FullScreenDialogProps) {
124
+ const { labels } = useExpressiveTheme();
125
+ const { colors, mode } = useExpressiveTheme();
126
+ const { width, height } = useWindowDimensions();
127
+ const spec = resolveFullScreenDialog();
128
+ const { progress, opacity, mounted } = usePresence(open);
129
+ if (!mounted) return null;
130
+ const docked = width >= spec.breakpoint;
131
+
132
+ const header = (
133
+ <View style={[styles.fsHeader, { minHeight: spec.headerHeight, paddingTop: docked ? 12 : topInset + 8 }, divider && { borderBottomWidth: 1, borderBottomColor: colors[spec.divider] }]}>
134
+ <Pressable
135
+ accessibilityRole="button"
136
+ accessibilityLabel={labels.close}
137
+ onPress={onClose}
138
+ style={({ pressed }) => [styles.close, pressed && { backgroundColor: withAlpha(colors.onSurfaceVariant, tokens.state.pressed) }]}
139
+ >
140
+ <Icon name="close" color="onSurfaceVariant" />
141
+ </Pressable>
142
+ <T variant={spec.title} accessibilityRole="header" numberOfLines={1} style={styles.fsTitle}>
143
+ {title}
144
+ </T>
145
+ {action ? <Button action={{ id: action.label, label: action.label }} variant="text" disabled={action.disabled} onPress={action.onPress} /> : null}
146
+ </View>
147
+ );
148
+ const body = <ScrollView contentContainerStyle={styles.fsContent}>{children}</ScrollView>;
149
+
150
+ if (docked) {
151
+ const dialog = spec.dialog;
152
+ return (
153
+ <Modal visible transparent animationType="none" onRequestClose={onClose} statusBarTranslucent>
154
+ <View style={styles.center}>
155
+ <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: withAlpha(colors[dialog.scrim.color], dialog.scrim.opacity), opacity }]}>
156
+ <Pressable accessibilityRole="button" accessibilityLabel={labels.close} style={StyleSheet.absoluteFill} onPress={onClose} />
157
+ </Animated.View>
158
+ <Animated.View
159
+ accessibilityViewIsModal
160
+ style={[
161
+ {
162
+ width: '100%',
163
+ maxWidth: dialog.maxWidth,
164
+ maxHeight: height * dialog.maxHeight,
165
+ borderRadius: dialog.radius,
166
+ overflow: 'hidden',
167
+ backgroundColor: colors[dialog.container],
168
+ boxShadow: tokens.elevation[mode][dialog.elevation],
169
+ opacity,
170
+ transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.85, 1] }) }],
171
+ },
172
+ style,
173
+ ]}
174
+ >
175
+ {header}
176
+ {body}
177
+ </Animated.View>
178
+ </View>
179
+ </Modal>
180
+ );
181
+ }
182
+ return (
183
+ <Modal visible transparent animationType="none" onRequestClose={onClose} statusBarTranslucent>
184
+ <Animated.View
185
+ accessibilityViewIsModal
186
+ style={[
187
+ styles.fill,
188
+ {
189
+ backgroundColor: colors[spec.container],
190
+ opacity,
191
+ transform: [{ translateY: progress.interpolate({ inputRange: [0, 1], outputRange: [32, 0] }) }],
192
+ },
193
+ style,
194
+ ]}
195
+ >
196
+ {header}
197
+ {body}
198
+ </Animated.View>
199
+ </Modal>
200
+ );
201
+ }
202
+
203
+ // --- Alert.alert expressivo -----------------------------------------------------------------
204
+
205
+ /**
206
+ * Troca o Alert.alert nativo pelo Dialog enquanto montado (ExpressiveAlertHost do mobile-app-rhosse).
207
+ * Monte uma vez perto da raiz, dentro do ExpressiveThemeProvider.
208
+ */
209
+ export function ExpressiveAlertHost() {
210
+ const [current, setCurrent] = useState<{ title: string; message?: string; buttons: AlertButton[]; options?: AlertOptions } | null>(null);
211
+ useEffect(() => {
212
+ const nativeAlert = Alert.alert;
213
+ Alert.alert = (title, message, buttons, options) => setCurrent({ title, message, buttons: buttons?.length ? buttons : [{ text: 'OK' }], options });
214
+ return () => {
215
+ Alert.alert = nativeAlert;
216
+ };
217
+ }, []);
218
+ const close = (button?: AlertButton) => {
219
+ setCurrent(null);
220
+ button?.onPress?.();
221
+ };
222
+ const destructive = current?.buttons.some((button) => button.style === 'destructive') ?? false;
223
+ return (
224
+ <Dialog
225
+ open={current !== null}
226
+ icon={destructive ? 'warning' : undefined}
227
+ headline={current?.title}
228
+ supportingText={current?.message}
229
+ dismissible={current?.options?.cancelable !== false}
230
+ onClose={() => {
231
+ setCurrent(null);
232
+ current?.options?.onDismiss?.();
233
+ }}
234
+ actions={(current?.buttons ?? []).map((button) => ({
235
+ label: button.text ?? 'OK',
236
+ tone: button.style === 'destructive' ? 'danger' : button.style === 'cancel' ? 'cancel' : 'default',
237
+ onPress: () => close(button),
238
+ }))}
239
+ />
240
+ );
241
+ }
242
+
243
+ const styles = StyleSheet.create({
244
+ fill: { flex: 1 },
245
+ center: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 24 },
246
+ content: { flexGrow: 0 },
247
+ actions: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8, marginTop: 8 },
248
+ fsHeader: { flexDirection: 'row', alignItems: 'center', gap: 4, paddingLeft: 4, paddingRight: 12, paddingBottom: 8 },
249
+ close: { width: 48, height: 48, borderRadius: 24, alignItems: 'center', justifyContent: 'center' },
250
+ fsTitle: { flex: 1, marginLeft: 4 },
251
+ fsContent: { paddingHorizontal: 24, paddingTop: 16, paddingBottom: 24 },
252
+ });