@expressive-ui/native 0.2.0 → 0.3.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.
- package/README.md +10 -0
- package/dist/Feedback.d.ts +3 -3
- package/dist/Feedback.d.ts.map +1 -1
- package/dist/Feedback.js +73 -14
- package/dist/Feedback.js.map +1 -1
- package/dist/Fields.d.ts +10 -6
- package/dist/Fields.d.ts.map +1 -1
- package/dist/Fields.js +125 -29
- package/dist/Fields.js.map +1 -1
- package/dist/FileUpload.d.ts.map +1 -1
- package/dist/FileUpload.js +61 -19
- package/dist/FileUpload.js.map +1 -1
- package/dist/NumberField.d.ts +6 -2
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/NumberField.js +71 -11
- package/dist/NumberField.js.map +1 -1
- package/dist/Pickers.d.ts.map +1 -1
- package/dist/Pickers.js +227 -36
- package/dist/Pickers.js.map +1 -1
- package/dist/RenderUI.d.ts +3 -0
- package/dist/RenderUI.d.ts.map +1 -0
- package/dist/RenderUI.js +45 -0
- package/dist/RenderUI.js.map +1 -0
- package/dist/Search.js +1 -1
- package/dist/Search.js.map +1 -1
- package/dist/Select.d.ts +5 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +52 -10
- package/dist/Select.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/theme.d.ts +3 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +36 -11
- package/dist/theme.js.map +1 -1
- package/package.json +4 -4
- package/src/Feedback.tsx +211 -16
- package/src/Fields.tsx +341 -58
- package/src/FileUpload.tsx +169 -7
- package/src/NumberField.tsx +187 -9
- package/src/Pickers.tsx +783 -86
- package/src/RenderUI.tsx +47 -0
- package/src/Search.tsx +1 -1
- package/src/Select.tsx +209 -27
- package/src/index.ts +2 -0
- package/src/theme.tsx +77 -14
package/README.md
CHANGED
|
@@ -49,3 +49,13 @@ MIT
|
|
|
49
49
|
Select, Autocomplete/Combobox, NumberField, Skeleton, Alert/InlineMessage, FileUpload e EmptyState estão disponíveis em Web e React Native. DataTable está disponível inicialmente na Web. A seleção rolável de Menu continua compatível; Select fornece o contrato de campo de formulário. FileUpload recebe adaptadores de envio e, no Native, de escolha de arquivos.
|
|
50
50
|
|
|
51
51
|
Veja os contratos, exemplos e diferenças de plataforma em [docs/10-formularios-dados-feedback.md](../../docs/10-formularios-dados-feedback.md).
|
|
52
|
+
|
|
53
|
+
## Integração e Prompt-to-UI
|
|
54
|
+
|
|
55
|
+
`RenderUI` valida árvores antes de renderizar. `onAction` recebe ações declarativas e `onValueChange` recebe o valor e a identificação do campo. A árvore aceita campos, mensagens e diálogos; DataTable é exclusiva da Web. [Contratos e exemplos](../../docs/12-robustez-integracao.md).
|
|
56
|
+
|
|
57
|
+
`labels` do provider permite traduzir Select, Autocomplete, NumberField, upload, mensagens da tabela e rótulos dos pickers (`pickerLabels`). `dir="rtl"` configura a direção do escopo; no Native, a opção cria um View raiz com `flex: 1` e direção explícita. Sem `dir`, a plataforma determina a direção.
|
|
58
|
+
|
|
59
|
+
Autocomplete remoto só carrega enquanto aberto. Use `preload` para antecipar a busca e memorize `loadOptions` com `useCallback`. Fechar o campo cancela a requisição ativa.
|
|
60
|
+
|
|
61
|
+
TextField e NumberField expõem `ref`/`id` e `inputProps` para o TextInput. Select/Autocomplete expõem `ref`/`id` e `controlProps` para o Pressable. Isso permite foco, blur, testID e atributos de acessibilidade sem substituir o comportamento interno. [Testes no simulador/emulador](../../tests/native/README.md).
|
package/dist/Feedback.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type SkeletonProps = {
|
|
|
10
10
|
label?: string;
|
|
11
11
|
style?: StyleProp<ViewStyle>;
|
|
12
12
|
};
|
|
13
|
-
export declare function Skeleton({ variant, width, height, lines, animation, label, style }: SkeletonProps): import("react").JSX.Element;
|
|
13
|
+
export declare function Skeleton({ variant, width, height, lines, animation, label, style, }: SkeletonProps): import("react").JSX.Element;
|
|
14
14
|
export type AlertProps = {
|
|
15
15
|
severity?: AlertSeverity;
|
|
16
16
|
title?: string;
|
|
@@ -24,7 +24,7 @@ export type AlertProps = {
|
|
|
24
24
|
live?: boolean;
|
|
25
25
|
style?: StyleProp<ViewStyle>;
|
|
26
26
|
};
|
|
27
|
-
export declare function Alert({ severity, title, children, icon, action, onClose, live, style }: AlertProps): import("react").JSX.Element;
|
|
27
|
+
export declare function Alert({ severity, title, children, icon, action, onClose, live, style, }: AlertProps): import("react").JSX.Element;
|
|
28
28
|
export declare const InlineMessage: typeof Alert;
|
|
29
29
|
export type EmptyStateProps = {
|
|
30
30
|
title: string;
|
|
@@ -38,5 +38,5 @@ export type EmptyStateProps = {
|
|
|
38
38
|
children?: ReactNode;
|
|
39
39
|
style?: StyleProp<ViewStyle>;
|
|
40
40
|
};
|
|
41
|
-
export declare function EmptyState({ title, description, icon, illustration, action, children, style }: EmptyStateProps): import("react").JSX.Element;
|
|
41
|
+
export declare function EmptyState({ title, description, icon, illustration, action, children, style, }: EmptyStateProps): import("react").JSX.Element;
|
|
42
42
|
//# sourceMappingURL=Feedback.d.ts.map
|
package/dist/Feedback.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feedback.d.ts","sourceRoot":"","sources":["../src/Feedback.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"Feedback.d.ts","sourceRoot":"","sources":["../src/Feedback.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIrE,MAAM,MAAM,aAA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AAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AACF,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,WAAW,EACX,IAAc,EACd,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,KAAK,GACN,EAAE,eAAe,+BA8BjB"}
|
package/dist/Feedback.js
CHANGED
|
@@ -1,26 +1,85 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { AccessibilityInfo, Animated, Pressable, View } from 'react-native';
|
|
3
|
+
import { AccessibilityInfo, Animated, Pressable, View, } from 'react-native';
|
|
4
4
|
import { alertIcons } from '@expressive-ui/core';
|
|
5
5
|
import { Button } from './Button.js';
|
|
6
6
|
import { Icon, T } from './primitives.js';
|
|
7
7
|
import { useExpressiveTheme } from './theme.js';
|
|
8
|
-
export function Skeleton({ variant = 'text', width = '100%', height, lines = 1, animation = true, label, style }) {
|
|
8
|
+
export function Skeleton({ variant = 'text', width = '100%', height, lines = 1, animation = true, label, style, }) {
|
|
9
9
|
const { colors } = useExpressiveTheme(), opacity = useRef(new Animated.Value(1)).current, [reduced, setReduced] = useState(true);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
let active = true;
|
|
12
|
+
AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
13
|
+
if (active)
|
|
14
|
+
setReduced(value);
|
|
15
|
+
});
|
|
16
|
+
const listener = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduced);
|
|
17
|
+
return () => {
|
|
18
|
+
active = false;
|
|
19
|
+
listener.remove();
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!animation || reduced) {
|
|
24
|
+
opacity.setValue(1);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const loop = Animated.loop(Animated.sequence([
|
|
28
|
+
Animated.timing(opacity, { toValue: 0.45, duration: 750, useNativeDriver: true }),
|
|
29
|
+
Animated.timing(opacity, { toValue: 1, duration: 750, useNativeDriver: true }),
|
|
30
|
+
]));
|
|
31
|
+
loop.start();
|
|
32
|
+
return () => loop.stop();
|
|
33
|
+
}, [animation, reduced, opacity]);
|
|
34
|
+
return (_jsx(View, { accessible: !!label, accessibilityLabel: label, accessibilityLiveRegion: label ? 'polite' : undefined, accessibilityElementsHidden: !label, importantForAccessibility: label ? 'yes' : 'no-hide-descendants', style: [{ width, gap: 10 }, style], children: Array.from({ length: Math.max(1, Math.floor(lines)) }, (_, index) => (_jsx(Animated.View, { style: {
|
|
35
|
+
height: height ?? (variant === 'text' ? 16 : 48),
|
|
36
|
+
width: variant === 'circular'
|
|
37
|
+
? height ?? 48
|
|
38
|
+
: index === Math.floor(lines) - 1 && lines > 1
|
|
39
|
+
? '72%'
|
|
40
|
+
: '100%',
|
|
41
|
+
borderRadius: variant === 'circular' ? 999 : 8,
|
|
42
|
+
backgroundColor: colors.surfaceContainerHighest,
|
|
43
|
+
opacity,
|
|
44
|
+
} }, index))) }));
|
|
17
45
|
}
|
|
18
|
-
export function Alert({ severity = 'info', title, children, icon, action, onClose, live = true, style }) {
|
|
46
|
+
export function Alert({ severity = 'info', title, children, icon, action, onClose, live = true, style, }) {
|
|
19
47
|
const { colors, labels } = useExpressiveTheme();
|
|
20
|
-
const background = severity === 'error'
|
|
21
|
-
|
|
22
|
-
|
|
48
|
+
const background = severity === 'error'
|
|
49
|
+
? colors.errorContainer
|
|
50
|
+
: severity === 'success'
|
|
51
|
+
? colors.tertiaryContainer
|
|
52
|
+
: severity === 'warning'
|
|
53
|
+
? colors.primaryContainer
|
|
54
|
+
: colors.secondaryContainer;
|
|
55
|
+
const content = severity === 'error'
|
|
56
|
+
? 'onErrorContainer'
|
|
57
|
+
: severity === 'success'
|
|
58
|
+
? 'onTertiaryContainer'
|
|
59
|
+
: severity === 'warning'
|
|
60
|
+
? 'onPrimaryContainer'
|
|
61
|
+
: 'onSecondaryContainer';
|
|
62
|
+
return (_jsxs(View, { accessibilityLiveRegion: live ? (severity === 'error' ? 'assertive' : 'polite') : 'none', style: [
|
|
63
|
+
{
|
|
64
|
+
flexDirection: 'row',
|
|
65
|
+
gap: 14,
|
|
66
|
+
padding: 18,
|
|
67
|
+
borderRadius: 16,
|
|
68
|
+
backgroundColor: background,
|
|
69
|
+
},
|
|
70
|
+
style,
|
|
71
|
+
], children: [icon !== false ? _jsx(Icon, { name: icon ?? alertIcons[severity], color: content }) : null, _jsxs(View, { style: { flex: 1, gap: 6 }, children: [title ? (_jsx(T, { variant: "titleSmall", color: content, children: title })) : null, typeof children === 'string' ? _jsx(T, { color: content, children: children }) : children, action ? (_jsx(Button, { variant: "text", action: { id: 'alert.action', label: action.label }, onPress: action.onPress })) : null] }), onClose ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: labels.close, onPress: onClose, style: { minWidth: 40, minHeight: 40, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Icon, { name: "close", color: content }) })) : null] }));
|
|
23
72
|
}
|
|
24
73
|
export const InlineMessage = Alert;
|
|
25
|
-
export function EmptyState({ title, description, icon = 'inbox', illustration, action, children, style
|
|
74
|
+
export function EmptyState({ title, description, icon = 'inbox', illustration, action, children, style, }) {
|
|
75
|
+
const { colors } = useExpressiveTheme();
|
|
76
|
+
return (_jsxs(View, { style: [{ alignItems: 'center', gap: 16, padding: 24 }, style], children: [_jsx(View, { style: {
|
|
77
|
+
width: 96,
|
|
78
|
+
height: 96,
|
|
79
|
+
borderRadius: 32,
|
|
80
|
+
backgroundColor: colors.secondaryContainer,
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
justifyContent: 'center',
|
|
83
|
+
}, children: illustration ?? _jsx(Icon, { name: icon, size: 48, color: "onSecondaryContainer" }) }), _jsx(T, { variant: "titleLarge", accessibilityRole: "header", style: { textAlign: 'center' }, children: title }), description ? (_jsx(T, { color: "onSurfaceVariant", style: { textAlign: 'center' }, children: description })) : null, action ? (_jsx(Button, { action: { id: 'empty.action', label: action.label }, onPress: action.onPress })) : null, children] }));
|
|
84
|
+
}
|
|
26
85
|
//# sourceMappingURL=Feedback.js.map
|
package/dist/Feedback.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feedback.js","sourceRoot":"","sources":["../src/Feedback.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"Feedback.js","sourceRoot":"","sources":["../src/Feedback.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,IAAI,GAIL,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAsB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAUhD,MAAM,UAAU,QAAQ,CAAC,EACvB,OAAO,GAAG,MAAM,EAChB,KAAK,GAAG,MAAM,EACd,MAAM,EACN,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,IAAI,EAChB,KAAK,EACL,KAAK,GACS;IACd,MAAM,EAAE,MAAM,EAAE,GAAG,kBAAkB,EAAE,EACrC,OAAO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U,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,aAClE,KAAC,IAAI,IACH,KAAK,EAAE;oBACL,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,EAAE;oBACV,YAAY,EAAE,EAAE;oBAChB,eAAe,EAAE,MAAM,CAAC,kBAAkB;oBAC1C,UAAU,EAAE,QAAQ;oBACpB,cAAc,EAAE,QAAQ;iBACzB,YAEA,YAAY,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAC,sBAAsB,GAAG,GACvE,EACP,KAAC,CAAC,IAAC,OAAO,EAAC,YAAY,EAAC,iBAAiB,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YAC9E,KAAK,GACJ,EACH,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,CAAC,IAAC,KAAK,EAAC,kBAAkB,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YACvD,WAAW,GACV,CACL,CAAC,CAAC,CAAC,IAAI,EACP,MAAM,CAAC,CAAC,CAAC,CACR,KAAC,MAAM,IAAC,MAAM,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,GAAI,CACzF,CAAC,CAAC,CAAC,IAAI,EACP,QAAQ,IACJ,CACR,CAAC;AACJ,CAAC"}
|
package/dist/Fields.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type Ref, type ReactNode } from 'react';
|
|
2
2
|
import { TextInput, type KeyboardTypeOptions, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
3
|
import { type FieldVariant, type RadioGroupVariant, type RadioOption, type TooltipPlacement } from '@expressive-ui/core';
|
|
4
4
|
export type TextFieldProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
ref?: Ref<TextInput>;
|
|
7
|
+
inputProps?: Omit<React.ComponentProps<typeof TextInput>, 'value' | 'defaultValue' | 'onChangeText' | 'ref'>;
|
|
5
8
|
label: string;
|
|
6
9
|
value?: string;
|
|
7
10
|
defaultValue?: string;
|
|
@@ -21,13 +24,14 @@ export type TextFieldProps = {
|
|
|
21
24
|
maxLength?: number;
|
|
22
25
|
required?: boolean;
|
|
23
26
|
disabled?: boolean;
|
|
27
|
+
readOnly?: boolean;
|
|
24
28
|
multiline?: boolean;
|
|
25
29
|
keyboardType?: KeyboardTypeOptions;
|
|
26
30
|
autoComplete?: React.ComponentProps<typeof TextInput>['autoComplete'];
|
|
27
31
|
style?: StyleProp<ViewStyle>;
|
|
28
32
|
};
|
|
29
33
|
/** Text field do M3 (filled = TextField do RM/Elo; outlined com a label sobre o contorno). */
|
|
30
|
-
export declare function TextField({ label, value, defaultValue, onChange, onSubmit, variant, placeholder, leadingIcon, trailingIcon, trailing, clearable, password, prefix, suffix, supportingText, error, maxLength, required, disabled, multiline, keyboardType, autoComplete, style, }: TextFieldProps): import("react").JSX.Element;
|
|
34
|
+
export declare function TextField({ id, ref, inputProps, label, value, defaultValue, onChange, onSubmit, variant, placeholder, leadingIcon, trailingIcon, trailing, clearable, password, prefix, suffix, supportingText, error, maxLength, required, disabled, readOnly, multiline, keyboardType, autoComplete, style, }: TextFieldProps): import("react").JSX.Element;
|
|
31
35
|
export type RadioProps = {
|
|
32
36
|
checked?: boolean;
|
|
33
37
|
onChange?: (checked: boolean) => void;
|
|
@@ -47,7 +51,7 @@ export type CheckboxProps = {
|
|
|
47
51
|
style?: StyleProp<ViewStyle>;
|
|
48
52
|
};
|
|
49
53
|
/** Checkbox do M3: caixa de 18px que preenche com ✓ ou − (indeterminado). */
|
|
50
|
-
export declare function Checkbox({ checked, onChange, label, disabled, invalid, style }: CheckboxProps): import("react").JSX.Element;
|
|
54
|
+
export declare function Checkbox({ checked, onChange, label, disabled, invalid, style, }: CheckboxProps): import("react").JSX.Element;
|
|
51
55
|
export type RadioGroupProps<V extends string> = {
|
|
52
56
|
options: readonly RadioOption<V>[];
|
|
53
57
|
value: V | null;
|
|
@@ -58,7 +62,7 @@ export type RadioGroupProps<V extends string> = {
|
|
|
58
62
|
error?: string | boolean;
|
|
59
63
|
style?: StyleProp<ViewStyle>;
|
|
60
64
|
};
|
|
61
|
-
export declare function RadioGroup<V extends string>({ options, value, onChange, label, variant, supportingText, error, style }: RadioGroupProps<V>): import("react").JSX.Element;
|
|
65
|
+
export declare function RadioGroup<V extends string>({ options, value, onChange, label, variant, supportingText, error, style, }: RadioGroupProps<V>): import("react").JSX.Element;
|
|
62
66
|
export type CheckboxGroupProps<V extends string> = {
|
|
63
67
|
options: readonly RadioOption<V>[];
|
|
64
68
|
value: readonly V[];
|
|
@@ -70,7 +74,7 @@ export type CheckboxGroupProps<V extends string> = {
|
|
|
70
74
|
error?: string | boolean;
|
|
71
75
|
style?: StyleProp<ViewStyle>;
|
|
72
76
|
};
|
|
73
|
-
export declare function CheckboxGroup<V extends string>({ options, value, onChange, label, variant, selectAll, supportingText, error, style }: CheckboxGroupProps<V>): import("react").JSX.Element;
|
|
77
|
+
export declare function CheckboxGroup<V extends string>({ options, value, onChange, label, variant, selectAll, supportingText, error, style, }: CheckboxGroupProps<V>): import("react").JSX.Element;
|
|
74
78
|
export type TooltipProps = {
|
|
75
79
|
text: string;
|
|
76
80
|
title?: string;
|
|
@@ -86,5 +90,5 @@ export type TooltipProps = {
|
|
|
86
90
|
style?: StyleProp<ViewStyle>;
|
|
87
91
|
};
|
|
88
92
|
/** Tooltip do M3 no celular: toque longo no gatilho mostra; o plain some após ~1,5 s. */
|
|
89
|
-
export declare function Tooltip({ text, title, actions, placement, open: controlled, onOpenChange, children, style }: TooltipProps): import("react").JSX.Element;
|
|
93
|
+
export declare function Tooltip({ text, title, actions, placement, open: controlled, onOpenChange, children, style, }: TooltipProps): import("react").JSX.Element;
|
|
90
94
|
//# sourceMappingURL=Fields.d.ts.map
|
package/dist/Fields.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fields.d.ts","sourceRoot":"","sources":["../src/Fields.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Fields.d.ts","sourceRoot":"","sources":["../src/Fields.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAIL,SAAS,EAET,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EASL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,IAAI,CACf,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,EACtC,OAAO,GAAG,cAAc,GAAG,cAAc,GAAG,KAAK,CAClD,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CA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SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,KAAK,EACL,OAAO,EACP,SAAiB,EACjB,IAAI,EAAE,UAAU,EAChB,YAAY,EACZ,QAAQ,EACR,KAAK,GACN,EAAE,YAAY,+BAqGd"}
|
package/dist/Fields.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { Animated, Pressable, StyleSheet, TextInput, View } from 'react-native';
|
|
3
|
+
import { Animated, Pressable, StyleSheet, TextInput, View, } from 'react-native';
|
|
4
4
|
import Svg, { Path } from 'react-native-svg';
|
|
5
5
|
import { CHECK_PATH, MIXED_PATH, parentCheckState, resolveCheckbox, resolveField, resolveRadio, resolveTooltip, useField, } from '@expressive-ui/core';
|
|
6
6
|
import { tokens } from '@expressive-ui/tokens';
|
|
@@ -8,13 +8,13 @@ import { Button } from './Button.js';
|
|
|
8
8
|
import { Icon, T, typeStyle, withAlpha } from './primitives.js';
|
|
9
9
|
import { useExpressiveTheme, useSpringValue } from './theme.js';
|
|
10
10
|
/** Text field do M3 (filled = TextField do RM/Elo; outlined com a label sobre o contorno). */
|
|
11
|
-
export function TextField({ label, value, defaultValue, onChange, onSubmit, variant = 'filled', placeholder, leadingIcon, trailingIcon, trailing, clearable = false, password = false, prefix, suffix, supportingText, error, maxLength, required, disabled = false, multiline = false, keyboardType, autoComplete, style, }) {
|
|
11
|
+
export function TextField({ id, ref, inputProps, label, value, defaultValue, onChange, onSubmit, variant = 'filled', placeholder, leadingIcon, trailingIcon, trailing, clearable = false, password = false, prefix, suffix, supportingText, error, maxLength, required, disabled = false, readOnly, multiline = false, keyboardType, autoComplete, style, }) {
|
|
12
12
|
const { labels } = useExpressiveTheme();
|
|
13
13
|
const { colors, mode } = useExpressiveTheme();
|
|
14
14
|
const spec = resolveField(variant);
|
|
15
15
|
const [inner, setInner] = useState(defaultValue ?? '');
|
|
16
16
|
const text = value ?? inner;
|
|
17
|
-
const field = useField({ value: text, error, supportingText, maxLength, required, label });
|
|
17
|
+
const field = useField({ value: text, error, supportingText, maxLength, required, label, id });
|
|
18
18
|
const [focused, setFocused] = useState(false);
|
|
19
19
|
const [hidden, setHidden] = useState(true);
|
|
20
20
|
const floating = focused || field.filled || Boolean(prefix || suffix);
|
|
@@ -32,16 +32,28 @@ export function TextField({ label, value, defaultValue, onChange, onSubmit, vari
|
|
|
32
32
|
const small = typeStyle(spec.label.floating);
|
|
33
33
|
const leadOffset = leadingIcon ? 36 : 0;
|
|
34
34
|
// Label: centro do campo → topo (filled) ou sobre o contorno (outlined, alinhada ao ícone).
|
|
35
|
-
const labelTop = float.interpolate({
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const labelTop = float.interpolate({
|
|
36
|
+
inputRange: [0, 1],
|
|
37
|
+
outputRange: [
|
|
38
|
+
(spec.height - (rest.lineHeight ?? 24)) / 2,
|
|
39
|
+
outlined ? -(small.lineHeight ?? 16) / 2 : 8,
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
const labelScale = float.interpolate({
|
|
43
|
+
inputRange: [0, 1],
|
|
44
|
+
outputRange: [1, (small.fontSize ?? 12) / (rest.fontSize ?? 16)],
|
|
45
|
+
});
|
|
46
|
+
const labelShift = float.interpolate({
|
|
47
|
+
inputRange: [0, 1],
|
|
48
|
+
outputRange: [0, outlined ? -leadOffset : 0],
|
|
49
|
+
});
|
|
38
50
|
let trail = null;
|
|
39
51
|
if (field.invalid)
|
|
40
52
|
trail = _jsx(Icon, { name: "error", color: "error", filled: true });
|
|
41
53
|
else if (password)
|
|
42
54
|
trail = (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: hidden ? labels.showPassword : labels.hidePassword, onPress: () => setHidden(!hidden), style: styles.action, children: _jsx(Icon, { name: hidden ? 'visibility' : 'visibility_off', color: spec.icon.color }) }));
|
|
43
|
-
else if (clearable && text)
|
|
44
|
-
trail = (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel:
|
|
55
|
+
else if (clearable && text && !disabled && !readOnly)
|
|
56
|
+
trail = (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: labels.clearField(label), onPress: () => set(''), style: styles.action, children: _jsx(Icon, { name: "cancel", color: spec.icon.color }) }));
|
|
45
57
|
else if (trailing)
|
|
46
58
|
trail = trailing;
|
|
47
59
|
else if (trailingIcon)
|
|
@@ -60,12 +72,22 @@ export function TextField({ label, value, defaultValue, onChange, onSubmit, vari
|
|
|
60
72
|
borderWidth: accent ? spec.indicator.focusWidth : spec.indicator.width,
|
|
61
73
|
borderColor: colors[accent ?? spec.indicator.rest],
|
|
62
74
|
},
|
|
63
|
-
], children: [leadingIcon ? _jsx(Icon, { name: leadingIcon, color: field.invalid ? spec.icon.error : spec.icon.color }) : null, _jsxs(View, { style: styles.control, children: [prefix && floating ? _jsx(T, { variant: "bodyLarge", color: spec.supporting.color, style: styles.affix, children: prefix }) : null, _jsx(TextInput, { accessibilityLabel: field.labelText, accessibilityHint: field.help ?? undefined, value: text, onChangeText: set, onSubmitEditing: () => onSubmit?.(text), placeholder: focused ? placeholder : undefined, placeholderTextColor: colors[spec.input.placeholder], secureTextEntry: password && hidden, editable: !disabled, maxLength: maxLength, multiline: multiline, keyboardType: keyboardType, autoComplete: autoComplete, keyboardAppearance: mode, selectionColor: colors[spec.indicator.focus], onFocus: () =>
|
|
75
|
+
], children: [leadingIcon ? (_jsx(Icon, { name: leadingIcon, color: field.invalid ? spec.icon.error : spec.icon.color })) : null, _jsxs(View, { style: styles.control, children: [prefix && floating ? (_jsx(T, { variant: "bodyLarge", color: spec.supporting.color, style: styles.affix, children: prefix })) : null, _jsx(TextInput, { ...inputProps, ref: ref, nativeID: field.ids.input, accessibilityLabel: field.labelText, accessibilityHint: field.help ?? undefined, value: text, onChangeText: set, onSubmitEditing: () => onSubmit?.(text), placeholder: focused ? placeholder : undefined, placeholderTextColor: colors[spec.input.placeholder], secureTextEntry: password && hidden, editable: !disabled && !readOnly && inputProps?.editable !== false, maxLength: maxLength, multiline: multiline, keyboardType: keyboardType, autoComplete: autoComplete, keyboardAppearance: mode, selectionColor: colors[spec.indicator.focus], onFocus: (event) => {
|
|
76
|
+
setFocused(true);
|
|
77
|
+
inputProps?.onFocus?.(event);
|
|
78
|
+
}, onBlur: (event) => {
|
|
79
|
+
setFocused(false);
|
|
80
|
+
inputProps?.onBlur?.(event);
|
|
81
|
+
}, style: [
|
|
64
82
|
typeStyle(spec.input.type),
|
|
65
83
|
styles.input,
|
|
66
|
-
{
|
|
84
|
+
{
|
|
85
|
+
color: colors[spec.input.color],
|
|
86
|
+
paddingTop: outlined ? 16 : 24,
|
|
87
|
+
paddingBottom: outlined ? 16 : 8,
|
|
88
|
+
},
|
|
67
89
|
multiline && { minHeight: 96, textAlignVertical: 'top' },
|
|
68
|
-
] }), suffix && floating ? _jsx(T, { variant: "bodyLarge", color: spec.supporting.color, style: styles.affix, children: suffix }) : null, _jsx(Animated.Text, { pointerEvents: "none", numberOfLines: 1, style: [
|
|
90
|
+
] }), suffix && floating ? (_jsx(T, { variant: "bodyLarge", color: spec.supporting.color, style: styles.affix, children: suffix })) : null, _jsx(Animated.Text, { pointerEvents: "none", numberOfLines: 1, style: [
|
|
69
91
|
rest,
|
|
70
92
|
styles.label,
|
|
71
93
|
{
|
|
@@ -74,8 +96,20 @@ export function TextField({ label, value, defaultValue, onChange, onSubmit, vari
|
|
|
74
96
|
transform: [{ translateX: labelShift }, { scale: labelScale }],
|
|
75
97
|
transformOrigin: 'left top',
|
|
76
98
|
},
|
|
77
|
-
outlined &&
|
|
78
|
-
|
|
99
|
+
outlined &&
|
|
100
|
+
floating && {
|
|
101
|
+
backgroundColor: colors.surface,
|
|
102
|
+
paddingHorizontal: 4,
|
|
103
|
+
marginLeft: -4,
|
|
104
|
+
},
|
|
105
|
+
], children: field.labelText })] }), trail ? _jsx(View, { style: styles.trail, children: trail }) : null, !outlined ? (_jsxs(_Fragment, { children: [_jsx(View, { pointerEvents: "none", style: [styles.line, { height: 1, backgroundColor: colors[spec.indicator.rest] }] }), _jsx(Animated.View, { pointerEvents: "none", style: [
|
|
106
|
+
styles.line,
|
|
107
|
+
{
|
|
108
|
+
height: 2,
|
|
109
|
+
backgroundColor: colors[field.invalid ? spec.indicator.error : spec.indicator.focus],
|
|
110
|
+
transform: [{ scaleX: focus }],
|
|
111
|
+
},
|
|
112
|
+
] })] })) : null] }), field.help || field.counter ? (_jsxs(View, { style: styles.support, children: [_jsx(T, { variant: spec.supporting.type, color: field.invalid ? spec.supporting.error : spec.supporting.color, accessibilityLiveRegion: field.invalid ? 'polite' : undefined, style: { flex: 1 }, children: field.help ?? '' }), field.counter ? (_jsx(T, { variant: spec.supporting.type, color: spec.supporting.color, style: { fontVariant: ['tabular-nums'] }, children: field.counter })) : null] })) : null] }));
|
|
79
113
|
}
|
|
80
114
|
/** Radio do M3; o ponto entra com a mola spatial. */
|
|
81
115
|
export function Radio({ checked = false, onChange, label, disabled, invalid, style }) {
|
|
@@ -85,13 +119,32 @@ export function Radio({ checked = false, onChange, label, disabled, invalid, sty
|
|
|
85
119
|
const color = colors[invalid ? spec.error : checked ? spec.selected : spec.unselected];
|
|
86
120
|
return (_jsx(Pressable, { accessibilityRole: "radio", accessibilityLabel: label, accessibilityState: { checked, disabled }, disabled: disabled, onPress: () => onChange?.(true), style: ({ pressed }) => [
|
|
87
121
|
styles.control40,
|
|
88
|
-
{
|
|
122
|
+
{
|
|
123
|
+
width: spec.stateLayer,
|
|
124
|
+
height: spec.stateLayer,
|
|
125
|
+
borderRadius: spec.stateLayer / 2,
|
|
126
|
+
opacity: disabled ? spec.disabledOpacity : 1,
|
|
127
|
+
},
|
|
89
128
|
pressed && { backgroundColor: withAlpha(color, tokens.state.pressed) },
|
|
90
129
|
style,
|
|
91
|
-
], children: _jsx(View, { style: {
|
|
130
|
+
], children: _jsx(View, { style: {
|
|
131
|
+
width: spec.size,
|
|
132
|
+
height: spec.size,
|
|
133
|
+
borderRadius: spec.size / 2,
|
|
134
|
+
borderWidth: spec.border,
|
|
135
|
+
borderColor: color,
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
}, children: _jsx(Animated.View, { style: {
|
|
139
|
+
width: spec.dot,
|
|
140
|
+
height: spec.dot,
|
|
141
|
+
borderRadius: spec.dot / 2,
|
|
142
|
+
backgroundColor: color,
|
|
143
|
+
transform: [{ scale: dot }],
|
|
144
|
+
} }) }) }));
|
|
92
145
|
}
|
|
93
146
|
/** Checkbox do M3: caixa de 18px que preenche com ✓ ou − (indeterminado). */
|
|
94
|
-
export function Checkbox({ checked = false, onChange, label, disabled, invalid, style }) {
|
|
147
|
+
export function Checkbox({ checked = false, onChange, label, disabled, invalid, style, }) {
|
|
95
148
|
const { colors } = useExpressiveTheme();
|
|
96
149
|
const spec = resolveCheckbox();
|
|
97
150
|
const on = checked !== false;
|
|
@@ -99,10 +152,22 @@ export function Checkbox({ checked = false, onChange, label, disabled, invalid,
|
|
|
99
152
|
const color = colors[invalid ? spec.error : on ? spec.checked.container : spec.unchecked];
|
|
100
153
|
return (_jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: label, accessibilityState: { checked: checked === 'mixed' ? 'mixed' : checked, disabled }, disabled: disabled, onPress: () => onChange?.(checked !== true), style: ({ pressed }) => [
|
|
101
154
|
styles.control40,
|
|
102
|
-
{
|
|
155
|
+
{
|
|
156
|
+
width: spec.stateLayer,
|
|
157
|
+
height: spec.stateLayer,
|
|
158
|
+
borderRadius: spec.stateLayer / 2,
|
|
159
|
+
opacity: disabled ? spec.disabledOpacity : 1,
|
|
160
|
+
},
|
|
103
161
|
pressed && { backgroundColor: withAlpha(color, tokens.state.pressed) },
|
|
104
162
|
style,
|
|
105
|
-
], children: _jsxs(View, { style: {
|
|
163
|
+
], children: _jsxs(View, { style: {
|
|
164
|
+
width: spec.size,
|
|
165
|
+
height: spec.size,
|
|
166
|
+
borderRadius: spec.radius,
|
|
167
|
+
borderWidth: spec.border,
|
|
168
|
+
borderColor: color,
|
|
169
|
+
overflow: 'hidden',
|
|
170
|
+
}, children: [_jsx(Animated.View, { style: [StyleSheet.absoluteFill, { backgroundColor: color, opacity: fill }] }), on ? (_jsx(Svg, { width: spec.size, height: spec.size, viewBox: "0 0 18 18", style: { position: 'absolute', left: -spec.border, top: -spec.border }, children: _jsx(Path, { d: checked === 'mixed' ? MIXED_PATH : CHECK_PATH, stroke: colors[spec.checked.content], strokeWidth: 2, fill: "none", strokeLinecap: "square" }) })) : null] }) }));
|
|
106
171
|
}
|
|
107
172
|
// --- Grupos ---------------------------------------------------------------------------------
|
|
108
173
|
function OptionRow({ option, checked, variant, first, last, control, onPress, }) {
|
|
@@ -126,23 +191,25 @@ function OptionRow({ option, checked, variant, first, last, control, onPress, })
|
|
|
126
191
|
},
|
|
127
192
|
], children: [control, option.icon ? _jsx(Icon, { name: option.icon, color: "onSurfaceVariant" }) : null, _jsxs(View, { style: styles.optionText, children: [_jsx(T, { variant: "bodyLarge", color: fg, children: option.label }), option.supporting ? (_jsx(T, { variant: "bodyMedium", color: segmented && checked ? fg : 'onSurfaceVariant', children: option.supporting })) : null] })] }) }));
|
|
128
193
|
}
|
|
129
|
-
function GroupFrame({ label, variant, help, invalid, children }) {
|
|
194
|
+
function GroupFrame({ label, variant, help, invalid, children, }) {
|
|
130
195
|
return (_jsxs(View, { children: [_jsx(T, { variant: "titleSmall", accessibilityRole: "header", style: { marginBottom: 8 }, children: label }), _jsx(View, { style: variant === 'inline' ? styles.inline : variant === 'segmented' ? { gap: 2 } : undefined, children: children }), help ? (_jsx(T, { variant: "bodySmall", color: invalid ? 'error' : 'onSurfaceVariant', style: { marginTop: 4 }, children: help })) : null] }));
|
|
131
196
|
}
|
|
132
|
-
export function RadioGroup({ options, value, onChange, label, variant = 'list', supportingText, error, style }) {
|
|
197
|
+
export function RadioGroup({ options, value, onChange, label, variant = 'list', supportingText, error, style, }) {
|
|
133
198
|
const invalid = Boolean(error);
|
|
134
199
|
return (_jsx(View, { accessibilityRole: "radiogroup", accessibilityLabel: label, style: style, children: _jsx(GroupFrame, { label: label, variant: variant, help: typeof error === 'string' ? error : supportingText, invalid: invalid, children: options.map((option, i) => (_jsx(OptionRow, { option: option, checked: option.value === value, variant: variant, first: i === 0, last: i === options.length - 1, onPress: () => onChange?.(option.value), control: _jsx(Radio, { checked: option.value === value, label: option.label, disabled: option.disabled, invalid: invalid, onChange: () => onChange?.(option.value) }) }, option.value))) }) }));
|
|
135
200
|
}
|
|
136
|
-
export function CheckboxGroup({ options, value, onChange, label, variant = 'list', selectAll, supportingText, error, style }) {
|
|
201
|
+
export function CheckboxGroup({ options, value, onChange, label, variant = 'list', selectAll, supportingText, error, style, }) {
|
|
137
202
|
const invalid = Boolean(error);
|
|
138
203
|
const enabled = options.filter((option) => !option.disabled).map((option) => option.value);
|
|
139
204
|
const parent = parentCheckState(enabled.filter((v) => value.includes(v)).length, enabled.length);
|
|
140
205
|
const toggle = (option) => onChange?.(value.includes(option) ? value.filter((v) => v !== option) : [...value, option]);
|
|
141
|
-
const toggleAll = () => onChange?.(parent === true
|
|
206
|
+
const toggleAll = () => onChange?.(parent === true
|
|
207
|
+
? value.filter((v) => !enabled.includes(v))
|
|
208
|
+
: [...new Set([...value, ...enabled])]);
|
|
142
209
|
return (_jsx(View, { accessibilityLabel: label, style: style, children: _jsxs(GroupFrame, { label: label, variant: variant, help: typeof error === 'string' ? error : supportingText, invalid: invalid, children: [selectAll ? (_jsx(OptionRow, { option: { value: '__all', label: selectAll }, checked: parent === true, variant: variant, first: true, last: false, onPress: toggleAll, control: _jsx(Checkbox, { checked: parent, label: selectAll, invalid: invalid, onChange: toggleAll }) })) : null, options.map((option, i) => (_jsx(View, { style: variant === 'list' && selectAll ? { paddingLeft: 32 } : undefined, children: _jsx(OptionRow, { option: option, checked: value.includes(option.value), variant: variant, first: !selectAll && i === 0, last: i === options.length - 1, onPress: () => toggle(option.value), control: _jsx(Checkbox, { checked: value.includes(option.value), label: option.label, disabled: option.disabled, invalid: invalid, onChange: () => toggle(option.value) }) }) }, option.value)))] }) }));
|
|
143
210
|
}
|
|
144
211
|
/** Tooltip do M3 no celular: toque longo no gatilho mostra; o plain some após ~1,5 s. */
|
|
145
|
-
export function Tooltip({ text, title, actions, placement = 'top', open: controlled, onOpenChange, children, style }) {
|
|
212
|
+
export function Tooltip({ text, title, actions, placement = 'top', open: controlled, onOpenChange, children, style, }) {
|
|
146
213
|
const { colors, mode } = useExpressiveTheme();
|
|
147
214
|
const spec = resolveTooltip();
|
|
148
215
|
const rich = Boolean(title || actions?.length);
|
|
@@ -158,7 +225,11 @@ export function Tooltip({ text, title, actions, placement = 'top', open: control
|
|
|
158
225
|
useEffect(() => () => void (timer.current && clearTimeout(timer.current)), []);
|
|
159
226
|
const clear = () => timer.current && clearTimeout(timer.current);
|
|
160
227
|
const position = placement === 'top'
|
|
161
|
-
? {
|
|
228
|
+
? {
|
|
229
|
+
bottom: '100%',
|
|
230
|
+
marginBottom: spec.offset,
|
|
231
|
+
...(rich ? { left: 0 } : { alignSelf: 'center' }),
|
|
232
|
+
}
|
|
162
233
|
: placement === 'bottom'
|
|
163
234
|
? { top: '100%', marginTop: spec.offset, ...(rich ? { left: 0 } : { alignSelf: 'center' }) }
|
|
164
235
|
: placement === 'start'
|
|
@@ -180,11 +251,24 @@ export function Tooltip({ text, title, actions, placement = 'top', open: control
|
|
|
180
251
|
backgroundColor: colors[p.container],
|
|
181
252
|
borderRadius: p.radius,
|
|
182
253
|
opacity: shown,
|
|
183
|
-
transform: [
|
|
254
|
+
transform: [
|
|
255
|
+
{ scale: shown.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1] }) },
|
|
256
|
+
],
|
|
184
257
|
},
|
|
185
258
|
rich
|
|
186
|
-
? {
|
|
187
|
-
|
|
259
|
+
? {
|
|
260
|
+
padding: spec.rich.padding,
|
|
261
|
+
paddingBottom: actions?.length ? 8 : spec.rich.padding,
|
|
262
|
+
gap: 4,
|
|
263
|
+
boxShadow: tokens.elevation[mode][2],
|
|
264
|
+
width: p.maxWidth,
|
|
265
|
+
}
|
|
266
|
+
: {
|
|
267
|
+
minHeight: spec.plain.minHeight,
|
|
268
|
+
paddingHorizontal: spec.plain.paddingX,
|
|
269
|
+
paddingVertical: 4,
|
|
270
|
+
justifyContent: 'center',
|
|
271
|
+
},
|
|
188
272
|
], children: [title ? (_jsx(T, { variant: spec.rich.titleType, emphasized: true, color: spec.rich.title, children: title })) : null, _jsx(T, { variant: p.type, color: rich ? spec.rich.content : spec.plain.content, children: text }), actions?.length ? (_jsx(View, { style: styles.tipActions, children: actions.map((action) => (_jsx(Button, { action: { id: action.label, label: action.label }, variant: "text", size: "sm", onPress: () => {
|
|
189
273
|
action.onPress?.();
|
|
190
274
|
setOpen(false);
|
|
@@ -192,12 +276,24 @@ export function Tooltip({ text, title, actions, placement = 'top', open: control
|
|
|
192
276
|
}
|
|
193
277
|
const styles = StyleSheet.create({
|
|
194
278
|
box: { flexDirection: 'row', alignItems: 'center', gap: 12 },
|
|
195
|
-
control: {
|
|
279
|
+
control: {
|
|
280
|
+
flex: 1,
|
|
281
|
+
minWidth: 0,
|
|
282
|
+
flexDirection: 'row',
|
|
283
|
+
alignItems: 'center',
|
|
284
|
+
alignSelf: 'stretch',
|
|
285
|
+
},
|
|
196
286
|
input: { flex: 1, paddingHorizontal: 0 },
|
|
197
287
|
affix: { paddingTop: 16 },
|
|
198
288
|
label: { position: 'absolute', left: 0 },
|
|
199
289
|
trail: { flexDirection: 'row', alignItems: 'center' },
|
|
200
|
-
action: {
|
|
290
|
+
action: {
|
|
291
|
+
width: 48,
|
|
292
|
+
height: 48,
|
|
293
|
+
borderRadius: 24,
|
|
294
|
+
alignItems: 'center',
|
|
295
|
+
justifyContent: 'center',
|
|
296
|
+
},
|
|
201
297
|
line: { position: 'absolute', left: 0, right: 0, bottom: 0 },
|
|
202
298
|
support: { flexDirection: 'row', gap: 16, paddingHorizontal: 16, paddingTop: 4 },
|
|
203
299
|
control40: { alignItems: 'center', justifyContent: 'center' },
|