@appilots/sdk 0.8.0 → 0.10.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.mjs CHANGED
@@ -1,14 +1,28 @@
1
- export { AppilotsNavigationContainer } from './chunk-ZSEACJKU.mjs';
2
- import { useAppilotsChat, useAppilotsActions, shouldShowSuggestedPrompts, useSuggestedPrompts } from './chunk-MHWVRZYF.mjs';
3
- export { captureSnapshot, executeAction, useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from './chunk-MHWVRZYF.mjs';
4
- import { defaultLightTheme, describeAction, mergeThemeTokens, resolveBaseTheme, useAppilotsContext, AppilotsErrorBoundary, componentRegistry } from './chunk-C2KVVJ5K.mjs';
5
- export { AppilotsClient, AppilotsProvider, AppilotsRegistryProvider, RateLimitedError, SDK_VERSION, _patchJsxRuntimes, clearAppilotsDebugTraces, componentRegistry, createComponentRegistry, createElementRegistry, createListRegistry, defaultDarkTheme, defaultLightTheme, describeAction, elementRegistry, enableAppilotsAutoTracking, getAppilotsDebugTraces, getGlobalConfig, getIntrospectionDiagnostics, humanizeError, initAppilots, isAutoTrackingEnabled, listRegistry, mergeThemeTokens, recordAppilotsDebugTrace, registerScreen, subscribeAppilotsDebugTraces, useAppilotsContext, useResolvedRegistry } from './chunk-C2KVVJ5K.mjs';
1
+ export { AppilotsNavigationContainer } from './chunk-IHPLS5FE.mjs';
2
+ import { useAppilotsChat, useAppilotsActions, shouldShowSuggestedPrompts, useSuggestedPrompts } from './chunk-XHR65V2W.mjs';
3
+ export { appilotsSelfCheck, captureSnapshot, executeAction, useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from './chunk-XHR65V2W.mjs';
4
+ import { defaultLightTheme, describeAction, mergeThemeTokens, resolveBaseTheme, useAppilotsContext, AppilotsErrorBoundary, componentRegistry } from './chunk-AHHDOUVX.mjs';
5
+ export { AppilotsClient, AppilotsProvider, AppilotsRegistryProvider, RateLimitedError, SDK_VERSION, _patchJsxRuntimes, clearAppilotsDebugTraces, componentRegistry, createComponentRegistry, createElementRegistry, createListRegistry, defaultDarkTheme, defaultLightTheme, describeAction, elementRegistry, enableAppilotsAutoTracking, getAppilotsDebugTraces, getAutoTrackingState, getGlobalConfig, getIntrospectionDiagnostics, humanizeError, initAppilots, isAutoTrackingEnabled, listRegistry, mergeThemeTokens, recordAppilotsDebugTrace, registerScreen, setCurrentScreen, subscribeAppilotsDebugTraces, useAppilotsContext, useResolvedRegistry } from './chunk-AHHDOUVX.mjs';
6
6
  import * as React7 from 'react';
7
7
  import React7__default, { createContext, useRef, useEffect, useMemo, useContext, useState, useCallback } from 'react';
8
8
  import { StyleSheet, Dimensions, Platform, View, Animated, Text, TouchableOpacity, ActivityIndicator, useColorScheme, NativeModules, FlatList, Image, TextInput, Modal, KeyboardAvoidingView, Linking } from 'react-native';
9
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
9
+ import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
10
10
  import Svg, { Path } from 'react-native-svg';
11
11
 
12
+ var NO_INSETS = { top: 0, right: 0, bottom: 0, left: 0 };
13
+ var _warned = false;
14
+ function useSafeAreaInsetsOrDefault() {
15
+ const insets = useContext(SafeAreaInsetsContext);
16
+ if (insets) return insets;
17
+ if (!_warned) {
18
+ _warned = true;
19
+ console.warn(
20
+ "[Appilots] <AppilotsChat> found no <SafeAreaProvider> above it, so it is laying out with zero safe-area insets and may sit under the notch or the home indicator. Render <SafeAreaProvider> (from react-native-safe-area-context) at the root of your app, ABOVE <AppilotsProvider> \u2014 a provider nested inside your navigator does not cover a chat rendered as its sibling."
21
+ );
22
+ }
23
+ return NO_INSETS;
24
+ }
25
+
12
26
  // src/components/breadcrumbPresentation.ts
13
27
  var DEFAULT_BREADCRUMB_PALETTE = {
14
28
  primary: defaultLightTheme.colors.primary,
@@ -58,13 +72,24 @@ function isDestructiveAction(action) {
58
72
  return action.payload?.destructive === true || action.destructive === true;
59
73
  }
60
74
  DEFAULT_BREADCRUMB_PALETTE.error;
61
- function deriveConfirmCardContent(action, palette = DEFAULT_BREADCRUMB_PALETTE) {
75
+ var PT_BR_CONFIRM_FALLBACK = {
76
+ confirmDestructiveTitle: "A\xE7\xE3o destrutiva",
77
+ confirmTitle: "Confirma\xE7\xE3o necess\xE1ria",
78
+ confirmMessage: 'Tem certeza que deseja "{action}"?',
79
+ confirmDestructiveApprove: "Sim, executar",
80
+ confirmApprove: "Confirmar",
81
+ confirmCancel: "Cancelar",
82
+ confirmThisAction: "esta a\xE7\xE3o"
83
+ };
84
+ function deriveConfirmCardContent(action, palette = DEFAULT_BREADCRUMB_PALETTE, strings) {
62
85
  const payload = action.payload ?? {};
63
86
  const isDestructive = isDestructiveAction(action);
64
- const message = typeof payload.message === "string" && payload.message || typeof payload.actionDescription === "string" && payload.actionDescription || "Confirme para prosseguir";
65
- const title = typeof payload.title === "string" && payload.title || (isDestructive ? "A\xE7\xE3o destrutiva" : "Confirma\xE7\xE3o necess\xE1ria");
66
- const confirmLabel = typeof payload.confirmLabel === "string" && payload.confirmLabel || (isDestructive ? "Sim, executar" : "Confirmar");
67
- const cancelLabel = typeof payload.cancelLabel === "string" && payload.cancelLabel || "Cancelar";
87
+ const copy = { ...PT_BR_CONFIRM_FALLBACK, ...strings ?? {} };
88
+ const actionName = typeof payload.actionDescription === "string" && payload.actionDescription || copy.confirmThisAction;
89
+ const message = typeof payload.message === "string" && payload.message || copy.confirmMessage.replace("{action}", actionName);
90
+ const title = typeof payload.title === "string" && payload.title || (isDestructive ? copy.confirmDestructiveTitle : copy.confirmTitle);
91
+ const confirmLabel = typeof payload.confirmLabel === "string" && payload.confirmLabel || (isDestructive ? copy.confirmDestructiveApprove : copy.confirmApprove);
92
+ const cancelLabel = typeof payload.cancelLabel === "string" && payload.cancelLabel || copy.confirmCancel;
68
93
  return {
69
94
  isDestructive,
70
95
  title,
@@ -88,6 +113,7 @@ function ActionBreadcrumb({
88
113
  textColor,
89
114
  fontFamily,
90
115
  palette,
116
+ confirmStrings,
91
117
  requireApprovalFor,
92
118
  onApprove,
93
119
  onReject
@@ -108,6 +134,7 @@ function ActionBreadcrumb({
108
134
  textColor,
109
135
  fontFamily,
110
136
  palette: resolvedPalette,
137
+ confirmStrings,
111
138
  needsApproval: requireApprovalFor?.(action) ?? false,
112
139
  onApprove,
113
140
  onReject
@@ -123,6 +150,7 @@ function BreadcrumbRow(props) {
123
150
  action,
124
151
  palette: props.palette,
125
152
  fontFamily: props.fontFamily,
153
+ confirmStrings: props.confirmStrings,
126
154
  onApprove: props.onApprove,
127
155
  onReject: props.onReject
128
156
  }
@@ -163,25 +191,26 @@ function RegularBreadcrumbRow({
163
191
  }).start();
164
192
  }, [state, pulse]);
165
193
  const isDestructive = isDestructiveAction(action);
166
- return /* @__PURE__ */ React7__default.createElement(Animated.View, { style: [styles.row, { opacity: fade }] }, /* @__PURE__ */ React7__default.createElement(Animated.View, { style: { opacity: pulse, flexDirection: "row", alignItems: "flex-start", flex: 1 } }, /* @__PURE__ */ React7__default.createElement(StateIcon, { state, tone, primaryColor }), /* @__PURE__ */ React7__default.createElement(
167
- Text,
194
+ return /* @__PURE__ */ React7__default.createElement(Animated.View, { style: [styles.row, { opacity: fade }] }, /* @__PURE__ */ React7__default.createElement(
195
+ Animated.View,
168
196
  {
169
- style: [
170
- styles.label,
171
- { color: state === "failed" ? tone.color : textColor, fontFamily }
172
- ],
173
- accessibilityLabel: `${state}: ${label}`
197
+ style: { opacity: pulse, flexDirection: "row", alignItems: "flex-start", flex: 1 }
174
198
  },
175
- label,
176
- isDestructive && /* @__PURE__ */ React7__default.createElement(Text, { style: [styles.destructiveTag, { color: palette.error }] }, " \u26A0 destrutiva")
177
- )), needsApproval && action.status === "pending" && onApprove && onReject && /* @__PURE__ */ React7__default.createElement(View, { style: styles.approvalButtons }, /* @__PURE__ */ React7__default.createElement(
199
+ /* @__PURE__ */ React7__default.createElement(StateIcon, { state, tone, primaryColor }),
200
+ /* @__PURE__ */ React7__default.createElement(
201
+ Text,
202
+ {
203
+ style: [styles.label, { color: state === "failed" ? tone.color : textColor, fontFamily }],
204
+ accessibilityLabel: `${state}: ${label}`
205
+ },
206
+ label,
207
+ isDestructive && /* @__PURE__ */ React7__default.createElement(Text, { style: [styles.destructiveTag, { color: palette.error }] }, " \u26A0 destrutiva")
208
+ )
209
+ ), needsApproval && action.status === "pending" && onApprove && onReject && /* @__PURE__ */ React7__default.createElement(View, { style: styles.approvalButtons }, /* @__PURE__ */ React7__default.createElement(
178
210
  TouchableOpacity,
179
211
  {
180
212
  onPress: () => onReject(action.id),
181
- style: [
182
- styles.btn,
183
- { backgroundColor: deriveStateTone(palette).failed.iconBg }
184
- ],
213
+ style: [styles.btn, { backgroundColor: deriveStateTone(palette).failed.iconBg }],
185
214
  activeOpacity: 0.7,
186
215
  accessibilityLabel: "Rejeitar a\xE7\xE3o"
187
216
  },
@@ -197,7 +226,14 @@ function RegularBreadcrumbRow({
197
226
  /* @__PURE__ */ React7__default.createElement(Text, { style: styles.approveBtnText }, "Aprovar")
198
227
  )));
199
228
  }
200
- function ConfirmCard({ action, palette, fontFamily, onApprove, onReject }) {
229
+ function ConfirmCard({
230
+ action,
231
+ palette,
232
+ fontFamily,
233
+ confirmStrings,
234
+ onApprove,
235
+ onReject
236
+ }) {
201
237
  const {
202
238
  isDestructive,
203
239
  title,
@@ -211,7 +247,7 @@ function ConfirmCard({ action, palette, fontFamily, onApprove, onReject }) {
211
247
  messageColor,
212
248
  cancelBackground,
213
249
  cancelTextColor
214
- } = deriveConfirmCardContent(action, palette);
250
+ } = deriveConfirmCardContent(action, palette, confirmStrings);
215
251
  return /* @__PURE__ */ React7__default.createElement(
216
252
  View,
217
253
  {
@@ -959,6 +995,13 @@ var ptBR = {
959
995
  approve: "Aprovar",
960
996
  reject: "Rejeitar",
961
997
  cancelledByUser: "Cancelado pelo usu\xE1rio",
998
+ confirmDestructiveTitle: "A\xE7\xE3o destrutiva",
999
+ confirmTitle: "Confirma\xE7\xE3o necess\xE1ria",
1000
+ confirmMessage: 'Tem certeza que deseja "{action}"?',
1001
+ confirmDestructiveApprove: "Sim, executar",
1002
+ confirmApprove: "Confirmar",
1003
+ confirmCancel: "Cancelar",
1004
+ confirmThisAction: "esta a\xE7\xE3o",
962
1005
  unknownAction: "A\xE7\xE3o desconhecida",
963
1006
  somethingWentWrong: "Algo deu errado",
964
1007
  openChatA11y: "Abrir chat do assistente",
@@ -990,6 +1033,13 @@ var en = {
990
1033
  approve: "Approve",
991
1034
  reject: "Reject",
992
1035
  cancelledByUser: "Cancelled by user",
1036
+ confirmDestructiveTitle: "Destructive action",
1037
+ confirmTitle: "Confirmation needed",
1038
+ confirmMessage: 'Are you sure you want to "{action}"?',
1039
+ confirmDestructiveApprove: "Yes, do it",
1040
+ confirmApprove: "Confirm",
1041
+ confirmCancel: "Cancel",
1042
+ confirmThisAction: "this action",
993
1043
  unknownAction: "Unknown action",
994
1044
  somethingWentWrong: "Something went wrong",
995
1045
  openChatA11y: "Open assistant chat",
@@ -1021,6 +1071,13 @@ var es = {
1021
1071
  approve: "Aprobar",
1022
1072
  reject: "Rechazar",
1023
1073
  cancelledByUser: "Cancelado por el usuario",
1074
+ confirmDestructiveTitle: "Acci\xF3n destructiva",
1075
+ confirmTitle: "Confirmaci\xF3n necesaria",
1076
+ confirmMessage: '\xBFSeguro que quieres "{action}"?',
1077
+ confirmDestructiveApprove: "S\xED, ejecutar",
1078
+ confirmApprove: "Confirmar",
1079
+ confirmCancel: "Cancelar",
1080
+ confirmThisAction: "esta acci\xF3n",
1024
1081
  unknownAction: "Acci\xF3n desconocida",
1025
1082
  somethingWentWrong: "Algo sali\xF3 mal",
1026
1083
  openChatA11y: "Abrir chat del asistente",
@@ -1186,13 +1243,7 @@ function AppilotsChatInner({
1186
1243
  offer: t("escalationOffer")
1187
1244
  }
1188
1245
  });
1189
- const {
1190
- pendingActions,
1191
- executingActions,
1192
- completedActions,
1193
- approveAction,
1194
- rejectAction
1195
- } = useAppilotsActions({ autoExecute });
1246
+ const { pendingActions, executingActions, completedActions, approveAction, rejectAction } = useAppilotsActions({ autoExecute });
1196
1247
  const { emit, remotePersonalization } = useAppilotsContext();
1197
1248
  const {
1198
1249
  headerTitle: resolvedTitle,
@@ -1223,7 +1274,7 @@ function AppilotsChatInner({
1223
1274
  }
1224
1275
  return void 0;
1225
1276
  }, [messages]);
1226
- const insets = useSafeAreaInsets();
1277
+ const insets = useSafeAreaInsetsOrDefault();
1227
1278
  const [internalVisible, setInternalVisible] = useState(mode === "inline");
1228
1279
  const [inputText, setInputText] = useState("");
1229
1280
  const flatListRef = useRef(null);
@@ -1408,6 +1459,15 @@ function AppilotsChatInner({
1408
1459
  primaryColor: theme.colors.primary,
1409
1460
  textColor: theme.colors.text,
1410
1461
  fontFamily: theme.typography.fontFamily,
1462
+ confirmStrings: {
1463
+ confirmDestructiveTitle: strings.confirmDestructiveTitle,
1464
+ confirmTitle: strings.confirmTitle,
1465
+ confirmMessage: strings.confirmMessage,
1466
+ confirmDestructiveApprove: strings.confirmDestructiveApprove,
1467
+ confirmApprove: strings.confirmApprove,
1468
+ confirmCancel: strings.confirmCancel,
1469
+ confirmThisAction: strings.confirmThisAction
1470
+ },
1411
1471
  palette: {
1412
1472
  textSecondary: theme.colors.textSecondary,
1413
1473
  surface: theme.colors.surface,
@@ -1513,7 +1573,15 @@ function AppilotsChatInner({
1513
1573
  color: escalation ? theme.colors.primary : theme.colors.textSecondary
1514
1574
  }
1515
1575
  )
1516
- ), /* @__PURE__ */ React7__default.createElement(TouchableOpacity, { ...APPILOTS_SKIP_PROPS, onPress: clearMessages, style: styles3.headerButton }, /* @__PURE__ */ React7__default.createElement(Text, { style: [styles3.headerButtonText, { color: theme.colors.textSecondary }] }, strings.clearButton)), mode !== "inline" && /* @__PURE__ */ React7__default.createElement(
1576
+ ), /* @__PURE__ */ React7__default.createElement(
1577
+ TouchableOpacity,
1578
+ {
1579
+ ...APPILOTS_SKIP_PROPS,
1580
+ onPress: clearMessages,
1581
+ style: styles3.headerButton
1582
+ },
1583
+ /* @__PURE__ */ React7__default.createElement(Text, { style: [styles3.headerButtonText, { color: theme.colors.textSecondary }] }, strings.clearButton)
1584
+ ), mode !== "inline" && /* @__PURE__ */ React7__default.createElement(
1517
1585
  TouchableOpacity,
1518
1586
  {
1519
1587
  ...APPILOTS_SKIP_PROPS,
@@ -1578,10 +1646,7 @@ function AppilotsChatInner({
1578
1646
  ) : /* @__PURE__ */ React7__default.createElement(
1579
1647
  View,
1580
1648
  {
1581
- style: [
1582
- styles3.emptyIconBadge,
1583
- { backgroundColor: theme.colors.primary + "14" }
1584
- ]
1649
+ style: [styles3.emptyIconBadge, { backgroundColor: theme.colors.primary + "14" }]
1585
1650
  },
1586
1651
  emptyStateIcon ? /* @__PURE__ */ React7__default.createElement(Text, { style: styles3.emptyIconEmoji }, emptyStateIcon) : /* @__PURE__ */ React7__default.createElement(ChatIcon, { size: 30, color: theme.colors.primary })
1587
1652
  ), /* @__PURE__ */ React7__default.createElement(
@@ -2112,66 +2177,101 @@ var styles3 = StyleSheet.create({
2112
2177
  function ConfirmDialog(_props = {}) {
2113
2178
  return null;
2114
2179
  }
2180
+
2181
+ // src/hoc/canHoldRef.ts
2182
+ var FORWARD_REF = /* @__PURE__ */ Symbol.for("react.forward_ref");
2183
+ var MEMO = /* @__PURE__ */ Symbol.for("react.memo");
2184
+ var LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
2185
+ function canHoldRef(type) {
2186
+ if (typeof type === "string") return true;
2187
+ if (!type) return false;
2188
+ const t = type;
2189
+ if (t.prototype?.isReactComponent) return true;
2190
+ switch (t.$$typeof) {
2191
+ case FORWARD_REF:
2192
+ return true;
2193
+ // memo(X) holds a ref only when X does. memo(forwardRef(f)) is the
2194
+ // common shape and must keep working.
2195
+ case MEMO:
2196
+ return canHoldRef(t.type);
2197
+ // lazy() resolves at render time; the payload is not inspectable here.
2198
+ // Assume it can — refusing a ref to something that wanted one is a
2199
+ // silent behaviour change, and lazy() is rare in this position.
2200
+ case LAZY:
2201
+ return true;
2202
+ default:
2203
+ return false;
2204
+ }
2205
+ }
2206
+
2207
+ // src/hoc/createAppilotsInput.tsx
2115
2208
  function normalizeId(label) {
2116
2209
  return label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+(.)/g, (_, c) => c.toUpperCase());
2117
2210
  }
2118
2211
  function createAppilotsInput(WrappedComponent) {
2119
- const AppilotsInput = React7__default.forwardRef(
2120
- (props, ref) => {
2121
- const {
2122
- appilotsId,
2123
- appilotsScreen,
2124
- appilotsFieldType = "text",
2125
- appilotsEnabled = true,
2126
- label,
2127
- value,
2128
- onChangeText,
2129
- ...rest
2130
- } = props;
2131
- const fieldId = appilotsId || (label ? normalizeId(label) : null);
2132
- const valueRef = useRef(value ?? "");
2133
- const onChangeRef = useRef(onChangeText);
2134
- const innerRef = useRef(null);
2135
- valueRef.current = value ?? "";
2136
- onChangeRef.current = onChangeText;
2137
- const getValue = useCallback(() => valueRef.current, []);
2138
- const setValue = useCallback((v) => onChangeRef.current?.(v), []);
2139
- const focus = useCallback(() => {
2140
- innerRef.current?.focus?.();
2141
- }, []);
2142
- useEffect(() => {
2143
- if (!fieldId || !appilotsEnabled) return;
2144
- const entry = {
2145
- kind: "field",
2146
- getValue,
2147
- setValue,
2148
- focus,
2149
- fieldType: appilotsFieldType,
2150
- label: label ?? fieldId,
2151
- screen: appilotsScreen
2152
- };
2153
- componentRegistry.register(fieldId, entry);
2154
- return () => {
2155
- componentRegistry.unregister(fieldId);
2156
- };
2157
- }, [fieldId, appilotsEnabled, getValue, setValue, focus, appilotsFieldType, label, appilotsScreen]);
2158
- const mergedRef = useCallback(
2159
- (instance) => {
2160
- innerRef.current = instance;
2161
- if (typeof ref === "function") ref(instance);
2162
- else if (ref) ref.current = instance;
2163
- },
2164
- [ref]
2165
- );
2166
- return /* @__PURE__ */ React7__default.createElement(
2167
- WrappedComponent,
2168
- {
2169
- ...{ label, value, onChangeText, ...rest },
2170
- ref: mergedRef
2171
- }
2172
- );
2173
- }
2174
- );
2212
+ const AppilotsInput = React7__default.forwardRef((props, ref) => {
2213
+ const {
2214
+ appilotsId,
2215
+ appilotsScreen,
2216
+ appilotsFieldType = "text",
2217
+ appilotsEnabled = true,
2218
+ label,
2219
+ value,
2220
+ onChangeText,
2221
+ ...rest
2222
+ } = props;
2223
+ const fieldId = appilotsId || (label ? normalizeId(label) : null);
2224
+ const valueRef = useRef(value ?? "");
2225
+ const onChangeRef = useRef(onChangeText);
2226
+ const innerRef = useRef(null);
2227
+ valueRef.current = value ?? "";
2228
+ onChangeRef.current = onChangeText;
2229
+ const getValue = useCallback(() => valueRef.current, []);
2230
+ const setValue = useCallback((v) => onChangeRef.current?.(v), []);
2231
+ const focus = useCallback(() => {
2232
+ innerRef.current?.focus?.();
2233
+ }, []);
2234
+ useEffect(() => {
2235
+ if (!fieldId || !appilotsEnabled) return;
2236
+ const entry = {
2237
+ kind: "field",
2238
+ getValue,
2239
+ setValue,
2240
+ focus,
2241
+ fieldType: appilotsFieldType,
2242
+ label: label ?? fieldId,
2243
+ screen: appilotsScreen
2244
+ };
2245
+ componentRegistry.register(fieldId, entry);
2246
+ return () => {
2247
+ componentRegistry.unregister(fieldId);
2248
+ };
2249
+ }, [
2250
+ fieldId,
2251
+ appilotsEnabled,
2252
+ getValue,
2253
+ setValue,
2254
+ focus,
2255
+ appilotsFieldType,
2256
+ label,
2257
+ appilotsScreen
2258
+ ]);
2259
+ const mergedRef = useCallback(
2260
+ (instance) => {
2261
+ innerRef.current = instance;
2262
+ if (typeof ref === "function") ref(instance);
2263
+ else if (ref) ref.current = instance;
2264
+ },
2265
+ [ref]
2266
+ );
2267
+ return /* @__PURE__ */ React7__default.createElement(
2268
+ WrappedComponent,
2269
+ {
2270
+ ...{ label, value, onChangeText, ...rest },
2271
+ ...canHoldRef(WrappedComponent) ? { ref: mergedRef } : {}
2272
+ }
2273
+ );
2274
+ });
2175
2275
  AppilotsInput.displayName = `AppilotsInput(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
2176
2276
  return AppilotsInput;
2177
2277
  }
@@ -2179,42 +2279,40 @@ function normalizeId2(label) {
2179
2279
  return label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+(.)/g, (_, c) => c.toUpperCase());
2180
2280
  }
2181
2281
  function createAppilotsButton(WrappedComponent) {
2182
- const AppilotsButton = React7__default.forwardRef(
2183
- (props, ref) => {
2184
- const {
2185
- appilotsId,
2186
- appilotsScreen,
2187
- appilotsEnabled = true,
2188
- title,
2189
- onPress,
2190
- ...rest
2191
- } = props;
2192
- const targetId = appilotsId || (title ? normalizeId2(title) : null);
2193
- const onPressRef = useRef(onPress);
2194
- onPressRef.current = onPress;
2195
- const press = useCallback(() => onPressRef.current?.(), []);
2196
- useEffect(() => {
2197
- if (!targetId || !appilotsEnabled) return;
2198
- const entry = {
2199
- kind: "target",
2200
- press,
2201
- label: title ?? targetId,
2202
- screen: appilotsScreen
2203
- };
2204
- componentRegistry.register(targetId, entry);
2205
- return () => {
2206
- componentRegistry.unregister(targetId);
2207
- };
2208
- }, [targetId, appilotsEnabled, press, title, appilotsScreen]);
2209
- return /* @__PURE__ */ React7__default.createElement(
2210
- WrappedComponent,
2211
- {
2212
- ...{ title, onPress, ...rest },
2213
- ref
2214
- }
2215
- );
2216
- }
2217
- );
2282
+ const AppilotsButton = React7__default.forwardRef((props, ref) => {
2283
+ const {
2284
+ appilotsId,
2285
+ appilotsScreen,
2286
+ appilotsEnabled = true,
2287
+ title,
2288
+ onPress,
2289
+ ...rest
2290
+ } = props;
2291
+ const targetId = appilotsId || (title ? normalizeId2(title) : null);
2292
+ const onPressRef = useRef(onPress);
2293
+ onPressRef.current = onPress;
2294
+ const press = useCallback(() => onPressRef.current?.(), []);
2295
+ useEffect(() => {
2296
+ if (!targetId || !appilotsEnabled) return;
2297
+ const entry = {
2298
+ kind: "target",
2299
+ press,
2300
+ label: title ?? targetId,
2301
+ screen: appilotsScreen
2302
+ };
2303
+ componentRegistry.register(targetId, entry);
2304
+ return () => {
2305
+ componentRegistry.unregister(targetId);
2306
+ };
2307
+ }, [targetId, appilotsEnabled, press, title, appilotsScreen]);
2308
+ return /* @__PURE__ */ React7__default.createElement(
2309
+ WrappedComponent,
2310
+ {
2311
+ ...{ title, onPress, ...rest },
2312
+ ...canHoldRef(WrappedComponent) ? { ref } : {}
2313
+ }
2314
+ );
2315
+ });
2218
2316
  AppilotsButton.displayName = `AppilotsButton(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
2219
2317
  return AppilotsButton;
2220
2318
  }
@@ -2222,47 +2320,45 @@ function normalizeId3(label) {
2222
2320
  return label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+(.)/g, (_, c) => c.toUpperCase());
2223
2321
  }
2224
2322
  function createAppilotsSwitch(WrappedComponent) {
2225
- const AppilotsSwitch = React7__default.forwardRef(
2226
- (props, ref) => {
2227
- const {
2228
- appilotsId,
2229
- appilotsScreen,
2230
- appilotsEnabled = true,
2231
- label,
2232
- value,
2233
- onValueChange,
2234
- ...rest
2235
- } = props;
2236
- const toggleId = appilotsId || (label ? normalizeId3(label) : null);
2237
- const valueRef = useRef(value ?? false);
2238
- const onChangeRef = useRef(onValueChange);
2239
- valueRef.current = value ?? false;
2240
- onChangeRef.current = onValueChange;
2241
- const getValue = useCallback(() => valueRef.current, []);
2242
- const setValue = useCallback((v) => onChangeRef.current?.(v), []);
2243
- useEffect(() => {
2244
- if (!toggleId || !appilotsEnabled) return;
2245
- const entry = {
2246
- kind: "toggle",
2247
- getValue,
2248
- setValue,
2249
- label: label ?? toggleId,
2250
- screen: appilotsScreen
2251
- };
2252
- componentRegistry.register(toggleId, entry);
2253
- return () => {
2254
- componentRegistry.unregister(toggleId);
2255
- };
2256
- }, [toggleId, appilotsEnabled, getValue, setValue, label, appilotsScreen]);
2257
- return /* @__PURE__ */ React7__default.createElement(
2258
- WrappedComponent,
2259
- {
2260
- ...{ label, value, onValueChange, ...rest },
2261
- ref
2262
- }
2263
- );
2264
- }
2265
- );
2323
+ const AppilotsSwitch = React7__default.forwardRef((props, ref) => {
2324
+ const {
2325
+ appilotsId,
2326
+ appilotsScreen,
2327
+ appilotsEnabled = true,
2328
+ label,
2329
+ value,
2330
+ onValueChange,
2331
+ ...rest
2332
+ } = props;
2333
+ const toggleId = appilotsId || (label ? normalizeId3(label) : null);
2334
+ const valueRef = useRef(value ?? false);
2335
+ const onChangeRef = useRef(onValueChange);
2336
+ valueRef.current = value ?? false;
2337
+ onChangeRef.current = onValueChange;
2338
+ const getValue = useCallback(() => valueRef.current, []);
2339
+ const setValue = useCallback((v) => onChangeRef.current?.(v), []);
2340
+ useEffect(() => {
2341
+ if (!toggleId || !appilotsEnabled) return;
2342
+ const entry = {
2343
+ kind: "toggle",
2344
+ getValue,
2345
+ setValue,
2346
+ label: label ?? toggleId,
2347
+ screen: appilotsScreen
2348
+ };
2349
+ componentRegistry.register(toggleId, entry);
2350
+ return () => {
2351
+ componentRegistry.unregister(toggleId);
2352
+ };
2353
+ }, [toggleId, appilotsEnabled, getValue, setValue, label, appilotsScreen]);
2354
+ return /* @__PURE__ */ React7__default.createElement(
2355
+ WrappedComponent,
2356
+ {
2357
+ ...{ label, value, onValueChange, ...rest },
2358
+ ...canHoldRef(WrappedComponent) ? { ref } : {}
2359
+ }
2360
+ );
2361
+ });
2266
2362
  AppilotsSwitch.displayName = `AppilotsSwitch(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
2267
2363
  return AppilotsSwitch;
2268
2364
  }