@solucx/react-native-solucx-widget 0.1.15 → 0.1.16
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.intern.md +513 -513
- package/README.md +285 -285
- package/package.json +23 -23
- package/src/SoluCXWidget.tsx +119 -119
- package/src/__tests__/urlUtils.test.ts +56 -56
- package/src/__tests__/useWidgetState.test.ts +188 -188
- package/src/components/CloseButton.tsx +36 -36
- package/src/components/InlineWidget.tsx +36 -36
- package/src/components/ModalWidget.tsx +59 -59
- package/src/components/OverlayWidget.tsx +88 -88
- package/src/constants/webViewConstants.ts +14 -14
- package/src/hooks/index.ts +2 -2
- package/src/hooks/useHeightAnimation.ts +22 -22
- package/src/hooks/useWidgetHeight.ts +38 -38
- package/src/hooks/useWidgetState.ts +101 -101
- package/src/index.ts +8 -8
- package/src/interfaces/WidgetData.ts +19 -19
- package/src/interfaces/WidgetOptions.ts +7 -7
- package/src/interfaces/WidgetResponse.ts +15 -15
- package/src/interfaces/WidgetSamplerLog.ts +5 -5
- package/src/interfaces/index.ts +23 -23
- package/src/services/storage.ts +20 -20
- package/src/services/widgetEventService.ts +126 -111
- package/src/services/widgetValidationService.ts +86 -86
- package/src/styles/widgetStyles.ts +58 -58
- package/src/utils/urlUtils.ts +13 -13
package/README.md
CHANGED
|
@@ -1,285 +1,285 @@
|
|
|
1
|
-
# @solucx/react-native-solucx-widget
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/@solucx%2Freact-native-solucx-widget)
|
|
4
|
-
[](https://reactnative.dev/)
|
|
5
|
-
[](https://expo.dev/)
|
|
6
|
-
[](https://www.typescriptlang.org/)
|
|
7
|
-
[](https://developer.apple.com/ios/)
|
|
8
|
-
[](https://developer.android.com/)
|
|
9
|
-
[](LICENSE)
|
|
10
|
-
|
|
11
|
-
Um widget React Native modular para coleta de feedback e pesquisas de satisfação, desenvolvido pela SoluCX seguindo princípios de Clean Code e arquitetura escalável.
|
|
12
|
-
|
|
13
|
-
## 🛠️ Tecnologias
|
|
14
|
-
|
|
15
|
-

|
|
16
|
-

|
|
17
|
-

|
|
18
|
-

|
|
19
|
-

|
|
20
|
-
|
|
21
|
-
## 📋 Visão Geral
|
|
22
|
-
|
|
23
|
-
O SoluCX Widget permite integrar pesquisas de satisfação diretamente em aplicações React Native/Expo de forma simples e flexível. Desenvolvido para empresas que precisam coletar feedback em tempo real através de diferentes modalidades de apresentação.
|
|
24
|
-
|
|
25
|
-
### 🎯 Principais Características
|
|
26
|
-
|
|
27
|
-
- **4 Modos de Renderização**: Bottom, Top, Modal e Inline
|
|
28
|
-
- **Persistência Automática**: Controle inteligente de frequência
|
|
29
|
-
- **Comunicação WebView**: Integração transparente com plataforma SoluCX
|
|
30
|
-
- **TypeScript**: Totalmente tipado para melhor experiência de desenvolvimento
|
|
31
|
-
- **Performático**: Carregamento otimizado e cache local
|
|
32
|
-
|
|
33
|
-
## 🚀 Instalação
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm install @solucx/react-native-solucx-widget
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 🎛️ Uso Básico
|
|
40
|
-
|
|
41
|
-
```tsx
|
|
42
|
-
import React from 'react';
|
|
43
|
-
import { SoluCXWidget } from '@solucx/react-native-solucx-widget';
|
|
44
|
-
|
|
45
|
-
export default function MyScreen() {
|
|
46
|
-
return (
|
|
47
|
-
<SoluCXWidget
|
|
48
|
-
soluCXKey='sua-chave-solucx'
|
|
49
|
-
type='bottom'
|
|
50
|
-
data={{
|
|
51
|
-
journey: 'checkout_flow',
|
|
52
|
-
name: 'João Silva',
|
|
53
|
-
email: 'joao@email.com',
|
|
54
|
-
store_id: 'loja_01',
|
|
55
|
-
amount: 150.0
|
|
56
|
-
}}
|
|
57
|
-
options={{
|
|
58
|
-
height: 400
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## 📱 Modos de Renderização
|
|
66
|
-
|
|
67
|
-
### Bottom (Padrão)
|
|
68
|
-
|
|
69
|
-
Widget fixo na parte inferior da tela, ideal para feedback não intrusivo.
|
|
70
|
-
|
|
71
|
-
```tsx
|
|
72
|
-
<SoluCXWidget type='bottom' {...props} />
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Top
|
|
76
|
-
|
|
77
|
-
Widget fixo no topo da tela, perfeito para notificações importantes.
|
|
78
|
-
|
|
79
|
-
```tsx
|
|
80
|
-
<SoluCXWidget type='top' {...props} />
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Modal
|
|
84
|
-
|
|
85
|
-
Sobreposição centralizada que bloqueia interação com o fundo.
|
|
86
|
-
|
|
87
|
-
```tsx
|
|
88
|
-
<SoluCXWidget type='modal' {...props} />
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Inline
|
|
92
|
-
|
|
93
|
-
Integrado ao fluxo normal do layout, respeitando a posição no código.
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
<SoluCXWidget type='inline' {...props} />
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## 🔧 API Completa
|
|
100
|
-
|
|
101
|
-
### Props
|
|
102
|
-
|
|
103
|
-
| Propriedade | Tipo | Obrigatório | Descrição |
|
|
104
|
-
| ----------- | --------------- | ----------- | ---------------------------- |
|
|
105
|
-
| `soluCXKey` | `string` | ✅ | Chave de autenticação SoluCX |
|
|
106
|
-
| `type` | `WidgetType` | ✅ | Modo de renderização |
|
|
107
|
-
| `data` | `WidgetData` | ✅ | Dados do cliente/transação |
|
|
108
|
-
| `options` | `WidgetOptions` | ✅ | Configurações do widget |
|
|
109
|
-
|
|
110
|
-
### WidgetData
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
interface WidgetData {
|
|
114
|
-
// Identificadores
|
|
115
|
-
transaction_id?: string;
|
|
116
|
-
customer_id?: string;
|
|
117
|
-
|
|
118
|
-
// Dados do cliente
|
|
119
|
-
name?: string;
|
|
120
|
-
email?: string;
|
|
121
|
-
phone?: string;
|
|
122
|
-
birth_date?: string; // Formato: YYYY-MM-DD
|
|
123
|
-
document?: string;
|
|
124
|
-
|
|
125
|
-
// Contexto da transação
|
|
126
|
-
store_id?: string;
|
|
127
|
-
store_name?: string;
|
|
128
|
-
employee_id?: string;
|
|
129
|
-
employee_name?: string;
|
|
130
|
-
amount?: number;
|
|
131
|
-
score?: number;
|
|
132
|
-
journey?: string; // Nome da jornada/fluxo
|
|
133
|
-
|
|
134
|
-
// Parâmetros customizados (prefixo param_)
|
|
135
|
-
param_REGIAO?: string;
|
|
136
|
-
[key: string]: string | number | undefined;
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### WidgetOptions
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
interface WidgetOptions {
|
|
144
|
-
height?: number; // Altura fixa em pontos (points, não pixels)
|
|
145
|
-
// Se não fornecido, será dinâmica baseada em eventos de resize
|
|
146
|
-
// Se fornecido, será fixa independente do tipo de widget
|
|
147
|
-
retry?: {
|
|
148
|
-
attempts?: number; // Tentativas (padrão: 3)
|
|
149
|
-
interval?: number; // Intervalo em ms (padrão: 1000)
|
|
150
|
-
};
|
|
151
|
-
waitDelayAfterRating?: number; // Delay após avaliação
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
**Comportamento da Altura (height):**
|
|
156
|
-
|
|
157
|
-
- **Altura Dinâmica (padrão)**: Quando `height` não é fornecido, o widget se ajusta automaticamente baseado em eventos de resize do conteúdo. Isso funciona para todos os tipos: `bottom`, `top`, `inline` e `modal`.
|
|
158
|
-
|
|
159
|
-
```tsx
|
|
160
|
-
// Altura dinâmica - se adapta ao conteúdo
|
|
161
|
-
<SoluCXWidget
|
|
162
|
-
type='bottom'
|
|
163
|
-
options={{}} // ou options={{ retry: { attempts: 3 } }}
|
|
164
|
-
{...props}
|
|
165
|
-
/>
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
- **Altura Fixa**: Quando `height` é especificado, o valor é fixo e eventos de resize são ignorados. Funciona para todos os tipos de widget.
|
|
169
|
-
|
|
170
|
-
```tsx
|
|
171
|
-
// Altura fixa de 400 pontos
|
|
172
|
-
<SoluCXWidget type='modal' options={{ height: 400 }} {...props} />
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
**⚠️ Importante**: O valor de `height` é sempre em **pontos** (points), não pixels, seguindo o padrão do React e React Native. O sistema operacional converte automaticamente para pixels considerando a densidade da tela.
|
|
176
|
-
|
|
177
|
-
### WidgetType
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
type WidgetType = 'bottom' | 'top' | 'inline' | 'modal';
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## 🔄 Sistema de Eventos
|
|
184
|
-
|
|
185
|
-
O widget processa automaticamente os seguintes eventos da pesquisa:
|
|
186
|
-
|
|
187
|
-
- `FORM_OPENED` - Widget foi aberto
|
|
188
|
-
- `FORM_CLOSE` - Usuário fechou o widget
|
|
189
|
-
- `FORM_COMPLETED` - Pesquisa concluída
|
|
190
|
-
- `FORM_PARTIALCOMPLETED` - Completada parcialmente
|
|
191
|
-
- `FORM_RESIZE` - Widget redimensionado
|
|
192
|
-
- `FORM_ERROR` - Erro no carregamento
|
|
193
|
-
|
|
194
|
-
## 💾 Persistência Inteligente
|
|
195
|
-
|
|
196
|
-
O widget controla automaticamente:
|
|
197
|
-
|
|
198
|
-
- **Histórico de tentativas**: Evita spam de widgets
|
|
199
|
-
- **Última avaliação**: Data da última interação
|
|
200
|
-
- **Controle de frequência**: Respeita configurações de exibição
|
|
201
|
-
- **Armazenamento local**: Dados persistem entre sessões
|
|
202
|
-
|
|
203
|
-
## ⚙️ Múltiplos Widgets
|
|
204
|
-
|
|
205
|
-
```tsx
|
|
206
|
-
const widgets = ['bottom', 'top'] as WidgetType[];
|
|
207
|
-
|
|
208
|
-
return (
|
|
209
|
-
<>
|
|
210
|
-
{widgets.map((type) => (
|
|
211
|
-
<SoluCXWidget
|
|
212
|
-
key={type}
|
|
213
|
-
soluCXKey={key}
|
|
214
|
-
type={type}
|
|
215
|
-
data={data}
|
|
216
|
-
options={options}
|
|
217
|
-
/>
|
|
218
|
-
))}
|
|
219
|
-
</>
|
|
220
|
-
);
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
## 🚨 Considerações Importantes
|
|
224
|
-
|
|
225
|
-
### Posicionamento
|
|
226
|
-
|
|
227
|
-
⚠️ **Comportamento Crítico**: A posição no JSX **não determina** onde widgets `top`, `bottom` e `modal` aparecem:
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
// ❌ Widget "bottom" sempre aparece embaixo, independente da posição
|
|
231
|
-
<Text>Conteúdo antes</Text>
|
|
232
|
-
<SoluCXWidget type="bottom" {...props} />
|
|
233
|
-
<Text>Conteúdo depois</Text>
|
|
234
|
-
|
|
235
|
-
// ✅ Apenas "inline" respeita a posição no código
|
|
236
|
-
<Text>Conteúdo antes</Text>
|
|
237
|
-
<SoluCXWidget type="inline" {...props} />
|
|
238
|
-
<Text>Conteúdo depois</Text>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
## 🔍 Troubleshooting
|
|
242
|
-
|
|
243
|
-
### Widget não aparece
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
// Verificações essenciais:
|
|
247
|
-
// ✅ Chave SoluCX válida?
|
|
248
|
-
// ✅ Conectividade com internet?
|
|
249
|
-
// ✅ Logs do WebView no console?
|
|
250
|
-
// ✅ Dados obrigatórios preenchidos?
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### Eventos não funcionam
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
// Debug de comunicação:
|
|
257
|
-
const handleMessage = (message: string) => {
|
|
258
|
-
console.log('Widget event:', message);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// Verificar se JavaScript foi injetado corretamente
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### Layout quebrado
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
// Ajustar dimensões para o dispositivo:
|
|
268
|
-
const { height } = Dimensions.get('window');
|
|
269
|
-
|
|
270
|
-
const options = {
|
|
271
|
-
height: Math.min(height * 0.6, 400)
|
|
272
|
-
};
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## 📚 Compatibilidade
|
|
276
|
-
|
|
277
|
-
| Versão | React Native | Expo | iOS | Android |
|
|
278
|
-
| ------ | ------------ | ---- | --- | ------- |
|
|
279
|
-
| 1.0.x | 0.70+ | 50+ | 11+ | API 21+ |
|
|
280
|
-
|
|
281
|
-
## 📄 Licença
|
|
282
|
-
|
|
283
|
-
Este pacote é proprietário da SoluCX. O uso é restrito a clientes licenciados da plataforma SoluCX.
|
|
284
|
-
|
|
285
|
-
---
|
|
1
|
+
# @solucx/react-native-solucx-widget
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@solucx%2Freact-native-solucx-widget)
|
|
4
|
+
[](https://reactnative.dev/)
|
|
5
|
+
[](https://expo.dev/)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://developer.apple.com/ios/)
|
|
8
|
+
[](https://developer.android.com/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
Um widget React Native modular para coleta de feedback e pesquisas de satisfação, desenvolvido pela SoluCX seguindo princípios de Clean Code e arquitetura escalável.
|
|
12
|
+
|
|
13
|
+
## 🛠️ Tecnologias
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## 📋 Visão Geral
|
|
22
|
+
|
|
23
|
+
O SoluCX Widget permite integrar pesquisas de satisfação diretamente em aplicações React Native/Expo de forma simples e flexível. Desenvolvido para empresas que precisam coletar feedback em tempo real através de diferentes modalidades de apresentação.
|
|
24
|
+
|
|
25
|
+
### 🎯 Principais Características
|
|
26
|
+
|
|
27
|
+
- **4 Modos de Renderização**: Bottom, Top, Modal e Inline
|
|
28
|
+
- **Persistência Automática**: Controle inteligente de frequência
|
|
29
|
+
- **Comunicação WebView**: Integração transparente com plataforma SoluCX
|
|
30
|
+
- **TypeScript**: Totalmente tipado para melhor experiência de desenvolvimento
|
|
31
|
+
- **Performático**: Carregamento otimizado e cache local
|
|
32
|
+
|
|
33
|
+
## 🚀 Instalação
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install @solucx/react-native-solucx-widget
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 🎛️ Uso Básico
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import React from 'react';
|
|
43
|
+
import { SoluCXWidget } from '@solucx/react-native-solucx-widget';
|
|
44
|
+
|
|
45
|
+
export default function MyScreen() {
|
|
46
|
+
return (
|
|
47
|
+
<SoluCXWidget
|
|
48
|
+
soluCXKey='sua-chave-solucx'
|
|
49
|
+
type='bottom'
|
|
50
|
+
data={{
|
|
51
|
+
journey: 'checkout_flow',
|
|
52
|
+
name: 'João Silva',
|
|
53
|
+
email: 'joao@email.com',
|
|
54
|
+
store_id: 'loja_01',
|
|
55
|
+
amount: 150.0
|
|
56
|
+
}}
|
|
57
|
+
options={{
|
|
58
|
+
height: 400
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 📱 Modos de Renderização
|
|
66
|
+
|
|
67
|
+
### Bottom (Padrão)
|
|
68
|
+
|
|
69
|
+
Widget fixo na parte inferior da tela, ideal para feedback não intrusivo.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<SoluCXWidget type='bottom' {...props} />
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Top
|
|
76
|
+
|
|
77
|
+
Widget fixo no topo da tela, perfeito para notificações importantes.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<SoluCXWidget type='top' {...props} />
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Modal
|
|
84
|
+
|
|
85
|
+
Sobreposição centralizada que bloqueia interação com o fundo.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<SoluCXWidget type='modal' {...props} />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Inline
|
|
92
|
+
|
|
93
|
+
Integrado ao fluxo normal do layout, respeitando a posição no código.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<SoluCXWidget type='inline' {...props} />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 🔧 API Completa
|
|
100
|
+
|
|
101
|
+
### Props
|
|
102
|
+
|
|
103
|
+
| Propriedade | Tipo | Obrigatório | Descrição |
|
|
104
|
+
| ----------- | --------------- | ----------- | ---------------------------- |
|
|
105
|
+
| `soluCXKey` | `string` | ✅ | Chave de autenticação SoluCX |
|
|
106
|
+
| `type` | `WidgetType` | ✅ | Modo de renderização |
|
|
107
|
+
| `data` | `WidgetData` | ✅ | Dados do cliente/transação |
|
|
108
|
+
| `options` | `WidgetOptions` | ✅ | Configurações do widget |
|
|
109
|
+
|
|
110
|
+
### WidgetData
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface WidgetData {
|
|
114
|
+
// Identificadores
|
|
115
|
+
transaction_id?: string;
|
|
116
|
+
customer_id?: string;
|
|
117
|
+
|
|
118
|
+
// Dados do cliente
|
|
119
|
+
name?: string;
|
|
120
|
+
email?: string;
|
|
121
|
+
phone?: string;
|
|
122
|
+
birth_date?: string; // Formato: YYYY-MM-DD
|
|
123
|
+
document?: string;
|
|
124
|
+
|
|
125
|
+
// Contexto da transação
|
|
126
|
+
store_id?: string;
|
|
127
|
+
store_name?: string;
|
|
128
|
+
employee_id?: string;
|
|
129
|
+
employee_name?: string;
|
|
130
|
+
amount?: number;
|
|
131
|
+
score?: number;
|
|
132
|
+
journey?: string; // Nome da jornada/fluxo
|
|
133
|
+
|
|
134
|
+
// Parâmetros customizados (prefixo param_)
|
|
135
|
+
param_REGIAO?: string;
|
|
136
|
+
[key: string]: string | number | undefined;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### WidgetOptions
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
interface WidgetOptions {
|
|
144
|
+
height?: number; // Altura fixa em pontos (points, não pixels)
|
|
145
|
+
// Se não fornecido, será dinâmica baseada em eventos de resize
|
|
146
|
+
// Se fornecido, será fixa independente do tipo de widget
|
|
147
|
+
retry?: {
|
|
148
|
+
attempts?: number; // Tentativas (padrão: 3)
|
|
149
|
+
interval?: number; // Intervalo em ms (padrão: 1000)
|
|
150
|
+
};
|
|
151
|
+
waitDelayAfterRating?: number; // Delay após avaliação
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Comportamento da Altura (height):**
|
|
156
|
+
|
|
157
|
+
- **Altura Dinâmica (padrão)**: Quando `height` não é fornecido, o widget se ajusta automaticamente baseado em eventos de resize do conteúdo. Isso funciona para todos os tipos: `bottom`, `top`, `inline` e `modal`.
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
// Altura dinâmica - se adapta ao conteúdo
|
|
161
|
+
<SoluCXWidget
|
|
162
|
+
type='bottom'
|
|
163
|
+
options={{}} // ou options={{ retry: { attempts: 3 } }}
|
|
164
|
+
{...props}
|
|
165
|
+
/>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- **Altura Fixa**: Quando `height` é especificado, o valor é fixo e eventos de resize são ignorados. Funciona para todos os tipos de widget.
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
// Altura fixa de 400 pontos
|
|
172
|
+
<SoluCXWidget type='modal' options={{ height: 400 }} {...props} />
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**⚠️ Importante**: O valor de `height` é sempre em **pontos** (points), não pixels, seguindo o padrão do React e React Native. O sistema operacional converte automaticamente para pixels considerando a densidade da tela.
|
|
176
|
+
|
|
177
|
+
### WidgetType
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
type WidgetType = 'bottom' | 'top' | 'inline' | 'modal';
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 🔄 Sistema de Eventos
|
|
184
|
+
|
|
185
|
+
O widget processa automaticamente os seguintes eventos da pesquisa:
|
|
186
|
+
|
|
187
|
+
- `FORM_OPENED` - Widget foi aberto
|
|
188
|
+
- `FORM_CLOSE` - Usuário fechou o widget
|
|
189
|
+
- `FORM_COMPLETED` - Pesquisa concluída
|
|
190
|
+
- `FORM_PARTIALCOMPLETED` - Completada parcialmente
|
|
191
|
+
- `FORM_RESIZE` - Widget redimensionado
|
|
192
|
+
- `FORM_ERROR` - Erro no carregamento
|
|
193
|
+
|
|
194
|
+
## 💾 Persistência Inteligente
|
|
195
|
+
|
|
196
|
+
O widget controla automaticamente:
|
|
197
|
+
|
|
198
|
+
- **Histórico de tentativas**: Evita spam de widgets
|
|
199
|
+
- **Última avaliação**: Data da última interação
|
|
200
|
+
- **Controle de frequência**: Respeita configurações de exibição
|
|
201
|
+
- **Armazenamento local**: Dados persistem entre sessões
|
|
202
|
+
|
|
203
|
+
## ⚙️ Múltiplos Widgets
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
const widgets = ['bottom', 'top'] as WidgetType[];
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<>
|
|
210
|
+
{widgets.map((type) => (
|
|
211
|
+
<SoluCXWidget
|
|
212
|
+
key={type}
|
|
213
|
+
soluCXKey={key}
|
|
214
|
+
type={type}
|
|
215
|
+
data={data}
|
|
216
|
+
options={options}
|
|
217
|
+
/>
|
|
218
|
+
))}
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## 🚨 Considerações Importantes
|
|
224
|
+
|
|
225
|
+
### Posicionamento
|
|
226
|
+
|
|
227
|
+
⚠️ **Comportamento Crítico**: A posição no JSX **não determina** onde widgets `top`, `bottom` e `modal` aparecem:
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
// ❌ Widget "bottom" sempre aparece embaixo, independente da posição
|
|
231
|
+
<Text>Conteúdo antes</Text>
|
|
232
|
+
<SoluCXWidget type="bottom" {...props} />
|
|
233
|
+
<Text>Conteúdo depois</Text>
|
|
234
|
+
|
|
235
|
+
// ✅ Apenas "inline" respeita a posição no código
|
|
236
|
+
<Text>Conteúdo antes</Text>
|
|
237
|
+
<SoluCXWidget type="inline" {...props} />
|
|
238
|
+
<Text>Conteúdo depois</Text>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## 🔍 Troubleshooting
|
|
242
|
+
|
|
243
|
+
### Widget não aparece
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// Verificações essenciais:
|
|
247
|
+
// ✅ Chave SoluCX válida?
|
|
248
|
+
// ✅ Conectividade com internet?
|
|
249
|
+
// ✅ Logs do WebView no console?
|
|
250
|
+
// ✅ Dados obrigatórios preenchidos?
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Eventos não funcionam
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
// Debug de comunicação:
|
|
257
|
+
const handleMessage = (message: string) => {
|
|
258
|
+
console.log('Widget event:', message);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// Verificar se JavaScript foi injetado corretamente
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Layout quebrado
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
// Ajustar dimensões para o dispositivo:
|
|
268
|
+
const { height } = Dimensions.get('window');
|
|
269
|
+
|
|
270
|
+
const options = {
|
|
271
|
+
height: Math.min(height * 0.6, 400)
|
|
272
|
+
};
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## 📚 Compatibilidade
|
|
276
|
+
|
|
277
|
+
| Versão | React Native | Expo | iOS | Android |
|
|
278
|
+
| ------ | ------------ | ---- | --- | ------- |
|
|
279
|
+
| 1.0.x | 0.70+ | 50+ | 11+ | API 21+ |
|
|
280
|
+
|
|
281
|
+
## 📄 Licença
|
|
282
|
+
|
|
283
|
+
Este pacote é proprietário da SoluCX. O uso é restrito a clientes licenciados da plataforma SoluCX.
|
|
284
|
+
|
|
285
|
+
---
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@solucx/react-native-solucx-widget",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "The React Native SDK for Solucx Widget",
|
|
5
|
-
"main": "src/index",
|
|
6
|
-
"author": " <> ()",
|
|
7
|
-
"homepage": "#readme",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"prepublishOnly": "npm run build"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"src/",
|
|
14
|
-
"README.md"
|
|
15
|
-
],
|
|
16
|
-
"peerDependencies": {
|
|
17
|
-
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
18
|
-
"react": ">=18.0.0",
|
|
19
|
-
"react-native": ">=0.72.0",
|
|
20
|
-
"react-native-webview": "^13.16.0",
|
|
21
|
-
"react-native-safe-area-context": "^5.6.1"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@solucx/react-native-solucx-widget",
|
|
3
|
+
"version": "0.1.16",
|
|
4
|
+
"description": "The React Native SDK for Solucx Widget",
|
|
5
|
+
"main": "src/index",
|
|
6
|
+
"author": " <> ()",
|
|
7
|
+
"homepage": "#readme",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
18
|
+
"react": ">=18.0.0",
|
|
19
|
+
"react-native": ">=0.72.0",
|
|
20
|
+
"react-native-webview": "^13.16.0",
|
|
21
|
+
"react-native-safe-area-context": "^5.6.1"
|
|
22
|
+
}
|
|
23
|
+
}
|