@appilots/sdk 0.7.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/README.md +46 -4
- package/dist/.build-meta.json +5 -0
- package/dist/{chunk-KYFAXT6V.js → chunk-2GCWCPSD.js} +19 -16
- package/dist/{chunk-R4D34FEW.mjs → chunk-AHHDOUVX.mjs} +2151 -333
- package/dist/{chunk-DR75QTYK.mjs → chunk-IHPLS5FE.mjs} +16 -13
- package/dist/{chunk-HFRIB4YN.js → chunk-VX7AL4SA.js} +1049 -1162
- package/dist/{chunk-KUFWRJC4.mjs → chunk-XHR65V2W.mjs} +831 -949
- package/dist/{chunk-DZ7QRFHD.js → chunk-YB77RYCC.js} +2178 -332
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +11 -11
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-nI-s3Exg.d.mts → index-BPZ0j71S.d.mts} +315 -15
- package/dist/{index-nI-s3Exg.d.ts → index-BPZ0j71S.d.ts} +315 -15
- package/dist/index.d.mts +325 -22
- package/dist/index.d.ts +325 -22
- package/dist/index.js +340 -227
- package/dist/index.mjs +274 -173
- package/dist/navigation/index.d.mts +171 -3
- package/dist/navigation/index.d.ts +171 -3
- package/dist/navigation/index.js +13 -13
- package/dist/navigation/index.mjs +2 -2
- package/metro.d.ts +16 -1
- package/metro.js +104 -10
- package/package.json +16 -6
- package/dist/registerScreen-D1oGm28T.d.mts +0 -159
- package/dist/registerScreen-D1oGm28T.d.ts +0 -159
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
export { AppilotsNavigationContainer } from './chunk-
|
|
2
|
-
import { useAppilotsChat, useAppilotsActions, shouldShowSuggestedPrompts, useSuggestedPrompts } from './chunk-
|
|
3
|
-
export { captureSnapshot, executeAction, useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from './chunk-
|
|
4
|
-
import { defaultLightTheme, describeAction, mergeThemeTokens, resolveBaseTheme, useAppilotsContext, componentRegistry } from './chunk-
|
|
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-
|
|
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 {
|
|
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
|
-
|
|
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
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
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(
|
|
167
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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({
|
|
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",
|
|
@@ -1129,6 +1186,11 @@ var APPILOTS_SKIP_PROPS = {
|
|
|
1129
1186
|
__appilotsInternal: true
|
|
1130
1187
|
};
|
|
1131
1188
|
function AppilotsChat(props) {
|
|
1189
|
+
const { degraded } = useAppilotsContext();
|
|
1190
|
+
if (degraded) return null;
|
|
1191
|
+
return /* @__PURE__ */ React7__default.createElement(AppilotsErrorBoundary, { surface: "chat", fallback: null }, /* @__PURE__ */ React7__default.createElement(AppilotsChatSurface, { ...props }));
|
|
1192
|
+
}
|
|
1193
|
+
function AppilotsChatSurface(props) {
|
|
1132
1194
|
const { remotePersonalization } = useAppilotsContext();
|
|
1133
1195
|
const themeProp = useMemo(() => {
|
|
1134
1196
|
if (!props.theme) return void 0;
|
|
@@ -1181,13 +1243,7 @@ function AppilotsChatInner({
|
|
|
1181
1243
|
offer: t("escalationOffer")
|
|
1182
1244
|
}
|
|
1183
1245
|
});
|
|
1184
|
-
const {
|
|
1185
|
-
pendingActions,
|
|
1186
|
-
executingActions,
|
|
1187
|
-
completedActions,
|
|
1188
|
-
approveAction,
|
|
1189
|
-
rejectAction
|
|
1190
|
-
} = useAppilotsActions({ autoExecute });
|
|
1246
|
+
const { pendingActions, executingActions, completedActions, approveAction, rejectAction } = useAppilotsActions({ autoExecute });
|
|
1191
1247
|
const { emit, remotePersonalization } = useAppilotsContext();
|
|
1192
1248
|
const {
|
|
1193
1249
|
headerTitle: resolvedTitle,
|
|
@@ -1218,7 +1274,7 @@ function AppilotsChatInner({
|
|
|
1218
1274
|
}
|
|
1219
1275
|
return void 0;
|
|
1220
1276
|
}, [messages]);
|
|
1221
|
-
const insets =
|
|
1277
|
+
const insets = useSafeAreaInsetsOrDefault();
|
|
1222
1278
|
const [internalVisible, setInternalVisible] = useState(mode === "inline");
|
|
1223
1279
|
const [inputText, setInputText] = useState("");
|
|
1224
1280
|
const flatListRef = useRef(null);
|
|
@@ -1403,6 +1459,15 @@ function AppilotsChatInner({
|
|
|
1403
1459
|
primaryColor: theme.colors.primary,
|
|
1404
1460
|
textColor: theme.colors.text,
|
|
1405
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
|
+
},
|
|
1406
1471
|
palette: {
|
|
1407
1472
|
textSecondary: theme.colors.textSecondary,
|
|
1408
1473
|
surface: theme.colors.surface,
|
|
@@ -1508,7 +1573,15 @@ function AppilotsChatInner({
|
|
|
1508
1573
|
color: escalation ? theme.colors.primary : theme.colors.textSecondary
|
|
1509
1574
|
}
|
|
1510
1575
|
)
|
|
1511
|
-
), /* @__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(
|
|
1512
1585
|
TouchableOpacity,
|
|
1513
1586
|
{
|
|
1514
1587
|
...APPILOTS_SKIP_PROPS,
|
|
@@ -1573,10 +1646,7 @@ function AppilotsChatInner({
|
|
|
1573
1646
|
) : /* @__PURE__ */ React7__default.createElement(
|
|
1574
1647
|
View,
|
|
1575
1648
|
{
|
|
1576
|
-
style: [
|
|
1577
|
-
styles3.emptyIconBadge,
|
|
1578
|
-
{ backgroundColor: theme.colors.primary + "14" }
|
|
1579
|
-
]
|
|
1649
|
+
style: [styles3.emptyIconBadge, { backgroundColor: theme.colors.primary + "14" }]
|
|
1580
1650
|
},
|
|
1581
1651
|
emptyStateIcon ? /* @__PURE__ */ React7__default.createElement(Text, { style: styles3.emptyIconEmoji }, emptyStateIcon) : /* @__PURE__ */ React7__default.createElement(ChatIcon, { size: 30, color: theme.colors.primary })
|
|
1582
1652
|
), /* @__PURE__ */ React7__default.createElement(
|
|
@@ -2107,66 +2177,101 @@ var styles3 = StyleSheet.create({
|
|
|
2107
2177
|
function ConfirmDialog(_props = {}) {
|
|
2108
2178
|
return null;
|
|
2109
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
|
|
2110
2208
|
function normalizeId(label) {
|
|
2111
2209
|
return label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+(.)/g, (_, c) => c.toUpperCase());
|
|
2112
2210
|
}
|
|
2113
2211
|
function createAppilotsInput(WrappedComponent) {
|
|
2114
|
-
const AppilotsInput = React7__default.forwardRef(
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
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
|
+
});
|
|
2170
2275
|
AppilotsInput.displayName = `AppilotsInput(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
|
|
2171
2276
|
return AppilotsInput;
|
|
2172
2277
|
}
|
|
@@ -2174,42 +2279,40 @@ function normalizeId2(label) {
|
|
|
2174
2279
|
return label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+(.)/g, (_, c) => c.toUpperCase());
|
|
2175
2280
|
}
|
|
2176
2281
|
function createAppilotsButton(WrappedComponent) {
|
|
2177
|
-
const AppilotsButton = React7__default.forwardRef(
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
{
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
}
|
|
2212
|
-
);
|
|
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
|
+
});
|
|
2213
2316
|
AppilotsButton.displayName = `AppilotsButton(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
|
|
2214
2317
|
return AppilotsButton;
|
|
2215
2318
|
}
|
|
@@ -2217,47 +2320,45 @@ function normalizeId3(label) {
|
|
|
2217
2320
|
return label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+(.)/g, (_, c) => c.toUpperCase());
|
|
2218
2321
|
}
|
|
2219
2322
|
function createAppilotsSwitch(WrappedComponent) {
|
|
2220
|
-
const AppilotsSwitch = React7__default.forwardRef(
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
{
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
}
|
|
2260
|
-
);
|
|
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
|
+
});
|
|
2261
2362
|
AppilotsSwitch.displayName = `AppilotsSwitch(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
|
|
2262
2363
|
return AppilotsSwitch;
|
|
2263
2364
|
}
|