@duffel/react-native-components-assistant 0.5.0 → 0.5.1-canary.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/lib/module/index.js +38 -25
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +45 -24
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Linking, Modal, Platform, StyleSheet, View } from 'react-native';
|
|
4
|
+
import { KeyboardAvoidingView, Linking, Modal, Platform, StyleSheet, View } from 'react-native';
|
|
5
5
|
import { WebView } from 'react-native-webview';
|
|
6
6
|
import { hasJsonWebTokenFormat } from "./lib/hasJsonWebTokenFormat.js";
|
|
7
7
|
import { getClientKeyPayload } from "./lib/getClientKeyPayload.js";
|
|
@@ -82,24 +82,29 @@ export const DuffelAssistant = ({
|
|
|
82
82
|
visible: isOpen,
|
|
83
83
|
onRequestClose: () => onClose(),
|
|
84
84
|
animationType: "slide",
|
|
85
|
-
children: /*#__PURE__*/_jsx(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
children: /*#__PURE__*/_jsx(KeyboardAvoidingView, {
|
|
86
|
+
behavior: Platform.OS === 'android' ? 'padding' : undefined,
|
|
87
|
+
enabled: Platform.OS === 'android',
|
|
88
|
+
style: styles.keyboardAvoidingView,
|
|
89
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
90
|
+
style: styles.container,
|
|
91
|
+
children: Platform.OS === 'ios' ? /*#__PURE__*/_jsx(WebView, {
|
|
92
|
+
injectedJavaScriptObject: properties
|
|
93
|
+
// When you are running this in development iOS doesn't allow request from hosts with invalid https certificates.
|
|
94
|
+
// If you try ngrok with the local esbuild server it will fail because ngrok requests in https and the dev server rejects http requests.
|
|
95
|
+
// Easiest solution is to use the production URL with test data.
|
|
96
|
+
// If that's not possible, you can also upload the assistant built assets to a different folder in assets.duffel and work with that.
|
|
97
|
+
,
|
|
98
|
+
source: {
|
|
99
|
+
uri: assistantIframeUrl
|
|
100
|
+
},
|
|
101
|
+
onMessage: handleMessage,
|
|
102
|
+
onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,
|
|
103
|
+
style: styles.webView
|
|
104
|
+
}) : /*#__PURE__*/_jsx(WebView
|
|
105
|
+
// Required for Android
|
|
106
|
+
, {
|
|
107
|
+
injectedJavaScript: `
|
|
103
108
|
postMessage(
|
|
104
109
|
{
|
|
105
110
|
type: "duffel-assistant-open",
|
|
@@ -108,22 +113,30 @@ export const DuffelAssistant = ({
|
|
|
108
113
|
"*",
|
|
109
114
|
);
|
|
110
115
|
true;`,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
source: {
|
|
117
|
+
uri: assistantIframeUrl
|
|
118
|
+
},
|
|
119
|
+
onMessage: handleMessage,
|
|
120
|
+
onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,
|
|
121
|
+
style: styles.webView
|
|
122
|
+
})
|
|
116
123
|
})
|
|
117
124
|
})
|
|
118
125
|
});
|
|
119
126
|
};
|
|
120
127
|
const styles = StyleSheet.create({
|
|
128
|
+
keyboardAvoidingView: {
|
|
129
|
+
flex: 1
|
|
130
|
+
},
|
|
121
131
|
container: {
|
|
122
|
-
|
|
132
|
+
flex: 1,
|
|
123
133
|
width: '100%',
|
|
124
134
|
paddingHorizontal: 12,
|
|
125
135
|
paddingTop: 50,
|
|
126
136
|
paddingBottom: 30
|
|
137
|
+
},
|
|
138
|
+
webView: {
|
|
139
|
+
flex: 1
|
|
127
140
|
}
|
|
128
141
|
});
|
|
129
142
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Linking","Modal","Platform","StyleSheet","View","WebView","hasJsonWebTokenFormat","getClientKeyPayload","jsx","_jsx","assistantIframeUrl","isHttpUrl","url","test","isAssistantIframeUrl","parsedUrl","URL","origin","pathname","error","DuffelAssistant","isOpen","onClose","onNewMessage","properties","clientKey","Error","clientKeyPayload","clientKeyIncludesResource","order_id","undefined","booking_id","cars_booking_id","issueType","console","warn","context","supportChannels","chat","showMinimiseButton","onMinimise","handleMessage","event","nativeEvent","data","parsedData","JSON","parse","type","userId","resourceId","handleShouldStartLoadWithRequest","request","OS","navigationType","openURL","catch","visible","onRequestClose","animationType","children","style","styles","container","injectedJavaScriptObject","source","uri","onMessage","onShouldStartLoadWithRequest","injectedJavaScript","stringify","create","
|
|
1
|
+
{"version":3,"names":["React","KeyboardAvoidingView","Linking","Modal","Platform","StyleSheet","View","WebView","hasJsonWebTokenFormat","getClientKeyPayload","jsx","_jsx","assistantIframeUrl","isHttpUrl","url","test","isAssistantIframeUrl","parsedUrl","URL","origin","pathname","error","DuffelAssistant","isOpen","onClose","onNewMessage","properties","clientKey","Error","clientKeyPayload","clientKeyIncludesResource","order_id","undefined","booking_id","cars_booking_id","issueType","console","warn","context","supportChannels","chat","showMinimiseButton","onMinimise","handleMessage","event","nativeEvent","data","parsedData","JSON","parse","type","userId","resourceId","handleShouldStartLoadWithRequest","request","OS","navigationType","openURL","catch","visible","onRequestClose","animationType","children","behavior","enabled","style","styles","keyboardAvoidingView","container","injectedJavaScriptObject","source","uri","onMessage","onShouldStartLoadWithRequest","webView","injectedJavaScript","stringify","create","flex","width","paddingHorizontal","paddingTop","paddingBottom"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,oBAAoB,EACpBC,OAAO,EACPC,KAAK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AK,EAAEC,MAAM,CAACQ;QAAQ,CACvB,CAAC,gBAEF/D,IAAA,CAACJ;QACC;QAAA;UACAoE,kBAAkB,EAAE;AAClC;AACA;AACA;AACA,4BAA4B3B,IAAI,CAAC4B,SAAS,CAAClD,UAAU,CAAC;AACtD;AACA;AACA;AACA,gBAAiB;UACH4C,MAAM,EAAE;YAAEC,GAAG,EAAE3D;UAAmB,CAAE;UACpC4D,SAAS,EAAE7B,aAAc;UACzB8B,4BAA4B,EAAEpB,gCAAiC;UAC/DY,KAAK,EAAEC,MAAM,CAACQ;QAAQ,CACvB;MACF,CACG;IAAC,CACa;EAAC,CAClB,CAAC;AAEZ,CAAC;AAED,MAAMR,MAAM,GAAG7D,UAAU,CAACwE,MAAM,CAAC;EAC/BV,oBAAoB,EAAE;IACpBW,IAAI,EAAE;EACR,CAAC;EACDV,SAAS,EAAE;IACTU,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,iBAAiB,EAAE,EAAE;IACrBC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE;EACjB,CAAC;EACDR,OAAO,EAAE;IACPI,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,KAAK,oBAAoB,IAAI,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAInG,MAAM,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AA2BhE,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAiK1D,CAAC"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
KeyboardAvoidingView,
|
|
4
|
+
Linking,
|
|
5
|
+
Modal,
|
|
6
|
+
Platform,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
3
10
|
import { WebView } from 'react-native-webview';
|
|
4
11
|
import { type DuffelAssistantProps as DuffelAssistantPropsImported } from './DuffelAssistantProps';
|
|
5
12
|
import { hasJsonWebTokenFormat } from './lib/hasJsonWebTokenFormat';
|
|
@@ -153,22 +160,28 @@ export const DuffelAssistant: React.FC<DuffelAssistantProps> = ({
|
|
|
153
160
|
onRequestClose={() => onClose()}
|
|
154
161
|
animationType="slide"
|
|
155
162
|
>
|
|
156
|
-
<
|
|
157
|
-
{Platform.OS === '
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
<KeyboardAvoidingView
|
|
164
|
+
behavior={Platform.OS === 'android' ? 'padding' : undefined}
|
|
165
|
+
enabled={Platform.OS === 'android'}
|
|
166
|
+
style={styles.keyboardAvoidingView}
|
|
167
|
+
>
|
|
168
|
+
<View style={styles.container}>
|
|
169
|
+
{Platform.OS === 'ios' ? (
|
|
170
|
+
<WebView
|
|
171
|
+
injectedJavaScriptObject={properties}
|
|
172
|
+
// When you are running this in development iOS doesn't allow request from hosts with invalid https certificates.
|
|
173
|
+
// If you try ngrok with the local esbuild server it will fail because ngrok requests in https and the dev server rejects http requests.
|
|
174
|
+
// Easiest solution is to use the production URL with test data.
|
|
175
|
+
// If that's not possible, you can also upload the assistant built assets to a different folder in assets.duffel and work with that.
|
|
176
|
+
source={{ uri: assistantIframeUrl }}
|
|
177
|
+
onMessage={handleMessage}
|
|
178
|
+
onShouldStartLoadWithRequest={handleShouldStartLoadWithRequest}
|
|
179
|
+
style={styles.webView}
|
|
180
|
+
/>
|
|
181
|
+
) : (
|
|
182
|
+
<WebView
|
|
183
|
+
// Required for Android
|
|
184
|
+
injectedJavaScript={`
|
|
172
185
|
postMessage(
|
|
173
186
|
{
|
|
174
187
|
type: "duffel-assistant-open",
|
|
@@ -177,22 +190,30 @@ export const DuffelAssistant: React.FC<DuffelAssistantProps> = ({
|
|
|
177
190
|
"*",
|
|
178
191
|
);
|
|
179
192
|
true;`}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
source={{ uri: assistantIframeUrl }}
|
|
194
|
+
onMessage={handleMessage}
|
|
195
|
+
onShouldStartLoadWithRequest={handleShouldStartLoadWithRequest}
|
|
196
|
+
style={styles.webView}
|
|
197
|
+
/>
|
|
198
|
+
)}
|
|
199
|
+
</View>
|
|
200
|
+
</KeyboardAvoidingView>
|
|
186
201
|
</Modal>
|
|
187
202
|
);
|
|
188
203
|
};
|
|
189
204
|
|
|
190
205
|
const styles = StyleSheet.create({
|
|
206
|
+
keyboardAvoidingView: {
|
|
207
|
+
flex: 1,
|
|
208
|
+
},
|
|
191
209
|
container: {
|
|
192
|
-
|
|
210
|
+
flex: 1,
|
|
193
211
|
width: '100%',
|
|
194
212
|
paddingHorizontal: 12,
|
|
195
213
|
paddingTop: 50,
|
|
196
214
|
paddingBottom: 30,
|
|
197
215
|
},
|
|
216
|
+
webView: {
|
|
217
|
+
flex: 1,
|
|
218
|
+
},
|
|
198
219
|
});
|