@originallyus/feedback-rn-sdk 4.0.0-beta.6 → 4.0.0-beta.8
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.
Potentially problematic release.
This version of @originallyus/feedback-rn-sdk might be problematic. Click here for more details.
- package/lib/module/AIAContentUsefulness.js +1 -1
- package/lib/module/AIAContentUsefulness.js.map +1 -1
- package/lib/module/AIAFeedback.js +8 -8
- package/lib/module/AIAFeedback.js.map +1 -1
- package/lib/module/AIAFeedbackForm.js.map +1 -1
- package/lib/module/AIAFeedbackSplash.js.map +1 -1
- package/lib/module/AIAFeedbackStyles.js.map +1 -1
- package/lib/module/AIAFeedbackSuccess.js.map +1 -1
- package/lib/module/component/ButtonSubmit.js +2 -2
- package/lib/module/component/ButtonSubmit.js.map +1 -1
- package/lib/module/component/Input.js +3 -3
- package/lib/module/component/Input.js.map +1 -1
- package/lib/module/component/MultiSelectButtons.js +5 -5
- package/lib/module/component/MultiSelectButtons.js.map +1 -1
- package/lib/module/component/Rating.js +4 -4
- package/lib/module/component/Rating.js.map +1 -1
- package/lib/module/component/RatingNumber.js +3 -3
- package/lib/module/component/RatingNumber.js.map +1 -1
- package/lib/module/component/Textarea.js +3 -3
- package/lib/module/component/Textarea.js.map +1 -1
- package/lib/module/component/YesNoButtons.js +2 -2
- package/lib/module/component/YesNoButtons.js.map +1 -1
- package/lib/module/index.js +8 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/service/feedbackService.js +1 -1
- package/lib/module/service/feedbackService.js.map +1 -1
- package/lib/module/utils/networking.js +3 -3
- package/lib/module/utils/networking.js.map +1 -1
- package/package.json +4 -4
- package/src/AIAContentUsefulness.tsx +0 -296
- package/src/AIAFeedback.tsx +0 -354
- package/src/AIAFeedbackForm.tsx +0 -267
- package/src/AIAFeedbackSplash.tsx +0 -49
- package/src/AIAFeedbackStyles.ts +0 -311
- package/src/AIAFeedbackSuccess.tsx +0 -67
- package/src/assets/CheckIcon.tsx +0 -18
- package/src/assets/CloseIcon.tsx +0 -18
- package/src/assets/ErrorIcon.tsx +0 -18
- package/src/assets/PlusIcon.tsx +0 -18
- package/src/assets/StarIcon.tsx +0 -18
- package/src/component/Button.tsx +0 -68
- package/src/component/ButtonSubmit.tsx +0 -335
- package/src/component/Input.tsx +0 -288
- package/src/component/MultiSelectButtons.tsx +0 -272
- package/src/component/README.md +0 -215
- package/src/component/READMEVI.md +0 -192
- package/src/component/Rating.tsx +0 -248
- package/src/component/RatingNumber.tsx +0 -421
- package/src/component/Textarea.tsx +0 -282
- package/src/component/YesNoButtons.tsx +0 -236
- package/src/index.tsx +0 -33
- package/src/service/feedbackService.ts +0 -108
- package/src/utils/common.ts +0 -241
- package/src/utils/constants.ts +0 -60
- package/src/utils/index.ts +0 -167
- package/src/utils/networking.ts +0 -134
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import {useMemo} from 'react'
|
|
2
|
-
import {View, Text, StyleSheet, type TextStyle, type ViewStyle} from 'react-native'
|
|
3
|
-
import ButtonSubmit from '@component/ButtonSubmit'
|
|
4
|
-
import {
|
|
5
|
-
BG_DEFAULT,
|
|
6
|
-
BG_SECONDARY,
|
|
7
|
-
BORDER_DEFAULT,
|
|
8
|
-
BORDER_SELECTED,
|
|
9
|
-
ERROR_COLOR,
|
|
10
|
-
PRESSED_COLOR,
|
|
11
|
-
PRIMARY_COLOR,
|
|
12
|
-
TEXT_DARK,
|
|
13
|
-
TEXT_WHITE,
|
|
14
|
-
} from '@utils/constants'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Value type for `YesNoButtons`.
|
|
18
|
-
*
|
|
19
|
-
* - `'yes'` – Yes selected.
|
|
20
|
-
* - `'no'` – No selected.
|
|
21
|
-
* - `null` – no selection.
|
|
22
|
-
*/
|
|
23
|
-
export type YesNoValue = 'yes' | 'no' | null
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Visual variant for the selected state of `YesNoButtons`.
|
|
27
|
-
*
|
|
28
|
-
* - `'primary'` – solid primary background with white text.
|
|
29
|
-
* - `'secondary'` – light background with border and dark text.
|
|
30
|
-
*/
|
|
31
|
-
export type YesNoSelectedVariant = 'primary' | 'secondary'
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Props for the `YesNoButtons` component.
|
|
35
|
-
*
|
|
36
|
-
* Renders a question label and two `ButtonSubmit` instances for Yes/No selection.
|
|
37
|
-
*/
|
|
38
|
-
export interface YesNoButtonsProps {
|
|
39
|
-
/**
|
|
40
|
-
* Question text displayed above the buttons.
|
|
41
|
-
*/
|
|
42
|
-
question: string
|
|
43
|
-
/**
|
|
44
|
-
* Current selection value.
|
|
45
|
-
*/
|
|
46
|
-
value: YesNoValue
|
|
47
|
-
/**
|
|
48
|
-
* Called when user selects Yes or No.
|
|
49
|
-
*/
|
|
50
|
-
onSelect: (value: 'yes' | 'no') => void
|
|
51
|
-
/**
|
|
52
|
-
* Visual variant for the selected button.
|
|
53
|
-
*
|
|
54
|
-
* @default 'primary'
|
|
55
|
-
*/
|
|
56
|
-
selectedVariant?: YesNoSelectedVariant
|
|
57
|
-
/**
|
|
58
|
-
* Label for the Yes button.
|
|
59
|
-
*
|
|
60
|
-
* @default 'Yes'
|
|
61
|
-
*/
|
|
62
|
-
yesLabel?: string
|
|
63
|
-
/**
|
|
64
|
-
* Label for the No button.
|
|
65
|
-
*
|
|
66
|
-
* @default 'No'
|
|
67
|
-
*/
|
|
68
|
-
noLabel?: string
|
|
69
|
-
/**
|
|
70
|
-
* Error message; when present, shown below the buttons with an "!" icon.
|
|
71
|
-
*/
|
|
72
|
-
error?: string
|
|
73
|
-
/**
|
|
74
|
-
* App width, passed to the underlying `ButtonSubmit` components.
|
|
75
|
-
*/
|
|
76
|
-
appWidth: number
|
|
77
|
-
/**
|
|
78
|
-
* Override background color when an option is selected (secondary variant).
|
|
79
|
-
*/
|
|
80
|
-
selectedBackgroundColor?: string
|
|
81
|
-
/**
|
|
82
|
-
* Override border color when an option is selected (secondary variant).
|
|
83
|
-
*/
|
|
84
|
-
selectedBorderColor?: string
|
|
85
|
-
/**
|
|
86
|
-
* Override text color when an option is selected (secondary variant).
|
|
87
|
-
*/
|
|
88
|
-
selectedTextColor?: string
|
|
89
|
-
/**
|
|
90
|
-
* Style for the question text.
|
|
91
|
-
*/
|
|
92
|
-
questionStyle?: TextStyle
|
|
93
|
-
/**
|
|
94
|
-
* Style for the error text.
|
|
95
|
-
*/
|
|
96
|
-
errorStyle?: TextStyle
|
|
97
|
-
/**
|
|
98
|
-
* Color for the error text and "!" icon.
|
|
99
|
-
*
|
|
100
|
-
* @default red (`ERROR_COLOR`)
|
|
101
|
-
*/
|
|
102
|
-
errorColor?: string
|
|
103
|
-
/**
|
|
104
|
-
* Style for the outer wrapper view.
|
|
105
|
-
*/
|
|
106
|
-
style?: ViewStyle
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function YesNoButtons({
|
|
110
|
-
question,
|
|
111
|
-
value,
|
|
112
|
-
onSelect,
|
|
113
|
-
selectedVariant = 'primary',
|
|
114
|
-
yesLabel = 'Yes',
|
|
115
|
-
noLabel = 'No',
|
|
116
|
-
error,
|
|
117
|
-
appWidth,
|
|
118
|
-
selectedBackgroundColor,
|
|
119
|
-
selectedBorderColor,
|
|
120
|
-
selectedTextColor,
|
|
121
|
-
questionStyle,
|
|
122
|
-
errorStyle,
|
|
123
|
-
errorColor = ERROR_COLOR,
|
|
124
|
-
style,
|
|
125
|
-
}: YesNoButtonsProps) {
|
|
126
|
-
const hasError = error != null && error !== ''
|
|
127
|
-
|
|
128
|
-
const isPrimarySelected = selectedVariant === 'primary'
|
|
129
|
-
const variantStyles = useMemo(
|
|
130
|
-
() =>
|
|
131
|
-
({
|
|
132
|
-
primary: {
|
|
133
|
-
selectedBg: PRIMARY_COLOR,
|
|
134
|
-
selectedBorder: undefined,
|
|
135
|
-
selectedText: TEXT_WHITE,
|
|
136
|
-
},
|
|
137
|
-
secondary: {
|
|
138
|
-
selectedBg: selectedBackgroundColor ?? BG_SECONDARY,
|
|
139
|
-
selectedBorder: selectedBorderColor ?? BORDER_SELECTED,
|
|
140
|
-
selectedText: selectedTextColor ?? TEXT_DARK,
|
|
141
|
-
},
|
|
142
|
-
}[selectedVariant]),
|
|
143
|
-
[selectedVariant, selectedBackgroundColor, selectedBorderColor, selectedTextColor],
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
const {selectedBg, selectedBorder, selectedText} = variantStyles
|
|
147
|
-
|
|
148
|
-
const buttonStyles = useMemo(() => {
|
|
149
|
-
const getStyles = (option: 'yes' | 'no') => {
|
|
150
|
-
const isSelected = value === option
|
|
151
|
-
return {
|
|
152
|
-
variant: isSelected && isPrimarySelected ? 'primary' : 'secondary',
|
|
153
|
-
backgroundColor: isSelected ? selectedBg : BG_DEFAULT,
|
|
154
|
-
textColor: isSelected ? selectedText : hasError ? errorColor : TEXT_DARK,
|
|
155
|
-
borderColor: isSelected ? selectedBorder : hasError ? errorColor : BORDER_DEFAULT,
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
yes: getStyles('yes'),
|
|
161
|
-
no: getStyles('no'),
|
|
162
|
-
}
|
|
163
|
-
}, [value, isPrimarySelected, selectedBg, selectedText, hasError, errorColor, selectedBorder])
|
|
164
|
-
|
|
165
|
-
const renderButton = (option: 'yes' | 'no') => {
|
|
166
|
-
const stylesBtn = buttonStyles[option]
|
|
167
|
-
const label = option === 'yes' ? yesLabel : noLabel
|
|
168
|
-
return (
|
|
169
|
-
<ButtonSubmit
|
|
170
|
-
appWidth={appWidth}
|
|
171
|
-
title={label}
|
|
172
|
-
onPress={() => onSelect(option)}
|
|
173
|
-
variant={stylesBtn.variant as any}
|
|
174
|
-
fullWidth
|
|
175
|
-
backgroundColor={stylesBtn.backgroundColor}
|
|
176
|
-
textColor={stylesBtn.textColor}
|
|
177
|
-
borderColor={stylesBtn.borderColor}
|
|
178
|
-
pressedColor={PRESSED_COLOR}
|
|
179
|
-
containerStyle={styles.buttonContainer}
|
|
180
|
-
/>
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<View style={[styles.wrapper, style]}>
|
|
186
|
-
{question != null && question !== '' && <Text style={[styles.question, questionStyle]}>{question}</Text>}
|
|
187
|
-
<View style={styles.row}>
|
|
188
|
-
<View style={styles.buttonSlot}>{renderButton('yes')}</View>
|
|
189
|
-
<View style={styles.buttonSlot}>{renderButton('no')}</View>
|
|
190
|
-
</View>
|
|
191
|
-
{hasError && (
|
|
192
|
-
<View style={styles.errorRow}>
|
|
193
|
-
<Text style={[styles.errorIcon, {color: errorColor}]}>!</Text>
|
|
194
|
-
<Text style={[styles.errorText, {color: errorColor}, errorStyle]}>{error}</Text>
|
|
195
|
-
</View>
|
|
196
|
-
)}
|
|
197
|
-
</View>
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export default YesNoButtons
|
|
202
|
-
|
|
203
|
-
const styles = StyleSheet.create({
|
|
204
|
-
wrapper: {
|
|
205
|
-
width: '100%',
|
|
206
|
-
},
|
|
207
|
-
question: {
|
|
208
|
-
fontSize: 16,
|
|
209
|
-
fontWeight: '600',
|
|
210
|
-
color: '#000000',
|
|
211
|
-
marginBottom: 12,
|
|
212
|
-
},
|
|
213
|
-
row: {
|
|
214
|
-
flexDirection: 'row',
|
|
215
|
-
gap: 12,
|
|
216
|
-
},
|
|
217
|
-
buttonSlot: {
|
|
218
|
-
flex: 1,
|
|
219
|
-
},
|
|
220
|
-
buttonContainer: {
|
|
221
|
-
marginTop: 0,
|
|
222
|
-
},
|
|
223
|
-
errorRow: {
|
|
224
|
-
flexDirection: 'row',
|
|
225
|
-
alignItems: 'center',
|
|
226
|
-
marginTop: 8,
|
|
227
|
-
gap: 6,
|
|
228
|
-
},
|
|
229
|
-
errorIcon: {
|
|
230
|
-
fontSize: 14,
|
|
231
|
-
fontWeight: '700',
|
|
232
|
-
},
|
|
233
|
-
errorText: {
|
|
234
|
-
fontSize: 12,
|
|
235
|
-
},
|
|
236
|
-
})
|
package/src/index.tsx
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export {Button} from '@component/Button'
|
|
2
|
-
export type {ButtonProps} from '@component/Button'
|
|
3
|
-
|
|
4
|
-
export {default as RatingNumber} from '@component/RatingNumber'
|
|
5
|
-
export type {RatingNumberProps, RatingNumberSize} from '@component/RatingNumber'
|
|
6
|
-
|
|
7
|
-
export {default as Rating} from '@component/Rating'
|
|
8
|
-
export type {RatingProps} from '@component/Rating'
|
|
9
|
-
|
|
10
|
-
export {default as Textarea} from '@component/Textarea'
|
|
11
|
-
export type {TextareaProps} from '@component/Textarea'
|
|
12
|
-
|
|
13
|
-
export {default as Input} from '@component/Input'
|
|
14
|
-
export type {InputProps} from '@component/Input'
|
|
15
|
-
|
|
16
|
-
export {default as ButtonSubmit} from '@component/ButtonSubmit'
|
|
17
|
-
export type {ButtonSubmitProps, ButtonSubmitVariant} from '@component/ButtonSubmit'
|
|
18
|
-
|
|
19
|
-
export {default as YesNoButtons} from '@component/YesNoButtons'
|
|
20
|
-
export type {YesNoButtonsProps, YesNoValue, YesNoSelectedVariant} from '@component/YesNoButtons'
|
|
21
|
-
|
|
22
|
-
export {default as MultiSelectButtons} from '@component/MultiSelectButtons'
|
|
23
|
-
export type {
|
|
24
|
-
MultiSelectButtonsProps,
|
|
25
|
-
MultiSelectOption,
|
|
26
|
-
MultiSelectSelectedVariant,
|
|
27
|
-
} from '@component/MultiSelectButtons'
|
|
28
|
-
|
|
29
|
-
export {default as AIAFeedback} from './AIAFeedback'
|
|
30
|
-
export type {AIAFeedbackProps, AIAFeedbackRef} from './AIAFeedback'
|
|
31
|
-
|
|
32
|
-
export {default as AIAContentUsefulness} from './AIAContentUsefulness'
|
|
33
|
-
export type {AIAContentUsefulnessProps} from './AIAContentUsefulness'
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {customFetch} from '@/utils/networking'
|
|
2
|
-
import {type InitOptions} from '@/utils/constants'
|
|
3
|
-
|
|
4
|
-
export interface SubmitFormData {
|
|
5
|
-
slug: string
|
|
6
|
-
debug: boolean
|
|
7
|
-
event_tag: string
|
|
8
|
-
metadata: any
|
|
9
|
-
request_id: string
|
|
10
|
-
rating: number
|
|
11
|
-
selected_options: string
|
|
12
|
-
free_text: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface SubmitSelectionData {
|
|
16
|
-
slug: string
|
|
17
|
-
debug: boolean
|
|
18
|
-
event_tag: string
|
|
19
|
-
metadata: any
|
|
20
|
-
rating: number
|
|
21
|
-
request_id: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ShowOptions {
|
|
25
|
-
forceModal?: boolean
|
|
26
|
-
initialData?: any
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type ShowListener = (slug: string, options?: ShowOptions) => boolean
|
|
30
|
-
|
|
31
|
-
const showListeners: ShowListener[] = []
|
|
32
|
-
|
|
33
|
-
export const feedbackService = {
|
|
34
|
-
onShow: (callback: ShowListener) => {
|
|
35
|
-
showListeners.push(callback)
|
|
36
|
-
return () => {
|
|
37
|
-
const index = showListeners.indexOf(callback)
|
|
38
|
-
if (index > -1) showListeners.splice(index, 1)
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
emitShow: (slug: string, options?: ShowOptions): boolean => {
|
|
43
|
-
let handled = false
|
|
44
|
-
for (const listener of showListeners) {
|
|
45
|
-
if (listener(slug, options)) handled = true
|
|
46
|
-
}
|
|
47
|
-
return handled
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
requestForm: (options: InitOptions, callback: (response: any) => void) => {
|
|
51
|
-
customFetch({
|
|
52
|
-
_shouldRetry: true,
|
|
53
|
-
_url: '8vs2qwFD1rlSFWIa13Wc',
|
|
54
|
-
_data: {
|
|
55
|
-
slug: options.formSlug,
|
|
56
|
-
debug: options.debug,
|
|
57
|
-
event_tag: options.eventTag,
|
|
58
|
-
metadata: options.metadata,
|
|
59
|
-
},
|
|
60
|
-
_callback: callback,
|
|
61
|
-
options: options,
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
submitForm: async (formData: SubmitFormData, options: InitOptions): Promise<any> => {
|
|
66
|
-
return new Promise((resolve, reject) => {
|
|
67
|
-
customFetch({
|
|
68
|
-
_shouldRetry: true,
|
|
69
|
-
_url: 'LXvcFSTTOqxxmJX9qQar',
|
|
70
|
-
_data: formData,
|
|
71
|
-
_callback: (res: any) => {
|
|
72
|
-
if (!res) {
|
|
73
|
-
reject(new Error('Empty response'))
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
if (res.error) {
|
|
77
|
-
reject(new Error(res.error))
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
resolve(res)
|
|
81
|
-
},
|
|
82
|
-
options: options,
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
submitSelection: async (selectionData: SubmitSelectionData, options: InitOptions): Promise<any> => {
|
|
88
|
-
return new Promise((resolve, reject) => {
|
|
89
|
-
customFetch({
|
|
90
|
-
_shouldRetry: true,
|
|
91
|
-
_url: 'LXvcFSTTOqxxmJX9qQar',
|
|
92
|
-
_data: selectionData,
|
|
93
|
-
_callback: (res: any) => {
|
|
94
|
-
if (!res) {
|
|
95
|
-
reject(new Error('Empty response'))
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
if (res.error) {
|
|
99
|
-
reject(new Error(res.error))
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
resolve(res)
|
|
103
|
-
},
|
|
104
|
-
options: options,
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
},
|
|
108
|
-
}
|
package/src/utils/common.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import {Dimensions, I18nManager, Platform, Settings, NativeModules} from 'react-native'
|
|
2
|
-
|
|
3
|
-
const isExpo = !NativeModules || Object.keys(NativeModules).length === 0 || !NativeModules.RNDeviceInfo
|
|
4
|
-
|
|
5
|
-
type DeviceInfoLike = {
|
|
6
|
-
getUniqueId: () => string | Promise<string>
|
|
7
|
-
getSystemVersion: () => string | Promise<string>
|
|
8
|
-
getVersion: () => string | Promise<string>
|
|
9
|
-
getBuildNumber: () => string | Promise<string>
|
|
10
|
-
getModel: () => string | Promise<string>
|
|
11
|
-
getBundleId: () => string | Promise<string>
|
|
12
|
-
getManufacturer: () => string | Promise<string>
|
|
13
|
-
getDeviceType: () => string | Promise<string>
|
|
14
|
-
getDeviceId: () => string | Promise<string>
|
|
15
|
-
getBrand: () => string | Promise<string>
|
|
16
|
-
isTablet: () => boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let DeviceInfo: DeviceInfoLike = {
|
|
20
|
-
getUniqueId: function getUniqueIdDefault() {
|
|
21
|
-
return ''
|
|
22
|
-
},
|
|
23
|
-
getSystemVersion: function getSystemVersionDefault() {
|
|
24
|
-
return ''
|
|
25
|
-
},
|
|
26
|
-
getVersion: function getVersionDefault() {
|
|
27
|
-
return ''
|
|
28
|
-
},
|
|
29
|
-
getBuildNumber: function getBuildNumberDefault() {
|
|
30
|
-
return ''
|
|
31
|
-
},
|
|
32
|
-
getModel: function getModelDefault() {
|
|
33
|
-
return ''
|
|
34
|
-
},
|
|
35
|
-
getBundleId: function getBundleIdDefault() {
|
|
36
|
-
return ''
|
|
37
|
-
},
|
|
38
|
-
getManufacturer: function getManufacturerDefault() {
|
|
39
|
-
return ''
|
|
40
|
-
},
|
|
41
|
-
getDeviceType: function getDeviceTypeDefault() {
|
|
42
|
-
return ''
|
|
43
|
-
},
|
|
44
|
-
getDeviceId: function getDeviceIdDefault() {
|
|
45
|
-
return ''
|
|
46
|
-
},
|
|
47
|
-
getBrand: function getBrandDefault() {
|
|
48
|
-
return ''
|
|
49
|
-
},
|
|
50
|
-
isTablet: function isTabletDefault() {
|
|
51
|
-
return false
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (isExpo) {
|
|
56
|
-
const expoDevice = require('expo-device')
|
|
57
|
-
|
|
58
|
-
const expoApplication = require('expo-application')
|
|
59
|
-
|
|
60
|
-
DeviceInfo = {
|
|
61
|
-
getUniqueId: function getUniqueIdForExpo() {
|
|
62
|
-
if (Platform.OS === 'android') {
|
|
63
|
-
return expoApplication.getAndroidId()
|
|
64
|
-
}
|
|
65
|
-
return expoApplication.getIosIdForVendorAsync()
|
|
66
|
-
},
|
|
67
|
-
getSystemVersion: function getSystemVersionForExpo() {
|
|
68
|
-
return expoDevice.osVersion || ''
|
|
69
|
-
},
|
|
70
|
-
getVersion: function getVersionForExpo() {
|
|
71
|
-
return expoApplication.nativeApplicationVersion || ''
|
|
72
|
-
},
|
|
73
|
-
getBuildNumber: function getBuildNumberForExpo() {
|
|
74
|
-
return expoApplication.nativeBuildVersion || ''
|
|
75
|
-
},
|
|
76
|
-
getModel: function getModelForExpo() {
|
|
77
|
-
return expoDevice.modelName || ''
|
|
78
|
-
},
|
|
79
|
-
getBundleId: function getBundleIdForExpo() {
|
|
80
|
-
return expoApplication.applicationId || ''
|
|
81
|
-
},
|
|
82
|
-
getManufacturer: function getManufacturerForExpo() {
|
|
83
|
-
if (expoDevice.getManufacturerAsync) {
|
|
84
|
-
return expoDevice.getManufacturerAsync()
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return expoDevice.manufacturer || ''
|
|
88
|
-
},
|
|
89
|
-
getDeviceType: function getDeviceTypeForExpo() {
|
|
90
|
-
if (expoDevice.deviceType) {
|
|
91
|
-
return String(expoDevice.deviceType)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return ''
|
|
95
|
-
},
|
|
96
|
-
getDeviceId: function getDeviceIdForExpo() {
|
|
97
|
-
if (expoDevice.modelId) {
|
|
98
|
-
return expoDevice.modelId
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (expoDevice.modelName) {
|
|
102
|
-
return expoDevice.modelName
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return ''
|
|
106
|
-
},
|
|
107
|
-
getBrand: function getBrandForExpo() {
|
|
108
|
-
return expoDevice.brand || ''
|
|
109
|
-
},
|
|
110
|
-
isTablet: function isTabletForExpo() {
|
|
111
|
-
if (expoDevice.deviceType === 'tablet' || expoDevice.deviceType === 2) {
|
|
112
|
-
return true
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return false
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!isExpo) {
|
|
120
|
-
const rnDeviceInfo = require('react-native-device-info') as DeviceInfoLike
|
|
121
|
-
DeviceInfo = rnDeviceInfo
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export const isTablet: boolean = DeviceInfo.isTablet()
|
|
125
|
-
const {width, height} = Dimensions.get('window')
|
|
126
|
-
|
|
127
|
-
export function isObject(value: unknown): value is object {
|
|
128
|
-
const type = typeof value
|
|
129
|
-
return value != null && (type === 'object' || type === 'function')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function sample<T>(array: T[] | null | undefined): T | undefined {
|
|
133
|
-
const length = array == null ? 0 : array.length
|
|
134
|
-
const timestampSeconds = Math.floor(Date.now() / 1000)
|
|
135
|
-
return length && array ? array[timestampSeconds % length] : undefined
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function isNil(value: unknown): value is null | undefined {
|
|
139
|
-
return value == null
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function w_p(widthVal: number, paddingNumber: number): number {
|
|
143
|
-
return (paddingNumber / 375) * widthVal
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function w_p21(widthVal: number): number {
|
|
147
|
-
return (21 / 375) * widthVal
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export function w_p16(widthVal: number): number {
|
|
151
|
-
return (16 / 375) * widthVal
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function h_p21(heightVal: number): number {
|
|
155
|
-
return (21 / 667) * heightVal
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function h_p16(heightVal: number): number {
|
|
159
|
-
return (16 / 667) * heightVal
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function getAppWidth(isIntrusive: boolean): number {
|
|
163
|
-
let appWidth = width
|
|
164
|
-
if (isTablet) {
|
|
165
|
-
appWidth = isIntrusive ? 768 : 375
|
|
166
|
-
}
|
|
167
|
-
return appWidth
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function getAppHeight(isIntrusive: boolean): number {
|
|
171
|
-
let appHeight = height
|
|
172
|
-
if (isTablet) {
|
|
173
|
-
appHeight = isIntrusive ? (height * 3) / 4 : 450
|
|
174
|
-
}
|
|
175
|
-
return appHeight
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export const getUniqueID = async (): Promise<string> => {
|
|
179
|
-
const result = DeviceInfo.getUniqueId()
|
|
180
|
-
return typeof result === 'object' ? await result : result
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export const getSystemVersion = async (): Promise<string> => {
|
|
184
|
-
const result = DeviceInfo.getSystemVersion()
|
|
185
|
-
return typeof result === 'object' ? await result : result
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export const getVersion = async (): Promise<string> => {
|
|
189
|
-
const result = DeviceInfo.getVersion()
|
|
190
|
-
return typeof result === 'object' ? await result : result
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export const getBuildNumber = async (): Promise<string> => {
|
|
194
|
-
const result = DeviceInfo.getBuildNumber()
|
|
195
|
-
return typeof result === 'object' ? await result : result
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export const getModel = async (): Promise<string> => {
|
|
199
|
-
const result = DeviceInfo.getModel()
|
|
200
|
-
return typeof result === 'object' ? await result : result
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export const getBundleId = async (): Promise<string> => {
|
|
204
|
-
const result = DeviceInfo.getBundleId()
|
|
205
|
-
return typeof result === 'object' ? await result : result
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export const getManufacturer = async (): Promise<string> => {
|
|
209
|
-
const result = DeviceInfo.getManufacturer()
|
|
210
|
-
return typeof result === 'object' ? await result : result
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export const getDeviceType = async (): Promise<string> => {
|
|
214
|
-
const result = DeviceInfo.getDeviceType()
|
|
215
|
-
return typeof result === 'object' ? await result : result
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export const getDeviceId = async (): Promise<string> => {
|
|
219
|
-
const result = DeviceInfo.getDeviceId()
|
|
220
|
-
return typeof result === 'object' ? await result : result
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export const getBrand = async (): Promise<string> => {
|
|
224
|
-
const result = DeviceInfo.getBrand()
|
|
225
|
-
return typeof result === 'object' ? await result : result
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export const getLocale = async (): Promise<string> => {
|
|
229
|
-
let currentLocale = 'en'
|
|
230
|
-
|
|
231
|
-
if (Platform.OS === 'ios') {
|
|
232
|
-
const settings = Settings.get('AppleLocale') as string | undefined
|
|
233
|
-
const locale = settings
|
|
234
|
-
if (locale) currentLocale = typeof locale === 'string' ? locale : String(locale)
|
|
235
|
-
} else {
|
|
236
|
-
const locale = I18nManager.getConstants().localeIdentifier
|
|
237
|
-
if (locale) currentLocale = locale
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return currentLocale
|
|
241
|
-
}
|
package/src/utils/constants.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// Brand Colors
|
|
2
|
-
export const PRIMARY_COLOR = 'rgba(224, 8, 66, 1)'
|
|
3
|
-
export const PRESSED_COLOR = 'hsl(344, 92.90%, 38.40%)'
|
|
4
|
-
export const ERROR_COLOR = '#D40C74'
|
|
5
|
-
|
|
6
|
-
// Background Colors
|
|
7
|
-
export const BG_DEFAULT = '#FFFFFF'
|
|
8
|
-
export const BG_SECONDARY = '#EBEDF3'
|
|
9
|
-
export const BG_DISABLED = 'rgba(224, 224, 224, 1)'
|
|
10
|
-
export const BG_DISABLED_SECONDARY = 'rgba(240, 240, 240, 1)'
|
|
11
|
-
export const BG_BUTTON_SECONDARY = 'rgba(255, 237, 241, 1)'
|
|
12
|
-
|
|
13
|
-
export const BG_SELECTED = '#ebedf3'
|
|
14
|
-
// Border Colors
|
|
15
|
-
export const BORDER_DEFAULT = '#858b91'
|
|
16
|
-
export const BORDER_SECONDARY = 'rgba(133, 139, 145, 1)'
|
|
17
|
-
export const BORDER_FOCUS = '#082065'
|
|
18
|
-
export const BORDER_SELECTED = '#082065'
|
|
19
|
-
|
|
20
|
-
// Text Colors
|
|
21
|
-
export const TEXT_DEFAULT = '#082065'
|
|
22
|
-
export const TEXT_DARK = '#000000'
|
|
23
|
-
export const TEXT_WHITE = '#FFFFFF'
|
|
24
|
-
export const TEXT_PLACEHOLDER = '#9E9E9E'
|
|
25
|
-
export const TEXT_NOTE = '#757575'
|
|
26
|
-
export const TEXT_DISABLED = 'rgba(168, 168, 168, 1)'
|
|
27
|
-
|
|
28
|
-
// Component Specific Colors
|
|
29
|
-
export const COLOR_STAR_NORMAL = '#D0D0D0'
|
|
30
|
-
export const COLOR_STAR_SELECTED = '#F7C926'
|
|
31
|
-
|
|
32
|
-
export interface InitOptions {
|
|
33
|
-
language?: string
|
|
34
|
-
userId?: string | null
|
|
35
|
-
formSlug?: string
|
|
36
|
-
debug?: boolean
|
|
37
|
-
eventTag?: string
|
|
38
|
-
metadata?: any
|
|
39
|
-
appSec?: string
|
|
40
|
-
packageId?: string
|
|
41
|
-
deviceUuid?: string
|
|
42
|
-
[key: string]: any
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const OUS_VARS: any = {
|
|
46
|
-
ratingStars: 0,
|
|
47
|
-
fonts: null,
|
|
48
|
-
theme: null,
|
|
49
|
-
sdkCallbackFunction: null,
|
|
50
|
-
version: '4.0.0.beta.16', // Aligning with web version for compatibility
|
|
51
|
-
uuid: '',
|
|
52
|
-
language: 'en',
|
|
53
|
-
options: null,
|
|
54
|
-
ENDPOINTS: ['VlAI2Q1FDHvASMhqTXe0', 'rNwrNi5Iw36epJS9gprO', 'Ij8Ji87IpdZTXSw1kAFV'],
|
|
55
|
-
API_URL: 'https://aia-dfs.originally.us/backend',
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const xmlsUrl = 'http://www.w3.org/2000/svg'
|
|
59
|
-
export const containerId = 'sdk_view_container'
|
|
60
|
-
export const inlineComponentId = 'sdk_inline_view_container'
|