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.
Files changed (34) hide show
  1. package/README.md +91 -95
  2. package/lib/index.cjs.js +1 -1
  3. package/lib/index.esm.js +1 -1
  4. package/lib/types/components/binary/index.d.ts +1 -1
  5. package/lib/types/components/prompt/index.d.ts +3 -1
  6. package/lib/types/components/text-input/index.d.ts +6 -6
  7. package/lib/types/index.d.ts +1 -0
  8. package/lib/types/survey/card/index.d.ts +2 -2
  9. package/lib/types/{components/nps/index.d.ts → survey/channels.stories.d.ts} +0 -0
  10. package/lib/types/survey/channelsPreview/channels.stories.d.ts +1 -0
  11. package/lib/types/survey/channelsPreview/index.d.ts +5 -0
  12. package/lib/types/survey/channelsPreview/instagram.d.ts +3 -0
  13. package/lib/types/survey/channelsPreview/question.d.ts +12 -0
  14. package/lib/types/survey/channelsPreview/utils.d.ts +1 -0
  15. package/lib/types/survey/channelsPreview/whatsapp.d.ts +3 -0
  16. package/lib/types/survey/meta-channel-preview/channels.stories.d.ts +1 -0
  17. package/lib/types/survey/meta-channel-preview/index.d.ts +5 -0
  18. package/lib/types/survey/meta-channel-preview/question.d.ts +12 -0
  19. package/lib/types/survey/meta-channel-preview/utils.d.ts +1 -0
  20. package/lib/types/survey/meta-channel-preview/whatsapp.d.ts +3 -0
  21. package/lib/types/survey/standard/index.d.ts +2 -2
  22. package/lib/types/survey/utils/logics.d.ts +42 -42
  23. package/lib/types/survey/utils/use-card-survey.d.ts +8 -8
  24. package/lib/types/survey/utils/use-standard-survey.d.ts +8 -8
  25. package/lib/types/survey/utils/use-survey.d.ts +5 -2
  26. package/lib/types/survey/whatsapp/index.d.ts +3 -0
  27. package/lib/types/survey/whatsapp/question.d.ts +8 -0
  28. package/lib/types/survey/whatsapp/utils.d.ts +1 -0
  29. package/lib/types/survey/widget/index.d.ts +4 -2
  30. package/lib/types/types.d.ts +23 -16
  31. package/package.json +1 -1
  32. package/lib/types/components/nps/nps.stories.d.ts +0 -0
  33. package/lib/types/newTypes.d.ts +0 -0
  34. 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
- const WebSurveyPreview = () => {
103
- return <Survey
104
- survey={surveyObjectFromSurveyServ}
105
- surveyStyle="card"
106
- onSubmit = {async (data : surveyFormData,callback,status : 'PARTIAL' | 'COMPLETE') => {
107
- // this will get called for every answer selection with status = 'PARTIAL'
108
- await saveToDb(surveyFormData)
109
- if(status === 'COMPETE')
110
- callback?.() // callback should be executed in the caller once the save is done.
111
- }}
112
- placeholders = {{
113
- '{{account.company_name}}': 'Freshworks',
114
- '{{account.account_name}}': 'Freshworks Account',
115
- }} // placeholders to resolve against any such placeholder in question's text
116
- preview = {true} // preview true will not save the response
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'}`)}
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
- return <WebInAppSurvey
128
- survey={surveyObjectFromSurveyServ}
129
- surveyType="compact"
130
- placeholders={null}
131
- onSubmit={(data, callback,status) => {
132
- if(status === 'COMPLETE')
133
- callback?.()
134
- setIsSurveyCompleted(true)
135
- }}
136
- onDismiss={() => {
137
- // when the widget is dismissed, this gets executed.
138
- ....
139
- }}
140
- unsubscribeUrl={'#'}
141
- isSurveyCompleted={isSurveyCompleted}
142
- children={null} // if we want render with respect to the widget's fixed onAnsweringPrompt={(id) =>
143
- console.log(`Prompt ${id ? 'accepted' : 'rejected'}`)
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
- const RangePreview = () => {
151
- return <Range
152
- type_info={{
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,
162
- },
163
- {
164
- id: '2',
165
- label: 'passive',
166
- min: 3,
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
- 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
- ],
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
- footer_text: 'We look forward to your feedback.',
197
- }}
198
- value={value}
199
- onChangeHandler={(value: any) => {
200
- setValue(value)
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 object passed to Survey and WebInAppSurvey is cached on mount. In order to pass new survey object, it needs to be remounted with the new survey object.
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.