@menuia/react-native 1.0.0 → 1.1.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/dist/index.d.mts CHANGED
@@ -27,6 +27,8 @@ interface MenuIAChatProps {
27
27
  phone?: string;
28
28
  [key: string]: unknown;
29
29
  };
30
+ /** Expo push notification token */
31
+ expoPushToken?: string;
30
32
  /** Custom fields for AI tools */
31
33
  customFields?: Record<string, string>;
32
34
  /** Callback when new message received */
@@ -37,6 +39,6 @@ interface MenuIAChatProps {
37
39
  /** Callback when chat opens/closes */
38
40
  onToggle?: (isOpen: boolean) => void;
39
41
  }
40
- declare function MenuIAChat({ widgetId, agentId, apiUrl, primaryColor, position, bubbleSize, bubbleMargin, defaultOpen, inline, metadata, customFields, onMessage, onToggle, }: MenuIAChatProps): react_jsx_runtime.JSX.Element | null;
42
+ declare function MenuIAChat({ widgetId, agentId, apiUrl, primaryColor, position, bubbleSize, bubbleMargin, defaultOpen, inline, metadata, expoPushToken, customFields, onMessage, onToggle, }: MenuIAChatProps): react_jsx_runtime.JSX.Element | null;
41
43
 
42
44
  export { MenuIAChat, type MenuIAChatProps };
package/dist/index.d.ts CHANGED
@@ -27,6 +27,8 @@ interface MenuIAChatProps {
27
27
  phone?: string;
28
28
  [key: string]: unknown;
29
29
  };
30
+ /** Expo push notification token */
31
+ expoPushToken?: string;
30
32
  /** Custom fields for AI tools */
31
33
  customFields?: Record<string, string>;
32
34
  /** Callback when new message received */
@@ -37,6 +39,6 @@ interface MenuIAChatProps {
37
39
  /** Callback when chat opens/closes */
38
40
  onToggle?: (isOpen: boolean) => void;
39
41
  }
40
- declare function MenuIAChat({ widgetId, agentId, apiUrl, primaryColor, position, bubbleSize, bubbleMargin, defaultOpen, inline, metadata, customFields, onMessage, onToggle, }: MenuIAChatProps): react_jsx_runtime.JSX.Element | null;
42
+ declare function MenuIAChat({ widgetId, agentId, apiUrl, primaryColor, position, bubbleSize, bubbleMargin, defaultOpen, inline, metadata, expoPushToken, customFields, onMessage, onToggle, }: MenuIAChatProps): react_jsx_runtime.JSX.Element | null;
41
43
 
42
44
  export { MenuIAChat, type MenuIAChatProps };
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ function MenuIAChat({
45
45
  defaultOpen = false,
46
46
  inline = false,
47
47
  metadata,
48
+ expoPushToken,
48
49
  customFields,
49
50
  onMessage,
50
51
  onToggle
@@ -60,13 +61,13 @@ function MenuIAChat({
60
61
  if (metadata?.name) params.set("name", metadata.name);
61
62
  if (metadata?.email) params.set("email", metadata.email);
62
63
  if (metadata?.phone) params.set("phone", metadata.phone);
63
- if (customFields) {
64
- Object.entries(customFields).forEach(([k, v]) => {
65
- params.set(`cf_${k}`, v);
66
- });
64
+ const allCustomFields = { ...customFields };
65
+ if (expoPushToken) allCustomFields.expoPushToken = expoPushToken;
66
+ if (Object.keys(allCustomFields).length > 0) {
67
+ params.set("customData", JSON.stringify(allCustomFields));
67
68
  }
68
69
  return `${apiUrl}/embed/chat/${id}?${params.toString()}`;
69
- }, [id, apiUrl, primaryColor, metadata, customFields]);
70
+ }, [id, apiUrl, primaryColor, metadata, customFields, expoPushToken]);
70
71
  const toggle = (0, import_react.useCallback)(() => {
71
72
  const newState = !isOpen;
72
73
  setIsOpen(newState);
@@ -121,6 +122,13 @@ function MenuIAChat({
121
122
  }
122
123
  const isLeft = position === "bottom-left";
123
124
  const { width: screenWidth } = import_react_native.Dimensions.get("window");
125
+ const safeBottom = import_react_native.Platform.select({
126
+ ios: bubbleMargin + 34,
127
+ // Home indicator height
128
+ android: bubbleMargin + 48,
129
+ // Gesture nav / 3-button nav height
130
+ default: bubbleMargin
131
+ });
124
132
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
125
133
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
126
134
  import_react_native.TouchableOpacity,
@@ -134,7 +142,7 @@ function MenuIAChat({
134
142
  height: bubbleSize,
135
143
  borderRadius: bubbleSize / 2,
136
144
  backgroundColor: primaryColor,
137
- bottom: bubbleMargin,
145
+ bottom: safeBottom,
138
146
  ...isLeft ? { left: bubbleMargin } : { right: bubbleMargin }
139
147
  }
140
148
  ],
package/dist/index.mjs CHANGED
@@ -34,6 +34,7 @@ function MenuIAChat({
34
34
  defaultOpen = false,
35
35
  inline = false,
36
36
  metadata,
37
+ expoPushToken,
37
38
  customFields,
38
39
  onMessage,
39
40
  onToggle
@@ -49,13 +50,13 @@ function MenuIAChat({
49
50
  if (metadata?.name) params.set("name", metadata.name);
50
51
  if (metadata?.email) params.set("email", metadata.email);
51
52
  if (metadata?.phone) params.set("phone", metadata.phone);
52
- if (customFields) {
53
- Object.entries(customFields).forEach(([k, v]) => {
54
- params.set(`cf_${k}`, v);
55
- });
53
+ const allCustomFields = { ...customFields };
54
+ if (expoPushToken) allCustomFields.expoPushToken = expoPushToken;
55
+ if (Object.keys(allCustomFields).length > 0) {
56
+ params.set("customData", JSON.stringify(allCustomFields));
56
57
  }
57
58
  return `${apiUrl}/embed/chat/${id}?${params.toString()}`;
58
- }, [id, apiUrl, primaryColor, metadata, customFields]);
59
+ }, [id, apiUrl, primaryColor, metadata, customFields, expoPushToken]);
59
60
  const toggle = useCallback(() => {
60
61
  const newState = !isOpen;
61
62
  setIsOpen(newState);
@@ -110,6 +111,13 @@ function MenuIAChat({
110
111
  }
111
112
  const isLeft = position === "bottom-left";
112
113
  const { width: screenWidth } = Dimensions.get("window");
114
+ const safeBottom = Platform.select({
115
+ ios: bubbleMargin + 34,
116
+ // Home indicator height
117
+ android: bubbleMargin + 48,
118
+ // Gesture nav / 3-button nav height
119
+ default: bubbleMargin
120
+ });
113
121
  return /* @__PURE__ */ jsxs(Fragment, { children: [
114
122
  /* @__PURE__ */ jsxs(
115
123
  TouchableOpacity,
@@ -123,7 +131,7 @@ function MenuIAChat({
123
131
  height: bubbleSize,
124
132
  borderRadius: bubbleSize / 2,
125
133
  backgroundColor: primaryColor,
126
- bottom: bubbleMargin,
134
+ bottom: safeBottom,
127
135
  ...isLeft ? { left: bubbleMargin } : { right: bubbleMargin }
128
136
  }
129
137
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@menuia/react-native",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "MenuIA Chat SDK - React Native Component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",