@expressive-ui/native 0.3.0 → 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.
- package/README.md +1 -1
- package/dist/OtpField.d.ts +34 -0
- package/dist/OtpField.d.ts.map +1 -0
- package/dist/OtpField.js +156 -0
- package/dist/OtpField.js.map +1 -0
- 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/package.json +4 -4
- package/src/OtpField.tsx +353 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ MIT
|
|
|
46
46
|
|
|
47
47
|
## Formulários, dados e feedback
|
|
48
48
|
|
|
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.
|
|
49
|
+
Select, Autocomplete/Combobox, NumberField, OtpField, 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
52
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Ref } from 'react';
|
|
2
|
+
import { TextInput, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type OtpStatus, type OtpVariant } from '@expressive-ui/core';
|
|
4
|
+
export type OtpFieldProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
ref?: Ref<TextInput>;
|
|
7
|
+
inputProps?: Omit<React.ComponentProps<typeof TextInput>, 'value' | 'defaultValue' | 'onChangeText' | 'ref' | 'maxLength'>;
|
|
8
|
+
label: string;
|
|
9
|
+
/** Só dígitos. Controlado; sem value o campo guarda o próprio código (use defaultValue). */
|
|
10
|
+
value?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
|
+
/** Chamado uma vez quando o último dígito entra (digitado, colado ou autopreenchido). */
|
|
14
|
+
onComplete?: (value: string) => void;
|
|
15
|
+
/** Quantidade de dígitos (1–12). Padrão 6. */
|
|
16
|
+
length?: number;
|
|
17
|
+
/** Dígitos por grupo na variante capsule (0 = sem grupos). Padrão 3 para 6 e 4 para 8 dígitos. */
|
|
18
|
+
groupSize?: number;
|
|
19
|
+
variant?: OtpVariant;
|
|
20
|
+
/** verifying e success bloqueiam a edição. */
|
|
21
|
+
status?: OtpStatus;
|
|
22
|
+
supportingText?: string;
|
|
23
|
+
/** true ou a mensagem. Com o campo cheio, o próximo dígito recomeça o código. */
|
|
24
|
+
error?: string | boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
autoFocus?: boolean;
|
|
29
|
+
autoComplete?: React.ComponentProps<typeof TextInput>['autoComplete'];
|
|
30
|
+
style?: StyleProp<ViewStyle>;
|
|
31
|
+
};
|
|
32
|
+
/** Código de uso único num único TextInput: colar, autopreenchimento e leitores de tela funcionam. */
|
|
33
|
+
export declare function OtpField({ id, ref, inputProps, label, value, defaultValue, onChange, onComplete, length, groupSize, variant, status, supportingText, error, required, disabled, readOnly, autoFocus, autoComplete, style, }: OtpFieldProps): import("react").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=OtpField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtpField.d.ts","sourceRoot":"","sources":["../src/OtpField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAC9D,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E,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AA0IF,sGAAsG;AACtG,wBAAgB,QAAQ,CAAC,EACvB,EAAE,EACF,GAAG,EACH,UAAU,EACV,KAAK,EACL,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,MAAM,EACN,SAAS,EACT,OAAmB,EACnB,MAAe,EACf,cAAc,EACd,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,QAAgB,EAChB,SAAS,EACT,YAA8B,EAC9B,KAAK,GACN,EAAE,aAAa,+BAuHf"}
|
package/dist/OtpField.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Animated, StyleSheet, TextInput, View, } from 'react-native';
|
|
4
|
+
import Svg, { Path } from 'react-native-svg';
|
|
5
|
+
import { otpCellRadius, otpShapePoints, resolveOtp, useOtp, } from '@expressive-ui/core';
|
|
6
|
+
import { T } from './primitives.js';
|
|
7
|
+
import { useExpressiveTheme, useSpringValue } from './theme.js';
|
|
8
|
+
const paths = Object.fromEntries(['empty', 'active', 'filled', 'verifying', 'success', 'error'].map((state) => [
|
|
9
|
+
state,
|
|
10
|
+
`M${otpShapePoints(state)
|
|
11
|
+
.map(([x, y]) => `${x} ${y}`)
|
|
12
|
+
.join('L')}Z`,
|
|
13
|
+
]));
|
|
14
|
+
function Caret({ color }) {
|
|
15
|
+
const { reduceMotion } = useExpressiveTheme();
|
|
16
|
+
const opacity = useRef(new Animated.Value(1)).current;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (reduceMotion)
|
|
19
|
+
return;
|
|
20
|
+
const blink = Animated.loop(Animated.sequence([
|
|
21
|
+
Animated.timing(opacity, { toValue: 1, duration: 550, useNativeDriver: true }),
|
|
22
|
+
Animated.timing(opacity, { toValue: 0, duration: 1, useNativeDriver: true }),
|
|
23
|
+
Animated.timing(opacity, { toValue: 0, duration: 550, useNativeDriver: true }),
|
|
24
|
+
Animated.timing(opacity, { toValue: 1, duration: 1, useNativeDriver: true }),
|
|
25
|
+
]));
|
|
26
|
+
blink.start();
|
|
27
|
+
return () => {
|
|
28
|
+
blink.stop();
|
|
29
|
+
opacity.setValue(1);
|
|
30
|
+
};
|
|
31
|
+
}, [opacity, reduceMotion]);
|
|
32
|
+
return _jsx(Animated.View, { style: [styles.caret, { backgroundColor: color, opacity }] });
|
|
33
|
+
}
|
|
34
|
+
/** Dígito que entra crescendo com a mola (remontado a cada troca pela key). */
|
|
35
|
+
function Digit({ char, color, spec }) {
|
|
36
|
+
const [target, setTarget] = useState(0.4);
|
|
37
|
+
useEffect(() => setTarget(1), []);
|
|
38
|
+
const scale = useSpringValue(target, 'spatialFast');
|
|
39
|
+
return (_jsx(Animated.View, { style: { transform: [{ scale }] }, children: _jsx(T, { variant: spec.type, emphasized: true, maxFontSizeMultiplier: 1.3, style: [styles.digit, { color }], children: char }) }));
|
|
40
|
+
}
|
|
41
|
+
function Cell({ cell, length, variant, status, invalid, spec, }) {
|
|
42
|
+
const { colors, reduceMotion } = useExpressiveTheme();
|
|
43
|
+
const [startTarget, endTarget] = otpCellRadius(variant, cell.state, cell.index, length);
|
|
44
|
+
const start = useSpringValue(startTarget, 'spatialFast');
|
|
45
|
+
const end = useSpringValue(endTarget, 'spatialFast');
|
|
46
|
+
const lift = useRef(new Animated.Value(0)).current;
|
|
47
|
+
const verifying = status === 'verifying' && !reduceMotion;
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!verifying)
|
|
50
|
+
return;
|
|
51
|
+
const delay = cell.index * 80;
|
|
52
|
+
const step = (toValue) => Animated.timing(lift, { toValue, duration: 280, useNativeDriver: false });
|
|
53
|
+
const wave = Animated.loop(Animated.sequence([
|
|
54
|
+
Animated.delay(delay),
|
|
55
|
+
step(-6),
|
|
56
|
+
step(0),
|
|
57
|
+
Animated.delay(Math.max(0, length * 80 - delay)),
|
|
58
|
+
]));
|
|
59
|
+
wave.start();
|
|
60
|
+
return () => {
|
|
61
|
+
wave.stop();
|
|
62
|
+
lift.setValue(0);
|
|
63
|
+
};
|
|
64
|
+
}, [verifying, cell.index, length, lift]);
|
|
65
|
+
const focus = colors[invalid ? spec.indicator.error : spec.indicator.color];
|
|
66
|
+
const { container, content } = spec.colors[cell.state];
|
|
67
|
+
const shapes = variant === 'shapes';
|
|
68
|
+
const active = cell.state === 'active';
|
|
69
|
+
return (_jsxs(Animated.View, { style: [
|
|
70
|
+
styles.cell,
|
|
71
|
+
{
|
|
72
|
+
transform: [{ translateY: lift }],
|
|
73
|
+
marginLeft: cell.index === 0 ? 0 : cell.groupStart ? spec.groupGap : spec.gap,
|
|
74
|
+
},
|
|
75
|
+
!shapes && {
|
|
76
|
+
backgroundColor: colors[container],
|
|
77
|
+
borderWidth: spec.indicator.width,
|
|
78
|
+
borderColor: cell.focused ? focus : 'transparent',
|
|
79
|
+
borderTopLeftRadius: start,
|
|
80
|
+
borderBottomLeftRadius: start,
|
|
81
|
+
borderTopRightRadius: end,
|
|
82
|
+
borderBottomRightRadius: end,
|
|
83
|
+
},
|
|
84
|
+
], children: [shapes ? (_jsx(Svg, { width: "100%", height: "100%", viewBox: "0 0 100 100", style: StyleSheet.absoluteFill, children: _jsx(Path, { d: paths[cell.state], fill: colors[container], stroke: active ? focus : undefined, strokeWidth: active ? 4 : 0 }) })) : null, shapes && cell.focused && !active ? (_jsx(View, { style: [styles.underline, { backgroundColor: focus }] })) : null, cell.char ? (_jsx(Digit, { char: cell.char, color: colors[content], spec: spec }, cell.char)) : cell.caret ? (_jsx(Caret, { color: focus })) : null] }));
|
|
85
|
+
}
|
|
86
|
+
/** Código de uso único num único TextInput: colar, autopreenchimento e leitores de tela funcionam. */
|
|
87
|
+
export function OtpField({ id, ref, inputProps, label, value, defaultValue, onChange, onComplete, length, groupSize, variant = 'capsule', status = 'idle', supportingText, error, required, disabled = false, readOnly = false, autoFocus, autoComplete = 'one-time-code', style, }) {
|
|
88
|
+
const { colors, mode, reduceMotion } = useExpressiveTheme();
|
|
89
|
+
const spec = resolveOtp(variant);
|
|
90
|
+
const otp = useOtp({
|
|
91
|
+
value,
|
|
92
|
+
defaultValue,
|
|
93
|
+
onChange,
|
|
94
|
+
onComplete,
|
|
95
|
+
length,
|
|
96
|
+
groupSize,
|
|
97
|
+
variant,
|
|
98
|
+
status,
|
|
99
|
+
disabled,
|
|
100
|
+
readOnly,
|
|
101
|
+
error,
|
|
102
|
+
supportingText,
|
|
103
|
+
required,
|
|
104
|
+
label,
|
|
105
|
+
id,
|
|
106
|
+
});
|
|
107
|
+
const { field } = otp;
|
|
108
|
+
const shake = useRef(new Animated.Value(0)).current;
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!field.invalid || reduceMotion)
|
|
111
|
+
return;
|
|
112
|
+
const animation = Animated.sequence([-6, 6, -6, 6, 0].map((toValue) => Animated.timing(shake, { toValue, duration: 80, useNativeDriver: true })));
|
|
113
|
+
animation.start();
|
|
114
|
+
return () => {
|
|
115
|
+
animation.stop();
|
|
116
|
+
shake.setValue(0);
|
|
117
|
+
};
|
|
118
|
+
}, [field.invalid, reduceMotion, shake]);
|
|
119
|
+
return (_jsxs(View, { style: [
|
|
120
|
+
styles.root,
|
|
121
|
+
{
|
|
122
|
+
maxWidth: otp.length * spec.maxCellWidth + (otp.length - 1) * spec.gap,
|
|
123
|
+
opacity: disabled ? spec.disabledOpacity : 1,
|
|
124
|
+
},
|
|
125
|
+
style,
|
|
126
|
+
], children: [_jsx(View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: _jsx(T, { variant: "labelLarge", color: "onSurfaceVariant", children: field.labelText }) }), _jsxs(View, { style: { height: spec.height }, children: [_jsx(Animated.View, { pointerEvents: "none", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: [styles.cells, { transform: [{ translateX: shake }] }], children: otp.cells.map((cell) => (_jsx(Cell, { cell: cell, length: otp.length, variant: variant, status: status, invalid: field.invalid, spec: spec }, cell.index))) }), _jsx(TextInput, { ...inputProps, ref: ref, nativeID: field.ids.input, accessibilityLabel: field.labelText, accessibilityHint: field.help ?? undefined, accessibilityState: { disabled, busy: status === 'verifying' }, value: otp.text, onChangeText: otp.change, editable: !otp.locked && inputProps?.editable !== false, autoFocus: autoFocus, keyboardType: "number-pad", textContentType: autoComplete === 'one-time-code' ? 'oneTimeCode' : undefined, autoComplete: autoComplete, autoCorrect: false, keyboardAppearance: mode, underlineColorAndroid: "transparent", selectionColor: "transparent", caretHidden: true, onFocus: (event) => {
|
|
127
|
+
otp.setFocused(true);
|
|
128
|
+
inputProps?.onFocus?.(event);
|
|
129
|
+
}, onBlur: (event) => {
|
|
130
|
+
otp.setFocused(false);
|
|
131
|
+
inputProps?.onBlur?.(event);
|
|
132
|
+
}, style: [StyleSheet.absoluteFill, styles.input] })] }), field.help ? (_jsx(T, { variant: spec.supporting.type, color: field.invalid
|
|
133
|
+
? spec.supporting.error
|
|
134
|
+
: status === 'success'
|
|
135
|
+
? spec.supporting.success
|
|
136
|
+
: spec.supporting.color, accessibilityLiveRegion: "polite", style: { minHeight: 16 }, children: field.help })) : null] }));
|
|
137
|
+
}
|
|
138
|
+
const styles = StyleSheet.create({
|
|
139
|
+
root: { width: '100%', gap: 8 },
|
|
140
|
+
// Códigos são lidos da esquerda para a direita também em RTL.
|
|
141
|
+
cells: { flex: 1, flexDirection: 'row', direction: 'ltr' },
|
|
142
|
+
cell: { flex: 1, minWidth: 0, alignItems: 'center', justifyContent: 'center' },
|
|
143
|
+
caret: { width: 2, height: 24, borderRadius: 1 },
|
|
144
|
+
digit: { fontVariant: ['tabular-nums'], textAlign: 'center' },
|
|
145
|
+
underline: {
|
|
146
|
+
position: 'absolute',
|
|
147
|
+
bottom: -5,
|
|
148
|
+
left: '25%',
|
|
149
|
+
right: '25%',
|
|
150
|
+
height: 3,
|
|
151
|
+
borderRadius: 2,
|
|
152
|
+
},
|
|
153
|
+
// O texto do input fica invisível; os espaços acima desenham o código.
|
|
154
|
+
input: { color: 'transparent', backgroundColor: 'transparent', padding: 0, fontSize: 16 },
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=OtpField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtpField.js","sourceRoot":"","sources":["../src/OtpField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAY,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EACT,IAAI,GAGL,MAAM,cAAc,CAAC;AACtB,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,cAAc,EACd,UAAU,EACV,MAAM,GAMP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAkChE,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC7B,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IACvF,KAAK;IACL,IAAI,cAAc,CAAC,KAAK,CAAC;SACtB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;SAC5B,IAAI,CAAC,GAAG,CAAC,GAAG;CAChB,CAAC,CAC6B,CAAC;AAElC,SAAS,KAAK,CAAC,EAAE,KAAK,EAAqB;IACzC,MAAM,EAAE,YAAY,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CA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IAChD,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;IAC7D,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,CAAC;KAChB;IACD,uEAAuE;IACvE,KAAK,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;CAC1F,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from './RangeSlider.js';
|
|
|
25
25
|
export * from './Select.js';
|
|
26
26
|
export * from './Feedback.js';
|
|
27
27
|
export * from './NumberField.js';
|
|
28
|
+
export * from './OtpField.js';
|
|
28
29
|
export * from './FileUpload.js';
|
|
29
30
|
export * from './RenderUI.js';
|
|
30
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from './RangeSlider.js';
|
|
|
25
25
|
export * from './Select.js';
|
|
26
26
|
export * from './Feedback.js';
|
|
27
27
|
export * from './NumberField.js';
|
|
28
|
+
export * from './OtpField.js';
|
|
28
29
|
export * from './FileUpload.js';
|
|
29
30
|
export * from './RenderUI.js';
|
|
30
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressive-ui/native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"homepage": "https://expressive-ui.com",
|
|
5
5
|
"description": "Componentes React Native (Expo) do ExpressiveUI em Material 3 Expressive.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"build": "tsc -b"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@expressive-ui/core": "0.
|
|
38
|
-
"@expressive-ui/schema": "0.
|
|
39
|
-
"@expressive-ui/tokens": "0.
|
|
37
|
+
"@expressive-ui/core": "0.4.0",
|
|
38
|
+
"@expressive-ui/schema": "0.4.0",
|
|
39
|
+
"@expressive-ui/tokens": "0.4.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=19",
|
package/src/OtpField.tsx
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { useEffect, useRef, useState, type Ref } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
TextInput,
|
|
6
|
+
View,
|
|
7
|
+
type StyleProp,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import Svg, { Path } from 'react-native-svg';
|
|
11
|
+
import {
|
|
12
|
+
otpCellRadius,
|
|
13
|
+
otpShapePoints,
|
|
14
|
+
resolveOtp,
|
|
15
|
+
useOtp,
|
|
16
|
+
type OtpCell,
|
|
17
|
+
type OtpCellState,
|
|
18
|
+
type OtpSpec,
|
|
19
|
+
type OtpStatus,
|
|
20
|
+
type OtpVariant,
|
|
21
|
+
} from '@expressive-ui/core';
|
|
22
|
+
import { T } from './primitives.js';
|
|
23
|
+
import { useExpressiveTheme, useSpringValue } from './theme.js';
|
|
24
|
+
|
|
25
|
+
export type OtpFieldProps = {
|
|
26
|
+
id?: string;
|
|
27
|
+
ref?: Ref<TextInput>;
|
|
28
|
+
inputProps?: Omit<
|
|
29
|
+
React.ComponentProps<typeof TextInput>,
|
|
30
|
+
'value' | 'defaultValue' | 'onChangeText' | 'ref' | 'maxLength'
|
|
31
|
+
>;
|
|
32
|
+
label: string;
|
|
33
|
+
/** Só dígitos. Controlado; sem value o campo guarda o próprio código (use defaultValue). */
|
|
34
|
+
value?: string;
|
|
35
|
+
defaultValue?: string;
|
|
36
|
+
onChange?: (value: string) => void;
|
|
37
|
+
/** Chamado uma vez quando o último dígito entra (digitado, colado ou autopreenchido). */
|
|
38
|
+
onComplete?: (value: string) => void;
|
|
39
|
+
/** Quantidade de dígitos (1–12). Padrão 6. */
|
|
40
|
+
length?: number;
|
|
41
|
+
/** Dígitos por grupo na variante capsule (0 = sem grupos). Padrão 3 para 6 e 4 para 8 dígitos. */
|
|
42
|
+
groupSize?: number;
|
|
43
|
+
variant?: OtpVariant;
|
|
44
|
+
/** verifying e success bloqueiam a edição. */
|
|
45
|
+
status?: OtpStatus;
|
|
46
|
+
supportingText?: string;
|
|
47
|
+
/** true ou a mensagem. Com o campo cheio, o próximo dígito recomeça o código. */
|
|
48
|
+
error?: string | boolean;
|
|
49
|
+
required?: boolean;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
autoFocus?: boolean;
|
|
53
|
+
autoComplete?: React.ComponentProps<typeof TextInput>['autoComplete'];
|
|
54
|
+
style?: StyleProp<ViewStyle>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const paths = Object.fromEntries(
|
|
58
|
+
(['empty', 'active', 'filled', 'verifying', 'success', 'error'] as const).map((state) => [
|
|
59
|
+
state,
|
|
60
|
+
`M${otpShapePoints(state)
|
|
61
|
+
.map(([x, y]) => `${x} ${y}`)
|
|
62
|
+
.join('L')}Z`,
|
|
63
|
+
]),
|
|
64
|
+
) as Record<OtpCellState, string>;
|
|
65
|
+
|
|
66
|
+
function Caret({ color }: { color: string }) {
|
|
67
|
+
const { reduceMotion } = useExpressiveTheme();
|
|
68
|
+
const opacity = useRef(new Animated.Value(1)).current;
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (reduceMotion) return;
|
|
71
|
+
const blink = Animated.loop(
|
|
72
|
+
Animated.sequence([
|
|
73
|
+
Animated.timing(opacity, { toValue: 1, duration: 550, useNativeDriver: true }),
|
|
74
|
+
Animated.timing(opacity, { toValue: 0, duration: 1, useNativeDriver: true }),
|
|
75
|
+
Animated.timing(opacity, { toValue: 0, duration: 550, useNativeDriver: true }),
|
|
76
|
+
Animated.timing(opacity, { toValue: 1, duration: 1, useNativeDriver: true }),
|
|
77
|
+
]),
|
|
78
|
+
);
|
|
79
|
+
blink.start();
|
|
80
|
+
return () => {
|
|
81
|
+
blink.stop();
|
|
82
|
+
opacity.setValue(1);
|
|
83
|
+
};
|
|
84
|
+
}, [opacity, reduceMotion]);
|
|
85
|
+
return <Animated.View style={[styles.caret, { backgroundColor: color, opacity }]} />;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Dígito que entra crescendo com a mola (remontado a cada troca pela key). */
|
|
89
|
+
function Digit({ char, color, spec }: { char: string; color: string; spec: OtpSpec }) {
|
|
90
|
+
const [target, setTarget] = useState(0.4);
|
|
91
|
+
useEffect(() => setTarget(1), []);
|
|
92
|
+
const scale = useSpringValue(target, 'spatialFast');
|
|
93
|
+
return (
|
|
94
|
+
<Animated.View style={{ transform: [{ scale }] }}>
|
|
95
|
+
<T
|
|
96
|
+
variant={spec.type}
|
|
97
|
+
emphasized
|
|
98
|
+
maxFontSizeMultiplier={1.3}
|
|
99
|
+
style={[styles.digit, { color }]}
|
|
100
|
+
>
|
|
101
|
+
{char}
|
|
102
|
+
</T>
|
|
103
|
+
</Animated.View>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function Cell({
|
|
108
|
+
cell,
|
|
109
|
+
length,
|
|
110
|
+
variant,
|
|
111
|
+
status,
|
|
112
|
+
invalid,
|
|
113
|
+
spec,
|
|
114
|
+
}: {
|
|
115
|
+
cell: OtpCell;
|
|
116
|
+
length: number;
|
|
117
|
+
variant: OtpVariant;
|
|
118
|
+
status: OtpStatus;
|
|
119
|
+
invalid: boolean;
|
|
120
|
+
spec: OtpSpec;
|
|
121
|
+
}) {
|
|
122
|
+
const { colors, reduceMotion } = useExpressiveTheme();
|
|
123
|
+
const [startTarget, endTarget] = otpCellRadius(variant, cell.state, cell.index, length);
|
|
124
|
+
const start = useSpringValue(startTarget, 'spatialFast');
|
|
125
|
+
const end = useSpringValue(endTarget, 'spatialFast');
|
|
126
|
+
const lift = useRef(new Animated.Value(0)).current;
|
|
127
|
+
const verifying = status === 'verifying' && !reduceMotion;
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (!verifying) return;
|
|
130
|
+
const delay = cell.index * 80;
|
|
131
|
+
const step = (toValue: number) =>
|
|
132
|
+
Animated.timing(lift, { toValue, duration: 280, useNativeDriver: false });
|
|
133
|
+
const wave = Animated.loop(
|
|
134
|
+
Animated.sequence([
|
|
135
|
+
Animated.delay(delay),
|
|
136
|
+
step(-6),
|
|
137
|
+
step(0),
|
|
138
|
+
Animated.delay(Math.max(0, length * 80 - delay)),
|
|
139
|
+
]),
|
|
140
|
+
);
|
|
141
|
+
wave.start();
|
|
142
|
+
return () => {
|
|
143
|
+
wave.stop();
|
|
144
|
+
lift.setValue(0);
|
|
145
|
+
};
|
|
146
|
+
}, [verifying, cell.index, length, lift]);
|
|
147
|
+
|
|
148
|
+
const focus = colors[invalid ? spec.indicator.error : spec.indicator.color];
|
|
149
|
+
const { container, content } = spec.colors[cell.state];
|
|
150
|
+
const shapes = variant === 'shapes';
|
|
151
|
+
const active = cell.state === 'active';
|
|
152
|
+
return (
|
|
153
|
+
<Animated.View
|
|
154
|
+
style={[
|
|
155
|
+
styles.cell,
|
|
156
|
+
{
|
|
157
|
+
transform: [{ translateY: lift }],
|
|
158
|
+
marginLeft: cell.index === 0 ? 0 : cell.groupStart ? spec.groupGap : spec.gap,
|
|
159
|
+
},
|
|
160
|
+
!shapes && {
|
|
161
|
+
backgroundColor: colors[container],
|
|
162
|
+
borderWidth: spec.indicator.width,
|
|
163
|
+
borderColor: cell.focused ? focus : 'transparent',
|
|
164
|
+
borderTopLeftRadius: start,
|
|
165
|
+
borderBottomLeftRadius: start,
|
|
166
|
+
borderTopRightRadius: end,
|
|
167
|
+
borderBottomRightRadius: end,
|
|
168
|
+
},
|
|
169
|
+
]}
|
|
170
|
+
>
|
|
171
|
+
{shapes ? (
|
|
172
|
+
<Svg width="100%" height="100%" viewBox="0 0 100 100" style={StyleSheet.absoluteFill}>
|
|
173
|
+
<Path
|
|
174
|
+
d={paths[cell.state]}
|
|
175
|
+
fill={colors[container]}
|
|
176
|
+
stroke={active ? focus : undefined}
|
|
177
|
+
strokeWidth={active ? 4 : 0}
|
|
178
|
+
/>
|
|
179
|
+
</Svg>
|
|
180
|
+
) : null}
|
|
181
|
+
{shapes && cell.focused && !active ? (
|
|
182
|
+
<View style={[styles.underline, { backgroundColor: focus }]} />
|
|
183
|
+
) : null}
|
|
184
|
+
{cell.char ? (
|
|
185
|
+
<Digit key={cell.char} char={cell.char} color={colors[content]} spec={spec} />
|
|
186
|
+
) : cell.caret ? (
|
|
187
|
+
<Caret color={focus} />
|
|
188
|
+
) : null}
|
|
189
|
+
</Animated.View>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Código de uso único num único TextInput: colar, autopreenchimento e leitores de tela funcionam. */
|
|
194
|
+
export function OtpField({
|
|
195
|
+
id,
|
|
196
|
+
ref,
|
|
197
|
+
inputProps,
|
|
198
|
+
label,
|
|
199
|
+
value,
|
|
200
|
+
defaultValue,
|
|
201
|
+
onChange,
|
|
202
|
+
onComplete,
|
|
203
|
+
length,
|
|
204
|
+
groupSize,
|
|
205
|
+
variant = 'capsule',
|
|
206
|
+
status = 'idle',
|
|
207
|
+
supportingText,
|
|
208
|
+
error,
|
|
209
|
+
required,
|
|
210
|
+
disabled = false,
|
|
211
|
+
readOnly = false,
|
|
212
|
+
autoFocus,
|
|
213
|
+
autoComplete = 'one-time-code',
|
|
214
|
+
style,
|
|
215
|
+
}: OtpFieldProps) {
|
|
216
|
+
const { colors, mode, reduceMotion } = useExpressiveTheme();
|
|
217
|
+
const spec = resolveOtp(variant);
|
|
218
|
+
const otp = useOtp({
|
|
219
|
+
value,
|
|
220
|
+
defaultValue,
|
|
221
|
+
onChange,
|
|
222
|
+
onComplete,
|
|
223
|
+
length,
|
|
224
|
+
groupSize,
|
|
225
|
+
variant,
|
|
226
|
+
status,
|
|
227
|
+
disabled,
|
|
228
|
+
readOnly,
|
|
229
|
+
error,
|
|
230
|
+
supportingText,
|
|
231
|
+
required,
|
|
232
|
+
label,
|
|
233
|
+
id,
|
|
234
|
+
});
|
|
235
|
+
const { field } = otp;
|
|
236
|
+
const shake = useRef(new Animated.Value(0)).current;
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (!field.invalid || reduceMotion) return;
|
|
239
|
+
const animation = Animated.sequence(
|
|
240
|
+
[-6, 6, -6, 6, 0].map((toValue) =>
|
|
241
|
+
Animated.timing(shake, { toValue, duration: 80, useNativeDriver: true }),
|
|
242
|
+
),
|
|
243
|
+
);
|
|
244
|
+
animation.start();
|
|
245
|
+
return () => {
|
|
246
|
+
animation.stop();
|
|
247
|
+
shake.setValue(0);
|
|
248
|
+
};
|
|
249
|
+
}, [field.invalid, reduceMotion, shake]);
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<View
|
|
253
|
+
style={[
|
|
254
|
+
styles.root,
|
|
255
|
+
{
|
|
256
|
+
maxWidth: otp.length * spec.maxCellWidth + (otp.length - 1) * spec.gap,
|
|
257
|
+
opacity: disabled ? spec.disabledOpacity : 1,
|
|
258
|
+
},
|
|
259
|
+
style,
|
|
260
|
+
]}
|
|
261
|
+
>
|
|
262
|
+
<View accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
|
263
|
+
<T variant="labelLarge" color="onSurfaceVariant">
|
|
264
|
+
{field.labelText}
|
|
265
|
+
</T>
|
|
266
|
+
</View>
|
|
267
|
+
<View style={{ height: spec.height }}>
|
|
268
|
+
<Animated.View
|
|
269
|
+
pointerEvents="none"
|
|
270
|
+
accessibilityElementsHidden
|
|
271
|
+
importantForAccessibility="no-hide-descendants"
|
|
272
|
+
style={[styles.cells, { transform: [{ translateX: shake }] }]}
|
|
273
|
+
>
|
|
274
|
+
{otp.cells.map((cell) => (
|
|
275
|
+
<Cell
|
|
276
|
+
key={cell.index}
|
|
277
|
+
cell={cell}
|
|
278
|
+
length={otp.length}
|
|
279
|
+
variant={variant}
|
|
280
|
+
status={status}
|
|
281
|
+
invalid={field.invalid}
|
|
282
|
+
spec={spec}
|
|
283
|
+
/>
|
|
284
|
+
))}
|
|
285
|
+
</Animated.View>
|
|
286
|
+
<TextInput
|
|
287
|
+
{...inputProps}
|
|
288
|
+
ref={ref}
|
|
289
|
+
nativeID={field.ids.input}
|
|
290
|
+
accessibilityLabel={field.labelText}
|
|
291
|
+
accessibilityHint={field.help ?? undefined}
|
|
292
|
+
accessibilityState={{ disabled, busy: status === 'verifying' }}
|
|
293
|
+
value={otp.text}
|
|
294
|
+
onChangeText={otp.change}
|
|
295
|
+
editable={!otp.locked && inputProps?.editable !== false}
|
|
296
|
+
autoFocus={autoFocus}
|
|
297
|
+
keyboardType="number-pad"
|
|
298
|
+
textContentType={autoComplete === 'one-time-code' ? 'oneTimeCode' : undefined}
|
|
299
|
+
autoComplete={autoComplete}
|
|
300
|
+
autoCorrect={false}
|
|
301
|
+
keyboardAppearance={mode}
|
|
302
|
+
underlineColorAndroid="transparent"
|
|
303
|
+
selectionColor="transparent"
|
|
304
|
+
caretHidden
|
|
305
|
+
onFocus={(event) => {
|
|
306
|
+
otp.setFocused(true);
|
|
307
|
+
inputProps?.onFocus?.(event);
|
|
308
|
+
}}
|
|
309
|
+
onBlur={(event) => {
|
|
310
|
+
otp.setFocused(false);
|
|
311
|
+
inputProps?.onBlur?.(event);
|
|
312
|
+
}}
|
|
313
|
+
style={[StyleSheet.absoluteFill, styles.input]}
|
|
314
|
+
/>
|
|
315
|
+
</View>
|
|
316
|
+
{field.help ? (
|
|
317
|
+
<T
|
|
318
|
+
variant={spec.supporting.type}
|
|
319
|
+
color={
|
|
320
|
+
field.invalid
|
|
321
|
+
? spec.supporting.error
|
|
322
|
+
: status === 'success'
|
|
323
|
+
? spec.supporting.success
|
|
324
|
+
: spec.supporting.color
|
|
325
|
+
}
|
|
326
|
+
accessibilityLiveRegion="polite"
|
|
327
|
+
style={{ minHeight: 16 }}
|
|
328
|
+
>
|
|
329
|
+
{field.help}
|
|
330
|
+
</T>
|
|
331
|
+
) : null}
|
|
332
|
+
</View>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const styles = StyleSheet.create({
|
|
337
|
+
root: { width: '100%', gap: 8 },
|
|
338
|
+
// Códigos são lidos da esquerda para a direita também em RTL.
|
|
339
|
+
cells: { flex: 1, flexDirection: 'row', direction: 'ltr' },
|
|
340
|
+
cell: { flex: 1, minWidth: 0, alignItems: 'center', justifyContent: 'center' },
|
|
341
|
+
caret: { width: 2, height: 24, borderRadius: 1 },
|
|
342
|
+
digit: { fontVariant: ['tabular-nums'], textAlign: 'center' },
|
|
343
|
+
underline: {
|
|
344
|
+
position: 'absolute',
|
|
345
|
+
bottom: -5,
|
|
346
|
+
left: '25%',
|
|
347
|
+
right: '25%',
|
|
348
|
+
height: 3,
|
|
349
|
+
borderRadius: 2,
|
|
350
|
+
},
|
|
351
|
+
// O texto do input fica invisível; os espaços acima desenham o código.
|
|
352
|
+
input: { color: 'transparent', backgroundColor: 'transparent', padding: 0, fontSize: 16 },
|
|
353
|
+
});
|
package/src/index.ts
CHANGED