freemium-survey-components 1.0.91 → 1.0.92
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/.github/workflows/playwright.yml +18 -18
- package/.husky/pre-commit +4 -0
- package/README.md +85 -75
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/constants.d.ts +13 -0
- package/lib/types/survey/Links/index.d.ts +1 -0
- package/lib/types/survey/widget/index.d.ts +1 -1
- package/lib/types/types.d.ts +1 -0
- package/package.json +7 -3
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
name: Playwright Tests
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
|
-
branches: [
|
|
4
|
+
branches: [main, master]
|
|
5
5
|
pull_request:
|
|
6
|
-
branches: [
|
|
6
|
+
branches: [main, master]
|
|
7
7
|
jobs:
|
|
8
8
|
test:
|
|
9
9
|
timeout-minutes: 60
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- uses: actions/setup-node@v2
|
|
14
|
+
with:
|
|
15
|
+
node-version: '14.x'
|
|
16
|
+
- name: Install dependencies
|
|
17
|
+
run: yarn
|
|
18
|
+
- name: Install Playwright Browsers
|
|
19
|
+
run: npx playwright install --with-deps
|
|
20
|
+
- name: Run Playwright tests
|
|
21
|
+
run: yarn playwright test
|
|
22
|
+
- uses: actions/upload-artifact@v2
|
|
23
|
+
if: always()
|
|
24
|
+
with:
|
|
25
|
+
name: playwright-report
|
|
26
|
+
path: playwright-report/
|
|
27
|
+
retention-days: 30
|
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ Make sure you have the below installed in your app.
|
|
|
23
23
|
- ChannelPreview : ChannelPreviewProps
|
|
24
24
|
|
|
25
25
|
### Types
|
|
26
|
+
|
|
26
27
|
```
|
|
27
28
|
type SurveyProps = {
|
|
28
29
|
survey: SurveyType
|
|
@@ -50,9 +51,11 @@ type SurveyProps = {
|
|
|
50
51
|
onAnsweringPrompt: (id: number) => void
|
|
51
52
|
}
|
|
52
53
|
```
|
|
54
|
+
|
|
53
55
|
```
|
|
54
56
|
type ChannelPreviewProps = SurveyProps & { channel: 'whatsapp' | 'instagram' }
|
|
55
57
|
```
|
|
58
|
+
|
|
56
59
|
```
|
|
57
60
|
type WidgetProps = {
|
|
58
61
|
survey: SurveyType
|
|
@@ -75,6 +78,7 @@ type WidgetProps = {
|
|
|
75
78
|
onAnsweringPrompt: (id: number) => void
|
|
76
79
|
}
|
|
77
80
|
```
|
|
81
|
+
|
|
78
82
|
```
|
|
79
83
|
type RangeProps = {
|
|
80
84
|
type_info: {
|
|
@@ -100,31 +104,37 @@ type RangeProps = {
|
|
|
100
104
|
|
|
101
105
|
### Usage
|
|
102
106
|
|
|
103
|
-
|
|
104
107
|
```js
|
|
105
|
-
import {Survey} from 'freemium-survey-components'
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
import { Survey } from 'freemium-survey-components';
|
|
109
|
+
<Survey
|
|
110
|
+
survey={surveyObjectFromSurveyServ}
|
|
111
|
+
surveyStyle="card"
|
|
112
|
+
onSubmit={async function (
|
|
113
|
+
data: { [key: string]: string | number | boolean | null | string[] },
|
|
114
|
+
callback,
|
|
115
|
+
status: 'PARTIAL' | 'COMPLETE',
|
|
116
|
+
) {
|
|
117
|
+
await saveToDb(surveyFormData);
|
|
118
|
+
if (status === 'COMPETE')
|
|
112
119
|
// callback should be executed in the caller once the save is done.
|
|
113
|
-
callback?.()
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
callback?.();
|
|
121
|
+
}}
|
|
122
|
+
// this will get called for every answer selection with status = 'PARTIAL'
|
|
123
|
+
placeholders={{
|
|
124
|
+
'{{account.company_name}}': 'Freshworks',
|
|
125
|
+
'{{account.account_name}}': 'Freshworks Account',
|
|
126
|
+
}}
|
|
127
|
+
// placeholders to resolve against any such placeholder in question's text
|
|
128
|
+
preview={true}
|
|
129
|
+
// preview true will not save the response
|
|
130
|
+
initialPivotAnswer={null}
|
|
131
|
+
// pass a number if pivot qn needed to be prefilled by default
|
|
132
|
+
onAnsweringPrompt={function (id) {
|
|
133
|
+
console.log(`Prompt ${id ? 'accepted' : 'rejected'}}`);
|
|
134
|
+
}}
|
|
135
|
+
/>;
|
|
127
136
|
```
|
|
137
|
+
|
|
128
138
|
```js
|
|
129
139
|
import {WebInAppSurvey} from 'freemium-survey-components'
|
|
130
140
|
const [isSurveyCompleted,setIsSurveyCompleted] = useState(false)
|
|
@@ -142,68 +152,68 @@ import {WebInAppSurvey} from 'freemium-survey-components'
|
|
|
142
152
|
}}
|
|
143
153
|
unsubscribeUrl={'#'}
|
|
144
154
|
isSurveyCompleted={isSurveyCompleted}
|
|
145
|
-
children={null}
|
|
146
|
-
// if we want render with respect to the widget's fixed
|
|
155
|
+
children={null}
|
|
156
|
+
// if we want render with respect to the widget's fixed
|
|
147
157
|
onAnsweringPrompt={function (id){ console.log(`Prompt ${id ? 'accepted' : 'rejected'}`)}}
|
|
148
158
|
/>
|
|
149
159
|
```
|
|
160
|
+
|
|
150
161
|
```js
|
|
151
|
-
import {Range} from 'freemium-survey-components'
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: '2',
|
|
166
|
-
label: 'passive',
|
|
167
|
-
min: 3,
|
|
168
|
-
max: 4,
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: '3',
|
|
172
|
-
label: 'promoter',
|
|
173
|
-
min: 5,
|
|
174
|
-
max: 10,
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
button_style: {
|
|
178
|
-
shape: 'rounded',
|
|
179
|
-
type: 'highlighted',
|
|
162
|
+
import { Range } from 'freemium-survey-components';
|
|
163
|
+
<Range
|
|
164
|
+
type_info={{
|
|
165
|
+
type_variant: 'TEXT',
|
|
166
|
+
scale_properties: {
|
|
167
|
+
order: 'ascending',
|
|
168
|
+
range: [
|
|
169
|
+
{
|
|
170
|
+
id: '1',
|
|
171
|
+
label: 'detractor',
|
|
172
|
+
min: 1,
|
|
173
|
+
max: 2,
|
|
180
174
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
'Dissatisfied',
|
|
187
|
-
'Neutral',
|
|
188
|
-
'Satisfied',
|
|
189
|
-
'Dissatisfied',
|
|
190
|
-
'Neutral',
|
|
191
|
-
'Satisfied',
|
|
192
|
-
'Dissatisfied',
|
|
193
|
-
'Satisfied',
|
|
194
|
-
],
|
|
175
|
+
{
|
|
176
|
+
id: '2',
|
|
177
|
+
label: 'passive',
|
|
178
|
+
min: 3,
|
|
179
|
+
max: 4,
|
|
195
180
|
},
|
|
181
|
+
{
|
|
182
|
+
id: '3',
|
|
183
|
+
label: 'promoter',
|
|
184
|
+
min: 5,
|
|
185
|
+
max: 10,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
button_style: {
|
|
189
|
+
shape: 'rounded',
|
|
190
|
+
type: 'highlighted',
|
|
191
|
+
},
|
|
192
|
+
labels: {
|
|
193
|
+
preference: 'edges',
|
|
194
|
+
values: [
|
|
195
|
+
'Very dissatisfied',
|
|
196
|
+
'Very dissatisfied',
|
|
197
|
+
'Dissatisfied',
|
|
198
|
+
'Neutral',
|
|
199
|
+
'Satisfied',
|
|
200
|
+
'Dissatisfied',
|
|
201
|
+
'Neutral',
|
|
202
|
+
'Satisfied',
|
|
203
|
+
'Dissatisfied',
|
|
204
|
+
'Satisfied',
|
|
205
|
+
],
|
|
196
206
|
},
|
|
207
|
+
},
|
|
197
208
|
footer_text: 'We look forward to your feedback.',
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
209
|
+
}}
|
|
210
|
+
value={value}
|
|
211
|
+
onChangeHandler={function (value: any) {
|
|
212
|
+
setValue(value);
|
|
213
|
+
}}
|
|
214
|
+
/>;
|
|
204
215
|
```
|
|
205
216
|
|
|
206
|
-
|
|
207
217
|
### Rules
|
|
208
218
|
|
|
209
|
-
|
|
219
|
+
- 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.
|