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.
- package/Contributing.md +2 -0
- package/README.md +133 -21
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/survey/standard/index.d.ts +1 -1
- package/lib/types/survey/utils/use-card-survey.d.ts +1 -0
- package/lib/types/types.d.ts +13 -5
- package/package.json +2 -1
package/Contributing.md
ADDED
package/README.md
CHANGED
|
@@ -1,39 +1,151 @@
|
|
|
1
|
-
|
|
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
|
|
5
|
+
Freemium-survey-components renders the survey collection form given the survey object from the survey-serv platform service.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Peer Dependencies
|
|
8
8
|
|
|
9
|
-
Make sure you
|
|
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
|
-
|
|
14
|
+
### Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
```sh
|
|
17
|
+
npm i freemium-survey-components
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Exports (Named)
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
- Survey : SurveyProps
|
|
23
|
+
- WebInAppSurvey : WebInAppSurveyProps
|
|
24
|
+
- NPS : NPSProps
|
|
21
25
|
|
|
22
|
-
|
|
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
|
-
|
|
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
|
|
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
|
+
}
|