freemium-survey-components 0.12.11 → 0.13.2

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.
@@ -0,0 +1,2 @@
1
+ ### Limitations
2
+ - Do not use ```JSON.stringify``` method since its causing issue with Freshservice when using ```freemium-survey-components``` since they use their polyfilled method for ```JSON.stringify``` instead of actual window object definition.
package/README.md CHANGED
@@ -1,39 +1,151 @@
1
- # [Freemium-survey-components](https://www.npmjs.com/package/freemium-survey-components)
1
+ ## [freemium-survey-components](https://www.npmjs.com/package/freemium-survey-components)
2
2
 
3
3
  ⚠️: **Not ready for public usage yet!**
4
4
 
5
- Freemium-survey-components is a react package that renders the survey collection form given the survey object from the survey-serv platform service.
5
+ Freemium-survey-components renders the survey collection form given the survey object from the survey-serv platform service.
6
6
 
7
- ## Peer Dependencies
7
+ ### Peer Dependencies
8
8
 
9
- Make sure you installed the above libraries in the parent application.
9
+ Make sure you have the below installed in your app.
10
10
 
11
11
  - react >= 17.0.2
12
12
  - react-dom >= 17.0.2
13
13
 
14
- ## Usage
14
+ ### Usage
15
15
 
16
- - install the peer dependencies (mentioned above )
17
- - yarn add freemium-survey-components
18
- - include reset css and css variables in index css file
16
+ ```sh
17
+ npm i freemium-survey-components
18
+ ```
19
+
20
+ ### Exports (Named)
19
21
 
20
- ## Exports (Named)
22
+ - Survey : SurveyProps
23
+ - WebInAppSurvey : WebInAppSurveyProps
24
+ - NPS : NPSProps
21
25
 
22
- Of the below components the parent app would only need to interact with the Survey component to render the survey.
26
+ ### Types
27
+ ```
28
+ type SurveyProps {
29
+ survey: SurveyType
30
+ surveyStyle?: 'standard' | 'card'
31
+ placeholders?: {
32
+ [key: string]: string
33
+ }
34
+ npsValue?: number
35
+ onSubmit: (
36
+ data: { [key: string]: string | number | Array<string | number> | null | {[key : string] : string } },
37
+ callback: Function
38
+ ) => void
39
+ preview?: boolean
40
+ mobilePreview?: boolean
41
+ }
42
+ ```
43
+ ```
44
+ type WidgetProps = {
45
+ survey: SurveyType
46
+ surveyType: 'default' | 'compact' | 'cozy'
47
+ placeholders: {
48
+ [key: string]: string
49
+ }
50
+ onSubmit: (
51
+ data: { [key: string]: string | number | Array<string | number> | null | {[key : string] : string } },
52
+ callback: Function,
53
+ ) => void
54
+ preview?: boolean
55
+ onDismiss: () => void
56
+ remindLater: () => void
57
+ onClose?: () => void
58
+ unsubscribeUrl?: string
59
+ isSurveyCompleted: boolean
60
+ children: React.ReactNode | null
61
+ }
62
+ ```
63
+ ```
64
+ type NPSProps = {
65
+ type_info: {
66
+ linear_scale: {
67
+ button_shape: 'rounded' | 'square' | 'curved'
68
+ button_style: 'standard' | 'highlighted'
69
+ }
70
+ validation: {
71
+ min: number
72
+ }
73
+ rating_presets: { start?: string; end?: string }
74
+ footer_text: string
75
+ }
76
+ onChangeHandler: (value: number) => void
77
+ npsValue?: number
78
+ }
79
+ ```
23
80
 
24
- - Survey
25
- - NPS
26
- - CheckboxGroup
27
- - RadioGroup
28
- - Input
29
- - Textarea
30
- - Button
31
- - Progressbar
81
+ ### Usage
32
82
 
33
- ## Using SURVEY
34
83
 
35
84
  ```sh
36
85
  import {Survey} from 'freemium-survey-components'
37
- ...
38
- <Survey survey={surveyObjectFromDb} onSubmit ={(data : surveyFormData) => {....}/>
86
+ const WebSurveyPreview = () => {
87
+ return <Survey
88
+ survey={surveyObjectFromSurveyServ}
89
+ surveyStyle="card"
90
+ onSubmit = {async (data : surveyFormData,callback) => {
91
+ await saveToDb(surveyFormData)
92
+ callback?.() // callback should be executed in the caller once the save is done.
93
+ }}
94
+ placeholders = {{
95
+ '{{account.company_name}}': 'Freshworks',
96
+ '{{account.account_name}}': 'Freshworks Account',
97
+ '{{contact.plan}}': 'blossom',
98
+ '{{contact.first_name}}': 'Alice',
99
+ }} // placeholders to resolve against any such placeholder in surveyObj
100
+ preview = {true} // preview true will not save the response
101
+ npsvalue={null} // pass a number if nps qn needed to be prefilled by default
102
+ />
103
+ }
104
+ ```
105
+ ```
106
+ import {WebInAppSurvey} from 'freemium-survey-components'
107
+ const Widget = () => {
108
+ const [isSurveyCompleted,setIsSurveyCompleted] = useState(false)
109
+ return <WebInAppSurvey
110
+ survey={surveyObjectFromSurveyServ}
111
+ surveyType="compact"
112
+ placeholders={null}
113
+ onSubmit={(data, callback) => {
114
+ console.log(data, callback?.())
115
+ setIsSurveyCompleted(true)
116
+ }}
117
+ onDismiss={() => {
118
+ // when the widget is dismissed, this gets executed.
119
+ ....
120
+ }}
121
+ remindLater={() => {
122
+ // when the remind later is selected on the widget, this gets executed.
123
+ ....
124
+ }}
125
+ unsubscribeUrl={'#'}
126
+ isSurveyCompleted={isSurveyCompleted}
127
+ children={null} // if we want render with respect to the widget's fixed position
128
+ />
129
+ }
130
+ ```
39
131
  ```
132
+ import {NPS} from 'freemium-survey-components'
133
+ const NPSPreview = () => {
134
+ return <NPS
135
+ type_info={{
136
+ linear_scale : {
137
+ button_shape : 'rounded',
138
+ button_style : 'highlighted'
139
+ },
140
+ validation : {
141
+ min : 0
142
+ },
143
+ rating_presets : {
144
+ start : 'Very unlikely',
145
+ end : 'Very likely'
146
+ },
147
+ footer_text : 'We look forward to act on your feedback',
148
+ onChangeHandler : (value) => console.log(value)
149
+ }}
150
+ />
151
+ }