@expressive-ui/native 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +11 -1
  2. package/dist/Feedback.d.ts +3 -3
  3. package/dist/Feedback.d.ts.map +1 -1
  4. package/dist/Feedback.js +73 -14
  5. package/dist/Feedback.js.map +1 -1
  6. package/dist/Fields.d.ts +10 -6
  7. package/dist/Fields.d.ts.map +1 -1
  8. package/dist/Fields.js +125 -29
  9. package/dist/Fields.js.map +1 -1
  10. package/dist/FileUpload.d.ts.map +1 -1
  11. package/dist/FileUpload.js +61 -19
  12. package/dist/FileUpload.js.map +1 -1
  13. package/dist/NumberField.d.ts +6 -2
  14. package/dist/NumberField.d.ts.map +1 -1
  15. package/dist/NumberField.js +71 -11
  16. package/dist/NumberField.js.map +1 -1
  17. package/dist/OtpField.d.ts +34 -0
  18. package/dist/OtpField.d.ts.map +1 -0
  19. package/dist/OtpField.js +156 -0
  20. package/dist/OtpField.js.map +1 -0
  21. package/dist/Pickers.d.ts.map +1 -1
  22. package/dist/Pickers.js +227 -36
  23. package/dist/Pickers.js.map +1 -1
  24. package/dist/RenderUI.d.ts +3 -0
  25. package/dist/RenderUI.d.ts.map +1 -0
  26. package/dist/RenderUI.js +45 -0
  27. package/dist/RenderUI.js.map +1 -0
  28. package/dist/Search.js +1 -1
  29. package/dist/Search.js.map +1 -1
  30. package/dist/Select.d.ts +5 -1
  31. package/dist/Select.d.ts.map +1 -1
  32. package/dist/Select.js +52 -10
  33. package/dist/Select.js.map +1 -1
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +2 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/theme.d.ts +3 -1
  39. package/dist/theme.d.ts.map +1 -1
  40. package/dist/theme.js +36 -11
  41. package/dist/theme.js.map +1 -1
  42. package/package.json +4 -4
  43. package/src/Feedback.tsx +211 -16
  44. package/src/Fields.tsx +341 -58
  45. package/src/FileUpload.tsx +169 -7
  46. package/src/NumberField.tsx +187 -9
  47. package/src/OtpField.tsx +353 -0
  48. package/src/Pickers.tsx +783 -86
  49. package/src/RenderUI.tsx +47 -0
  50. package/src/Search.tsx +1 -1
  51. package/src/Select.tsx +209 -27
  52. package/src/index.ts +3 -0
  53. package/src/theme.tsx +77 -14
package/src/Fields.tsx CHANGED
@@ -1,5 +1,14 @@
1
- import { useEffect, useRef, useState, type ReactNode } from 'react';
2
- import { Animated, Pressable, StyleSheet, TextInput, View, type KeyboardTypeOptions, type StyleProp, type ViewStyle } from 'react-native';
1
+ import { useEffect, useRef, useState, type Ref, type ReactNode } from 'react';
2
+ import {
3
+ Animated,
4
+ Pressable,
5
+ StyleSheet,
6
+ TextInput,
7
+ View,
8
+ type KeyboardTypeOptions,
9
+ type StyleProp,
10
+ type ViewStyle,
11
+ } from 'react-native';
3
12
  import Svg, { Path } from 'react-native-svg';
4
13
  import {
5
14
  CHECK_PATH,
@@ -23,6 +32,12 @@ import { useExpressiveTheme, useSpringValue } from './theme.js';
23
32
  // --- TextField ------------------------------------------------------------------------------
24
33
 
25
34
  export type TextFieldProps = {
35
+ id?: string;
36
+ ref?: Ref<TextInput>;
37
+ inputProps?: Omit<
38
+ React.ComponentProps<typeof TextInput>,
39
+ 'value' | 'defaultValue' | 'onChangeText' | 'ref'
40
+ >;
26
41
  label: string;
27
42
  value?: string;
28
43
  defaultValue?: string;
@@ -42,6 +57,7 @@ export type TextFieldProps = {
42
57
  maxLength?: number;
43
58
  required?: boolean;
44
59
  disabled?: boolean;
60
+ readOnly?: boolean;
45
61
  multiline?: boolean;
46
62
  keyboardType?: KeyboardTypeOptions;
47
63
  autoComplete?: React.ComponentProps<typeof TextInput>['autoComplete'];
@@ -50,6 +66,9 @@ export type TextFieldProps = {
50
66
 
51
67
  /** Text field do M3 (filled = TextField do RM/Elo; outlined com a label sobre o contorno). */
52
68
  export function TextField({
69
+ id,
70
+ ref,
71
+ inputProps,
53
72
  label,
54
73
  value,
55
74
  defaultValue,
@@ -69,6 +88,7 @@ export function TextField({
69
88
  maxLength,
70
89
  required,
71
90
  disabled = false,
91
+ readOnly,
72
92
  multiline = false,
73
93
  keyboardType,
74
94
  autoComplete,
@@ -79,7 +99,7 @@ export function TextField({
79
99
  const spec = resolveField(variant);
80
100
  const [inner, setInner] = useState(defaultValue ?? '');
81
101
  const text = value ?? inner;
82
- const field = useField({ value: text, error, supportingText, maxLength, required, label });
102
+ const field = useField({ value: text, error, supportingText, maxLength, required, label, id });
83
103
  const [focused, setFocused] = useState(false);
84
104
  const [hidden, setHidden] = useState(true);
85
105
  const floating = focused || field.filled || Boolean(prefix || suffix);
@@ -87,7 +107,8 @@ export function TextField({
87
107
  const focus = useSpringValue(focused || field.invalid ? 1 : 0, 'spatialDefault');
88
108
  const outlined = variant === 'outlined';
89
109
  const accent = field.invalid ? spec.indicator.error : focused ? spec.indicator.focus : null;
90
- const labelColor = colors[field.invalid ? spec.label.error : focused ? spec.label.focus : spec.label.color];
110
+ const labelColor =
111
+ colors[field.invalid ? spec.label.error : focused ? spec.label.focus : spec.label.color];
91
112
  const set = (next: string) => {
92
113
  if (value === undefined) setInner(next);
93
114
  onChange?.(next);
@@ -97,21 +118,43 @@ export function TextField({
97
118
  const small = typeStyle(spec.label.floating);
98
119
  const leadOffset = leadingIcon ? 36 : 0;
99
120
  // Label: centro do campo → topo (filled) ou sobre o contorno (outlined, alinhada ao ícone).
100
- const labelTop = float.interpolate({ inputRange: [0, 1], outputRange: [(spec.height - (rest.lineHeight ?? 24)) / 2, outlined ? -(small.lineHeight ?? 16) / 2 : 8] });
101
- const labelScale = float.interpolate({ inputRange: [0, 1], outputRange: [1, (small.fontSize ?? 12) / (rest.fontSize ?? 16)] });
102
- const labelShift = float.interpolate({ inputRange: [0, 1], outputRange: [0, outlined ? -leadOffset : 0] });
121
+ const labelTop = float.interpolate({
122
+ inputRange: [0, 1],
123
+ outputRange: [
124
+ (spec.height - (rest.lineHeight ?? 24)) / 2,
125
+ outlined ? -(small.lineHeight ?? 16) / 2 : 8,
126
+ ],
127
+ });
128
+ const labelScale = float.interpolate({
129
+ inputRange: [0, 1],
130
+ outputRange: [1, (small.fontSize ?? 12) / (rest.fontSize ?? 16)],
131
+ });
132
+ const labelShift = float.interpolate({
133
+ inputRange: [0, 1],
134
+ outputRange: [0, outlined ? -leadOffset : 0],
135
+ });
103
136
 
104
137
  let trail: ReactNode = null;
105
138
  if (field.invalid) trail = <Icon name="error" color="error" filled />;
106
139
  else if (password)
107
140
  trail = (
108
- <Pressable accessibilityRole="button" accessibilityLabel={hidden ? labels.showPassword : labels.hidePassword} onPress={() => setHidden(!hidden)} style={styles.action}>
141
+ <Pressable
142
+ accessibilityRole="button"
143
+ accessibilityLabel={hidden ? labels.showPassword : labels.hidePassword}
144
+ onPress={() => setHidden(!hidden)}
145
+ style={styles.action}
146
+ >
109
147
  <Icon name={hidden ? 'visibility' : 'visibility_off'} color={spec.icon.color} />
110
148
  </Pressable>
111
149
  );
112
- else if (clearable && text)
150
+ else if (clearable && text && !disabled && !readOnly)
113
151
  trail = (
114
- <Pressable accessibilityRole="button" accessibilityLabel={`Limpar ${label}`} onPress={() => set('')} style={styles.action}>
152
+ <Pressable
153
+ accessibilityRole="button"
154
+ accessibilityLabel={labels.clearField(label)}
155
+ onPress={() => set('')}
156
+ style={styles.action}
157
+ >
115
158
  <Icon name="cancel" color={spec.icon.color} />
116
159
  </Pressable>
117
160
  );
@@ -137,10 +180,19 @@ export function TextField({
137
180
  },
138
181
  ]}
139
182
  >
140
- {leadingIcon ? <Icon name={leadingIcon} color={field.invalid ? spec.icon.error : spec.icon.color} /> : null}
183
+ {leadingIcon ? (
184
+ <Icon name={leadingIcon} color={field.invalid ? spec.icon.error : spec.icon.color} />
185
+ ) : null}
141
186
  <View style={styles.control}>
142
- {prefix && floating ? <T variant="bodyLarge" color={spec.supporting.color} style={styles.affix}>{prefix}</T> : null}
187
+ {prefix && floating ? (
188
+ <T variant="bodyLarge" color={spec.supporting.color} style={styles.affix}>
189
+ {prefix}
190
+ </T>
191
+ ) : null}
143
192
  <TextInput
193
+ {...inputProps}
194
+ ref={ref}
195
+ nativeID={field.ids.input}
144
196
  accessibilityLabel={field.labelText}
145
197
  accessibilityHint={field.help ?? undefined}
146
198
  value={text}
@@ -149,23 +201,37 @@ export function TextField({
149
201
  placeholder={focused ? placeholder : undefined}
150
202
  placeholderTextColor={colors[spec.input.placeholder]}
151
203
  secureTextEntry={password && hidden}
152
- editable={!disabled}
204
+ editable={!disabled && !readOnly && inputProps?.editable !== false}
153
205
  maxLength={maxLength}
154
206
  multiline={multiline}
155
207
  keyboardType={keyboardType}
156
208
  autoComplete={autoComplete}
157
209
  keyboardAppearance={mode}
158
210
  selectionColor={colors[spec.indicator.focus]}
159
- onFocus={() => setFocused(true)}
160
- onBlur={() => setFocused(false)}
211
+ onFocus={(event) => {
212
+ setFocused(true);
213
+ inputProps?.onFocus?.(event);
214
+ }}
215
+ onBlur={(event) => {
216
+ setFocused(false);
217
+ inputProps?.onBlur?.(event);
218
+ }}
161
219
  style={[
162
220
  typeStyle(spec.input.type),
163
221
  styles.input,
164
- { color: colors[spec.input.color], paddingTop: outlined ? 16 : 24, paddingBottom: outlined ? 16 : 8 },
222
+ {
223
+ color: colors[spec.input.color],
224
+ paddingTop: outlined ? 16 : 24,
225
+ paddingBottom: outlined ? 16 : 8,
226
+ },
165
227
  multiline && { minHeight: 96, textAlignVertical: 'top' },
166
228
  ]}
167
229
  />
168
- {suffix && floating ? <T variant="bodyLarge" color={spec.supporting.color} style={styles.affix}>{suffix}</T> : null}
230
+ {suffix && floating ? (
231
+ <T variant="bodyLarge" color={spec.supporting.color} style={styles.affix}>
232
+ {suffix}
233
+ </T>
234
+ ) : null}
169
235
  <Animated.Text
170
236
  pointerEvents="none"
171
237
  numberOfLines={1}
@@ -178,7 +244,12 @@ export function TextField({
178
244
  transform: [{ translateX: labelShift }, { scale: labelScale }],
179
245
  transformOrigin: 'left top',
180
246
  },
181
- outlined && floating && { backgroundColor: colors.surface, paddingHorizontal: 4, marginLeft: -4 },
247
+ outlined &&
248
+ floating && {
249
+ backgroundColor: colors.surface,
250
+ paddingHorizontal: 4,
251
+ marginLeft: -4,
252
+ },
182
253
  ]}
183
254
  >
184
255
  {field.labelText}
@@ -187,21 +258,41 @@ export function TextField({
187
258
  {trail ? <View style={styles.trail}>{trail}</View> : null}
188
259
  {!outlined ? (
189
260
  <>
190
- <View pointerEvents="none" style={[styles.line, { height: 1, backgroundColor: colors[spec.indicator.rest] }]} />
261
+ <View
262
+ pointerEvents="none"
263
+ style={[styles.line, { height: 1, backgroundColor: colors[spec.indicator.rest] }]}
264
+ />
191
265
  <Animated.View
192
266
  pointerEvents="none"
193
- style={[styles.line, { height: 2, backgroundColor: colors[field.invalid ? spec.indicator.error : spec.indicator.focus], transform: [{ scaleX: focus }] }]}
267
+ style={[
268
+ styles.line,
269
+ {
270
+ height: 2,
271
+ backgroundColor:
272
+ colors[field.invalid ? spec.indicator.error : spec.indicator.focus],
273
+ transform: [{ scaleX: focus }],
274
+ },
275
+ ]}
194
276
  />
195
277
  </>
196
278
  ) : null}
197
279
  </View>
198
280
  {field.help || field.counter ? (
199
281
  <View style={styles.support}>
200
- <T variant={spec.supporting.type} color={field.invalid ? spec.supporting.error : spec.supporting.color} accessibilityLiveRegion={field.invalid ? 'polite' : undefined} style={{ flex: 1 }}>
282
+ <T
283
+ variant={spec.supporting.type}
284
+ color={field.invalid ? spec.supporting.error : spec.supporting.color}
285
+ accessibilityLiveRegion={field.invalid ? 'polite' : undefined}
286
+ style={{ flex: 1 }}
287
+ >
201
288
  {field.help ?? ''}
202
289
  </T>
203
290
  {field.counter ? (
204
- <T variant={spec.supporting.type} color={spec.supporting.color} style={{ fontVariant: ['tabular-nums'] }}>
291
+ <T
292
+ variant={spec.supporting.type}
293
+ color={spec.supporting.color}
294
+ style={{ fontVariant: ['tabular-nums'] }}
295
+ >
205
296
  {field.counter}
206
297
  </T>
207
298
  ) : null}
@@ -213,7 +304,14 @@ export function TextField({
213
304
 
214
305
  // --- Radio e Checkbox -----------------------------------------------------------------------
215
306
 
216
- export type RadioProps = { checked?: boolean; onChange?: (checked: boolean) => void; label?: string; disabled?: boolean; invalid?: boolean; style?: StyleProp<ViewStyle> };
307
+ export type RadioProps = {
308
+ checked?: boolean;
309
+ onChange?: (checked: boolean) => void;
310
+ label?: string;
311
+ disabled?: boolean;
312
+ invalid?: boolean;
313
+ style?: StyleProp<ViewStyle>;
314
+ };
217
315
 
218
316
  /** Radio do M3; o ponto entra com a mola spatial. */
219
317
  export function Radio({ checked = false, onChange, label, disabled, invalid, style }: RadioProps) {
@@ -230,22 +328,59 @@ export function Radio({ checked = false, onChange, label, disabled, invalid, sty
230
328
  onPress={() => onChange?.(true)}
231
329
  style={({ pressed }) => [
232
330
  styles.control40,
233
- { width: spec.stateLayer, height: spec.stateLayer, borderRadius: spec.stateLayer / 2, opacity: disabled ? spec.disabledOpacity : 1 },
331
+ {
332
+ width: spec.stateLayer,
333
+ height: spec.stateLayer,
334
+ borderRadius: spec.stateLayer / 2,
335
+ opacity: disabled ? spec.disabledOpacity : 1,
336
+ },
234
337
  pressed && { backgroundColor: withAlpha(color, tokens.state.pressed) },
235
338
  style,
236
339
  ]}
237
340
  >
238
- <View style={{ width: spec.size, height: spec.size, borderRadius: spec.size / 2, borderWidth: spec.border, borderColor: color, alignItems: 'center', justifyContent: 'center' }}>
239
- <Animated.View style={{ width: spec.dot, height: spec.dot, borderRadius: spec.dot / 2, backgroundColor: color, transform: [{ scale: dot }] }} />
341
+ <View
342
+ style={{
343
+ width: spec.size,
344
+ height: spec.size,
345
+ borderRadius: spec.size / 2,
346
+ borderWidth: spec.border,
347
+ borderColor: color,
348
+ alignItems: 'center',
349
+ justifyContent: 'center',
350
+ }}
351
+ >
352
+ <Animated.View
353
+ style={{
354
+ width: spec.dot,
355
+ height: spec.dot,
356
+ borderRadius: spec.dot / 2,
357
+ backgroundColor: color,
358
+ transform: [{ scale: dot }],
359
+ }}
360
+ />
240
361
  </View>
241
362
  </Pressable>
242
363
  );
243
364
  }
244
365
 
245
- export type CheckboxProps = { checked?: boolean | 'mixed'; onChange?: (checked: boolean) => void; label?: string; disabled?: boolean; invalid?: boolean; style?: StyleProp<ViewStyle> };
366
+ export type CheckboxProps = {
367
+ checked?: boolean | 'mixed';
368
+ onChange?: (checked: boolean) => void;
369
+ label?: string;
370
+ disabled?: boolean;
371
+ invalid?: boolean;
372
+ style?: StyleProp<ViewStyle>;
373
+ };
246
374
 
247
375
  /** Checkbox do M3: caixa de 18px que preenche com ✓ ou − (indeterminado). */
248
- export function Checkbox({ checked = false, onChange, label, disabled, invalid, style }: CheckboxProps) {
376
+ export function Checkbox({
377
+ checked = false,
378
+ onChange,
379
+ label,
380
+ disabled,
381
+ invalid,
382
+ style,
383
+ }: CheckboxProps) {
249
384
  const { colors } = useExpressiveTheme();
250
385
  const spec = resolveCheckbox();
251
386
  const on = checked !== false;
@@ -260,16 +395,43 @@ export function Checkbox({ checked = false, onChange, label, disabled, invalid,
260
395
  onPress={() => onChange?.(checked !== true)}
261
396
  style={({ pressed }) => [
262
397
  styles.control40,
263
- { width: spec.stateLayer, height: spec.stateLayer, borderRadius: spec.stateLayer / 2, opacity: disabled ? spec.disabledOpacity : 1 },
398
+ {
399
+ width: spec.stateLayer,
400
+ height: spec.stateLayer,
401
+ borderRadius: spec.stateLayer / 2,
402
+ opacity: disabled ? spec.disabledOpacity : 1,
403
+ },
264
404
  pressed && { backgroundColor: withAlpha(color, tokens.state.pressed) },
265
405
  style,
266
406
  ]}
267
407
  >
268
- <View style={{ width: spec.size, height: spec.size, borderRadius: spec.radius, borderWidth: spec.border, borderColor: color, overflow: 'hidden' }}>
269
- <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: color, opacity: fill }]} />
408
+ <View
409
+ style={{
410
+ width: spec.size,
411
+ height: spec.size,
412
+ borderRadius: spec.radius,
413
+ borderWidth: spec.border,
414
+ borderColor: color,
415
+ overflow: 'hidden',
416
+ }}
417
+ >
418
+ <Animated.View
419
+ style={[StyleSheet.absoluteFill, { backgroundColor: color, opacity: fill }]}
420
+ />
270
421
  {on ? (
271
- <Svg width={spec.size} height={spec.size} viewBox="0 0 18 18" style={{ position: 'absolute', left: -spec.border, top: -spec.border }}>
272
- <Path d={checked === 'mixed' ? MIXED_PATH : CHECK_PATH} stroke={colors[spec.checked.content]} strokeWidth={2} fill="none" strokeLinecap="square" />
422
+ <Svg
423
+ width={spec.size}
424
+ height={spec.size}
425
+ viewBox="0 0 18 18"
426
+ style={{ position: 'absolute', left: -spec.border, top: -spec.border }}
427
+ >
428
+ <Path
429
+ d={checked === 'mixed' ? MIXED_PATH : CHECK_PATH}
430
+ stroke={colors[spec.checked.content]}
431
+ strokeWidth={2}
432
+ fill="none"
433
+ strokeLinecap="square"
434
+ />
273
435
  </Svg>
274
436
  ) : null}
275
437
  </View>
@@ -302,7 +464,12 @@ function OptionRow({
302
464
  const bottom = useSpringValue(segmented && (last || checked) ? 20 : 4, 'spatialDefault');
303
465
  const fg = segmented && checked ? 'onSecondaryContainer' : 'onSurface';
304
466
  return (
305
- <Pressable accessible={false} disabled={option.disabled} onPress={onPress} style={variant === 'inline' ? undefined : { alignSelf: 'stretch' }}>
467
+ <Pressable
468
+ accessible={false}
469
+ disabled={option.disabled}
470
+ onPress={onPress}
471
+ style={variant === 'inline' ? undefined : { alignSelf: 'stretch' }}
472
+ >
306
473
  <Animated.View
307
474
  style={[
308
475
  styles.option,
@@ -336,15 +503,37 @@ function OptionRow({
336
503
  );
337
504
  }
338
505
 
339
- function GroupFrame({ label, variant, help, invalid, children }: { label: string; variant: RadioGroupVariant; help?: string; invalid: boolean; children: ReactNode }) {
506
+ function GroupFrame({
507
+ label,
508
+ variant,
509
+ help,
510
+ invalid,
511
+ children,
512
+ }: {
513
+ label: string;
514
+ variant: RadioGroupVariant;
515
+ help?: string;
516
+ invalid: boolean;
517
+ children: ReactNode;
518
+ }) {
340
519
  return (
341
520
  <View>
342
521
  <T variant="titleSmall" accessibilityRole="header" style={{ marginBottom: 8 }}>
343
522
  {label}
344
523
  </T>
345
- <View style={variant === 'inline' ? styles.inline : variant === 'segmented' ? { gap: 2 } : undefined}>{children}</View>
524
+ <View
525
+ style={
526
+ variant === 'inline' ? styles.inline : variant === 'segmented' ? { gap: 2 } : undefined
527
+ }
528
+ >
529
+ {children}
530
+ </View>
346
531
  {help ? (
347
- <T variant="bodySmall" color={invalid ? 'error' : 'onSurfaceVariant'} style={{ marginTop: 4 }}>
532
+ <T
533
+ variant="bodySmall"
534
+ color={invalid ? 'error' : 'onSurfaceVariant'}
535
+ style={{ marginTop: 4 }}
536
+ >
348
537
  {help}
349
538
  </T>
350
539
  ) : null}
@@ -363,11 +552,25 @@ export type RadioGroupProps<V extends string> = {
363
552
  style?: StyleProp<ViewStyle>;
364
553
  };
365
554
 
366
- export function RadioGroup<V extends string>({ options, value, onChange, label, variant = 'list', supportingText, error, style }: RadioGroupProps<V>) {
555
+ export function RadioGroup<V extends string>({
556
+ options,
557
+ value,
558
+ onChange,
559
+ label,
560
+ variant = 'list',
561
+ supportingText,
562
+ error,
563
+ style,
564
+ }: RadioGroupProps<V>) {
367
565
  const invalid = Boolean(error);
368
566
  return (
369
567
  <View accessibilityRole="radiogroup" accessibilityLabel={label} style={style}>
370
- <GroupFrame label={label} variant={variant} help={typeof error === 'string' ? error : supportingText} invalid={invalid}>
568
+ <GroupFrame
569
+ label={label}
570
+ variant={variant}
571
+ help={typeof error === 'string' ? error : supportingText}
572
+ invalid={invalid}
573
+ >
371
574
  {options.map((option, i) => (
372
575
  <OptionRow
373
576
  key={option.value}
@@ -377,7 +580,15 @@ export function RadioGroup<V extends string>({ options, value, onChange, label,
377
580
  first={i === 0}
378
581
  last={i === options.length - 1}
379
582
  onPress={() => onChange?.(option.value)}
380
- control={<Radio checked={option.value === value} label={option.label} disabled={option.disabled} invalid={invalid} onChange={() => onChange?.(option.value)} />}
583
+ control={
584
+ <Radio
585
+ checked={option.value === value}
586
+ label={option.label}
587
+ disabled={option.disabled}
588
+ invalid={invalid}
589
+ onChange={() => onChange?.(option.value)}
590
+ />
591
+ }
381
592
  />
382
593
  ))}
383
594
  </GroupFrame>
@@ -397,15 +608,36 @@ export type CheckboxGroupProps<V extends string> = {
397
608
  style?: StyleProp<ViewStyle>;
398
609
  };
399
610
 
400
- export function CheckboxGroup<V extends string>({ options, value, onChange, label, variant = 'list', selectAll, supportingText, error, style }: CheckboxGroupProps<V>) {
611
+ export function CheckboxGroup<V extends string>({
612
+ options,
613
+ value,
614
+ onChange,
615
+ label,
616
+ variant = 'list',
617
+ selectAll,
618
+ supportingText,
619
+ error,
620
+ style,
621
+ }: CheckboxGroupProps<V>) {
401
622
  const invalid = Boolean(error);
402
623
  const enabled = options.filter((option) => !option.disabled).map((option) => option.value);
403
624
  const parent = parentCheckState(enabled.filter((v) => value.includes(v)).length, enabled.length);
404
- const toggle = (option: V) => onChange?.(value.includes(option) ? value.filter((v) => v !== option) : [...value, option]);
405
- const toggleAll = () => onChange?.(parent === true ? value.filter((v) => !enabled.includes(v)) : [...new Set([...value, ...enabled])]);
625
+ const toggle = (option: V) =>
626
+ onChange?.(value.includes(option) ? value.filter((v) => v !== option) : [...value, option]);
627
+ const toggleAll = () =>
628
+ onChange?.(
629
+ parent === true
630
+ ? value.filter((v) => !enabled.includes(v))
631
+ : [...new Set([...value, ...enabled])],
632
+ );
406
633
  return (
407
634
  <View accessibilityLabel={label} style={style}>
408
- <GroupFrame label={label} variant={variant} help={typeof error === 'string' ? error : supportingText} invalid={invalid}>
635
+ <GroupFrame
636
+ label={label}
637
+ variant={variant}
638
+ help={typeof error === 'string' ? error : supportingText}
639
+ invalid={invalid}
640
+ >
409
641
  {selectAll ? (
410
642
  <OptionRow
411
643
  option={{ value: '__all', label: selectAll }}
@@ -414,11 +646,16 @@ export function CheckboxGroup<V extends string>({ options, value, onChange, labe
414
646
  first
415
647
  last={false}
416
648
  onPress={toggleAll}
417
- control={<Checkbox checked={parent} label={selectAll} invalid={invalid} onChange={toggleAll} />}
649
+ control={
650
+ <Checkbox checked={parent} label={selectAll} invalid={invalid} onChange={toggleAll} />
651
+ }
418
652
  />
419
653
  ) : null}
420
654
  {options.map((option, i) => (
421
- <View key={option.value} style={variant === 'list' && selectAll ? { paddingLeft: 32 } : undefined}>
655
+ <View
656
+ key={option.value}
657
+ style={variant === 'list' && selectAll ? { paddingLeft: 32 } : undefined}
658
+ >
422
659
  <OptionRow
423
660
  option={option}
424
661
  checked={value.includes(option.value)}
@@ -426,7 +663,15 @@ export function CheckboxGroup<V extends string>({ options, value, onChange, labe
426
663
  first={!selectAll && i === 0}
427
664
  last={i === options.length - 1}
428
665
  onPress={() => toggle(option.value)}
429
- control={<Checkbox checked={value.includes(option.value)} label={option.label} disabled={option.disabled} invalid={invalid} onChange={() => toggle(option.value)} />}
666
+ control={
667
+ <Checkbox
668
+ checked={value.includes(option.value)}
669
+ label={option.label}
670
+ disabled={option.disabled}
671
+ invalid={invalid}
672
+ onChange={() => toggle(option.value)}
673
+ />
674
+ }
430
675
  />
431
676
  </View>
432
677
  ))}
@@ -450,7 +695,16 @@ export type TooltipProps = {
450
695
  };
451
696
 
452
697
  /** Tooltip do M3 no celular: toque longo no gatilho mostra; o plain some após ~1,5 s. */
453
- export function Tooltip({ text, title, actions, placement = 'top', open: controlled, onOpenChange, children, style }: TooltipProps) {
698
+ export function Tooltip({
699
+ text,
700
+ title,
701
+ actions,
702
+ placement = 'top',
703
+ open: controlled,
704
+ onOpenChange,
705
+ children,
706
+ style,
707
+ }: TooltipProps) {
454
708
  const { colors, mode } = useExpressiveTheme();
455
709
  const spec = resolveTooltip();
456
710
  const rich = Boolean(title || actions?.length);
@@ -467,12 +721,16 @@ export function Tooltip({ text, title, actions, placement = 'top', open: control
467
721
  const clear = () => timer.current && clearTimeout(timer.current);
468
722
  const position: ViewStyle =
469
723
  placement === 'top'
470
- ? { bottom: '100%', marginBottom: spec.offset, ...(rich ? { left: 0 } : { alignSelf: 'center' }) }
724
+ ? {
725
+ bottom: '100%',
726
+ marginBottom: spec.offset,
727
+ ...(rich ? { left: 0 } : { alignSelf: 'center' }),
728
+ }
471
729
  : placement === 'bottom'
472
- ? { top: '100%', marginTop: spec.offset, ...(rich ? { left: 0 } : { alignSelf: 'center' }) }
473
- : placement === 'start'
474
- ? { right: '100%', marginRight: spec.offset, alignSelf: 'center' }
475
- : { left: '100%', marginLeft: spec.offset, alignSelf: 'center' };
730
+ ? { top: '100%', marginTop: spec.offset, ...(rich ? { left: 0 } : { alignSelf: 'center' }) }
731
+ : placement === 'start'
732
+ ? { right: '100%', marginRight: spec.offset, alignSelf: 'center' }
733
+ : { left: '100%', marginLeft: spec.offset, alignSelf: 'center' };
476
734
  const p = rich ? spec.rich : spec.plain;
477
735
  return (
478
736
  <View
@@ -499,11 +757,24 @@ export function Tooltip({ text, title, actions, placement = 'top', open: control
499
757
  backgroundColor: colors[p.container],
500
758
  borderRadius: p.radius,
501
759
  opacity: shown,
502
- transform: [{ scale: shown.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1] }) }],
760
+ transform: [
761
+ { scale: shown.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1] }) },
762
+ ],
503
763
  },
504
764
  rich
505
- ? { padding: spec.rich.padding, paddingBottom: actions?.length ? 8 : spec.rich.padding, gap: 4, boxShadow: tokens.elevation[mode][2], width: p.maxWidth }
506
- : { minHeight: spec.plain.minHeight, paddingHorizontal: spec.plain.paddingX, paddingVertical: 4, justifyContent: 'center' },
765
+ ? {
766
+ padding: spec.rich.padding,
767
+ paddingBottom: actions?.length ? 8 : spec.rich.padding,
768
+ gap: 4,
769
+ boxShadow: tokens.elevation[mode][2],
770
+ width: p.maxWidth,
771
+ }
772
+ : {
773
+ minHeight: spec.plain.minHeight,
774
+ paddingHorizontal: spec.plain.paddingX,
775
+ paddingVertical: 4,
776
+ justifyContent: 'center',
777
+ },
507
778
  ]}
508
779
  >
509
780
  {title ? (
@@ -538,12 +809,24 @@ export function Tooltip({ text, title, actions, placement = 'top', open: control
538
809
 
539
810
  const styles = StyleSheet.create({
540
811
  box: { flexDirection: 'row', alignItems: 'center', gap: 12 },
541
- control: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', alignSelf: 'stretch' },
812
+ control: {
813
+ flex: 1,
814
+ minWidth: 0,
815
+ flexDirection: 'row',
816
+ alignItems: 'center',
817
+ alignSelf: 'stretch',
818
+ },
542
819
  input: { flex: 1, paddingHorizontal: 0 },
543
820
  affix: { paddingTop: 16 },
544
821
  label: { position: 'absolute', left: 0 },
545
822
  trail: { flexDirection: 'row', alignItems: 'center' },
546
- action: { width: 48, height: 48, borderRadius: 24, alignItems: 'center', justifyContent: 'center' },
823
+ action: {
824
+ width: 48,
825
+ height: 48,
826
+ borderRadius: 24,
827
+ alignItems: 'center',
828
+ justifyContent: 'center',
829
+ },
547
830
  line: { position: 'absolute', left: 0, right: 0, bottom: 0 },
548
831
  support: { flexDirection: 'row', gap: 16, paddingHorizontal: 16, paddingTop: 4 },
549
832
  control40: { alignItems: 'center', justifyContent: 'center' },