freemium-survey-components 0.1.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/.eslintrc +24 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +59 -0
- package/.storybook/manager.js +9 -0
- package/.storybook/preview.js +1 -0
- package/README.md +3 -0
- package/index.ts +3 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.esm.js +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/src/components/button/index.d.ts +25 -0
- package/lib/types/src/components/checkbox/index.d.ts +14 -0
- package/lib/types/src/components/index.d.ts +6 -0
- package/lib/types/src/components/nps/index.d.ts +23 -0
- package/lib/types/src/components/progressbar/index.d.ts +8 -0
- package/lib/types/src/components/radio-button/index.d.ts +25 -0
- package/lib/types/src/components/text-input/index.d.ts +52 -0
- package/lib/types/src/index.d.ts +1 -0
- package/lib/types/src/mock.d.ts +215 -0
- package/lib/types/src/survey/index.d.ts +4 -0
- package/lib/types/src/survey/question.d.ts +3 -0
- package/lib/types/src/survey/widget.d.ts +4 -0
- package/lib/types/src/utils.d.ts +3 -0
- package/package.json +97 -0
- package/postcss.config.js +4 -0
- package/rollup.config.ts +32 -0
- package/src/components/button/button.stories.tsx +23 -0
- package/src/components/button/index.tsx +67 -0
- package/src/components/button/style.css +41 -0
- package/src/components/checkbox/checkbox.stories.tsx +34 -0
- package/src/components/checkbox/index.tsx +118 -0
- package/src/components/checkbox/style.css +85 -0
- package/src/components/index.tsx +6 -0
- package/src/components/nps/index.tsx +69 -0
- package/src/components/nps/nps.stories.tsx +34 -0
- package/src/components/nps/style.css +154 -0
- package/src/components/progressbar/index.tsx +21 -0
- package/src/components/progressbar/progressbar.stories.tsx +22 -0
- package/src/components/progressbar/style.css +14 -0
- package/src/components/radio-button/index.tsx +66 -0
- package/src/components/radio-button/radio.stories.tsx +26 -0
- package/src/components/radio-button/style.css +60 -0
- package/src/components/text-input/index.tsx +155 -0
- package/src/components/text-input/style.css +102 -0
- package/src/components/text-input/text-input.stories.tsx +84 -0
- package/src/index.tsx +1 -0
- package/src/mock.ts +363 -0
- package/src/survey/index.tsx +269 -0
- package/src/survey/question.tsx +79 -0
- package/src/survey/style.css +58 -0
- package/src/survey/survey.stories.tsx +28 -0
- package/src/survey/widget.css +46 -0
- package/src/survey/widget.tsx +17 -0
- package/src/theme/index.css +72 -0
- package/src/typings/index.d.ts +1 -0
- package/src/utils.tsx +12 -0
- package/tsconfig.json +22 -0
package/.eslintrc
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": ["@typescript-eslint", "react-hooks"],
|
|
5
|
+
"parserOptions": {
|
|
6
|
+
"ecmaFeatures": {
|
|
7
|
+
"jsx": true
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"extends": [
|
|
11
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
12
|
+
"plugin:@typescript-eslint/recommended"
|
|
13
|
+
],
|
|
14
|
+
"rules": {
|
|
15
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
16
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
17
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
18
|
+
"react-hooks/rules-of-hooks": "error",
|
|
19
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
20
|
+
"@typescript-eslint/ban-types": "off",
|
|
21
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
22
|
+
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
addons: [
|
|
5
|
+
'@storybook/addon-actions',
|
|
6
|
+
'@storybook/addon-links',
|
|
7
|
+
'@storybook/addon-knobs',
|
|
8
|
+
{
|
|
9
|
+
name: '@storybook/addon-docs',
|
|
10
|
+
options: {
|
|
11
|
+
configureJSX: true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
'@storybook/addon-postcss',
|
|
15
|
+
],
|
|
16
|
+
stories: ['../src/**/*.stories.tsx'],
|
|
17
|
+
webpackFinal: async (config) => {
|
|
18
|
+
// let cssRuleIndex = config.module.rules.findIndex(
|
|
19
|
+
// (rule) => String(rule.test) === String(/\.css$/),
|
|
20
|
+
// )
|
|
21
|
+
// let cssRule = config.module.rules.splice(cssRuleIndex, 1)
|
|
22
|
+
// console.log('Config in css....', cssRuleIndex, cssRule)
|
|
23
|
+
config.module.rules.push(
|
|
24
|
+
{
|
|
25
|
+
test: /\.(ts|tsx)$/,
|
|
26
|
+
include: path.resolve(__dirname, '../src'),
|
|
27
|
+
use: [
|
|
28
|
+
require.resolve('ts-loader'),
|
|
29
|
+
{
|
|
30
|
+
loader: require.resolve('react-docgen-typescript-loader'),
|
|
31
|
+
options: {
|
|
32
|
+
// Provide the path to your tsconfig.json so that your stories can
|
|
33
|
+
// display types from outside each individual story.
|
|
34
|
+
tsconfigPath: path.resolve(__dirname, '../tsconfig.json'),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
// {
|
|
40
|
+
// test: /\.css$/i,
|
|
41
|
+
// // include: path.resolve(__dirname, '../src'),
|
|
42
|
+
// use: [
|
|
43
|
+
// require.resolve('style-loader'),
|
|
44
|
+
// require.resolve('css-loader'),
|
|
45
|
+
// {
|
|
46
|
+
// loader: require.resolve('postcss-loader'),
|
|
47
|
+
// options: {
|
|
48
|
+
// postcssOptions: {
|
|
49
|
+
// plugins: ['autoprefixer'],
|
|
50
|
+
// },
|
|
51
|
+
// },
|
|
52
|
+
// },
|
|
53
|
+
// ],
|
|
54
|
+
// },
|
|
55
|
+
)
|
|
56
|
+
config.resolve.extensions.push('.ts', '.tsx')
|
|
57
|
+
return config
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/theme/index.css'
|
package/README.md
ADDED
package/index.ts
ADDED
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function o(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===t&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}o(".container {\n margin: 0 auto;\n width: 100%;\n}\n.title {\n color: var(--color-elephant-900);\n font-weight: 600;\n}\n\n.footer {\n margin-top: 20px;\n border-top: 1px solid var(--color-smoke-50);\n padding-top: 20px;\n display: flex;\n justify-content: center;\n font-size: 12px;\n}\n\n.widget span {\n color: #aaa;\n font-size: 12px;\n}\n.widget button {\n display: inline-block;\n font-size: 16px;\n white-space: nowrap;\n vertical-align: middle;\n background: none;\n border: none;\n box-shadow: none;\n cursor: pointer;\n text-align: center;\n font-weight: 500;\n border-radius: 4px;\n margin: 0;\n outline: none;\n margin-left: -1px;\n width: 40px;\n height: 40px;\n transform: scale(1);\n transition: background 0.2s ease-in, color 0.2s ease-in,\n border-color 0.2s ease-in, transform 0.2s cubic-bezier(0.5, 2, 0.5, 0.75);\n}\n.widget button:hover {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.widget button.active {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n\n.choices {\n width: 100%;\n display: flex;\n justify-content: space-between;\n}\n\n.choice.active,\n.choice:hover:nth-child(1) {\n background: #eb5b56;\n}\n.choice.active,\n.choice:hover:nth-child(2) {\n background: #fb8774;\n}\n.choice.active,\n.choice:hover:nth-child(3) {\n background: #f58f6b;\n}\n.choice.active,\n.choice:hover:nth-child(4) {\n background: #f6996a;\n}\n.choice.active,\n.choice:hover:nth-child(5) {\n background: #eab268;\n}\n.choice.active,\n.choice:hover:nth-child(6) {\n background: #cebb69;\n}\n.choice.active,\n.choice:hover:nth-child(7) {\n background: #bdc46c;\n}\n.choice.active,\n.choice:hover:nth-child(8) {\n background: #a4cd72;\n}\n.choice.active,\n.choice:hover:nth-child(9) {\n background: #77c955;\n}\n.choice.active,\n.choice:hover:nth-child(10) {\n background: #37c248;\n}\n\n.widget.highlighted button.active,\n.widget.highlighted button:hover {\n background: var(--color-elephant-800) !important;\n}\n.widget .rounded button {\n border-radius: 100%;\n}\n.widget .boxed button {\n border-radius: 0;\n}\n.widget {\n padding: 35px 0;\n box-sizing: border-box;\n position: relative;\n padding-bottom: 30px;\n}\n.widget .button-container {\n display: flex;\n justify-content: space-between;\n background: var(--color-smoke-50);\n}\n.widget .positive-text,\n.widget .negative-text {\n position: absolute;\n color: var(--color-elephant-500);\n}\n.widget .positive-text {\n right: 0px;\n bottom: 5px;\n text-align: right;\n}\n.widget .negative-text {\n left: 0;\n bottom: 5px;\n text-align: left;\n}\n@media (max-width: 550px) {\n .widget .button-container {\n background: transparent;\n }\n .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n }\n .widget button {\n border-radius: 50%;\n background: #ebeff3;\n }\n}\n");const r=e=>{const{type_info:{linear_scale:{button_shape:o,button_style:r},score_presets:{start:a,end:i},validation:{min:l},footer_text:c}}=e,s=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},d=n.useRef(Array.from({length:10},((e,n)=>n+l)));return t.createElement("div",{className:"container"},t.createElement("div",{className:`widget ${o} ${r}`},t.createElement("div",{className:"button-container"},t.createElement("span",{className:"negative-text"},a),t.createElement("div",{className:"choices"},d.current.map((n=>t.createElement("button",{onClick:t=>{e.onChangeHandler(n)},className:`choice ${s(n)} ${e.npsValue===n&&"active"}`},n)))),t.createElement("span",{className:"positive-text"},i))),t.createElement("div",{className:"footer"},c))},a=(e,n)=>(e.defaultProps=n,e);o(".input-container,\n.textarea-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n border-radius: 4px;\n position: relative;\n}\nlabel.input-label {\n display: inline-block;\n padding-bottom: 8px;\n padding-left: 2px;\n font-size: 12px;\n font-weight: 400;\n}\nlabel.required::after {\n content: '*';\n position: relative;\n top: 2px;\n font-weight: 500;\n font-size: 0.85rem;\n padding-left: 3px;\n color: var(--error-highlight-color);\n}\n\n.input-basic {\n width: 100%;\n display: flex;\n align-items: center;\n border-radius: var(--border-radius);\n border: 1px solid var(--input-border-color);\n transition: border-color 0.2s linear;\n background: #fff;\n}\n.textarea-container .input-basic {\n flex-direction: column;\n align-items: unset;\n}\n.input-basic.error {\n border: 1px solid var(--error-highlight-color);\n}\n.input-basic.error:hover {\n border: 1px solid var(--error-highlight-color);\n}\n.input-basic.error[focus-within] {\n box-shadow: none;\n}\n.input-basic.error:focus-within {\n box-shadow: none;\n}\n.input-basic:hover {\n border-color: var(--input-hover-border-color);\n transition: 0.2s linear;\n}\n.input-basic[focus-within] {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--input-highlight-color);\n}\n.input-basic:focus-within {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--input-highlight-color);\n}\n.end-max-length {\n padding: 0 8px;\n font-size: 0.85rem;\n}\n.textarea-container .end-max-length {\n padding: 8px;\n align-self: flex-end;\n}\nspan.input-error {\n display: block;\n padding-left: 2px;\n padding-top: 4px;\n font-size: 0.9rem;\n color: var(--error-highlight-color);\n}\ninput[type='text'] {\n padding: 4px 12px;\n flex: 1;\n border: unset;\n height: 32px;\n font-size: 1rem;\n /* line-height: ${typography.input.text.lineHeight}; */\n font-weight: 500;\n border-radius: 4px;\n}\ninput[type='text'],\ntextarea {\n outline: none;\n border: none;\n}\ninput[type='text']::-moz-placeholder {\n color: var(--input-placeholder-color);\n}\ninput[type='text']:-ms-input-placeholder {\n color: var(--input-placeholder-color);\n}\ninput[type='text']::placeholder {\n color: var(--input-placeholder-color);\n}\ntextarea {\n min-height: 116px;\n padding: 4px 12px;\n flex: 1;\n border: unset;\n resize: none;\n font-size: 1rem;\n /* line-height: ${typography.input.text.lineHeight}; */\n font-weight: 500;\n border-radius: 4px;\n}\ntextarea::-moz-placeholder {\n color: var(--input-placeholder-color);\n}\ntextarea:-ms-input-placeholder {\n color: var(--input-placeholder-color);\n}\ntextarea::placeholder {\n color: var(--input-placeholder-color);\n}\n");const i={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!1},l=n.forwardRef(((e,n)=>{const{inputStyle:o,style:r,className:a,showCount:i,isErrored:l,startLabel:c,isRequired:s,errorText:d,endLabel:p,maxLength:u,...h}=e;return console.log(e.value),t.createElement("div",{className:"input-container",style:r},e.label&&t.createElement("label",{className:"input-label "+(s?"required":"")},e.label),t.createElement("div",null,c&&t.createElement("div",{className:"start-label"},c),t.createElement("div",{className:`input-basic ${l?"error":""}${a||""}`},t.createElement("input",Object.assign({type:"text",autoComplete:"off"},h,{ref:n,style:o})),i&&u>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),p&&t.createElement("div",{className:"end-label"},p)),l&&d&&t.createElement("span",{className:"input-error"},e.errorText))})),c=n.forwardRef(((e,n)=>{const{inputStyle:o,style:r,className:a,showCount:i,maxLength:l,isErrored:c,startLabel:s,isRequired:d,...p}=e;return console.log(e.value),t.createElement(t.Fragment,null,t.createElement("div",{className:"textarea-container",style:r},e.label&&t.createElement("label",{className:"input-label "+(d?"required":"")},e.label),s&&t.createElement("div",{className:"start-label"},s),t.createElement("div",{className:`input-basic ${c?"error":""} ${a||""}`},t.createElement("textarea",Object.assign({autoComplete:"off"},p,{ref:n,style:o})),i&&l&&l>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),e.endLabel&&t.createElement("div",{className:"end-label"},e.endLabel)),e.isErrored&&e.errorText&&t.createElement("span",{className:"input-error"},e.errorText))})),s=a(l,i),d=a(c,i);o(".checkbox-group {\n display: flex;\n align-items: center;\n grid-gap: 12px;\n gap: 12px;\n flex-direction: column;\n white-space: nowrap;\n flex-wrap: wrap;\n}\n.icon-container {\n display: inline-block;\n flex: 0 0 12px;\n width: 12px;\n height: 12px;\n min-width: 12px;\n min-height: 12px;\n color: inherit;\n position: absolute;\n left: 1px;\n top: 2px;\n}\n.tick-icon {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n width: 100%;\n color: inherit;\n fill: currentColor;\n}\ninput[type='checkbox'] {\n clip: rect(0px 0px 0px 0px);\n width: 0px;\n height: 0px;\n}\ninput[type='checkbox']:focus ~ .checkbox {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 2px; */\n box-shadow: var(--input-highlight-color) 0px 0px 0px 2px;\n border-color: transparent;\n}\n.checkbox-label {\n display: flex;\n align-items: center;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n opacity: 1;\n cursor: pointer;\n font-size: 1rem;\n font-weight: 500;\n padding: 16px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 10%);\n border-radius: 4px;\n}\n.checkbox-label.disabled {\n opacity: 0.5;\n cursor: 'not-allowed';\n}\n.checkbox {\n transition: background-color ease-in 0.2s;\n min-width: 14px;\n min-height: 14px;\n border-radius: 2px;\n position: relative;\n margin-right: 10px;\n background-color: #fff;\n border: 1px solid;\n border-color: var(--input-highlight-color);\n}\n.checkbox:hover {\n border-color: var(--input-highlight-color);\n box-shadow: var(--focus-box-shadow-color) 0px 0px 0px 5px;\n}\ninput[type='checkbox']:checked ~ .checkbox {\n background-color: var(--input-highlight-color);\n border-color: var(--input-highlight-color);\n}\ninput[type='checkbox']:checked ~ .checkbox:hover {\n border-color: var(--input-highlight-color);\n}\ninput[type='checkbox']:disabled ~ .checkbox:hover {\n box-shadow: unset;\n border-color: unset;\n}\n");const p=()=>t.createElement("svg",{id:"tick",className:"tick-icon",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"title",viewBox:"0 0 10 10"},t.createElement("path",{d:"M3 5.87c-.18666814.00267463-.36667109-.06932655-.5-.2L.21 3.41c-.1786328-.17863279-.24839684-.43899577-.1830127-.6830127.06538414-.24401694.25598306-.43461586.5-.5C.77100423 2.16160316 1.0313672 2.23136721 1.21 2.41L3 4.18 6.8.33c.27679776-.27455556.72320224-.27455556 1 0 .13696438.13025306.21450026.31098915.21450026.5S7.93696438 1.19974694 7.8 1.33L3.45 5.67c-.12082534.11896945-.28072735.19003701-.45.2Z",fill:"#fff",fillRule:"evenodd"})),u=({values:e,options:n,onChangeHandler:o})=>t.createElement("div",{className:"checkbox-group"},n.map(((n,r)=>t.createElement(h,{key:n.id,checked:e?.includes(n.id),name:n.name??n.id,id:n.id,autoFocus:0===r,onChange:(t,r)=>{if(r)o([...e||[],n.id]);else{const t=e.indexOf(n.id);t>-1&&e.splice(t,1),o([...e])}}},n.label)))),h=a(n.forwardRef(((e,n)=>t.createElement("label",{className:`checkbox-label ${e.disabled&&"disabled"}`},t.createElement("input",{ref:n,id:e.id,type:"checkbox",name:e.name,readOnly:e.readOnly,disabled:e.disabled,"aria-disabled":e.disabled,value:e.value,checked:e.checked,autoFocus:e.autoFocus,onChange:e.readOnly?()=>{}:n=>e.onChange(n,n.target.checked)}),t.createElement("div",{className:"checkbox"},e.checked&&t.createElement("div",{className:"icon-container"},t.createElement(p,null)," ")),t.createElement("div",null,e.children)))),{checked:!1});o(".radio-group {\n display: flex;\n align-items: center;\n grid-gap: 12px;\n gap: 12px;\n white-space: nowrap;\n flex-direction: column;\n}\n\n.radio {\n background-color: #fff;\n border: 1px solid;\n border-color: var(--input-border-color);\n transition: background-color ease-in 0.2s;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n position: relative;\n margin-right: 12px;\n}\n.radio:before {\n left: 3px;\n top: 3px;\n content: '';\n position: absolute;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n transition: all ease-in 0.2s;\n background-color: #fff;\n}\n.radio-label {\n display: flex;\n align-items: center;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n cursor: pointer;\n font-size: 1rem;\n font-weight: 500;\n padding: 16px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 10%);\n border-radius: 4px;\n}\ninput[type='radio'] {\n clip: rect(0, 0, 0, 0);\n position: absolute;\n}\ninput[type='radio']:focus ~ .radio {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 3px; */\n box-shadow: var(--input-highlight-color) 0px 0px 0px 3px;\n border-color: transparent;\n}\n\ninput[type='radio']:checked ~ .radio:before {\n background-color: var(--input-highlight-color);\n}\n.radio-container:hover .radio {\n border-color: var(--input-highlight-color);\n box-shadow: var(--focus-box-shadow-color) 0px 0px 0px 5px;\n}\n");const x=({name:e,options:n,value:o,onChangeHandler:r})=>t.createElement("div",{className:"radio-group"},n.map((n=>t.createElement(m,{key:n.id,value:n.id,name:e,onChange:e=>{r(e.currentTarget.value)},checked:o===n.id},n.label)))),m=a(n.forwardRef(((e,n)=>t.createElement("label",{className:"radio-label"},t.createElement("input",{ref:n,type:"radio",name:e.name,value:e.value,checked:e.checked,onClick:e.onChange,autoFocus:!0}),t.createElement("div",{className:"radio"}),t.createElement("div",null,e.children)))),{checked:!1});o(".progressbar-container {\n width: 100%;\n height: 6px;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.progressbar {\n transition: transform 0.25s linear;\n transform-origin: left;\n height: 100%;\n background-color: var(--brand-color);\n}\n");const b=e=>{const{totalSteps:n,completedSteps:o}=e;return t.createElement("div",{className:"progressbar-container"},t.createElement("div",{className:"progressbar",style:{width:(o>0?100/n:0)+"%",transform:`scaleX(${o})`}}))};o(".action-button {\n width: auto;\n display: block;\n margin: 0;\n padding: 8px 16px;\n cursor: pointer;\n line-height: 1.5;\n text-align: center;\n font-weight: 500;\n letter-spacing: 0.3px;\n border-radius: 4px;\n white-space: nowrap;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n color: #fff;\n background: var(--primary-button-color);\n border: 1px solid var(--primary-button-color);\n border-radius: 4px;\n min-width: 200px;\n}\n@media (max-width: 550px) {\n .action-button {\n min-width: 120px;\n }\n}\n\n.action-button:not([disabled]):hover {\n background: var(--primary-button-hover-color);\n /* background-color: ${hover}; */\n}\n\n.action-button:not([disabled]):active {\n}\n\n.action-button[disabled] {\n cursor: not-allowed;\n}\n\nbutton:focus:not(:active) {\n border: 1px solid transparent;\n /* box-shadow: 0 0 0 2px ${pseudo.focus}; */\n}\n");const g=()=>t.createElement(t.Fragment,null,"..."),f=e=>{const{inline:n=!1,children:o,disabled:r,className:a="",htmlType:i,type:l="primary",onClick:c,size:s,overrideStyleClassName:d="",loading:p=!1,...u}=e;return t.createElement("button",Object.assign({style:n?{display:"inline-block"}:{},disabled:r,className:`action-button ${a} ${d}`,type:i,onClick:c},u),p?t.createElement(g,null):o)},v=({question:e,formValues:n,onChangeHandler:o})=>{switch(e.type_info.question_type){case"RANGE":return t.createElement(r,{type_info:e.type_info,onChangeHandler:o,npsValue:n[e.name]});case"CHECKBOX":return t.createElement(u,{values:n[e.name],options:e.type_info.choices,onChangeHandler:o});case"CHECKBOX":return t.createElement(x,{name:e.name,onChangeHandler:o,options:e.type_info.choices,value:n[e.name]});case"MESSAGE":return t.createElement("div",{className:"responsive-text-field"},t.createElement(s,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>o(e.target.value)}),t.createElement(d,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>o(e.target.value)}));case"PARAGRAPH":return t.createElement(d,{autoFocus:!0,label:"",isRequired:e.is_required,value:n[e.name]||"",onChange:e=>o(e.target.value)});default:return console.error(`Question type ${e.type_info.question_type} not found`),null}};o(".question-container {\n display: flex;\n flex-direction: column;\n text-align: center;\n max-width: 700px;\n margin: 0 auto;\n align-items: center;\n background: #ffffff;\n border-radius: 4px;\n transition: transform 400ms ease 0ms, opacity 200ms ease 0ms;\n box-shadow: 0px 2px 16px rgba(18, 52, 77, 0.1);\n margin-bottom: 40px;\n padding: 20px;\n grid-gap: 28px;\n gap: 28px;\n}\n.question-text {\n font-size: 1.1rem;\n line-height: 1.5;\n}\n\n.action-buttons {\n display: flex;\n justify-content: space-between;\n width: 100%;\n align-items: center;\n}\n.skip-button {\n cursor: pointer;\n background: transparent;\n border: none;\n min-width: 40px;\n padding: 4px 12px;\n border-radius: 4px;\n}\n\n.next-button {\n margin: 0 auto;\n}\n.submit {\n padding-bottom: 40px;\n display: flex;\n justify-content: center;\n}\n.responsive-text-field {\n width: 100%;\n}\n.responsive-text-field .textarea-container {\n display: none;\n}\n\n@media (max-width: 550px) {\n .responsive-text-field .input-container {\n display: none;\n }\n .responsive-text-field .textarea-container {\n display: flex;\n }\n}\n");const w=["RANGE","NPS","RADIO"],y=()=>t.createElement("div",{className:"question-container",style:{gap:"16px"}},t.createElement("h4",null,"Thank you for taking our survey!."),t.createElement("p",null," Your response is very important to us."));exports.BUTTON_SIZE_VARIANTS={LARGE:"large",MINI:"mini",NORMAL:"normal"},exports.Button=f,exports.CheckboxGroup=u,exports.Input=s,exports.NPS=r,exports.ProgressBar=b,exports.Radio=m,exports.RadioGroup=x,exports.TextArea=d,exports.default=({survey:e,onSubmit:o})=>{const{meta:{blocks:r},question_details:{questions:a}}=e,[i,l]=n.useState({}),[c,s]=n.useState(!1),[d,p]=n.useState([]),u=n.useRef(null),h=n.useRef(null),x=n.useRef(null),m=n.useRef(0),g=n.useRef(!1),k=n.useRef([]);n.useEffect((()=>{r&&!u.current&&r.length>0&&N(r[0])}),[r]),n.useEffect((()=>{x.current?.scrollIntoView({block:"center",behavior:"smooth"}),k.current=d}),[d]),n.useEffect((()=>{Object.keys(i).length>0&&h.current&&(w.includes(h.current.type_info.question_type)||g.current)&&!E()&&C()}),[i]);const E=()=>m.current===r.length-1||"end"===u.current.branchOption,N=e=>{let n={};if(e.is_based_on_score){const t=a[0].type_info.choices[i?.[a[0].name]]?.dependent_question_names,o=e.question_names.find((e=>t?.includes(e)));n=a.find((e=>e.name===o))}else n=a.find((n=>n.name===e.question_names[0]));u.current=e,h.current=n;k.current.find((e=>e.question.name===n.name))||p([...k.current,{...e,question:n}])},q=(e,n,t)=>{if(t)if(null!=i[e.question.name]&&e.name!==d[d.length-1].name){const[t,o]=(e=>{const n=d.findIndex((n=>n.name===e.name)),t=d.slice(0,n+1),o=t.reduce(((e,n)=>(e[n.question.name]=i[n.question.name],e)),{});return m.current=r.findIndex((n=>n.name===e.name)),[t,o]})(e);l({...o,...null!=n&&{[e.question.name]:n}}),k.current=t}else l({...i,...null!=n&&{[e.question.name]:n}});else l({...i,...null!=n&&{[e.question.name]:n}})},C=()=>{E()?s(!0):(u.current.nextBlock?m.current=r.findIndex((e=>e.name===u.current.nextBlock)):m.current+=1,N(r[m.current]))},_=e=>{const n=d.findIndex((n=>n.name===e.name)),t=[...d];t.splice(n,1),k.current=t,C()};return u.current&&h.current?c?t.createElement(y,null):t.createElement(t.Fragment,null,t.createElement(b,{totalSteps:r.length,completedSteps:m.current}),d.map(((e,n)=>{return t.createElement("div",{className:"question-container",ref:x,id:e.title,key:e.title},t.createElement("div",{className:"question-text"},e.question.text),t.createElement(v,{question:e.question,formValues:i,onChangeHandler:n=>{g.current=!1,m.current=r.findIndex((n=>n.name===e.name)),u.current=e,h.current=e.question,q(e,n,w.includes(e.question.type_info.question_type)&&!E())}}),t.createElement("div",{className:"action-buttons"},(o=e.question,o.name===h.current.name&&!w.includes(o.type_info.question_type)&&!E()&&t.createElement(f,{onClick:()=>{g.current=!0,q(e,null,!0)},className:"next-button"},"Next")),((e,n)=>!e.required&&n.name===h.current.name)(e,e.question)&&t.createElement("button",{className:"skip-button",onClick:_},"Skip")));var o})),E()&&t.createElement("div",{className:"submit"},t.createElement(f,{onClick:()=>{s(!0),o(i)}},"Submit Survey"))):null};
|
package/lib/index.esm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{useRef as n,forwardRef as t,useState as o,useEffect as r}from"react";function a(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===t&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}a(".container {\n margin: 0 auto;\n width: 100%;\n}\n.title {\n color: var(--color-elephant-900);\n font-weight: 600;\n}\n\n.footer {\n margin-top: 20px;\n border-top: 1px solid var(--color-smoke-50);\n padding-top: 20px;\n display: flex;\n justify-content: center;\n font-size: 12px;\n}\n\n.widget span {\n color: #aaa;\n font-size: 12px;\n}\n.widget button {\n display: inline-block;\n font-size: 16px;\n white-space: nowrap;\n vertical-align: middle;\n background: none;\n border: none;\n box-shadow: none;\n cursor: pointer;\n text-align: center;\n font-weight: 500;\n border-radius: 4px;\n margin: 0;\n outline: none;\n margin-left: -1px;\n width: 40px;\n height: 40px;\n transform: scale(1);\n transition: background 0.2s ease-in, color 0.2s ease-in,\n border-color 0.2s ease-in, transform 0.2s cubic-bezier(0.5, 2, 0.5, 0.75);\n}\n.widget button:hover {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.widget button.active {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n\n.choices {\n width: 100%;\n display: flex;\n justify-content: space-between;\n}\n\n.choice.active,\n.choice:hover:nth-child(1) {\n background: #eb5b56;\n}\n.choice.active,\n.choice:hover:nth-child(2) {\n background: #fb8774;\n}\n.choice.active,\n.choice:hover:nth-child(3) {\n background: #f58f6b;\n}\n.choice.active,\n.choice:hover:nth-child(4) {\n background: #f6996a;\n}\n.choice.active,\n.choice:hover:nth-child(5) {\n background: #eab268;\n}\n.choice.active,\n.choice:hover:nth-child(6) {\n background: #cebb69;\n}\n.choice.active,\n.choice:hover:nth-child(7) {\n background: #bdc46c;\n}\n.choice.active,\n.choice:hover:nth-child(8) {\n background: #a4cd72;\n}\n.choice.active,\n.choice:hover:nth-child(9) {\n background: #77c955;\n}\n.choice.active,\n.choice:hover:nth-child(10) {\n background: #37c248;\n}\n\n.widget.highlighted button.active,\n.widget.highlighted button:hover {\n background: var(--color-elephant-800) !important;\n}\n.widget .rounded button {\n border-radius: 100%;\n}\n.widget .boxed button {\n border-radius: 0;\n}\n.widget {\n padding: 35px 0;\n box-sizing: border-box;\n position: relative;\n padding-bottom: 30px;\n}\n.widget .button-container {\n display: flex;\n justify-content: space-between;\n background: var(--color-smoke-50);\n}\n.widget .positive-text,\n.widget .negative-text {\n position: absolute;\n color: var(--color-elephant-500);\n}\n.widget .positive-text {\n right: 0px;\n bottom: 5px;\n text-align: right;\n}\n.widget .negative-text {\n left: 0;\n bottom: 5px;\n text-align: left;\n}\n@media (max-width: 550px) {\n .widget .button-container {\n background: transparent;\n }\n .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n }\n .widget button {\n border-radius: 50%;\n background: #ebeff3;\n }\n}\n");const i=t=>{const{type_info:{linear_scale:{button_shape:o,button_style:r},score_presets:{start:a,end:i},validation:{min:l},footer_text:c}}=t,s=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},d=n(Array.from({length:10},((e,n)=>n+l)));return e.createElement("div",{className:"container"},e.createElement("div",{className:`widget ${o} ${r}`},e.createElement("div",{className:"button-container"},e.createElement("span",{className:"negative-text"},a),e.createElement("div",{className:"choices"},d.current.map((n=>e.createElement("button",{onClick:e=>{t.onChangeHandler(n)},className:`choice ${s(n)} ${t.npsValue===n&&"active"}`},n)))),e.createElement("span",{className:"positive-text"},i))),e.createElement("div",{className:"footer"},c))},l=(e,n)=>(e.defaultProps=n,e);a(".input-container,\n.textarea-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n border-radius: 4px;\n position: relative;\n}\nlabel.input-label {\n display: inline-block;\n padding-bottom: 8px;\n padding-left: 2px;\n font-size: 12px;\n font-weight: 400;\n}\nlabel.required::after {\n content: '*';\n position: relative;\n top: 2px;\n font-weight: 500;\n font-size: 0.85rem;\n padding-left: 3px;\n color: var(--error-highlight-color);\n}\n\n.input-basic {\n width: 100%;\n display: flex;\n align-items: center;\n border-radius: var(--border-radius);\n border: 1px solid var(--input-border-color);\n transition: border-color 0.2s linear;\n background: #fff;\n}\n.textarea-container .input-basic {\n flex-direction: column;\n align-items: unset;\n}\n.input-basic.error {\n border: 1px solid var(--error-highlight-color);\n}\n.input-basic.error:hover {\n border: 1px solid var(--error-highlight-color);\n}\n.input-basic.error[focus-within] {\n box-shadow: none;\n}\n.input-basic.error:focus-within {\n box-shadow: none;\n}\n.input-basic:hover {\n border-color: var(--input-hover-border-color);\n transition: 0.2s linear;\n}\n.input-basic[focus-within] {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--input-highlight-color);\n}\n.input-basic:focus-within {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--input-highlight-color);\n}\n.end-max-length {\n padding: 0 8px;\n font-size: 0.85rem;\n}\n.textarea-container .end-max-length {\n padding: 8px;\n align-self: flex-end;\n}\nspan.input-error {\n display: block;\n padding-left: 2px;\n padding-top: 4px;\n font-size: 0.9rem;\n color: var(--error-highlight-color);\n}\ninput[type='text'] {\n padding: 4px 12px;\n flex: 1;\n border: unset;\n height: 32px;\n font-size: 1rem;\n /* line-height: ${typography.input.text.lineHeight}; */\n font-weight: 500;\n border-radius: 4px;\n}\ninput[type='text'],\ntextarea {\n outline: none;\n border: none;\n}\ninput[type='text']::-moz-placeholder {\n color: var(--input-placeholder-color);\n}\ninput[type='text']:-ms-input-placeholder {\n color: var(--input-placeholder-color);\n}\ninput[type='text']::placeholder {\n color: var(--input-placeholder-color);\n}\ntextarea {\n min-height: 116px;\n padding: 4px 12px;\n flex: 1;\n border: unset;\n resize: none;\n font-size: 1rem;\n /* line-height: ${typography.input.text.lineHeight}; */\n font-weight: 500;\n border-radius: 4px;\n}\ntextarea::-moz-placeholder {\n color: var(--input-placeholder-color);\n}\ntextarea:-ms-input-placeholder {\n color: var(--input-placeholder-color);\n}\ntextarea::placeholder {\n color: var(--input-placeholder-color);\n}\n");const c={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!1},s=t(((n,t)=>{const{inputStyle:o,style:r,className:a,showCount:i,isErrored:l,startLabel:c,isRequired:s,errorText:d,endLabel:p,maxLength:u,...h}=n;return console.log(n.value),e.createElement("div",{className:"input-container",style:r},n.label&&e.createElement("label",{className:"input-label "+(s?"required":"")},n.label),e.createElement("div",null,c&&e.createElement("div",{className:"start-label"},c),e.createElement("div",{className:`input-basic ${l?"error":""}${a||""}`},e.createElement("input",Object.assign({type:"text",autoComplete:"off"},h,{ref:t,style:o})),i&&u>0&&e.createElement("div",{className:"end-max-length"},`${n.value&&n.value.length||0}/${n.maxLength}`)),p&&e.createElement("div",{className:"end-label"},p)),l&&d&&e.createElement("span",{className:"input-error"},n.errorText))})),d=t(((n,t)=>{const{inputStyle:o,style:r,className:a,showCount:i,maxLength:l,isErrored:c,startLabel:s,isRequired:d,...p}=n;return console.log(n.value),e.createElement(e.Fragment,null,e.createElement("div",{className:"textarea-container",style:r},n.label&&e.createElement("label",{className:"input-label "+(d?"required":"")},n.label),s&&e.createElement("div",{className:"start-label"},s),e.createElement("div",{className:`input-basic ${c?"error":""} ${a||""}`},e.createElement("textarea",Object.assign({autoComplete:"off"},p,{ref:t,style:o})),i&&l&&l>0&&e.createElement("div",{className:"end-max-length"},`${n.value&&n.value.length||0}/${n.maxLength}`)),n.endLabel&&e.createElement("div",{className:"end-label"},n.endLabel)),n.isErrored&&n.errorText&&e.createElement("span",{className:"input-error"},n.errorText))})),p=l(s,c),u=l(d,c);a(".checkbox-group {\n display: flex;\n align-items: center;\n grid-gap: 12px;\n gap: 12px;\n flex-direction: column;\n white-space: nowrap;\n flex-wrap: wrap;\n}\n.icon-container {\n display: inline-block;\n flex: 0 0 12px;\n width: 12px;\n height: 12px;\n min-width: 12px;\n min-height: 12px;\n color: inherit;\n position: absolute;\n left: 1px;\n top: 2px;\n}\n.tick-icon {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n width: 100%;\n color: inherit;\n fill: currentColor;\n}\ninput[type='checkbox'] {\n clip: rect(0px 0px 0px 0px);\n width: 0px;\n height: 0px;\n}\ninput[type='checkbox']:focus ~ .checkbox {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 2px; */\n box-shadow: var(--input-highlight-color) 0px 0px 0px 2px;\n border-color: transparent;\n}\n.checkbox-label {\n display: flex;\n align-items: center;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n opacity: 1;\n cursor: pointer;\n font-size: 1rem;\n font-weight: 500;\n padding: 16px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 10%);\n border-radius: 4px;\n}\n.checkbox-label.disabled {\n opacity: 0.5;\n cursor: 'not-allowed';\n}\n.checkbox {\n transition: background-color ease-in 0.2s;\n min-width: 14px;\n min-height: 14px;\n border-radius: 2px;\n position: relative;\n margin-right: 10px;\n background-color: #fff;\n border: 1px solid;\n border-color: var(--input-highlight-color);\n}\n.checkbox:hover {\n border-color: var(--input-highlight-color);\n box-shadow: var(--focus-box-shadow-color) 0px 0px 0px 5px;\n}\ninput[type='checkbox']:checked ~ .checkbox {\n background-color: var(--input-highlight-color);\n border-color: var(--input-highlight-color);\n}\ninput[type='checkbox']:checked ~ .checkbox:hover {\n border-color: var(--input-highlight-color);\n}\ninput[type='checkbox']:disabled ~ .checkbox:hover {\n box-shadow: unset;\n border-color: unset;\n}\n");const h=()=>e.createElement("svg",{id:"tick",className:"tick-icon",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"title",viewBox:"0 0 10 10"},e.createElement("path",{d:"M3 5.87c-.18666814.00267463-.36667109-.06932655-.5-.2L.21 3.41c-.1786328-.17863279-.24839684-.43899577-.1830127-.6830127.06538414-.24401694.25598306-.43461586.5-.5C.77100423 2.16160316 1.0313672 2.23136721 1.21 2.41L3 4.18 6.8.33c.27679776-.27455556.72320224-.27455556 1 0 .13696438.13025306.21450026.31098915.21450026.5S7.93696438 1.19974694 7.8 1.33L3.45 5.67c-.12082534.11896945-.28072735.19003701-.45.2Z",fill:"#fff",fillRule:"evenodd"})),m=({values:n,options:t,onChangeHandler:o})=>e.createElement("div",{className:"checkbox-group"},t.map(((t,r)=>e.createElement(x,{key:t.id,checked:n?.includes(t.id),name:t.name??t.id,id:t.id,autoFocus:0===r,onChange:(e,r)=>{if(r)o([...n||[],t.id]);else{const e=n.indexOf(t.id);e>-1&&n.splice(e,1),o([...n])}}},t.label)))),x=l(t(((n,t)=>e.createElement("label",{className:`checkbox-label ${n.disabled&&"disabled"}`},e.createElement("input",{ref:t,id:n.id,type:"checkbox",name:n.name,readOnly:n.readOnly,disabled:n.disabled,"aria-disabled":n.disabled,value:n.value,checked:n.checked,autoFocus:n.autoFocus,onChange:n.readOnly?()=>{}:e=>n.onChange(e,e.target.checked)}),e.createElement("div",{className:"checkbox"},n.checked&&e.createElement("div",{className:"icon-container"},e.createElement(h,null)," ")),e.createElement("div",null,n.children)))),{checked:!1});a(".radio-group {\n display: flex;\n align-items: center;\n grid-gap: 12px;\n gap: 12px;\n white-space: nowrap;\n flex-direction: column;\n}\n\n.radio {\n background-color: #fff;\n border: 1px solid;\n border-color: var(--input-border-color);\n transition: background-color ease-in 0.2s;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n position: relative;\n margin-right: 12px;\n}\n.radio:before {\n left: 3px;\n top: 3px;\n content: '';\n position: absolute;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n transition: all ease-in 0.2s;\n background-color: #fff;\n}\n.radio-label {\n display: flex;\n align-items: center;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n cursor: pointer;\n font-size: 1rem;\n font-weight: 500;\n padding: 16px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 10%);\n border-radius: 4px;\n}\ninput[type='radio'] {\n clip: rect(0, 0, 0, 0);\n position: absolute;\n}\ninput[type='radio']:focus ~ .radio {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 3px; */\n box-shadow: var(--input-highlight-color) 0px 0px 0px 3px;\n border-color: transparent;\n}\n\ninput[type='radio']:checked ~ .radio:before {\n background-color: var(--input-highlight-color);\n}\n.radio-container:hover .radio {\n border-color: var(--input-highlight-color);\n box-shadow: var(--focus-box-shadow-color) 0px 0px 0px 5px;\n}\n");const b=({name:n,options:t,value:o,onChangeHandler:r})=>e.createElement("div",{className:"radio-group"},t.map((t=>e.createElement(g,{key:t.id,value:t.id,name:n,onChange:e=>{r(e.currentTarget.value)},checked:o===t.id},t.label)))),g=l(t(((n,t)=>e.createElement("label",{className:"radio-label"},e.createElement("input",{ref:t,type:"radio",name:n.name,value:n.value,checked:n.checked,onClick:n.onChange,autoFocus:!0}),e.createElement("div",{className:"radio"}),e.createElement("div",null,n.children)))),{checked:!1});a(".progressbar-container {\n width: 100%;\n height: 6px;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.progressbar {\n transition: transform 0.25s linear;\n transform-origin: left;\n height: 100%;\n background-color: var(--brand-color);\n}\n");const f=n=>{const{totalSteps:t,completedSteps:o}=n;return e.createElement("div",{className:"progressbar-container"},e.createElement("div",{className:"progressbar",style:{width:(o>0?100/t:0)+"%",transform:`scaleX(${o})`}}))};a(".action-button {\n width: auto;\n display: block;\n margin: 0;\n padding: 8px 16px;\n cursor: pointer;\n line-height: 1.5;\n text-align: center;\n font-weight: 500;\n letter-spacing: 0.3px;\n border-radius: 4px;\n white-space: nowrap;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n color: #fff;\n background: var(--primary-button-color);\n border: 1px solid var(--primary-button-color);\n border-radius: 4px;\n min-width: 200px;\n}\n@media (max-width: 550px) {\n .action-button {\n min-width: 120px;\n }\n}\n\n.action-button:not([disabled]):hover {\n background: var(--primary-button-hover-color);\n /* background-color: ${hover}; */\n}\n\n.action-button:not([disabled]):active {\n}\n\n.action-button[disabled] {\n cursor: not-allowed;\n}\n\nbutton:focus:not(:active) {\n border: 1px solid transparent;\n /* box-shadow: 0 0 0 2px ${pseudo.focus}; */\n}\n");const v=()=>e.createElement(e.Fragment,null,"..."),w={LARGE:"large",MINI:"mini",NORMAL:"normal"},y=n=>{const{inline:t=!1,children:o,disabled:r,className:a="",htmlType:i,type:l="primary",onClick:c,size:s,overrideStyleClassName:d="",loading:p=!1,...u}=n;return e.createElement("button",Object.assign({style:t?{display:"inline-block"}:{},disabled:r,className:`action-button ${a} ${d}`,type:i,onClick:c},u),p?e.createElement(v,null):o)},k=({question:n,formValues:t,onChangeHandler:o})=>{switch(n.type_info.question_type){case"RANGE":return e.createElement(i,{type_info:n.type_info,onChangeHandler:o,npsValue:t[n.name]});case"CHECKBOX":return e.createElement(m,{values:t[n.name],options:n.type_info.choices,onChangeHandler:o});case"CHECKBOX":return e.createElement(b,{name:n.name,onChangeHandler:o,options:n.type_info.choices,value:t[n.name]});case"MESSAGE":return e.createElement("div",{className:"responsive-text-field"},e.createElement(p,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>o(e.target.value)}),e.createElement(u,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>o(e.target.value)}));case"PARAGRAPH":return e.createElement(u,{autoFocus:!0,label:"",isRequired:n.is_required,value:t[n.name]||"",onChange:e=>o(e.target.value)});default:return console.error(`Question type ${n.type_info.question_type} not found`),null}};a(".question-container {\n display: flex;\n flex-direction: column;\n text-align: center;\n max-width: 700px;\n margin: 0 auto;\n align-items: center;\n background: #ffffff;\n border-radius: 4px;\n transition: transform 400ms ease 0ms, opacity 200ms ease 0ms;\n box-shadow: 0px 2px 16px rgba(18, 52, 77, 0.1);\n margin-bottom: 40px;\n padding: 20px;\n grid-gap: 28px;\n gap: 28px;\n}\n.question-text {\n font-size: 1.1rem;\n line-height: 1.5;\n}\n\n.action-buttons {\n display: flex;\n justify-content: space-between;\n width: 100%;\n align-items: center;\n}\n.skip-button {\n cursor: pointer;\n background: transparent;\n border: none;\n min-width: 40px;\n padding: 4px 12px;\n border-radius: 4px;\n}\n\n.next-button {\n margin: 0 auto;\n}\n.submit {\n padding-bottom: 40px;\n display: flex;\n justify-content: center;\n}\n.responsive-text-field {\n width: 100%;\n}\n.responsive-text-field .textarea-container {\n display: none;\n}\n\n@media (max-width: 550px) {\n .responsive-text-field .input-container {\n display: none;\n }\n .responsive-text-field .textarea-container {\n display: flex;\n }\n}\n");const E=["RANGE","NPS","RADIO"],N=()=>e.createElement("div",{className:"question-container",style:{gap:"16px"}},e.createElement("h4",null,"Thank you for taking our survey!."),e.createElement("p",null," Your response is very important to us."));export default({survey:t,onSubmit:a})=>{const{meta:{blocks:i},question_details:{questions:l}}=t,[c,s]=o({}),[d,p]=o(!1),[u,h]=o([]),m=n(null),x=n(null),b=n(null),g=n(0),v=n(!1),w=n([]);r((()=>{i&&!m.current&&i.length>0&&C(i[0])}),[i]),r((()=>{b.current?.scrollIntoView({block:"center",behavior:"smooth"}),w.current=u}),[u]),r((()=>{Object.keys(c).length>0&&x.current&&(E.includes(x.current.type_info.question_type)||v.current)&&!q()&&z()}),[c]);const q=()=>g.current===i.length-1||"end"===m.current.branchOption,C=e=>{let n={};if(e.is_based_on_score){const t=l[0].type_info.choices[c?.[l[0].name]]?.dependent_question_names,o=e.question_names.find((e=>t?.includes(e)));n=l.find((e=>e.name===o))}else n=l.find((n=>n.name===e.question_names[0]));m.current=e,x.current=n;w.current.find((e=>e.question.name===n.name))||h([...w.current,{...e,question:n}])},_=(e,n,t)=>{if(t)if(null!=c[e.question.name]&&e.name!==u[u.length-1].name){const[t,o]=(e=>{const n=u.findIndex((n=>n.name===e.name)),t=u.slice(0,n+1),o=t.reduce(((e,n)=>(e[n.question.name]=c[n.question.name],e)),{});return g.current=i.findIndex((n=>n.name===e.name)),[t,o]})(e);s({...o,...null!=n&&{[e.question.name]:n}}),w.current=t}else s({...c,...null!=n&&{[e.question.name]:n}});else s({...c,...null!=n&&{[e.question.name]:n}})},z=()=>{q()?p(!0):(m.current.nextBlock?g.current=i.findIndex((e=>e.name===m.current.nextBlock)):g.current+=1,C(i[g.current]))},$=e=>{const n=u.findIndex((n=>n.name===e.name)),t=[...u];t.splice(n,1),w.current=t,z()};return m.current&&x.current?d?e.createElement(N,null):e.createElement(e.Fragment,null,e.createElement(f,{totalSteps:i.length,completedSteps:g.current}),u.map(((n,t)=>{return e.createElement("div",{className:"question-container",ref:b,id:n.title,key:n.title},e.createElement("div",{className:"question-text"},n.question.text),e.createElement(k,{question:n.question,formValues:c,onChangeHandler:e=>{v.current=!1,g.current=i.findIndex((e=>e.name===n.name)),m.current=n,x.current=n.question,_(n,e,E.includes(n.question.type_info.question_type)&&!q())}}),e.createElement("div",{className:"action-buttons"},(o=n.question,o.name===x.current.name&&!E.includes(o.type_info.question_type)&&!q()&&e.createElement(y,{onClick:()=>{v.current=!0,_(n,null,!0)},className:"next-button"},"Next")),((e,n)=>!e.required&&n.name===x.current.name)(n,n.question)&&e.createElement("button",{className:"skip-button",onClick:$},"Skip")));var o})),q()&&e.createElement("div",{className:"submit"},e.createElement(y,{onClick:()=>{p(!0),a(c)}},"Submit Survey"))):null};export{w as BUTTON_SIZE_VARIANTS,y as Button,m as CheckboxGroup,p as Input,i as NPS,f as ProgressBar,g as Radio,b as RadioGroup,u as TextArea};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style.css';
|
|
3
|
+
export declare const BUTTON_SIZE_VARIANTS: {
|
|
4
|
+
LARGE: string;
|
|
5
|
+
MINI: string;
|
|
6
|
+
NORMAL: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ButtonSizeKey = 'large' | 'mini' | 'normal' | undefined;
|
|
9
|
+
export declare type buttonHTMLType = 'button' | 'reset' | 'submit' | undefined;
|
|
10
|
+
export declare type buttonType = 'primary' | 'secondary' | 'danger' | 'link';
|
|
11
|
+
export declare type ButtonProps = {
|
|
12
|
+
type?: buttonType;
|
|
13
|
+
htmlType?: buttonHTMLType;
|
|
14
|
+
size?: ButtonSizeKey;
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
large?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
ref?: any;
|
|
20
|
+
onClick?: any;
|
|
21
|
+
overrideStyleClassName?: string;
|
|
22
|
+
loading?: boolean;
|
|
23
|
+
children: any;
|
|
24
|
+
};
|
|
25
|
+
export declare const Button: (props: ButtonProps & React.HTMLAttributes<HTMLButtonElement>) => JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './style.css';
|
|
3
|
+
declare type Option = {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
interface CheckboxGroupInterface {
|
|
9
|
+
options: Array<Option>;
|
|
10
|
+
values: string[];
|
|
11
|
+
onChangeHandler: (newValues: string[]) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const CheckboxGroup: ({ values, options, onChangeHandler, }: CheckboxGroupInterface) => JSX.Element;
|
|
14
|
+
export { CheckboxGroup };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './style.css';
|
|
3
|
+
export declare type ButtonShapeType = 'rounded' | 'square' | 'curved';
|
|
4
|
+
declare type NPSProps = {
|
|
5
|
+
type_info: {
|
|
6
|
+
linear_scale: {
|
|
7
|
+
button_shape: ButtonShapeType;
|
|
8
|
+
button_style: any;
|
|
9
|
+
};
|
|
10
|
+
validation: {
|
|
11
|
+
min: number;
|
|
12
|
+
};
|
|
13
|
+
score_presets: {
|
|
14
|
+
start: string;
|
|
15
|
+
end: string;
|
|
16
|
+
};
|
|
17
|
+
footer_text: string;
|
|
18
|
+
};
|
|
19
|
+
onChangeHandler: (value: number) => void;
|
|
20
|
+
npsValue: number;
|
|
21
|
+
};
|
|
22
|
+
declare const NPS: (props: NPSProps) => JSX.Element;
|
|
23
|
+
export { NPS };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style.css';
|
|
3
|
+
interface RadioButtonProps {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
children: string;
|
|
6
|
+
value: string | number;
|
|
7
|
+
name: string;
|
|
8
|
+
onChange: (e: any) => void;
|
|
9
|
+
id?: string;
|
|
10
|
+
}
|
|
11
|
+
interface RadioGroupInterface {
|
|
12
|
+
options: Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
value: string;
|
|
18
|
+
name: string;
|
|
19
|
+
onChangeHandler: (newValue: string) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const RadioGroup: ({ name, options, value, onChangeHandler, }: RadioGroupInterface) => JSX.Element;
|
|
22
|
+
declare const Radio: React.ComponentType<Partial<{
|
|
23
|
+
checked: boolean;
|
|
24
|
+
}> & Pick<RadioButtonProps & React.RefAttributes<HTMLInputElement>, "name" | "value" | "ref" | "children" | "onChange" | "id" | "key">>;
|
|
25
|
+
export { Radio, RadioGroup };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style.css';
|
|
3
|
+
interface InputProps extends React.HTMLAttributes<HTMLInputElement> {
|
|
4
|
+
isErrored?: boolean;
|
|
5
|
+
showCount?: boolean;
|
|
6
|
+
errorText?: string;
|
|
7
|
+
maxLength?: any;
|
|
8
|
+
type?: string;
|
|
9
|
+
label: string;
|
|
10
|
+
style?: any;
|
|
11
|
+
value?: any;
|
|
12
|
+
inputStyle?: any;
|
|
13
|
+
className?: string;
|
|
14
|
+
startLabel?: React.ReactNode | any;
|
|
15
|
+
endLabel?: React.ReactNode | any;
|
|
16
|
+
isRequired?: boolean;
|
|
17
|
+
inline?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface TextAreaProps extends React.HTMLAttributes<HTMLTextAreaElement> {
|
|
20
|
+
isErrored: boolean;
|
|
21
|
+
showCount?: boolean;
|
|
22
|
+
maxLength?: any;
|
|
23
|
+
errorText?: string;
|
|
24
|
+
style?: any;
|
|
25
|
+
value?: any;
|
|
26
|
+
inputStyle?: any;
|
|
27
|
+
className?: string;
|
|
28
|
+
label: string;
|
|
29
|
+
startLabel?: React.ReactNode | any;
|
|
30
|
+
startAdornment?: React.ReactNode | any;
|
|
31
|
+
endLabel?: React.ReactNode | any;
|
|
32
|
+
endAdornment?: React.ReactNode | any;
|
|
33
|
+
isRequired?: boolean;
|
|
34
|
+
inline?: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare const Input: React.ComponentType<Partial<{
|
|
37
|
+
isRequired: boolean;
|
|
38
|
+
showCount: boolean;
|
|
39
|
+
isErrored: boolean;
|
|
40
|
+
inline: boolean;
|
|
41
|
+
spellCheck: boolean;
|
|
42
|
+
autoFocus: boolean;
|
|
43
|
+
}> & Pick<InputProps & React.RefAttributes<HTMLInputElement>, "ref" | "errorText" | "maxLength" | "type" | "label" | "style" | "value" | "inputStyle" | "className" | "startLabel" | "endLabel" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key">>;
|
|
44
|
+
declare const TextArea: React.ComponentType<Partial<{
|
|
45
|
+
isRequired: boolean;
|
|
46
|
+
showCount: boolean;
|
|
47
|
+
isErrored: boolean;
|
|
48
|
+
inline: boolean;
|
|
49
|
+
spellCheck: boolean;
|
|
50
|
+
autoFocus: boolean;
|
|
51
|
+
}> & Pick<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>, "ref" | "errorText" | "maxLength" | "label" | "style" | "value" | "inputStyle" | "className" | "startLabel" | "endLabel" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "startAdornment" | "endAdornment" | "key">>;
|
|
52
|
+
export { Input, TextArea };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './survey';
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
name: string;
|
|
3
|
+
desc: string;
|
|
4
|
+
type: string;
|
|
5
|
+
header_message: string;
|
|
6
|
+
gratitude_message: string;
|
|
7
|
+
ui_branding: {
|
|
8
|
+
logo_url: string;
|
|
9
|
+
footer_html: string;
|
|
10
|
+
};
|
|
11
|
+
meta: {
|
|
12
|
+
blocks: ({
|
|
13
|
+
name: string;
|
|
14
|
+
title: string;
|
|
15
|
+
order: number;
|
|
16
|
+
question_names: string[];
|
|
17
|
+
type: string;
|
|
18
|
+
required: boolean;
|
|
19
|
+
is_based_on_score: boolean;
|
|
20
|
+
is_same_for_all: boolean;
|
|
21
|
+
jump_logic: null;
|
|
22
|
+
branchOption?: undefined;
|
|
23
|
+
nextBlock?: undefined;
|
|
24
|
+
position?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
name: string;
|
|
27
|
+
order: number;
|
|
28
|
+
type: string;
|
|
29
|
+
title: string;
|
|
30
|
+
question_names: string[];
|
|
31
|
+
required: boolean;
|
|
32
|
+
is_based_on_score: boolean;
|
|
33
|
+
is_same_for_all: boolean;
|
|
34
|
+
jump_logic: null;
|
|
35
|
+
branchOption: string;
|
|
36
|
+
nextBlock: string;
|
|
37
|
+
position?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
name: string;
|
|
40
|
+
order: number;
|
|
41
|
+
type: string;
|
|
42
|
+
title: string;
|
|
43
|
+
question_names: string[];
|
|
44
|
+
position: number;
|
|
45
|
+
required: boolean;
|
|
46
|
+
is_based_on_score: boolean;
|
|
47
|
+
is_same_for_all: boolean;
|
|
48
|
+
jump_logic: null;
|
|
49
|
+
branchOption?: undefined;
|
|
50
|
+
nextBlock?: undefined;
|
|
51
|
+
})[];
|
|
52
|
+
};
|
|
53
|
+
question_details: {
|
|
54
|
+
questions: ({
|
|
55
|
+
text: string;
|
|
56
|
+
name: string;
|
|
57
|
+
position: number;
|
|
58
|
+
type_info: {
|
|
59
|
+
question_type: string;
|
|
60
|
+
validation: {
|
|
61
|
+
min: number;
|
|
62
|
+
max: number;
|
|
63
|
+
};
|
|
64
|
+
choices: {
|
|
65
|
+
value: number;
|
|
66
|
+
position: number;
|
|
67
|
+
dependent_question_names: string[];
|
|
68
|
+
}[];
|
|
69
|
+
linear_scale: {
|
|
70
|
+
button_style: string;
|
|
71
|
+
button_shape: string;
|
|
72
|
+
};
|
|
73
|
+
score_presets: {
|
|
74
|
+
start: string;
|
|
75
|
+
end: string;
|
|
76
|
+
};
|
|
77
|
+
footer_text: string;
|
|
78
|
+
meta?: undefined;
|
|
79
|
+
};
|
|
80
|
+
question_type?: undefined;
|
|
81
|
+
choices?: undefined;
|
|
82
|
+
} | {
|
|
83
|
+
text: string;
|
|
84
|
+
name: string;
|
|
85
|
+
position: number;
|
|
86
|
+
type_info: {
|
|
87
|
+
question_type: string;
|
|
88
|
+
choices: {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
}[];
|
|
92
|
+
meta: {
|
|
93
|
+
value: string;
|
|
94
|
+
};
|
|
95
|
+
validation?: undefined;
|
|
96
|
+
linear_scale?: undefined;
|
|
97
|
+
score_presets?: undefined;
|
|
98
|
+
footer_text?: undefined;
|
|
99
|
+
};
|
|
100
|
+
question_type: string;
|
|
101
|
+
choices?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
text: string;
|
|
104
|
+
name: string;
|
|
105
|
+
position: number;
|
|
106
|
+
type_info: {
|
|
107
|
+
question_type: string;
|
|
108
|
+
choices: {
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
}[];
|
|
112
|
+
meta: {
|
|
113
|
+
value: string;
|
|
114
|
+
};
|
|
115
|
+
validation?: undefined;
|
|
116
|
+
linear_scale?: undefined;
|
|
117
|
+
score_presets?: undefined;
|
|
118
|
+
footer_text?: undefined;
|
|
119
|
+
};
|
|
120
|
+
question_type: string;
|
|
121
|
+
choices: {
|
|
122
|
+
id: string;
|
|
123
|
+
label: string;
|
|
124
|
+
}[];
|
|
125
|
+
} | {
|
|
126
|
+
name: string;
|
|
127
|
+
position: number;
|
|
128
|
+
text: string;
|
|
129
|
+
type_info: {
|
|
130
|
+
question_type: string;
|
|
131
|
+
choices: {
|
|
132
|
+
id: string;
|
|
133
|
+
label: string;
|
|
134
|
+
}[];
|
|
135
|
+
meta: {
|
|
136
|
+
value?: undefined;
|
|
137
|
+
};
|
|
138
|
+
validation?: undefined;
|
|
139
|
+
linear_scale?: undefined;
|
|
140
|
+
score_presets?: undefined;
|
|
141
|
+
footer_text?: undefined;
|
|
142
|
+
};
|
|
143
|
+
question_type: string;
|
|
144
|
+
choices?: undefined;
|
|
145
|
+
} | {
|
|
146
|
+
name: string;
|
|
147
|
+
position: number;
|
|
148
|
+
text: string;
|
|
149
|
+
type_info: {
|
|
150
|
+
question_type: string;
|
|
151
|
+
choices: {
|
|
152
|
+
id: string;
|
|
153
|
+
label: string;
|
|
154
|
+
}[];
|
|
155
|
+
meta: {
|
|
156
|
+
value?: undefined;
|
|
157
|
+
};
|
|
158
|
+
validation?: undefined;
|
|
159
|
+
linear_scale?: undefined;
|
|
160
|
+
score_presets?: undefined;
|
|
161
|
+
footer_text?: undefined;
|
|
162
|
+
};
|
|
163
|
+
question_type: string;
|
|
164
|
+
choices: {
|
|
165
|
+
id: string;
|
|
166
|
+
label: string;
|
|
167
|
+
}[];
|
|
168
|
+
} | {
|
|
169
|
+
name: string;
|
|
170
|
+
position: number;
|
|
171
|
+
text: string;
|
|
172
|
+
type_info: {
|
|
173
|
+
question_type: string;
|
|
174
|
+
choices: {
|
|
175
|
+
id: string;
|
|
176
|
+
label: string;
|
|
177
|
+
}[];
|
|
178
|
+
meta: {
|
|
179
|
+
value?: undefined;
|
|
180
|
+
};
|
|
181
|
+
validation?: undefined;
|
|
182
|
+
linear_scale?: undefined;
|
|
183
|
+
score_presets?: undefined;
|
|
184
|
+
footer_text?: undefined;
|
|
185
|
+
};
|
|
186
|
+
question_type?: undefined;
|
|
187
|
+
choices?: undefined;
|
|
188
|
+
})[];
|
|
189
|
+
};
|
|
190
|
+
state: string;
|
|
191
|
+
created_on: string;
|
|
192
|
+
updated_on: string;
|
|
193
|
+
schedule_info: {
|
|
194
|
+
start_date: string;
|
|
195
|
+
end_date: string;
|
|
196
|
+
preferred_time: {
|
|
197
|
+
hour: number;
|
|
198
|
+
minute: number;
|
|
199
|
+
};
|
|
200
|
+
remind_in: number[];
|
|
201
|
+
next_survey_when_responded: number;
|
|
202
|
+
next_survey_when_not_responded: number;
|
|
203
|
+
};
|
|
204
|
+
throttle_info: {
|
|
205
|
+
limit_per_day: number;
|
|
206
|
+
};
|
|
207
|
+
ui_theme: {
|
|
208
|
+
body_background_color: string;
|
|
209
|
+
primary_font: string;
|
|
210
|
+
secondary_font: string;
|
|
211
|
+
primary_button_color: string;
|
|
212
|
+
secondary_button_color: string;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export default _default;
|