vpt-sebraeds 0.0.90 → 0.0.91
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 +116 -2
- package/components/Accordion/index.jsx +33 -34
- package/components/Input/InputUnderline.tsx +30 -34
- package/components/Input/index.jsx +75 -51
- package/components/NotificationDialog/index.jsx +26 -26
- package/components/SEText/index.d.ts +3 -1
- package/components/SEText/index.js +26 -43
- package/components/SEText/styles.js +15 -343
- package/components/Table/index.jsx +1 -1
- package/components/Typography/index.jsx +53 -125
- package/components/styles/fonts.js +10 -8
- package/components/styles/index,js +32 -2
- package/components/styles/tokens/borders.ts +13 -0
- package/components/styles/tokens/colors.ts +81 -0
- package/components/styles/tokens/elevations.ts +49 -0
- package/components/styles/tokens/index.ts +47 -0
- package/components/styles/tokens/opacity.ts +11 -0
- package/components/styles/tokens/palette.ts +86 -0
- package/components/styles/tokens/radius.ts +12 -0
- package/components/styles/tokens/spacing.ts +25 -0
- package/components/styles/tokens/surfaces.ts +28 -0
- package/components/styles/tokens/typography.ts +282 -0
- package/components/styles/tokens.ts +13 -217
- package/components/utils/fontFamily.js +6 -3
- package/dist/components/Accordion/index.d.ts +1 -1
- package/dist/components/Accordion/index.js +33 -34
- package/dist/components/Input/InputUnderline.d.ts.map +1 -1
- package/dist/components/Input/InputUnderline.js +30 -34
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +72 -49
- package/dist/components/NotificationDialog/index.js +26 -26
- package/dist/components/SEText/index.d.ts +1 -1
- package/dist/components/SEText/index.d.ts.map +1 -1
- package/dist/components/SEText/index.js +24 -39
- package/dist/components/SEText/styles.d.ts +236 -266
- package/dist/components/SEText/styles.js +11 -329
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Typography/index.d.ts +2 -2
- package/dist/components/Typography/index.d.ts.map +1 -1
- package/dist/components/Typography/index.js +26 -98
- package/dist/components/styles/fonts.d.ts +8 -8
- package/dist/components/styles/fonts.js +9 -8
- package/dist/components/styles/tokens/borders.d.ts +14 -0
- package/dist/components/styles/tokens/borders.d.ts.map +1 -0
- package/dist/components/styles/tokens/borders.js +13 -0
- package/dist/components/styles/tokens/colors.d.ts +78 -0
- package/dist/components/styles/tokens/colors.d.ts.map +1 -0
- package/dist/components/styles/tokens/colors.js +79 -0
- package/dist/components/styles/tokens/elevations.d.ts +127 -0
- package/dist/components/styles/tokens/elevations.d.ts.map +1 -0
- package/dist/components/styles/tokens/elevations.js +47 -0
- package/dist/components/styles/tokens/index.d.ts +842 -0
- package/dist/components/styles/tokens/index.d.ts.map +1 -0
- package/dist/components/styles/tokens/index.js +28 -0
- package/dist/components/styles/tokens/opacity.d.ts +12 -0
- package/dist/components/styles/tokens/opacity.d.ts.map +1 -0
- package/dist/components/styles/tokens/opacity.js +11 -0
- package/dist/components/styles/tokens/palette.d.ts +86 -0
- package/dist/components/styles/tokens/palette.d.ts.map +1 -0
- package/dist/components/styles/tokens/palette.js +85 -0
- package/dist/components/styles/tokens/radius.d.ts +21 -0
- package/dist/components/styles/tokens/radius.d.ts.map +1 -0
- package/dist/components/styles/tokens/radius.js +11 -0
- package/dist/components/styles/tokens/spacing.d.ts +25 -0
- package/dist/components/styles/tokens/spacing.d.ts.map +1 -0
- package/dist/components/styles/tokens/spacing.js +24 -0
- package/dist/components/styles/tokens/surfaces.d.ts +27 -0
- package/dist/components/styles/tokens/surfaces.d.ts.map +1 -0
- package/dist/components/styles/tokens/surfaces.js +27 -0
- package/dist/components/styles/tokens/typography.d.ts +456 -0
- package/dist/components/styles/tokens/typography.d.ts.map +1 -0
- package/dist/components/styles/tokens/typography.js +259 -0
- package/dist/components/styles/tokens.d.ts +1 -259
- package/dist/components/styles/tokens.d.ts.map +1 -1
- package/dist/components/styles/tokens.js +1 -213
- package/dist/components/utils/fontFamily.d.ts +3 -0
- package/dist/components/utils/fontFamily.js +6 -3
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/package.json +1 -1
- package/src/index.ts +15 -0
package/README.md
CHANGED
|
@@ -14,6 +14,21 @@
|
|
|
14
14
|
|
|
15
15
|
Este é o repositório do Design System em React Native desenvolvido para o projeto Sebrae Na Palma da Mão. O objetivo é fornecer uma biblioteca de componentes reutilizáveis que seguem os padrões visuais e de interação do Sebrae, garantindo consistência e eficiência no desenvolvimento do aplicativo principal.
|
|
16
16
|
|
|
17
|
+
## 🧭 Princípios do Design System
|
|
18
|
+
|
|
19
|
+
- **Composition Pattern**: componentes devem priorizar composição sobre herança, com subcomponentes acessados via `Parent.Child` quando fizer sentido.
|
|
20
|
+
- **Tokenização obrigatória**: cores, tipografia, surfaces, bordas, elevações e demais aspectos visuais devem nascer em `components/styles/tokens/`.
|
|
21
|
+
- **Sem hardcodes visuais estruturais**: componentes não devem declarar diretamente `color`, `backgroundColor`, `borderColor`, `fontFamily`, `fontSize`, `fontWeight`, `shadow*` ou `elevation` fora do sistema de tokens.
|
|
22
|
+
- **Tipografia centralizada**: a família atual é Nunito, com adaptação entre iOS e Android encapsulada no domínio de tipografia do Design System.
|
|
23
|
+
|
|
24
|
+
Referências diretas:
|
|
25
|
+
|
|
26
|
+
- Tokens por aspecto: [components/styles/tokens/](file:///Users/tegra/sebrae/storybook/dev/components/styles/tokens)
|
|
27
|
+
- Entry point compatível: [components/styles/tokens.ts](file:///Users/tegra/sebrae/storybook/dev/components/styles/tokens.ts)
|
|
28
|
+
- Tipografia centralizada: [typography.ts](file:///Users/tegra/sebrae/storybook/dev/components/styles/tokens/typography.ts)
|
|
29
|
+
- Texto padronizado: [SEText/index.js](file:///Users/tegra/sebrae/storybook/dev/components/SEText/index.js)
|
|
30
|
+
- Regras do projeto: [AGENTS.md](file:///Users/tegra/sebrae/storybook/dev/AGENTS.md)
|
|
31
|
+
|
|
17
32
|
## ✅ Requisitos
|
|
18
33
|
|
|
19
34
|
- Node.js >= 18 ([package.json](file:///Users/tegra/sebrae/storybook/dev/package.json#L107-L109))
|
|
@@ -35,6 +50,12 @@ npm install
|
|
|
35
50
|
- Histórias em `*.stories.(jsx|tsx)` ao lado de cada componente
|
|
36
51
|
- Veja a lista completa em [components/](file:///Users/tegra/sebrae/storybook/dev/components) ou rode o Storybook
|
|
37
52
|
|
|
53
|
+
Padrão de construção esperado:
|
|
54
|
+
|
|
55
|
+
- Componentes novos devem seguir composição e contexto quando houver partes acopladas semanticamente.
|
|
56
|
+
- Tipografia deve ser aplicada com `SEText` ou via `tokens.textStyles`/`tokens.typography`.
|
|
57
|
+
- Estilos estáticos devem usar `StyleSheet.create` e tokens semânticos.
|
|
58
|
+
|
|
38
59
|
Exemplos de componentes:
|
|
39
60
|
|
|
40
61
|
- Accordion, Button, Checkbox, FilterTag, Input, Modal, Navbar, Pagination,
|
|
@@ -74,6 +95,96 @@ Cada componente possui sua própria história no Storybook, permitindo visualiza
|
|
|
74
95
|
- Nativo: `storybook:ios` e `storybook:android`
|
|
75
96
|
- Web: `storybook:web` ([@storybook/react-native-web-vite](file:///Users/tegra/sebrae/storybook/dev/package.json#L80-L83))
|
|
76
97
|
|
|
98
|
+
As stories devem refletir o contrato real dos componentes e demonstrar:
|
|
99
|
+
|
|
100
|
+
- Uso básico
|
|
101
|
+
- Variações semânticas
|
|
102
|
+
- Estados visuais importantes
|
|
103
|
+
- Exemplos aderentes aos tokens do projeto
|
|
104
|
+
|
|
105
|
+
## 🎯 Tokens e Estilo
|
|
106
|
+
|
|
107
|
+
O projeto adota um sistema central de design tokens por aspecto. A estrutura atual fica em `components/styles/tokens/` e está organizada em módulos como:
|
|
108
|
+
|
|
109
|
+
- `palette`
|
|
110
|
+
- `colors`
|
|
111
|
+
- `surfaces`
|
|
112
|
+
- `elevations`
|
|
113
|
+
- `spacing` e `space`
|
|
114
|
+
- `typography`
|
|
115
|
+
- `radius`
|
|
116
|
+
- `borders`
|
|
117
|
+
- `opacity`
|
|
118
|
+
|
|
119
|
+
### Como consumir
|
|
120
|
+
|
|
121
|
+
Entrada principal compatível:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import tokens from 'vpt-sebraeds/components/styles/tokens'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Uso recomendado em componentes:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { StyleSheet, View } from 'react-native'
|
|
131
|
+
import SEText from 'vpt-sebraeds/components/SEText'
|
|
132
|
+
import tokens from 'vpt-sebraeds/components/styles/tokens'
|
|
133
|
+
|
|
134
|
+
const styles = StyleSheet.create({
|
|
135
|
+
card: {
|
|
136
|
+
backgroundColor: tokens.colors.surface.default,
|
|
137
|
+
borderColor: tokens.colors.border.default,
|
|
138
|
+
borderRadius: tokens.radius.sm,
|
|
139
|
+
borderWidth: tokens.borders.width.thin,
|
|
140
|
+
padding: tokens.space.md,
|
|
141
|
+
...tokens.elevations[1],
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
export function ExemploTokenizado() {
|
|
146
|
+
return (
|
|
147
|
+
<View style={styles.card}>
|
|
148
|
+
<SEText type="ns-heading-5">Título</SEText>
|
|
149
|
+
<SEText type="ns-sm-body" color={tokens.colors.text.secondary}>
|
|
150
|
+
Conteúdo seguindo os tokens do projeto
|
|
151
|
+
</SEText>
|
|
152
|
+
</View>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Regras importantes
|
|
158
|
+
|
|
159
|
+
- Componentes devem consumir tokens semânticos, não `palette`.
|
|
160
|
+
- Se um valor visual ainda não existir, ele deve ser adicionado primeiro em `components/styles/tokens/`.
|
|
161
|
+
- A diferença tipográfica entre iOS e Android já está encapsulada em `tokens/typography.ts`.
|
|
162
|
+
- `colors.js`, `fonts.js` e utilitários antigos existem apenas como camadas de compatibilidade durante a migração.
|
|
163
|
+
|
|
164
|
+
## 🧩 Composition Pattern
|
|
165
|
+
|
|
166
|
+
O padrão preferencial para novos componentes é composição. Quando um componente possui partes relacionadas entre si, ele deve expor subcomponentes e, se necessário, compartilhar configuração via Context.
|
|
167
|
+
|
|
168
|
+
Exemplo conceitual:
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
<Card>
|
|
172
|
+
<Card.Header>
|
|
173
|
+
<SEText type="ns-heading-5">Título</SEText>
|
|
174
|
+
</Card.Header>
|
|
175
|
+
<Card.Body>
|
|
176
|
+
<SEText type="ns-sm-body">Conteúdo</SEText>
|
|
177
|
+
</Card.Body>
|
|
178
|
+
</Card>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Boas práticas:
|
|
182
|
+
|
|
183
|
+
- Expor partes via `Parent.Child`, e não como exports avulsos.
|
|
184
|
+
- Compartilhar estilos/configuração por Context quando isso reduzir acoplamento.
|
|
185
|
+
- Compor estilos na ordem `[baseStyle, contextStyle, propStyle]`.
|
|
186
|
+
- Evitar sobrecarga de props quando a composição resolve melhor a API.
|
|
187
|
+
|
|
77
188
|
## 🔗 Integração com o Projeto Principal
|
|
78
189
|
|
|
79
190
|
Este Design System é um artefato do projeto principal [Sebrae Na Palma da Mão], um aplicativo móvel que funciona como uma agência do Sebrae na palma da mão. O aplicativo principal inclui diversas funcionalidades como:
|
|
@@ -202,6 +313,8 @@ yarn publish
|
|
|
202
313
|
## 🗂️ Estrutura do Projeto
|
|
203
314
|
|
|
204
315
|
- `components/` – componentes e histórias
|
|
316
|
+
- `components/styles/tokens/` – design tokens por aspecto
|
|
317
|
+
- `components/styles/tokens.ts` – porta de entrada compatível para tokens
|
|
205
318
|
- `src/` – ponto de entrada e exports da biblioteca
|
|
206
319
|
- `assets/` – imagens, ícones e fontes
|
|
207
320
|
- `.rnstorybook/` e `.storybook/` – configs de Storybook nativo e web
|
|
@@ -218,8 +331,9 @@ Antes de adicionar novos componentes ou fazer modificações:
|
|
|
218
331
|
2. Adicione a documentação apropriada no Storybook
|
|
219
332
|
3. Teste o componente em diferentes dispositivos
|
|
220
333
|
4. Certifique-se de que as alterações não quebram a compatibilidade com o projeto principal
|
|
221
|
-
|
|
222
|
-
|
|
334
|
+
5. Use tokens semânticos em vez de hardcodes visuais
|
|
335
|
+
6. Adote composição quando a estrutura do componente pedir subpartes reutilizáveis
|
|
336
|
+
7. Mantenha o estilo de código (ESLint/Prettier) e exports em [src/index.ts](file:///Users/tegra/sebrae/storybook/dev/src/index.ts)
|
|
223
337
|
## 📝 Licença
|
|
224
338
|
|
|
225
339
|
Este projeto está sob a licença MIT.
|
|
@@ -3,7 +3,7 @@ import { View, TouchableOpacity, StyleSheet, Animated, LayoutAnimation, Platform
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Icon from '../Icon';
|
|
5
5
|
import SEText from '../SEText';
|
|
6
|
-
import
|
|
6
|
+
import tokens from '../styles/tokens';
|
|
7
7
|
|
|
8
8
|
if (Platform.OS === 'android' && UIManager.setLayoutAnimationEnabledExperimental) {
|
|
9
9
|
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
@@ -77,7 +77,7 @@ const AccordionHeader = ({
|
|
|
77
77
|
overline,
|
|
78
78
|
label,
|
|
79
79
|
icon,
|
|
80
|
-
backgroundColor =
|
|
80
|
+
backgroundColor = tokens.colors.surface.subtle,
|
|
81
81
|
style,
|
|
82
82
|
titleStyle: customTitleStyle,
|
|
83
83
|
...props
|
|
@@ -105,30 +105,30 @@ const AccordionHeader = ({
|
|
|
105
105
|
const getIconColor = () => {
|
|
106
106
|
switch (variant) {
|
|
107
107
|
case 'success':
|
|
108
|
-
return colors.
|
|
108
|
+
return tokens.colors.feedback.success;
|
|
109
109
|
case 'alert':
|
|
110
|
-
return
|
|
110
|
+
return tokens.palette.yellow[700];
|
|
111
111
|
case 'error':
|
|
112
|
-
return colors.
|
|
112
|
+
return tokens.colors.feedback.error;
|
|
113
113
|
default:
|
|
114
|
-
return colors.
|
|
114
|
+
return tokens.colors.text.default;
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const getIconContainerBackgroundColor = () => {
|
|
119
119
|
switch (variant) {
|
|
120
120
|
case 'success':
|
|
121
|
-
return
|
|
121
|
+
return tokens.palette.green[200];
|
|
122
122
|
case 'alert':
|
|
123
|
-
return
|
|
123
|
+
return tokens.palette.yellow[200];
|
|
124
124
|
case 'error':
|
|
125
|
-
return
|
|
125
|
+
return tokens.palette.red[200];
|
|
126
126
|
default:
|
|
127
127
|
return 'transparent';
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
const getTextColor = () =>
|
|
131
|
+
const getTextColor = () => tokens.colors.text.secondary;
|
|
132
132
|
|
|
133
133
|
const isTransparent = !backgroundColor || backgroundColor === 'transparent' ||
|
|
134
134
|
backgroundColor.toLowerCase() === '#ffffff' || backgroundColor.toLowerCase() === '#fff' ||
|
|
@@ -156,7 +156,7 @@ const AccordionHeader = ({
|
|
|
156
156
|
styles.header,
|
|
157
157
|
getVariantStyles(),
|
|
158
158
|
isOpen && styles.headerOpen,
|
|
159
|
-
isTransparent && !isOpen && { borderBottomWidth: 1, borderBottomColor:
|
|
159
|
+
isTransparent && !isOpen && { borderBottomWidth: 1, borderBottomColor: tokens.colors.border.default, borderBottomLeftRadius: 0, borderBottomRightRadius: 0 },
|
|
160
160
|
style
|
|
161
161
|
]}
|
|
162
162
|
onPress={toggle}
|
|
@@ -187,7 +187,7 @@ const AccordionHeader = ({
|
|
|
187
187
|
</View>
|
|
188
188
|
|
|
189
189
|
<Animated.View style={{ transform: [{ rotate: rotateArrow }] }}>
|
|
190
|
-
<Icon name="arrow-down-s-line" size={24} color=
|
|
190
|
+
<Icon name="arrow-down-s-line" size={24} color={tokens.colors.text.secondary} />
|
|
191
191
|
</Animated.View>
|
|
192
192
|
</TouchableOpacity>
|
|
193
193
|
);
|
|
@@ -208,7 +208,7 @@ const AccordionContent = ({ children, style, backgroundColor, ...props }) => {
|
|
|
208
208
|
styles.content,
|
|
209
209
|
styles.contentOpen,
|
|
210
210
|
backgroundColor && { backgroundColor },
|
|
211
|
-
isTransparent && { borderBottomWidth: 1, borderBottomColor:
|
|
211
|
+
isTransparent && { borderBottomWidth: 1, borderBottomColor: tokens.colors.border.default, borderBottomLeftRadius: 0, borderBottomRightRadius: 0 },
|
|
212
212
|
style
|
|
213
213
|
]}
|
|
214
214
|
{...props}
|
|
@@ -221,16 +221,16 @@ const AccordionContent = ({ children, style, backgroundColor, ...props }) => {
|
|
|
221
221
|
const styles = StyleSheet.create({
|
|
222
222
|
container: {
|
|
223
223
|
overflow: 'hidden',
|
|
224
|
-
marginBottom:
|
|
224
|
+
marginBottom: tokens.space.xs,
|
|
225
225
|
},
|
|
226
226
|
header: {
|
|
227
227
|
flexDirection: 'row',
|
|
228
228
|
alignItems: 'center',
|
|
229
229
|
justifyContent: 'space-between',
|
|
230
|
-
paddingVertical:
|
|
231
|
-
paddingHorizontal:
|
|
232
|
-
borderRadius:
|
|
233
|
-
backgroundColor:
|
|
230
|
+
paddingVertical: tokens.space.md,
|
|
231
|
+
paddingHorizontal: tokens.space.md,
|
|
232
|
+
borderRadius: tokens.radius.sm,
|
|
233
|
+
backgroundColor: tokens.colors.surface.subtle,
|
|
234
234
|
},
|
|
235
235
|
headerOpen: {
|
|
236
236
|
borderBottomLeftRadius: 0,
|
|
@@ -242,9 +242,9 @@ const styles = StyleSheet.create({
|
|
|
242
242
|
flex: 1,
|
|
243
243
|
},
|
|
244
244
|
leadingIconContainer: {
|
|
245
|
-
padding:
|
|
246
|
-
borderRadius:
|
|
247
|
-
marginRight:
|
|
245
|
+
padding: tokens.space.xxs,
|
|
246
|
+
borderRadius: tokens.radius.pill,
|
|
247
|
+
marginRight: tokens.space.sm,
|
|
248
248
|
},
|
|
249
249
|
leadingIcon: {
|
|
250
250
|
// marginRight: 12, // Removed
|
|
@@ -254,23 +254,22 @@ const styles = StyleSheet.create({
|
|
|
254
254
|
justifyContent: 'center',
|
|
255
255
|
},
|
|
256
256
|
title: {
|
|
257
|
-
|
|
257
|
+
color: tokens.colors.text.default,
|
|
258
258
|
},
|
|
259
259
|
overline: {
|
|
260
|
-
fontSize:
|
|
261
|
-
|
|
262
|
-
marginBottom: 4,
|
|
260
|
+
fontSize: tokens.typography.fontSize.xxs,
|
|
261
|
+
marginBottom: tokens.space.xxs,
|
|
263
262
|
textTransform: 'uppercase',
|
|
264
|
-
letterSpacing:
|
|
263
|
+
letterSpacing: tokens.typography.letterSpacing.wide,
|
|
265
264
|
},
|
|
266
265
|
label: {
|
|
267
|
-
|
|
266
|
+
color: tokens.colors.text.default,
|
|
268
267
|
},
|
|
269
268
|
content: {
|
|
270
|
-
padding:
|
|
271
|
-
backgroundColor:
|
|
272
|
-
borderBottomLeftRadius:
|
|
273
|
-
borderBottomRightRadius:
|
|
269
|
+
padding: tokens.space.md,
|
|
270
|
+
backgroundColor: tokens.colors.surface.default,
|
|
271
|
+
borderBottomLeftRadius: tokens.radius.sm,
|
|
272
|
+
borderBottomRightRadius: tokens.radius.sm,
|
|
274
273
|
},
|
|
275
274
|
contentOpen: {
|
|
276
275
|
borderTopLeftRadius: 0,
|
|
@@ -284,17 +283,17 @@ const styles = StyleSheet.create({
|
|
|
284
283
|
// borderBottomColor: '#E2E9FC',
|
|
285
284
|
// },
|
|
286
285
|
headerSuccess: {
|
|
287
|
-
backgroundColor:
|
|
286
|
+
backgroundColor: tokens.colors.surface.subtle,
|
|
288
287
|
height: 40,
|
|
289
288
|
paddingVertical: 0,
|
|
290
289
|
},
|
|
291
290
|
headerAlert: {
|
|
292
|
-
backgroundColor:
|
|
291
|
+
backgroundColor: tokens.colors.surface.subtle,
|
|
293
292
|
height: 40,
|
|
294
293
|
paddingVertical: 0,
|
|
295
294
|
},
|
|
296
295
|
headerError: {
|
|
297
|
-
backgroundColor:
|
|
296
|
+
backgroundColor: tokens.colors.surface.subtle,
|
|
298
297
|
height: 40,
|
|
299
298
|
paddingVertical: 0,
|
|
300
299
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { View, TextInput, StyleSheet, TextInputProps
|
|
2
|
+
import { View, TextInput, StyleSheet, TextInputProps } from 'react-native';
|
|
3
3
|
import SEText from '../SEText';
|
|
4
|
+
import tokens from '../styles/tokens';
|
|
4
5
|
|
|
5
6
|
export interface InputTextProps extends TextInputProps {
|
|
6
7
|
/**
|
|
@@ -69,7 +70,7 @@ const InputUnderline: React.FC<InputTextProps> = ({
|
|
|
69
70
|
onFocus={handleFocus}
|
|
70
71
|
onBlur={handleBlur}
|
|
71
72
|
placeholder={placeholder}
|
|
72
|
-
placeholderTextColor=
|
|
73
|
+
placeholderTextColor={tokens.colors.text.secondary}
|
|
73
74
|
editable={!disabled}
|
|
74
75
|
textAlignVertical="center"
|
|
75
76
|
{...textInputProps}
|
|
@@ -84,28 +85,27 @@ const styles = StyleSheet.create({
|
|
|
84
85
|
width: '100%',
|
|
85
86
|
},
|
|
86
87
|
label: {
|
|
87
|
-
color:
|
|
88
|
-
marginBottom:
|
|
88
|
+
color: tokens.colors.text.default,
|
|
89
|
+
marginBottom: tokens.space.xs,
|
|
89
90
|
},
|
|
90
91
|
labelDisabled: {
|
|
91
|
-
color:
|
|
92
|
+
color: tokens.colors.text.disabled,
|
|
92
93
|
},
|
|
93
94
|
container: {
|
|
94
95
|
flexDirection: 'row',
|
|
95
96
|
alignItems: 'baseline',
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
borderBottomColor: '#96ACFF',
|
|
97
|
+
borderBottomWidth: tokens.borders.width.regular,
|
|
98
|
+
borderBottomColor: tokens.colors.border.default,
|
|
99
99
|
paddingHorizontal: 0,
|
|
100
|
-
paddingVertical:
|
|
100
|
+
paddingVertical: tokens.space.sm,
|
|
101
101
|
minHeight: 56,
|
|
102
102
|
},
|
|
103
103
|
containerFocused: {
|
|
104
104
|
flexDirection: 'row',
|
|
105
105
|
alignItems: 'baseline',
|
|
106
|
-
backgroundColor:
|
|
107
|
-
borderBottomWidth:
|
|
108
|
-
borderBottomColor:
|
|
106
|
+
backgroundColor: tokens.colors.background.default,
|
|
107
|
+
borderBottomWidth: tokens.borders.width.regular,
|
|
108
|
+
borderBottomColor: tokens.colors.border.focus,
|
|
109
109
|
paddingHorizontal: 0,
|
|
110
110
|
paddingVertical: 11,
|
|
111
111
|
minHeight: 56,
|
|
@@ -113,48 +113,44 @@ const styles = StyleSheet.create({
|
|
|
113
113
|
containerDisabled: {
|
|
114
114
|
flexDirection: 'row',
|
|
115
115
|
alignItems: 'baseline',
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
borderBottomColor: '#E5E7EB',
|
|
116
|
+
borderBottomWidth: tokens.borders.width.regular,
|
|
117
|
+
borderBottomColor: tokens.colors.border.disabled,
|
|
119
118
|
paddingHorizontal: 0,
|
|
120
|
-
paddingVertical:
|
|
119
|
+
paddingVertical: tokens.space.sm,
|
|
121
120
|
minHeight: 56,
|
|
122
121
|
},
|
|
123
122
|
input: {
|
|
124
123
|
flex: 1,
|
|
125
|
-
fontSize:
|
|
126
|
-
|
|
124
|
+
fontSize: tokens.typography.fontSize['2xl'],
|
|
125
|
+
lineHeight: tokens.typography.lineHeight.xl,
|
|
126
|
+
color: tokens.colors.text.secondary,
|
|
127
127
|
padding: 0,
|
|
128
128
|
margin: 0,
|
|
129
129
|
includeFontPadding: false,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
android: { fontFamily: 'NunitoSans_10pt-Regular' },
|
|
133
|
-
}),
|
|
130
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
131
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
134
132
|
},
|
|
135
133
|
inputFilled: {
|
|
136
134
|
flex: 1,
|
|
137
|
-
fontSize:
|
|
138
|
-
|
|
135
|
+
fontSize: tokens.typography.fontSize['2xl'],
|
|
136
|
+
lineHeight: tokens.typography.lineHeight.xl,
|
|
137
|
+
color: tokens.colors.text.brand,
|
|
139
138
|
padding: 0,
|
|
140
139
|
margin: 0,
|
|
141
140
|
includeFontPadding: false,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
android: { fontFamily: 'NunitoSans_10pt-Regular' },
|
|
145
|
-
}),
|
|
141
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
142
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
146
143
|
},
|
|
147
144
|
inputDisabled: {
|
|
148
145
|
flex: 1,
|
|
149
|
-
fontSize:
|
|
150
|
-
|
|
146
|
+
fontSize: tokens.typography.fontSize.md,
|
|
147
|
+
lineHeight: tokens.typography.lineHeight.md,
|
|
148
|
+
color: tokens.colors.text.disabled,
|
|
151
149
|
padding: 0,
|
|
152
150
|
margin: 0,
|
|
153
151
|
includeFontPadding: false,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
android: { fontFamily: 'NunitoSans_10pt-Regular' },
|
|
157
|
-
}),
|
|
152
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
153
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
158
154
|
},
|
|
159
155
|
});
|
|
160
156
|
|
|
@@ -4,7 +4,23 @@ import Icon from '../Icon';
|
|
|
4
4
|
import TooltipCard from '../TooltipCard';
|
|
5
5
|
import SEText from '../SEText';
|
|
6
6
|
import InputUnderline from './InputUnderline';
|
|
7
|
-
import
|
|
7
|
+
import tokens from '../styles/tokens';
|
|
8
|
+
|
|
9
|
+
const INPUT_COLORS = {
|
|
10
|
+
labelDefault: tokens.colors.text.default,
|
|
11
|
+
labelMuted: tokens.colors.text.disabled,
|
|
12
|
+
labelInfo: tokens.colors.text.secondary,
|
|
13
|
+
placeholder: tokens.colors.text.disabled,
|
|
14
|
+
borderDefault: tokens.colors.border.default,
|
|
15
|
+
borderFocus: tokens.colors.border.focus,
|
|
16
|
+
borderError: tokens.colors.border.error,
|
|
17
|
+
borderSuccess: tokens.colors.border.success,
|
|
18
|
+
borderDisabled: tokens.colors.border.subtle,
|
|
19
|
+
supportInfo: tokens.colors.state.focus,
|
|
20
|
+
supportSuccess: tokens.colors.feedback.success,
|
|
21
|
+
supportError: tokens.colors.feedback.error,
|
|
22
|
+
iconInfo: tokens.colors.text.secondary,
|
|
23
|
+
};
|
|
8
24
|
|
|
9
25
|
/**
|
|
10
26
|
* Componente de Input controlado e reutilizável com suporte a máscaras e estados de validação.
|
|
@@ -126,10 +142,10 @@ const Input = React.forwardRef((
|
|
|
126
142
|
};
|
|
127
143
|
|
|
128
144
|
const getLabelColor = () => {
|
|
129
|
-
if (disabled) return
|
|
130
|
-
if (error) return
|
|
131
|
-
if (success) return
|
|
132
|
-
return
|
|
145
|
+
if (disabled) return INPUT_COLORS.labelMuted;
|
|
146
|
+
if (error) return INPUT_COLORS.supportError;
|
|
147
|
+
if (success) return INPUT_COLORS.supportSuccess;
|
|
148
|
+
return INPUT_COLORS.labelDefault;
|
|
133
149
|
};
|
|
134
150
|
|
|
135
151
|
const getInputStyle = () => {
|
|
@@ -140,10 +156,10 @@ const Input = React.forwardRef((
|
|
|
140
156
|
};
|
|
141
157
|
|
|
142
158
|
const getSupportTextColor = () => {
|
|
143
|
-
if (error) return
|
|
144
|
-
if (success) return
|
|
145
|
-
if (disabled) return
|
|
146
|
-
return
|
|
159
|
+
if (error) return INPUT_COLORS.supportError;
|
|
160
|
+
if (success) return INPUT_COLORS.supportSuccess;
|
|
161
|
+
if (disabled) return INPUT_COLORS.labelMuted;
|
|
162
|
+
return INPUT_COLORS.supportInfo;
|
|
147
163
|
};
|
|
148
164
|
|
|
149
165
|
if (variant === 'underline') {
|
|
@@ -152,10 +168,10 @@ const Input = React.forwardRef((
|
|
|
152
168
|
|
|
153
169
|
const getLabelIconColor = () => {
|
|
154
170
|
if (labelIconColor) return labelIconColor;
|
|
155
|
-
if (disabled) return
|
|
156
|
-
if (error) return
|
|
157
|
-
if (success) return
|
|
158
|
-
return
|
|
171
|
+
if (disabled) return INPUT_COLORS.labelMuted;
|
|
172
|
+
if (error) return INPUT_COLORS.supportError;
|
|
173
|
+
if (success) return INPUT_COLORS.supportSuccess;
|
|
174
|
+
return INPUT_COLORS.labelInfo;
|
|
159
175
|
};
|
|
160
176
|
|
|
161
177
|
const renderLabel = () => {
|
|
@@ -203,21 +219,21 @@ const Input = React.forwardRef((
|
|
|
203
219
|
editable={!disabled}
|
|
204
220
|
keyboardType={getKeyboardType()}
|
|
205
221
|
maxLength={getMaxLength()}
|
|
206
|
-
placeholderTextColor=
|
|
222
|
+
placeholderTextColor={INPUT_COLORS.placeholder}
|
|
207
223
|
{...textInputProps}
|
|
208
224
|
/>
|
|
209
225
|
{showInfoIcon && !disabled && tooltipProps ? (
|
|
210
226
|
<TooltipCard
|
|
211
227
|
{...tooltipProps}
|
|
212
228
|
trigger={
|
|
213
|
-
<Icon name="information-line" size={20} color=
|
|
229
|
+
<Icon name="information-line" size={20} color={INPUT_COLORS.iconInfo} />
|
|
214
230
|
}
|
|
215
231
|
/>
|
|
216
232
|
) : showInfoIcon && !disabled && (
|
|
217
|
-
<Icon name="information-line" size={20} color=
|
|
233
|
+
<Icon name="information-line" size={20} color={INPUT_COLORS.iconInfo} />
|
|
218
234
|
)}
|
|
219
|
-
{error && <Icon name="close-line" size={20} color=
|
|
220
|
-
{success && <Icon name="check-line" size={20} color=
|
|
235
|
+
{error && <Icon name="close-line" size={20} color={INPUT_COLORS.supportError} />}
|
|
236
|
+
{success && <Icon name="check-line" size={20} color={INPUT_COLORS.supportSuccess} />}
|
|
221
237
|
</View>
|
|
222
238
|
{supportText && <SEText type="ns-xs-body" color={getSupportTextColor()}>{supportText}</SEText>}
|
|
223
239
|
</View>
|
|
@@ -240,71 +256,79 @@ const styles = StyleSheet.create({
|
|
|
240
256
|
container: {
|
|
241
257
|
flexDirection: 'row',
|
|
242
258
|
alignItems: 'center',
|
|
243
|
-
borderWidth:
|
|
244
|
-
borderColor:
|
|
245
|
-
borderRadius:
|
|
246
|
-
paddingHorizontal:
|
|
259
|
+
borderWidth: tokens.borders.width.regular,
|
|
260
|
+
borderColor: INPUT_COLORS.borderDefault,
|
|
261
|
+
borderRadius: tokens.radius.sm,
|
|
262
|
+
paddingHorizontal: tokens.space.sm,
|
|
247
263
|
},
|
|
248
264
|
containerFocused: {
|
|
249
265
|
flexDirection: 'row',
|
|
250
266
|
alignItems: 'center',
|
|
251
|
-
borderWidth:
|
|
252
|
-
borderColor:
|
|
253
|
-
borderRadius:
|
|
254
|
-
paddingHorizontal:
|
|
267
|
+
borderWidth: tokens.borders.width.regular,
|
|
268
|
+
borderColor: INPUT_COLORS.borderFocus,
|
|
269
|
+
borderRadius: tokens.radius.sm,
|
|
270
|
+
paddingHorizontal: tokens.space.sm,
|
|
255
271
|
},
|
|
256
272
|
containerError: {
|
|
257
273
|
flexDirection: 'row',
|
|
258
274
|
alignItems: 'center',
|
|
259
|
-
borderWidth:
|
|
260
|
-
borderColor:
|
|
261
|
-
borderRadius:
|
|
262
|
-
paddingHorizontal:
|
|
275
|
+
borderWidth: tokens.borders.width.regular,
|
|
276
|
+
borderColor: INPUT_COLORS.borderError,
|
|
277
|
+
borderRadius: tokens.radius.sm,
|
|
278
|
+
paddingHorizontal: tokens.space.sm,
|
|
263
279
|
},
|
|
264
280
|
containerSuccess: {
|
|
265
281
|
flexDirection: 'row',
|
|
266
282
|
alignItems: 'center',
|
|
267
|
-
borderWidth:
|
|
268
|
-
borderColor:
|
|
269
|
-
borderRadius:
|
|
270
|
-
paddingHorizontal:
|
|
283
|
+
borderWidth: tokens.borders.width.regular,
|
|
284
|
+
borderColor: INPUT_COLORS.borderSuccess,
|
|
285
|
+
borderRadius: tokens.radius.sm,
|
|
286
|
+
paddingHorizontal: tokens.space.sm,
|
|
271
287
|
},
|
|
272
288
|
containerDisabled: {
|
|
273
289
|
flexDirection: 'row',
|
|
274
290
|
alignItems: 'center',
|
|
275
|
-
borderWidth:
|
|
276
|
-
borderColor:
|
|
277
|
-
borderRadius:
|
|
278
|
-
paddingHorizontal:
|
|
291
|
+
borderWidth: tokens.borders.width.regular,
|
|
292
|
+
borderColor: INPUT_COLORS.borderDisabled,
|
|
293
|
+
borderRadius: tokens.radius.sm,
|
|
294
|
+
paddingHorizontal: tokens.space.sm,
|
|
279
295
|
},
|
|
280
296
|
input: {
|
|
281
297
|
flex: 1,
|
|
282
298
|
height: 40,
|
|
283
|
-
color:
|
|
284
|
-
fontSize:
|
|
285
|
-
|
|
299
|
+
color: INPUT_COLORS.labelDefault,
|
|
300
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
301
|
+
lineHeight: tokens.typography.lineHeight.sm,
|
|
302
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
303
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
286
304
|
},
|
|
287
305
|
inputError: {
|
|
288
306
|
flex: 1,
|
|
289
307
|
height: 40,
|
|
290
|
-
color:
|
|
291
|
-
fontSize:
|
|
292
|
-
|
|
308
|
+
color: INPUT_COLORS.supportError,
|
|
309
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
310
|
+
lineHeight: tokens.typography.lineHeight.sm,
|
|
311
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
312
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
293
313
|
},
|
|
294
314
|
inputSuccess: {
|
|
295
315
|
flex: 1,
|
|
296
316
|
height: 40,
|
|
297
|
-
color:
|
|
298
|
-
fontSize:
|
|
299
|
-
|
|
317
|
+
color: INPUT_COLORS.supportSuccess,
|
|
318
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
319
|
+
lineHeight: tokens.typography.lineHeight.sm,
|
|
320
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
321
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
300
322
|
},
|
|
301
323
|
inputDisabled: {
|
|
302
324
|
flex: 1,
|
|
303
325
|
height: 40,
|
|
304
|
-
color:
|
|
305
|
-
fontSize:
|
|
306
|
-
|
|
326
|
+
color: INPUT_COLORS.labelInfo,
|
|
327
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
328
|
+
lineHeight: tokens.typography.lineHeight.sm,
|
|
329
|
+
fontFamily: tokens.typography.fontFamily.regular,
|
|
330
|
+
fontWeight: tokens.typography.fontWeight.regular,
|
|
307
331
|
},
|
|
308
332
|
});
|
|
309
333
|
|
|
310
|
-
export default Input;
|
|
334
|
+
export default Input;
|