freemium-survey-components 0.16.3 → 0.16.5
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 +98 -37
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/components/nps/index.d.ts +0 -31
- package/lib/types/components/nps/nps.stories.d.ts +0 -1
- package/lib/types/components/range/utils.d.ts +2 -0
- package/lib/types/survey/utils/logics.d.ts +14 -14
- package/lib/types/survey/utils/use-card-survey.d.ts +1 -1
- package/lib/types/survey/utils/use-standard-survey.d.ts +1 -1
- package/lib/types/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,59 +19,78 @@ Make sure you have the below installed in your app.
|
|
|
19
19
|
|
|
20
20
|
- Survey : SurveyProps
|
|
21
21
|
- WebInAppSurvey : WebInAppSurveyProps
|
|
22
|
-
-
|
|
22
|
+
- Range : RangeProps
|
|
23
23
|
|
|
24
24
|
### Types
|
|
25
25
|
```
|
|
26
26
|
type SurveyProps {
|
|
27
27
|
survey: SurveyType
|
|
28
|
+
answers: SurveyResponseType | null
|
|
28
29
|
surveyStyle?: 'standard' | 'card'
|
|
29
30
|
placeholders?: {
|
|
30
31
|
[key: string]: string
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
initialPivotAnswer?: number
|
|
33
34
|
onSubmit: (
|
|
34
|
-
data: {
|
|
35
|
-
|
|
35
|
+
data: {
|
|
36
|
+
[key: string]:
|
|
37
|
+
| string
|
|
38
|
+
| number
|
|
39
|
+
| Array<string | number>
|
|
40
|
+
| { [key: string]: string }
|
|
41
|
+
| null
|
|
42
|
+
},
|
|
43
|
+
callback: Function,
|
|
44
|
+
status: AnswerStatus,
|
|
36
45
|
) => void
|
|
37
46
|
preview?: boolean
|
|
38
47
|
mobilePreview?: boolean
|
|
48
|
+
closePreview?: () => void
|
|
49
|
+
onAnsweringPrompt: (id: number) => void
|
|
39
50
|
}
|
|
40
51
|
```
|
|
41
52
|
```
|
|
42
53
|
type WidgetProps = {
|
|
43
54
|
survey: SurveyType
|
|
44
|
-
|
|
55
|
+
answers: SurveyResponseType | null
|
|
56
|
+
preview?: boolean
|
|
45
57
|
placeholders: {
|
|
46
58
|
[key: string]: string
|
|
47
59
|
}
|
|
48
60
|
onSubmit: (
|
|
49
|
-
data: { [key: string]: string | number | Array<string | number> | null
|
|
61
|
+
data: { [key: string]: string | number | Array<string | number> | null },
|
|
50
62
|
callback: Function,
|
|
63
|
+
status: AnswerStatus,
|
|
51
64
|
) => void
|
|
52
|
-
preview?: boolean
|
|
53
65
|
onDismiss: () => void
|
|
54
66
|
onClose?: () => void
|
|
67
|
+
surveyType: 'default' | 'compact' | 'cozy'
|
|
55
68
|
unsubscribeUrl?: string
|
|
56
69
|
isSurveyCompleted: boolean
|
|
57
|
-
children: React.ReactNode
|
|
70
|
+
children: React.ReactNode
|
|
71
|
+
onAnsweringPrompt: (id: number) => void
|
|
58
72
|
}
|
|
59
73
|
```
|
|
60
74
|
```
|
|
61
|
-
type
|
|
75
|
+
type RangeProps = {
|
|
62
76
|
type_info: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
type_variant: 'NUMBER' | 'TEXT' | 'EMOJI' | 'STAR'
|
|
78
|
+
scale_properties?: {
|
|
79
|
+
order: 'ascending' | 'descending'
|
|
80
|
+
button_style: {
|
|
81
|
+
shape: ButtonShapeType
|
|
82
|
+
type: 'standard' | 'highlighted'
|
|
83
|
+
}
|
|
84
|
+
range: ScalePropertiesRangeType[]
|
|
85
|
+
labels: {
|
|
86
|
+
values: string[]
|
|
87
|
+
preference: 'edges' | 'all' | null
|
|
88
|
+
}
|
|
69
89
|
}
|
|
70
|
-
rating_presets: { start?: string; end?: string }
|
|
71
90
|
footer_text: string
|
|
72
91
|
}
|
|
73
92
|
onChangeHandler: (value: number) => void
|
|
74
|
-
|
|
93
|
+
value?: number
|
|
75
94
|
}
|
|
76
95
|
```
|
|
77
96
|
|
|
@@ -84,16 +103,20 @@ const WebSurveyPreview = () => {
|
|
|
84
103
|
return <Survey
|
|
85
104
|
survey={surveyObjectFromSurveyServ}
|
|
86
105
|
surveyStyle="card"
|
|
87
|
-
onSubmit = {async (data : surveyFormData,callback) => {
|
|
106
|
+
onSubmit = {async (data : surveyFormData,callback,status : 'PARTIAL' | 'COMPLETE') => {
|
|
107
|
+
// this will get called for every answer selection with status = 'PARTIAL'
|
|
88
108
|
await saveToDb(surveyFormData)
|
|
109
|
+
if(status === 'COMPETE')
|
|
89
110
|
callback?.() // callback should be executed in the caller once the save is done.
|
|
90
111
|
}}
|
|
91
112
|
placeholders = {{
|
|
92
113
|
'{{account.company_name}}': 'Freshworks',
|
|
93
114
|
'{{account.account_name}}': 'Freshworks Account',
|
|
94
|
-
}} // placeholders to resolve against any such placeholder in
|
|
115
|
+
}} // placeholders to resolve against any such placeholder in question's text
|
|
95
116
|
preview = {true} // preview true will not save the response
|
|
96
|
-
|
|
117
|
+
initialPivotAnswer={null} // pass a number if pivot qn needed to be prefilled by default
|
|
118
|
+
onAnsweringPrompt={(id) =>
|
|
119
|
+
console.log(`Prompt ${id ? 'accepted' : 'rejected'}`)}
|
|
97
120
|
/>
|
|
98
121
|
}
|
|
99
122
|
```
|
|
@@ -105,8 +128,9 @@ const Widget = () => {
|
|
|
105
128
|
survey={surveyObjectFromSurveyServ}
|
|
106
129
|
surveyType="compact"
|
|
107
130
|
placeholders={null}
|
|
108
|
-
onSubmit={(data, callback) => {
|
|
109
|
-
|
|
131
|
+
onSubmit={(data, callback,status) => {
|
|
132
|
+
if(status === 'COMPLETE')
|
|
133
|
+
callback?.()
|
|
110
134
|
setIsSurveyCompleted(true)
|
|
111
135
|
}}
|
|
112
136
|
onDismiss={() => {
|
|
@@ -115,29 +139,66 @@ const Widget = () => {
|
|
|
115
139
|
}}
|
|
116
140
|
unsubscribeUrl={'#'}
|
|
117
141
|
isSurveyCompleted={isSurveyCompleted}
|
|
118
|
-
children={null} // if we want render with respect to the widget's fixed
|
|
142
|
+
children={null} // if we want render with respect to the widget's fixed onAnsweringPrompt={(id) =>
|
|
143
|
+
console.log(`Prompt ${id ? 'accepted' : 'rejected'}`)
|
|
144
|
+
}
|
|
119
145
|
/>
|
|
120
146
|
}
|
|
121
147
|
```
|
|
122
148
|
```
|
|
123
|
-
import {
|
|
124
|
-
const
|
|
125
|
-
return <
|
|
149
|
+
import {Range} from 'freemium-survey-components'
|
|
150
|
+
const RangePreview = () => {
|
|
151
|
+
return <Range
|
|
126
152
|
type_info={{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
153
|
+
type_variant: 'TEXT',
|
|
154
|
+
scale_properties: {
|
|
155
|
+
order: 'ascending',
|
|
156
|
+
range: [
|
|
157
|
+
{
|
|
158
|
+
id: '1',
|
|
159
|
+
label: 'detractor',
|
|
160
|
+
min: 1,
|
|
161
|
+
max: 2,
|
|
130
162
|
},
|
|
131
|
-
|
|
132
|
-
|
|
163
|
+
{
|
|
164
|
+
id: '2',
|
|
165
|
+
label: 'passive',
|
|
166
|
+
min: 3,
|
|
167
|
+
max: 4,
|
|
133
168
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
169
|
+
{
|
|
170
|
+
id: '3',
|
|
171
|
+
label: 'promoter',
|
|
172
|
+
min: 5,
|
|
173
|
+
max: 10,
|
|
137
174
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
175
|
+
],
|
|
176
|
+
button_style: {
|
|
177
|
+
shape: 'rounded',
|
|
178
|
+
type: 'highlighted',
|
|
179
|
+
},
|
|
180
|
+
labels: {
|
|
181
|
+
preference: 'edges',
|
|
182
|
+
values: [
|
|
183
|
+
'Very dissatisfied',
|
|
184
|
+
'Very dissatisfied',
|
|
185
|
+
'Dissatisfied',
|
|
186
|
+
'Neutral',
|
|
187
|
+
'Satisfied',
|
|
188
|
+
'Dissatisfied',
|
|
189
|
+
'Neutral',
|
|
190
|
+
'Satisfied',
|
|
191
|
+
'Dissatisfied',
|
|
192
|
+
'Satisfied',
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
footer_text: 'We look forward to your feedback.',
|
|
197
|
+
}}
|
|
198
|
+
value={value}
|
|
199
|
+
onChangeHandler={(value: any) => {
|
|
200
|
+
setValue(value)
|
|
201
|
+
}}
|
|
141
202
|
/>
|
|
142
203
|
}
|
|
143
204
|
```
|