@medway-ui/native 1.7.1 → 1.7.2
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 +89 -89
- package/lib/commonjs/editor/editorHtml.generated.js +1 -1
- package/lib/commonjs/editor/editorHtml.generated.js.map +1 -1
- package/lib/module/editor/editorHtml.generated.js +1 -1
- package/lib/module/editor/editorHtml.generated.js.map +1 -1
- package/lib/typescript/editor/editorHtml.generated.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/editor/editorHtml.generated.ts +1 -1
package/README.md
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
# @medway-ui/native
|
|
2
2
|
|
|
3
|
-
React Native
|
|
3
|
+
Componentes React Native para iOS e Android (Expo). Mesma API visual do `@medway-ui/core`, construída sobre NativeWind + `@rn-primitives`.
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**Versão mínima recomendada para setup brownfield via npm:** `1.1.2+`
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Instalação
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install @medway-ui/native @medway-ui/core @medway-ui/icons \
|
|
13
13
|
class-variance-authority clsx tailwind-merge nativewind \
|
|
14
14
|
react-native-reanimated react-native-svg
|
|
15
15
|
|
|
16
|
-
# Expo (
|
|
17
|
-
# expo-linear-gradient + masked-view:
|
|
18
|
-
#
|
|
16
|
+
# Expo (alinha as versões com o seu SDK)
|
|
17
|
+
# expo-linear-gradient + masked-view: peers opcionais para o anel `animated` do IndexLevel
|
|
18
|
+
# e as variantes com gradiente do Toast (fallback para cor sólida quando ausentes)
|
|
19
19
|
npx expo install react-native-reanimated react-native-svg expo-linear-gradient @react-native-masked-view/masked-view
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
`react-native-safe-area-context`
|
|
22
|
+
`react-native-safe-area-context` é uma peer dependency opcional usada pelo `ToastProvider` para o inset superior. Apps Expo normalmente já têm (e um `SafeAreaProvider` na raiz via React Navigation). Sem um provider, o toast volta para o offset anterior de `pt-12`.
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
npx expo install react-native-safe-area-context
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Apps brownfield que já usam `babel-plugin-module-resolver` com aliases `@/` apontando para o `src/` do app também precisam de:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
31
|
npm install -D babel-plugin-module-resolver
|
|
@@ -33,11 +33,11 @@ npm install -D babel-plugin-module-resolver
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## Setup brownfield (Expo + UI legada / Restyle)
|
|
37
37
|
|
|
38
|
-
NativeWind
|
|
38
|
+
O NativeWind se aplica **apenas** ao `@medway-ui/native` + telas/componentes que usam a biblioteca (ex.: `src/pages/medway-ui/`, features parcialmente migradas).
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
Implementação de referência: **test-prep-app** (`metro.config.js`, `babel.config.js`, `tailwind.config.js`, `src/pages/medway-ui/`).
|
|
41
41
|
|
|
42
42
|
### 1. `metro.config.js`
|
|
43
43
|
|
|
@@ -47,17 +47,17 @@ const { withMedwayUi } = require("@medway-ui/native/metro");
|
|
|
47
47
|
|
|
48
48
|
module.exports = withMedwayUi(getDefaultConfig(__dirname), {
|
|
49
49
|
projectRoot: __dirname,
|
|
50
|
-
// linkedMedwayUiRoot:
|
|
50
|
+
// linkedMedwayUiRoot: detectado automaticamente (npm ou monorepo)
|
|
51
51
|
});
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
|
|
|
54
|
+
| Cenário | `linkedMedwayUiRoot` |
|
|
55
55
|
| --- | --- |
|
|
56
|
-
| npm
|
|
57
|
-
| Monorepo
|
|
58
|
-
| Symlink `file:../medway-ui/native` |
|
|
56
|
+
| Pacotes npm (`npm install`) | **Omita**: detecta `node_modules/@medway-ui` automaticamente |
|
|
57
|
+
| Monorepo com clone local | `"../medway-ui"` (opcional; também detectado automaticamente) |
|
|
58
|
+
| Symlink `file:../medway-ui/native` | Detectado automaticamente como monorepo |
|
|
59
59
|
|
|
60
|
-
>
|
|
60
|
+
> **Não** defina `resolveNativeSource: false`: a lib compilada ainda referencia aliases internos `@/`. O padrão (`true`) resolve para `native/src` e funciona com npm.
|
|
61
61
|
|
|
62
62
|
### 2. `tailwind.config.js`
|
|
63
63
|
|
|
@@ -68,19 +68,19 @@ module.exports = createMedwayUiTailwindConfig({
|
|
|
68
68
|
projectRoot: __dirname,
|
|
69
69
|
content: [
|
|
70
70
|
"./src/pages/medway-ui/**/*.{ts,tsx}",
|
|
71
|
-
//
|
|
71
|
+
// adicione pastas extras que usam className + @medway-ui/native:
|
|
72
72
|
// "./src/pages/MyFeature/**/*.{ts,tsx}",
|
|
73
73
|
],
|
|
74
74
|
});
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
`createMedwayUiTailwindConfig`
|
|
77
|
+
`createMedwayUiTailwindConfig` já inclui os globs de `node_modules/@medway-ui/native/src` e carrega os tokens de `@medway-ui/core` (compatível com Node 22+).
|
|
78
78
|
|
|
79
79
|
### 3. `babel.config.js`
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
O preset padrão do app **não** deve habilitar o NativeWind globalmente. Use `createBrownfieldOverride` para restringir o NativeWind à biblioteca + pasta de telas migradas.
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Se o app define aliases `@/` para `./src/*` via `babel-plugin-module-resolver`, você **precisa** redirecionar os imports `@/` dos arquivos do `@medway-ui/native` para o código-fonte da biblioteca. Caso contrário, imports como `@/components/Badge` resolvem para o `src/` do app e quebram o bundle.
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
86
|
const {
|
|
@@ -102,14 +102,14 @@ module.exports = function (api) {
|
|
|
102
102
|
alias: {
|
|
103
103
|
"@/components": "./src/components",
|
|
104
104
|
"@/pages": "./src/pages",
|
|
105
|
-
// ...
|
|
105
|
+
// ... outros aliases do app
|
|
106
106
|
},
|
|
107
107
|
resolvePath(sourcePath, currentFile) {
|
|
108
108
|
return resolveMedwayUiAlias(sourcePath, currentFile);
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
],
|
|
112
|
-
//
|
|
112
|
+
// outros plugins do app (sem reanimated aqui)
|
|
113
113
|
];
|
|
114
114
|
|
|
115
115
|
return {
|
|
@@ -118,10 +118,10 @@ module.exports = function (api) {
|
|
|
118
118
|
overrides: [
|
|
119
119
|
createBrownfieldOverride({
|
|
120
120
|
projectRoot: __dirname,
|
|
121
|
-
appPagesDir: "medway-ui", // src/pages
|
|
121
|
+
appPagesDir: "medway-ui", // subpasta de src/pages com as telas NativeWind
|
|
122
122
|
plugins: [
|
|
123
|
-
//
|
|
124
|
-
"react-native-reanimated/plugin", //
|
|
123
|
+
// repita os plugins necessários no escopo do medway-ui
|
|
124
|
+
"react-native-reanimated/plugin", // sempre por último
|
|
125
125
|
],
|
|
126
126
|
}),
|
|
127
127
|
],
|
|
@@ -129,11 +129,11 @@ module.exports = function (api) {
|
|
|
129
129
|
};
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
Apps **
|
|
132
|
+
Apps **sem** aliases `@/` no Babel não precisam de `createMedwayUiAliasResolver`.
|
|
133
133
|
|
|
134
134
|
### 4. Provider + CSS
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
Envolva a subárvore que usa `@medway-ui/native` com `MedwayUiProvider` e importe o CSS uma única vez:
|
|
137
137
|
|
|
138
138
|
```tsx
|
|
139
139
|
import { MedwayUiProvider } from "@medway-ui/native/setup";
|
|
@@ -148,7 +148,7 @@ function MyScreen() {
|
|
|
148
148
|
}
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
**Dark mode:**
|
|
151
|
+
**Dark mode:** passe `colorScheme="light" | "dark"` quando o app já resolve o tema (Redux, Zustand, etc.):
|
|
152
152
|
|
|
153
153
|
```tsx
|
|
154
154
|
<MedwayUiProvider colorScheme={appColorScheme}>
|
|
@@ -156,13 +156,13 @@ function MyScreen() {
|
|
|
156
156
|
</MedwayUiProvider>
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
`MedwayUiProvider`
|
|
159
|
+
`MedwayUiProvider` inclui o `PortalHost` (obrigatório para Select, Dialog, Popover, Tooltip).
|
|
160
160
|
|
|
161
|
-
>
|
|
161
|
+
> **Não** importe `@medway-ui/core/tokens.css` diretamente: é incompatível com o NativeWind v4. Os tokens vêm de `setup/global.css` + `setup/tokens.native.css`.
|
|
162
162
|
|
|
163
|
-
### 5.
|
|
163
|
+
### 5. Navigator automático (catálogo / telas isoladas)
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
Crie uma única vez `src/pages/medway-ui/navigator.tsx`:
|
|
166
166
|
|
|
167
167
|
```tsx
|
|
168
168
|
import { createMedwayUiNavigator, MedwayUiProvider } from "@medway-ui/native/setup";
|
|
@@ -183,17 +183,17 @@ function MedwayUiRoot() {
|
|
|
183
183
|
export { MedwayUiRoot, MedwayUiNavigator };
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
Registre no stack do app:
|
|
187
187
|
|
|
188
188
|
```tsx
|
|
189
189
|
<Stack.Screen name="MedwayUi" component={MedwayUiRoot} options={{ headerShown: false }} />
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
Nova tela = nova pasta `src/pages/medway-ui/MyScreen/index.tsx`, sem registro manual de rota.
|
|
193
193
|
|
|
194
|
-
### 6.
|
|
194
|
+
### 6. Usando componentes em telas existentes (mistura de Restyle + Medway UI)
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
Padrão usado no Content Hub e em features parcialmente migradas:
|
|
197
197
|
|
|
198
198
|
```tsx
|
|
199
199
|
import { Button, CardNews } from "@medway-ui/native";
|
|
@@ -211,11 +211,11 @@ function ContentHubScreen() {
|
|
|
211
211
|
}
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
Adicione a pasta da feature ao `content` do `tailwind.config.js`.
|
|
215
215
|
|
|
216
216
|
---
|
|
217
217
|
|
|
218
|
-
##
|
|
218
|
+
## Desenvolvimento em monorepo (`file:../medway-ui/native`)
|
|
219
219
|
|
|
220
220
|
```json
|
|
221
221
|
{
|
|
@@ -224,32 +224,32 @@ Add the feature folder to `content` in `tailwind.config.js`.
|
|
|
224
224
|
}
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
Metro
|
|
227
|
+
Metro e Babel detectam o clone local automaticamente. Depois de mudanças na biblioteca:
|
|
228
228
|
|
|
229
229
|
```bash
|
|
230
|
-
cd ../medway-ui/native && npm run build:lib #
|
|
230
|
+
cd ../medway-ui/native && npm run build:lib # se estiver testando a lib compilada
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
Reinicie o Metro com cache limpo: `npx expo start --clear`.
|
|
234
234
|
|
|
235
235
|
---
|
|
236
236
|
|
|
237
|
-
##
|
|
237
|
+
## Solução de problemas
|
|
238
238
|
|
|
239
|
-
|
|
|
239
|
+
| Erro | Causa | Correção |
|
|
240
240
|
| --- | --- | --- |
|
|
241
|
-
| `Unable to resolve .../src/components/Badge` |
|
|
242
|
-
| `Unable to resolve @/lib/medwayIcons` | Bug
|
|
243
|
-
| `Unable to resolve ../../../../../src/...`
|
|
244
|
-
| Tokens / tailwind
|
|
245
|
-
| NativeWind
|
|
246
|
-
| Select/Dialog
|
|
241
|
+
| `Unable to resolve .../src/components/Badge` | Alias `@/` do app sobrescreve o `@/` da lib | Adicione `createMedwayUiAliasResolver` no Babel |
|
|
242
|
+
| `Unable to resolve @/lib/medwayIcons` | Bug no `@medway-ui/native@1.1.1` | Atualize para `1.1.2+` |
|
|
243
|
+
| `Unable to resolve ../../../../../src/...` a partir de `lib/module/` | `resolveNativeSource: false` | Remova a opção (use o padrão `true`) |
|
|
244
|
+
| Tokens / tailwind não carregam (Node 22+) | `require` de `.ts` dentro de `node_modules` | Use `@medway-ui/native@1.1.2+` (`createMedwayUiTailwindConfig` usa fallback com jiti) |
|
|
245
|
+
| Estilos do NativeWind não aplicados | Arquivo fora do escopo brownfield | Mova para `src/pages/medway-ui/` ou adicione um glob no tailwind |
|
|
246
|
+
| Select/Dialog não abre | `PortalHost` ausente | Use `MedwayUiProvider` |
|
|
247
247
|
|
|
248
248
|
---
|
|
249
249
|
|
|
250
|
-
##
|
|
250
|
+
## Setup greenfield (app 100% NativeWind)
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
Para apps novos, sem UI legada:
|
|
253
253
|
|
|
254
254
|
```js
|
|
255
255
|
// babel.config.js
|
|
@@ -275,11 +275,11 @@ module.exports = withMedwayUi(getDefaultConfig(__dirname), {
|
|
|
275
275
|
});
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
Importe `@medway-ui/native/setup/global.css` no layout raiz.
|
|
279
279
|
|
|
280
280
|
---
|
|
281
281
|
|
|
282
|
-
##
|
|
282
|
+
## Uso
|
|
283
283
|
|
|
284
284
|
```tsx
|
|
285
285
|
import {
|
|
@@ -297,11 +297,11 @@ export default function Screen() {
|
|
|
297
297
|
return (
|
|
298
298
|
<>
|
|
299
299
|
<Button variant="regular" size="md" onPress={() => {}}>
|
|
300
|
-
|
|
300
|
+
Continuar
|
|
301
301
|
</Button>
|
|
302
302
|
|
|
303
303
|
<Input
|
|
304
|
-
label="
|
|
304
|
+
label="E-mail"
|
|
305
305
|
type="email"
|
|
306
306
|
size="lg"
|
|
307
307
|
value={email}
|
|
@@ -312,8 +312,8 @@ export default function Screen() {
|
|
|
312
312
|
<Alert variant="success" onClose={() => {}}>
|
|
313
313
|
<AlertContainer>
|
|
314
314
|
<AlertContent>
|
|
315
|
-
<AlertTitle>
|
|
316
|
-
<AlertDescription>
|
|
315
|
+
<AlertTitle>Pronto</AlertTitle>
|
|
316
|
+
<AlertDescription>Operação concluída com sucesso.</AlertDescription>
|
|
317
317
|
</AlertContent>
|
|
318
318
|
</AlertContainer>
|
|
319
319
|
</Alert>
|
|
@@ -324,9 +324,9 @@ export default function Screen() {
|
|
|
324
324
|
}
|
|
325
325
|
```
|
|
326
326
|
|
|
327
|
-
##
|
|
327
|
+
## Ícones
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
O pacote `@medway-ui/icons` inclui um entry point nativo:
|
|
330
330
|
|
|
331
331
|
```tsx
|
|
332
332
|
import { Check, CloseMd } from "@medway-ui/icons/native";
|
|
@@ -334,53 +334,53 @@ import { Check, CloseMd } from "@medway-ui/icons/native";
|
|
|
334
334
|
|
|
335
335
|
---
|
|
336
336
|
|
|
337
|
-
##
|
|
337
|
+
## Componentes: status
|
|
338
338
|
|
|
339
|
-
|
|
|
339
|
+
| Componente | Status | Notas |
|
|
340
340
|
| --- | --- | --- |
|
|
341
|
-
| Button | ✅ |
|
|
341
|
+
| Button | ✅ | Variantes, loading, badge, ponto de alerta |
|
|
342
342
|
| Input | ✅ | text, email, password, numeric |
|
|
343
|
-
| Alert | ✅ |
|
|
344
|
-
| Badge | ✅ |
|
|
345
|
-
| Loading | ✅ | Reanimated
|
|
346
|
-
| LoadingOverlay | ✅ | Card + Modal
|
|
343
|
+
| Alert | ✅ | Subcomponentes, todas as variantes |
|
|
344
|
+
| Badge | ✅ | Variantes, só ícone |
|
|
345
|
+
| Loading | ✅ | Spin com Reanimated |
|
|
346
|
+
| LoadingOverlay | ✅ | Overlay de Card + Modal, ícone central customizável |
|
|
347
347
|
| Checkbox | ✅ | @rn-primitives/checkbox |
|
|
348
348
|
| RadioGroup | ✅ | @rn-primitives/radio-group |
|
|
349
349
|
| Switch | ✅ | @rn-primitives/switch |
|
|
350
350
|
| Select | ✅ | @rn-primitives/select |
|
|
351
351
|
| Label | ✅ | Pressable + Text |
|
|
352
|
-
| Separator | ✅ | View 1px |
|
|
352
|
+
| Separator | ✅ | View de 1px |
|
|
353
353
|
| Dialog | ✅ | @rn-primitives/dialog |
|
|
354
354
|
| AlertDialog | ✅ | @rn-primitives/alert-dialog |
|
|
355
|
-
| Sheet | ✅ | @rn-primitives/dialog (
|
|
356
|
-
| Tag | ✅ | 16+
|
|
357
|
-
| Toast | ✅ | useToast + toast();
|
|
355
|
+
| Sheet | ✅ | @rn-primitives/dialog (ciente do lado) |
|
|
356
|
+
| Tag | ✅ | 16+ variantes |
|
|
357
|
+
| Toast | ✅ | useToast + toast(); variantes com gradiente + inset de safe area |
|
|
358
358
|
| Tooltip | ✅ | @rn-primitives/tooltip |
|
|
359
359
|
| Popover | ✅ | @rn-primitives/popover |
|
|
360
360
|
| Skeleton | ✅ | Shimmer |
|
|
361
361
|
| Avatar | ✅ | @rn-primitives/avatar |
|
|
362
362
|
| FallbackImage | ✅ | react-native-svg |
|
|
363
|
-
| CardNews | ✅ |
|
|
364
|
-
| IndexLevel | ✅ |
|
|
363
|
+
| CardNews | ✅ | Card composable (Content Hub) |
|
|
364
|
+
| IndexLevel | ✅ | Níveis p/h/m/l, variantes, anel com gradiente `animated` |
|
|
365
365
|
| Tabs | ✅ | Tabs, TabsList, TabsTrigger, TabsContent |
|
|
366
|
-
| Chip | ✅ |
|
|
367
|
-
| Choice | ✅ |
|
|
368
|
-
| Filter | ✅ | Pill
|
|
369
|
-
| Text | ✅ |
|
|
370
|
-
| ThemedIcon | ✅ |
|
|
366
|
+
| Chip | ✅ | Tamanhos e variantes |
|
|
367
|
+
| Choice | ✅ | Pill selecionável com cores do tema |
|
|
368
|
+
| Filter | ✅ | Pill com critérios e indicador de dropdown |
|
|
369
|
+
| Text | ✅ | Resolução da fonte Montserrat |
|
|
370
|
+
| ThemedIcon | ✅ | Ícone colorido por token do tema |
|
|
371
371
|
| DropdownMenu | ✅ | @rn-primitives/dropdown-menu |
|
|
372
|
-
| Carousel | ✅ |
|
|
373
|
-
| EmptyState | ✅ |
|
|
372
|
+
| Carousel | ✅ | Slides de mídia e de métrica |
|
|
373
|
+
| EmptyState | ✅ | Placeholder de lista/tela vazia |
|
|
374
374
|
| Feed | ✅ | Feed, FeedTitle, FeedComposer |
|
|
375
|
-
| FeedNotice | ✅ |
|
|
376
|
-
| Feedback | ✅ |
|
|
377
|
-
| InvitePopover | ✅ |
|
|
378
|
-
| LeaderboardCard | ✅ |
|
|
379
|
-
| MemberRow | ✅ |
|
|
380
|
-
| PageHeader | ✅ |
|
|
381
|
-
| PostForm | ✅ |
|
|
382
|
-
| PrizeCollection | ✅ |
|
|
383
|
-
| SectionHeader | ✅ |
|
|
375
|
+
| FeedNotice | ✅ | Banner de aviso do feed |
|
|
376
|
+
| Feedback | ✅ | Card de feedback |
|
|
377
|
+
| InvitePopover | ✅ | Popover de convite composable |
|
|
378
|
+
| LeaderboardCard | ✅ | Cabeçalho e lista ranqueada |
|
|
379
|
+
| MemberRow | ✅ | Linha de membro com indicador de posição |
|
|
380
|
+
| PageHeader | ✅ | Cabeçalho de tela |
|
|
381
|
+
| PostForm | ✅ | Formulário de post composable (mídia, data/hora, opções) |
|
|
382
|
+
| PrizeCollection | ✅ | Estatísticas, prateleira, linhas e itens |
|
|
383
|
+
| SectionHeader | ✅ | Cabeçalho com título de seção |
|
|
384
384
|
| Progress | 🔜 | @rn-primitives/progress |
|
|
385
385
|
| ProgressCircle | 🔜 | react-native-svg |
|
|
386
386
|
| Cards | 🔜 | CardModule, CardLesson, etc. |
|