@originallyus/feedback-rn-sdk 4.0.0-beta.1 → 4.0.0-beta.11
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/README.md +67 -49
- package/lib/module/AIAContentUsefulness.js +1 -1
- package/lib/module/AIAContentUsefulness.js.map +1 -1
- package/lib/module/AIAFeedback.js +64 -18
- 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 +8 -3
- 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 +6 -7
- package/lib/module/component/MultiSelectButtons.js.map +1 -1
- package/lib/module/component/Rating.js +5 -6
- package/lib/module/component/Rating.js.map +1 -1
- package/lib/module/component/RatingNumber.js +4 -5
- 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/common.js +86 -56
- package/lib/module/utils/common.js.map +1 -1
- package/lib/module/utils/networking.js +3 -3
- package/lib/module/utils/networking.js.map +1 -1
- package/lib/typescript/AIAFeedback.d.ts +1 -1
- package/lib/typescript/AIAFeedback.d.ts.map +1 -1
- package/lib/typescript/AIAFeedbackStyles.d.ts +8 -0
- package/lib/typescript/AIAFeedbackStyles.d.ts.map +1 -1
- package/lib/typescript/component/MultiSelectButtons.d.ts.map +1 -1
- package/lib/typescript/component/Rating.d.ts.map +1 -1
- package/lib/typescript/component/RatingNumber.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +16 -16
- package/lib/typescript/service/feedbackService.d.ts +1 -1
- package/lib/typescript/utils/common.d.ts +1 -0
- package/lib/typescript/utils/common.d.ts.map +1 -1
- package/lib/typescript/utils/networking.d.ts +2 -2
- package/package.json +16 -5
- package/lib/module/component/READMEVI.md +0 -192
- 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,282 +0,0 @@
|
|
|
1
|
-
import {useMemo, useState} from 'react'
|
|
2
|
-
import {View, Text, StyleSheet, TextInput, type ViewStyle, type TextStyle} from 'react-native'
|
|
3
|
-
import * as f from '@utils/common'
|
|
4
|
-
import {
|
|
5
|
-
BG_DEFAULT,
|
|
6
|
-
BORDER_FOCUS,
|
|
7
|
-
BORDER_SECONDARY,
|
|
8
|
-
ERROR_COLOR,
|
|
9
|
-
TEXT_DARK,
|
|
10
|
-
TEXT_NOTE,
|
|
11
|
-
TEXT_PLACEHOLDER,
|
|
12
|
-
} from '@utils/constants'
|
|
13
|
-
import ErrorIcon from '@/assets/ErrorIcon'
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Props for the multi-line `Textarea` component.
|
|
17
|
-
*
|
|
18
|
-
* Renders a label, multi-line input, optional note, error, and character counter.
|
|
19
|
-
*/
|
|
20
|
-
export interface TextareaProps {
|
|
21
|
-
/**
|
|
22
|
-
* Current text value.
|
|
23
|
-
*/
|
|
24
|
-
value: string
|
|
25
|
-
/**
|
|
26
|
-
* Called when the text changes.
|
|
27
|
-
*/
|
|
28
|
-
onChangeText: (text: string) => void
|
|
29
|
-
/**
|
|
30
|
-
* Placeholder text.
|
|
31
|
-
*
|
|
32
|
-
* @default 'Placeholder'
|
|
33
|
-
*/
|
|
34
|
-
placeholder?: string
|
|
35
|
-
/**
|
|
36
|
-
* Label text rendered above the field.
|
|
37
|
-
*/
|
|
38
|
-
label?: string
|
|
39
|
-
/**
|
|
40
|
-
* Helper text rendered below the field.
|
|
41
|
-
*/
|
|
42
|
-
note?: string
|
|
43
|
-
/**
|
|
44
|
-
* Error message; when present, border and text are styled as error.
|
|
45
|
-
*/
|
|
46
|
-
error?: string
|
|
47
|
-
/**
|
|
48
|
-
* Maximum number of characters allowed. When set, a counter is shown.
|
|
49
|
-
*/
|
|
50
|
-
maxLength?: number
|
|
51
|
-
/**
|
|
52
|
-
* App width, used to compute internal padding.
|
|
53
|
-
*/
|
|
54
|
-
appWidth: number
|
|
55
|
-
/**
|
|
56
|
-
* Minimum height of the textarea.
|
|
57
|
-
*
|
|
58
|
-
* @default 120
|
|
59
|
-
*/
|
|
60
|
-
minHeight?: number
|
|
61
|
-
// Style
|
|
62
|
-
/**
|
|
63
|
-
* Background color when not focused.
|
|
64
|
-
*/
|
|
65
|
-
backgroundColor?: string
|
|
66
|
-
/**
|
|
67
|
-
* Border color when not focused and not errored.
|
|
68
|
-
*/
|
|
69
|
-
borderColor?: string
|
|
70
|
-
/**
|
|
71
|
-
* Background color when focused.
|
|
72
|
-
*/
|
|
73
|
-
focusBackgroundColor?: string
|
|
74
|
-
/**
|
|
75
|
-
* Border color when focused.
|
|
76
|
-
*/
|
|
77
|
-
focusBorderColor?: string
|
|
78
|
-
/**
|
|
79
|
-
* Border color when `error` is present.
|
|
80
|
-
*
|
|
81
|
-
* @default '#D32F2F'
|
|
82
|
-
*/
|
|
83
|
-
errorBorderColor?: string
|
|
84
|
-
/**
|
|
85
|
-
* Font family for the text input.
|
|
86
|
-
*/
|
|
87
|
-
fontFamily?: string
|
|
88
|
-
/**
|
|
89
|
-
* Font size for the text input.
|
|
90
|
-
*
|
|
91
|
-
* @default 16
|
|
92
|
-
*/
|
|
93
|
-
fontSize?: number
|
|
94
|
-
/**
|
|
95
|
-
* Color used for the placeholder text.
|
|
96
|
-
*/
|
|
97
|
-
placeholderTextColor?: string
|
|
98
|
-
/**
|
|
99
|
-
* Color used for the input text.
|
|
100
|
-
*/
|
|
101
|
-
textColor?: string
|
|
102
|
-
/**
|
|
103
|
-
* Style for the label text.
|
|
104
|
-
*/
|
|
105
|
-
labelStyle?: TextStyle
|
|
106
|
-
/**
|
|
107
|
-
* (Reserved) Style for a caption text, if used.
|
|
108
|
-
*/
|
|
109
|
-
captionStyle?: TextStyle
|
|
110
|
-
/**
|
|
111
|
-
* Style for the note text.
|
|
112
|
-
*/
|
|
113
|
-
noteStyle?: TextStyle
|
|
114
|
-
/**
|
|
115
|
-
* Style for the error text.
|
|
116
|
-
*/
|
|
117
|
-
errorStyle?: TextStyle
|
|
118
|
-
/**
|
|
119
|
-
* Style for the character counter text.
|
|
120
|
-
*/
|
|
121
|
-
counterStyle?: TextStyle
|
|
122
|
-
/**
|
|
123
|
-
* Style for the outer wrapper view.
|
|
124
|
-
*/
|
|
125
|
-
style?: ViewStyle
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function Textarea({
|
|
129
|
-
value,
|
|
130
|
-
onChangeText,
|
|
131
|
-
placeholder = 'Placeholder',
|
|
132
|
-
label,
|
|
133
|
-
note,
|
|
134
|
-
error,
|
|
135
|
-
maxLength,
|
|
136
|
-
appWidth,
|
|
137
|
-
minHeight = 120,
|
|
138
|
-
backgroundColor = BG_DEFAULT,
|
|
139
|
-
borderColor = BORDER_SECONDARY,
|
|
140
|
-
focusBackgroundColor = BG_DEFAULT,
|
|
141
|
-
focusBorderColor = BORDER_FOCUS,
|
|
142
|
-
errorBorderColor = ERROR_COLOR,
|
|
143
|
-
fontFamily,
|
|
144
|
-
fontSize = 16,
|
|
145
|
-
placeholderTextColor = TEXT_PLACEHOLDER,
|
|
146
|
-
textColor = TEXT_DARK,
|
|
147
|
-
labelStyle,
|
|
148
|
-
noteStyle,
|
|
149
|
-
errorStyle,
|
|
150
|
-
counterStyle,
|
|
151
|
-
style,
|
|
152
|
-
}: TextareaProps) {
|
|
153
|
-
const [focused, setFocused] = useState(false)
|
|
154
|
-
const length = value.length
|
|
155
|
-
const hasError = error != null && error !== ''
|
|
156
|
-
|
|
157
|
-
const effectiveBorderColor = useMemo(() => {
|
|
158
|
-
if (hasError) return errorBorderColor
|
|
159
|
-
if (focused) return focusBorderColor
|
|
160
|
-
return borderColor
|
|
161
|
-
}, [hasError, focused, errorBorderColor, focusBorderColor, borderColor])
|
|
162
|
-
|
|
163
|
-
const inputContainerStyle = useMemo(
|
|
164
|
-
() => [
|
|
165
|
-
styles.inputWrapper,
|
|
166
|
-
{
|
|
167
|
-
minHeight,
|
|
168
|
-
padding: f.w_p(appWidth, 8),
|
|
169
|
-
borderRadius: f.isTablet ? 6 : 4,
|
|
170
|
-
backgroundColor: focused ? focusBackgroundColor : backgroundColor,
|
|
171
|
-
borderColor: effectiveBorderColor,
|
|
172
|
-
borderWidth: 1,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
[minHeight, appWidth, focused, focusBackgroundColor, backgroundColor, effectiveBorderColor],
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
const textInputStyle = useMemo(
|
|
179
|
-
() => [
|
|
180
|
-
styles.input,
|
|
181
|
-
{
|
|
182
|
-
fontFamily,
|
|
183
|
-
fontSize,
|
|
184
|
-
color: textColor,
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
[fontFamily, fontSize, textColor],
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
<View style={[styles.wrapper, style]}>
|
|
192
|
-
{label != null && label !== '' && <Text style={[styles.label, labelStyle]}>{label}</Text>}
|
|
193
|
-
<View style={inputContainerStyle}>
|
|
194
|
-
<TextInput
|
|
195
|
-
placeholder={placeholder}
|
|
196
|
-
placeholderTextColor={placeholderTextColor}
|
|
197
|
-
style={textInputStyle}
|
|
198
|
-
multiline
|
|
199
|
-
value={value}
|
|
200
|
-
onChangeText={text => {
|
|
201
|
-
if (maxLength == null || text.length <= maxLength) {
|
|
202
|
-
onChangeText(text)
|
|
203
|
-
} else {
|
|
204
|
-
onChangeText(text.slice(0, maxLength))
|
|
205
|
-
}
|
|
206
|
-
}}
|
|
207
|
-
onFocus={() => setFocused(true)}
|
|
208
|
-
onBlur={() => setFocused(false)}
|
|
209
|
-
autoCorrect={false}
|
|
210
|
-
/>
|
|
211
|
-
{maxLength != null && (
|
|
212
|
-
<View style={styles.counterWrapper} pointerEvents="none">
|
|
213
|
-
<Text style={[styles.counter, {color: TEXT_PLACEHOLDER}, counterStyle]}>
|
|
214
|
-
{length}/{maxLength}
|
|
215
|
-
</Text>
|
|
216
|
-
</View>
|
|
217
|
-
)}
|
|
218
|
-
</View>
|
|
219
|
-
{note != null && note !== '' && <Text style={[styles.note, {color: TEXT_NOTE}, noteStyle]}>{note}</Text>}
|
|
220
|
-
{hasError && (
|
|
221
|
-
<View style={styles.errorWrap}>
|
|
222
|
-
<ErrorIcon size={20} color={ERROR_COLOR} />
|
|
223
|
-
<Text style={[styles.error, {color: ERROR_COLOR}, errorStyle]}>{error}</Text>
|
|
224
|
-
</View>
|
|
225
|
-
)}
|
|
226
|
-
</View>
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export default Textarea
|
|
231
|
-
|
|
232
|
-
const styles = StyleSheet.create({
|
|
233
|
-
wrapper: {
|
|
234
|
-
width: '100%',
|
|
235
|
-
alignSelf: 'stretch',
|
|
236
|
-
},
|
|
237
|
-
label: {
|
|
238
|
-
fontSize: 16,
|
|
239
|
-
fontWeight: '600',
|
|
240
|
-
color: '#000000',
|
|
241
|
-
marginBottom: 8,
|
|
242
|
-
},
|
|
243
|
-
inputWrapper: {
|
|
244
|
-
width: '100%',
|
|
245
|
-
position: 'relative',
|
|
246
|
-
flexShrink: 0,
|
|
247
|
-
},
|
|
248
|
-
note: {
|
|
249
|
-
fontSize: 12,
|
|
250
|
-
marginTop: 8,
|
|
251
|
-
},
|
|
252
|
-
input: {
|
|
253
|
-
flex: 1,
|
|
254
|
-
minHeight: 80,
|
|
255
|
-
textAlignVertical: 'top',
|
|
256
|
-
paddingBottom: 28,
|
|
257
|
-
width: '100%',
|
|
258
|
-
flexShrink: 0,
|
|
259
|
-
},
|
|
260
|
-
counterWrapper: {
|
|
261
|
-
position: 'absolute',
|
|
262
|
-
right: 12,
|
|
263
|
-
bottom: 8,
|
|
264
|
-
},
|
|
265
|
-
counter: {
|
|
266
|
-
fontSize: 12,
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
errorWrap: {
|
|
270
|
-
flexDirection: 'row',
|
|
271
|
-
alignItems: 'center',
|
|
272
|
-
marginTop: 8,
|
|
273
|
-
gap: 6,
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
error: {
|
|
277
|
-
fontSize: 14,
|
|
278
|
-
lineHeight: 20,
|
|
279
|
-
flex: 1,
|
|
280
|
-
fontWeight: '400',
|
|
281
|
-
},
|
|
282
|
-
})
|
|
@@ -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
|
-
}
|