freemium-survey-components 0.16.5 → 1.0.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 +91 -95
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/components/binary/index.d.ts +1 -1
- package/lib/types/components/prompt/index.d.ts +3 -1
- package/lib/types/components/text-input/index.d.ts +6 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/survey/card/index.d.ts +2 -2
- package/lib/types/{components/nps/index.d.ts → survey/channels.stories.d.ts} +0 -0
- package/lib/types/survey/channelsPreview/channels.stories.d.ts +1 -0
- package/lib/types/survey/channelsPreview/index.d.ts +5 -0
- package/lib/types/survey/channelsPreview/instagram.d.ts +3 -0
- package/lib/types/survey/channelsPreview/question.d.ts +12 -0
- package/lib/types/survey/channelsPreview/utils.d.ts +1 -0
- package/lib/types/survey/channelsPreview/whatsapp.d.ts +3 -0
- package/lib/types/survey/meta-channel-preview/channels.stories.d.ts +1 -0
- package/lib/types/survey/meta-channel-preview/index.d.ts +5 -0
- package/lib/types/survey/meta-channel-preview/question.d.ts +12 -0
- package/lib/types/survey/meta-channel-preview/utils.d.ts +1 -0
- package/lib/types/survey/meta-channel-preview/whatsapp.d.ts +3 -0
- package/lib/types/survey/standard/index.d.ts +2 -2
- package/lib/types/survey/utils/logics.d.ts +42 -42
- package/lib/types/survey/utils/use-card-survey.d.ts +8 -8
- package/lib/types/survey/utils/use-standard-survey.d.ts +8 -8
- package/lib/types/survey/utils/use-survey.d.ts +5 -2
- package/lib/types/survey/whatsapp/index.d.ts +3 -0
- package/lib/types/survey/whatsapp/question.d.ts +8 -0
- package/lib/types/survey/whatsapp/utils.d.ts +1 -0
- package/lib/types/survey/widget/index.d.ts +4 -2
- package/lib/types/types.d.ts +23 -16
- package/package.json +1 -1
- package/lib/types/components/nps/nps.stories.d.ts +0 -0
- package/lib/types/newTypes.d.ts +0 -0
- package/lib/types/survey/utils/utils.d.ts +0 -0
package/README.md
CHANGED
|
@@ -97,113 +97,109 @@ type RangeProps = {
|
|
|
97
97
|
### Usage
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
```
|
|
100
|
+
```js
|
|
101
101
|
import {Survey} from 'freemium-survey-components'
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
102
|
+
<Survey
|
|
103
|
+
survey={surveyObjectFromSurveyServ}
|
|
104
|
+
surveyStyle="card"
|
|
105
|
+
onSubmit = {async function(data : {[key : string] : string | number | boolean | null | string[]},callback,status : 'PARTIAL' | 'COMPLETE') {
|
|
106
|
+
await saveToDb(surveyFormData)
|
|
107
|
+
if(status === 'COMPETE')
|
|
108
|
+
// callback should be executed in the caller once the save is done.
|
|
109
|
+
callback?.()
|
|
110
|
+
}}
|
|
111
|
+
// this will get called for every answer selection with status = 'PARTIAL'
|
|
112
|
+
placeholders = {{
|
|
113
|
+
'{{account.company_name}}': 'Freshworks',
|
|
114
|
+
'{{account.account_name}}': 'Freshworks Account',
|
|
115
|
+
}}
|
|
116
|
+
// placeholders to resolve against any such placeholder in question's text
|
|
117
|
+
preview = {true}
|
|
118
|
+
// preview true will not save the response
|
|
119
|
+
initialPivotAnswer={null}
|
|
120
|
+
// pass a number if pivot qn needed to be prefilled by default
|
|
121
|
+
onAnsweringPrompt={function(id){ console.log(`Prompt ${id ? 'accepted' : 'rejected'}}`)}}
|
|
122
|
+
/>
|
|
123
123
|
```
|
|
124
|
+
```js
|
|
124
125
|
import {WebInAppSurvey} from 'freemium-survey-components'
|
|
125
|
-
const Widget = () => {
|
|
126
126
|
const [isSurveyCompleted,setIsSurveyCompleted] = useState(false)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
127
|
+
<WebInAppSurvey
|
|
128
|
+
survey={surveyObjectFromSurveyServ}
|
|
129
|
+
surveyType="compact"
|
|
130
|
+
placeholders={null}
|
|
131
|
+
onSubmit={function (data, callback,status){
|
|
132
|
+
if(status === 'COMPLETE')
|
|
133
|
+
callback?.()
|
|
134
|
+
setIsSurveyCompleted(true)
|
|
135
|
+
}}
|
|
136
|
+
onDismiss={function() {
|
|
137
|
+
// when the widget is dismissed, this gets executed.
|
|
138
|
+
}}
|
|
139
|
+
unsubscribeUrl={'#'}
|
|
140
|
+
isSurveyCompleted={isSurveyCompleted}
|
|
141
|
+
children={null}
|
|
142
|
+
// if we want render with respect to the widget's fixed
|
|
143
|
+
onAnsweringPrompt={function (id){ console.log(`Prompt ${id ? 'accepted' : 'rejected'}`)}}
|
|
145
144
|
/>
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
145
|
```
|
|
146
|
+
```js
|
|
149
147
|
import {Range} from 'freemium-survey-components'
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
max: 4,
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
id: '3',
|
|
171
|
-
label: 'promoter',
|
|
172
|
-
min: 5,
|
|
173
|
-
max: 10,
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
button_style: {
|
|
177
|
-
shape: 'rounded',
|
|
178
|
-
type: 'highlighted',
|
|
148
|
+
<Range
|
|
149
|
+
type_info={{
|
|
150
|
+
type_variant: 'TEXT',
|
|
151
|
+
scale_properties: {
|
|
152
|
+
order: 'ascending',
|
|
153
|
+
range: [
|
|
154
|
+
{
|
|
155
|
+
id: '1',
|
|
156
|
+
label: 'detractor',
|
|
157
|
+
min: 1,
|
|
158
|
+
max: 2,
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: '2',
|
|
162
|
+
label: 'passive',
|
|
163
|
+
min: 3,
|
|
164
|
+
max: 4,
|
|
179
165
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
'Dissatisfied',
|
|
186
|
-
'Neutral',
|
|
187
|
-
'Satisfied',
|
|
188
|
-
'Dissatisfied',
|
|
189
|
-
'Neutral',
|
|
190
|
-
'Satisfied',
|
|
191
|
-
'Dissatisfied',
|
|
192
|
-
'Satisfied',
|
|
193
|
-
],
|
|
166
|
+
{
|
|
167
|
+
id: '3',
|
|
168
|
+
label: 'promoter',
|
|
169
|
+
min: 5,
|
|
170
|
+
max: 10,
|
|
194
171
|
},
|
|
172
|
+
],
|
|
173
|
+
button_style: {
|
|
174
|
+
shape: 'rounded',
|
|
175
|
+
type: 'highlighted',
|
|
195
176
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
177
|
+
labels: {
|
|
178
|
+
preference: 'edges',
|
|
179
|
+
values: [
|
|
180
|
+
'Very dissatisfied',
|
|
181
|
+
'Very dissatisfied',
|
|
182
|
+
'Dissatisfied',
|
|
183
|
+
'Neutral',
|
|
184
|
+
'Satisfied',
|
|
185
|
+
'Dissatisfied',
|
|
186
|
+
'Neutral',
|
|
187
|
+
'Satisfied',
|
|
188
|
+
'Dissatisfied',
|
|
189
|
+
'Satisfied',
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
footer_text: 'We look forward to your feedback.',
|
|
194
|
+
}}
|
|
195
|
+
value={value}
|
|
196
|
+
onChangeHandler={function(value: any) {
|
|
197
|
+
setValue(value)
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
204
200
|
```
|
|
205
201
|
|
|
206
202
|
|
|
207
203
|
### Rules
|
|
208
204
|
|
|
209
|
-
- survey
|
|
205
|
+
- Props (survey,answers) passed to Survey component and WebInAppSurvey component are cached on mount. In order to pass new value, component needs to be remounted.
|