@solucx/react-native-solucx-widget 0.1.3 → 0.1.4

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 CHANGED
@@ -85,7 +85,6 @@ export default function MyComponent() {
85
85
  param_REGIAO: "SUDESTE"
86
86
  }}
87
87
  options={{
88
- width: 380,
89
88
  height: 400
90
89
  }}
91
90
  />
@@ -145,8 +144,7 @@ interface WidgetData {
145
144
 
146
145
  ```typescript
147
146
  interface WidgetOptions {
148
- width?: number; // Largura do widget (padrão: 380)
149
- height?: number; // Altura do widget (padrão: 400)
147
+ height?: number; // Altura
150
148
  retry?: { // Configuração de retry
151
149
  attempts?: number; // Número de tentativas
152
150
  interval?: number; // Intervalo entre tentativas
@@ -277,7 +275,6 @@ Configurações centralizadas em [`webViewConstants.ts`](src/constants/webViewCo
277
275
  ```typescript
278
276
  export const BASE_URL = 'https://survey-link.solucx.com.br/link';
279
277
  export const STORAGE_KEY = '@solucxWidgetLog';
280
- export const DEFAULT_WIDTH = 380;
281
278
  export const MIN_HEIGHT = 200;
282
279
  export const FIXED_Z_INDEX = 9999;
283
280
  export const MODAL_Z_INDEX = 10000;
package/README.md CHANGED
@@ -54,8 +54,7 @@ export default function MyScreen() {
54
54
  store_id: "loja_01",
55
55
  amount: 150.00
56
56
  }}
57
- options={{
58
- width: 380,
57
+ options={{
59
58
  height: 400
60
59
  }}
61
60
  />
@@ -138,8 +137,7 @@ interface WidgetData {
138
137
 
139
138
  ```typescript
140
139
  interface WidgetOptions {
141
- width?: number; // Largura (padrão: 380)
142
- height?: number; // Altura (padrão: 400)
140
+ height?: number; // Altura
143
141
  retry?: {
144
142
  attempts?: number; // Tentativas (padrão: 3)
145
143
  interval?: number; // Intervalo em ms (padrão: 1000)
@@ -239,10 +237,9 @@ const handleMessage = (message: string) => {
239
237
 
240
238
  ```typescript
241
239
  // Ajustar dimensões para o dispositivo:
242
- const { width, height } = Dimensions.get('window');
240
+ const { height } = Dimensions.get('window');
243
241
 
244
242
  const options = {
245
- width: width * 0.9,
246
243
  height: Math.min(height * 0.6, 400)
247
244
  };
248
245
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solucx/react-native-solucx-widget",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The React Native SDK for Solucx Widget",
5
5
  "main": "src/index",
6
6
  "author": " <> ()",
@@ -18,4 +18,4 @@
18
18
  "react": ">=18.0.0",
19
19
  "react-native": ">=0.72.0"
20
20
  }
21
- }
21
+ }
@@ -36,13 +36,12 @@ export const SoluCXWidget: React.FC<SoluCXWidgetProps> = ({
36
36
  open,
37
37
  close,
38
38
  userId,
39
- } = useWidgetState(data, type);
39
+ } = useWidgetState(data, options, type);
40
40
 
41
41
  const eventService = new WidgetEventService(setIsWidgetVisible, resize, open, userId, options);
42
42
 
43
43
  const uri = buildWidgetURL(soluCXKey, data);
44
44
  const isForm = Boolean(data.form_id);
45
- const height = options.height ? Number(options.height) : undefined;
46
45
 
47
46
  useEffect(() => {
48
47
  loadSavedData();
@@ -91,7 +90,7 @@ export const SoluCXWidget: React.FC<SoluCXWidgetProps> = ({
91
90
 
92
91
  if (type === 'inline') {
93
92
  return (
94
- <InlineWidget visible={isWidgetVisible} onClose={handleClose}>
93
+ <InlineWidget visible={isWidgetVisible} height={widgetHeight} onClose={handleClose}>
95
94
  <WebView
96
95
  ref={webviewRef}
97
96
  style={webViewStyle}
@@ -5,15 +5,16 @@ import { CloseButton } from './CloseButton';
5
5
 
6
6
  interface InlineWidgetProps {
7
7
  visible: boolean;
8
+ height: number;
8
9
  children?: React.ReactNode;
9
10
  onClose?: () => void;
10
11
  }
11
12
 
12
- export const InlineWidget: React.FC<InlineWidgetProps> = ({ visible, children, onClose }) => {
13
+ export const InlineWidget: React.FC<InlineWidgetProps> = ({ visible, height, children, onClose }) => {
13
14
 
14
15
  return (
15
- <View style={[styles.wrapper, getWidgetVisibility(visible)]}>
16
- <View style={[styles.inline, getWidgetVisibility(visible)]}>
16
+ <View style={[styles.inlineWrapper, getWidgetVisibility(visible)]}>
17
+ <View style={[styles.inline, { height }, getWidgetVisibility(visible)]}>
17
18
  {children}
18
19
  <CloseButton
19
20
  visible={visible}
@@ -2,12 +2,13 @@ import { useState, useCallback } from 'react';
2
2
  import { Dimensions } from 'react-native';
3
3
  import { WidgetSamplerLog, WidgetData, WidgetType } from '../interfaces';
4
4
  import { StorageService } from '../services/storage';
5
+ import { WidgetOptions } from '@solucx/react-native-solucx-widget';
5
6
 
6
7
  function getUserId(widgetData: WidgetData): string {
7
8
  return widgetData.customer_id ?? widgetData.document ?? widgetData.email ?? "";
8
9
  }
9
10
 
10
- export const useWidgetState = (data: WidgetData, type?: WidgetType) => {
11
+ export const useWidgetState = (data: WidgetData, options?: WidgetOptions, type?: WidgetType) => {
11
12
  const [savedData, setSavedData] = useState<WidgetSamplerLog | null>(null);
12
13
  const [widgetHeight, setWidgetHeight] = useState<number>(0);
13
14
  const [isWidgetVisible, setIsWidgetVisible] = useState<boolean>(false);
@@ -15,6 +16,7 @@ export const useWidgetState = (data: WidgetData, type?: WidgetType) => {
15
16
  const userId = getUserId(data);
16
17
  const storageService = new StorageService(userId);
17
18
  const screenHeight = Dimensions.get('screen').height;
19
+ const height = options?.height ? Number(options.height) : undefined;
18
20
 
19
21
  const loadSavedData = useCallback(async () => {
20
22
  try {
@@ -53,6 +55,10 @@ export const useWidgetState = (data: WidgetData, type?: WidgetType) => {
53
55
 
54
56
  const resize = useCallback((value: string) => {
55
57
  const receivedHeight = Number(value);
58
+ if (height && receivedHeight > height) {
59
+ setWidgetHeight(height);
60
+ return;
61
+ }
56
62
  setWidgetHeight(receivedHeight);
57
63
  }, [screenHeight]);
58
64
 
@@ -1,5 +1,4 @@
1
1
  export interface WidgetOptions {
2
- width?: number;
3
2
  height?: number;
4
3
  retry?: {
5
4
  attempts?: number;