freemium-survey-components 0.5.1-beta.3 → 0.5.2-beta.4
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/README.md +1 -1
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/index.d.ts +2 -2
- package/package.json +5 -12
- package/lib/types/components/button/index.d.ts +0 -24
- package/lib/types/components/checkbox/index.d.ts +0 -13
- package/lib/types/components/index.d.ts +0 -6
- package/lib/types/components/nps/index.d.ts +0 -22
- package/lib/types/components/progressbar/index.d.ts +0 -7
- package/lib/types/components/radio-button/index.d.ts +0 -26
- package/lib/types/components/text-input/index.d.ts +0 -51
- package/lib/types/survey/index.d.ts +0 -11
- package/lib/types/survey/question.d.ts +0 -3
- package/lib/types/utils.d.ts +0 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
Freemium-survey-components is a react package that renders the survey collection form given the survey object from the survey-serv platform service.
|
|
6
6
|
|
package/lib/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;const a=e=>{const{type_info:{linear_scale:{button_shape:a,button_style:r},score_presets:{start:l,end:s},validation:{min:c},footer_text:o}}=e,i=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},u=t.useRef(Array.from({length:10},((e,t)=>t+c)));return n.createElement("div",{className:"nps-container"},n.createElement("div",{className:`widget ${a} ${r}`},n.createElement("div",{className:"button-container"},n.createElement("span",{className:"negative-text"},l),n.createElement("div",{className:"choices"},u.current.map((t=>n.createElement("button",{key:t,onClick:n=>{e.onChangeHandler(t)},className:`choice ${i(t)} ${e.npsValue===t&&"active"}`},t)))),n.createElement("span",{className:"positive-text"},s))),n.createElement("div",{className:"footer"},o))},r=(e,t)=>(e.defaultProps=t,e),l={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!1},s=t.forwardRef(((e,t)=>{const{inputStyle:a,style:r,className:l,showCount:s,isErrored:c,startLabel:o,isRequired:i,errorText:u,endLabel:m,maxLength:d,...p}=e;return console.log(e.value),n.createElement("div",{className:"input-container",style:r},e.label&&n.createElement("label",{className:"input-label "+(i?"required":"")},e.label),n.createElement("div",null,o&&n.createElement("div",{className:"start-label"},o),n.createElement("div",{className:`input-basic ${c?"error":""}${l||""}`},n.createElement("input",Object.assign({type:"text",autoComplete:"off"},p,{ref:t,style:a})),s&&d>0&&n.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),m&&n.createElement("div",{className:"end-label"},m)),c&&u&&n.createElement("span",{className:"input-error"},e.errorText))})),c=t.forwardRef(((e,t)=>{const{inputStyle:a,style:r,className:l,showCount:s,maxLength:c,isErrored:o,startLabel:i,isRequired:u,...m}=e;return console.log(e.value),n.createElement(n.Fragment,null,n.createElement("div",{className:"textarea-container",style:r},e.label&&n.createElement("label",{className:"input-label "+(u?"required":"")},e.label),i&&n.createElement("div",{className:"start-label"},i),n.createElement("div",{className:`input-basic ${o?"error":""} ${l||""}`},n.createElement("textarea",Object.assign({autoComplete:"off"},m,{ref:t,style:a})),s&&c&&c>0&&n.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),e.endLabel&&n.createElement("div",{className:"end-label"},e.endLabel)),e.isErrored&&e.errorText&&n.createElement("span",{className:"input-error"},e.errorText))})),o=r(s,l),i=r(c,l),u=()=>n.createElement("svg",{id:"tick",className:"tick-icon",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"title",viewBox:"0 0 10 10"},n.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:e,options:t,onChangeHandler:a})=>n.createElement("div",{className:"checkbox-group"},t.map(((t,r)=>n.createElement(d,{key:t.id,checked:e?.includes(t.id),name:t.name??t.id,id:t.id,autoFocus:0===r,onChange:(n,r)=>{if(r)a([...e||[],t.id]);else{const n=e.indexOf(t.id);n>-1&&e.splice(n,1),a([...e])}}},t.label)))),d=r(t.forwardRef(((e,t)=>n.createElement("label",{className:`checkbox-label ${e.disabled&&"disabled"}`},n.createElement("input",{ref:t,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?()=>{}:t=>e.onChange(t,t.target.checked)}),n.createElement("div",{className:"checkbox"},e.checked&&n.createElement("div",{className:"icon-container"},n.createElement(u,null)," ")),n.createElement("div",null,e.children)))),{checked:!1}),p=({name:e,options:t,value:a,onChangeHandler:r})=>n.createElement("div",{className:"radio-group"},t.map(((t,l)=>n.createElement(E,{key:t.id,value:t.id,name:e,onChange:e=>{r(e.currentTarget.value)},autoFocus:0===l,checked:a===t.id},t.label)))),E=r(t.forwardRef(((e,t)=>n.createElement("label",{className:"radio-label"},n.createElement("input",{ref:t,type:"radio",name:e.name,value:e.value,checked:e.checked,onChange:e.onChange,autoFocus:e.autoFocus}),n.createElement("div",{className:"radio"}),n.createElement("div",null,e.children)))),{checked:!1,autoFocus:!1}),f=e=>{const{totalSteps:t,completedSteps:a}=e;return n.createElement("div",{className:"progressbar-container"},n.createElement("div",{className:"progressbar",style:{width:(a>0?100/t:0)+"%",transform:`scaleX(${a})`}}))},h=()=>n.createElement(n.Fragment,null,"..."),v=e=>{const{inline:t=!1,children:a,disabled:r,className:l="",htmlType:s,type:c="primary",onClick:o,size:i,overrideStyleClassName:u="",loading:m=!1,...d}=e;return n.createElement("button",Object.assign({style:t?{display:"inline-block"}:{},disabled:r,className:`action-button ${l} ${u}`,type:s,onClick:o},d),m?n.createElement(h,null):a)},b=({question:e,formValues:t,onChangeHandler:r})=>{switch(e.type_info.question_type){case"RANGE":return n.createElement(a,{type_info:e.type_info,onChangeHandler:r,npsValue:t[e.name]});case"CHECKBOX":case"DROPDOWN":return n.createElement(m,{values:t[e.name],options:e.type_info.choices,onChangeHandler:r});case"RADIO":case"MULTICHOICE":return n.createElement(p,{name:e.name,onChangeHandler:r,options:e.type_info.choices,value:t[e.name]});case"INPUT":return n.createElement("div",{className:"responsive-text-field"},n.createElement(o,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:t[e.name]||"",onChange:e=>r(e.target.value)}),n.createElement(i,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:t[e.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return n.createElement(i,{autoFocus:!0,label:"",isRequired:e.is_required,value:t[e.name]||"",onChange:e=>r(e.target.value)});case"MESSAGE":return n.createElement("div",{className:"message-container"},e.type_info?.meta?.value);default:return console.error(`Question type ${e.type_info.question_type} not found`),null}},g=["RANGE","NPS","RADIO"],y=()=>n.createElement("div",{className:"question-container",style:{gap:"16px"}},n.createElement("h4",null,"Thank you for taking our survey!."),n.createElement("p",null," Your response is very important to us."));exports.BUTTON_SIZE_VARIANTS={LARGE:"large",MINI:"mini",NORMAL:"normal"},exports.Button=v,exports.CheckboxGroup=m,exports.Input=o,exports.NPS=a,exports.ProgressBar=f,exports.Radio=E,exports.RadioGroup=p,exports.Survey=({survey:e,onSubmit:a})=>{const{meta:{blocks:r},question_details:{questions:l}}=e,[s,c]=t.useState({}),[o,i]=t.useState(!1),[u,m]=t.useState([]),d=t.useRef(null),p=t.useRef(null),E=t.useRef(null),h=t.useRef(0),N=t.useRef(!1),x=t.useRef([]);t.useEffect((()=>{r&&!d.current&&r.length>0&&k(r[0])}),[r]),t.useEffect((()=>{E.current?.scrollIntoView({block:"center",behavior:"smooth"}),x.current=u}),[u]),t.useEffect((()=>{Object.keys(s).length>0&&p.current&&(g.includes(p.current.type_info.question_type)||N.current)&&!q()&&_()}),[s]);const q=()=>h.current===r.length-1||"end"===d.current.branchOption,k=e=>{let t={};if(e.is_based_on_score){const n=l[0].type_info.choices[s?.[l[0].name]]?.dependent_question_names,a=e.question_names.find((e=>n?.includes(e)));t=l.find((e=>e.name===a))}else t=l.find((t=>t.name===e.question_names[0]));d.current=e,p.current=t;x.current.find((e=>e.question.name===t.name))||m([...x.current,{...e,question:t}])},C=(e,t,n)=>{if(n)if(null!=s[e.question.name]&&e.name!==u[u.length-1].name){const[n,a]=(e=>{const t=u.findIndex((t=>t.name===e.name)),n=u.slice(0,t+1),a=n.reduce(((e,t)=>(e[t.question.name]=s[t.question.name],e)),{});return h.current=r.findIndex((t=>t.name===e.name)),[n,a]})(e);c({...a,...null!=t&&{[e.question.name]:t}}),x.current=n}else c({...s,...null!=t&&{[e.question.name]:t}});else c({...s,...null!=t&&{[e.question.name]:t}})},_=()=>{q()?i(!0):(d.current.nextBlock?h.current=r.findIndex((e=>e.name===d.current.nextBlock)):h.current+=1,k(r[h.current]))},R=e=>{const t=u.findIndex((t=>t.name===e.name)),n=[...u];n.splice(t,1),x.current=n,_()},S=(e,t)=>t.name===p.current.name&&!g.includes(t.type_info.question_type)&&!q(),w=(e,t)=>!e.required&&t.name===p.current.name;return d.current&&p.current?o?n.createElement(y,null):n.createElement(n.Fragment,null,n.createElement(f,{totalSteps:r.length,completedSteps:h.current}),u.map(((e,t)=>n.createElement("div",{className:"question-container",ref:E,id:e.title,key:e.title},n.createElement("div",{className:"question-text"},e.question.text),n.createElement(b,{question:e.question,formValues:s,onChangeHandler:t=>{N.current=!1,h.current=r.findIndex((t=>t.name===e.name)),d.current=e,p.current=e.question,C(e,t,g.includes(e.question.type_info.question_type)&&!q())}}),S(0,e.question)||w(e,e.question)?n.createElement("div",{className:"action-buttons"},S(0,e.question)&&n.createElement(v,{onClick:()=>{N.current=!0,C(e,null,!0)},className:"next-button"},"Next"),w(e,e.question)&&n.createElement("button",{className:"skip-button",onClick:R},"Skip")):null))),q()&&n.createElement("div",{className:"submit"},n.createElement(v,{onClick:()=>{i(!0),a(s)}},"Submit Survey"))):null},exports.TextArea=i;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n,e=require("react"),t=(n=e)&&"object"==typeof n&&"default"in n?n.default:n;function r(n,e){void 0===e&&(e={});var t=e.insertAt;if(n&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}r(".nps-container {\n margin: 0 auto;\n width: 100%;\n display: flex;\n flex-direction: column;\n grid-gap: 52px;\n gap: 52px;\n}\n.nps-container .footer {\n border-top: 1px solid var(--default-background-color);\n border-top: 1px solid var(--background-color, var(--default-background-color));\n padding-top: 20px;\n display: flex;\n justify-content: center;\n font-size: 0.75rem;\n}\n.nps-container .widget {\n position: relative;\n}\n.nps-container .widget .button-container {\n display: flex;\n justify-content: space-between;\n background: var(--default-background-color);\n background: var(--background-color, var(--default-background-color));\n}\n.nps-container .widget .positive-text {\n position: absolute;\n color: var(--color-elephant-500);\n bottom: -28px;\n right: 0px;\n text-align: right;\n}\n.nps-container .widget .negative-text {\n position: absolute;\n color: var(--color-elephant-500);\n bottom: -28px;\n left: 0;\n text-align: left;\n}\n.nps-container .widget span {\n color: #aaa;\n font-size: 0.75rem;\n}\n.nps-container .widget button {\n display: inline-block;\n font-size: 1rem;\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: 400;\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, border-color 0.2s ease-in, transform 0.2s cubic-bezier(0.5, 2, 0.5, 0.75);\n}\n.nps-container .widget button:hover {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.nps-container .widget button.active {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.nps-container .widget.highlighted button:hover, .nps-container .widget.highlighted button.active {\n background: var(--default-brand-color) !important;\n background: var(--brand-color, var(--default-brand-color)) !important;\n}\n.nps-container .widget.rounded button {\n border-radius: 50%;\n}\n.nps-container .widget.rounded.boxed button {\n border-radius: 0;\n}\n.nps-container .choices {\n width: 100%;\n display: flex;\n justify-content: space-between;\n}\n.nps-container .choice:nth-child(1).active, .nps-container .choice:nth-child(1):hover {\n background: #eb5b56;\n}\n.nps-container .choice:nth-child(2).active, .nps-container .choice:nth-child(2):hover {\n background: #fb8774;\n}\n.nps-container .choice:nth-child(3).active, .nps-container .choice:nth-child(3):hover {\n background: #f58f6b;\n}\n.nps-container .choice:nth-child(4).active, .nps-container .choice:nth-child(4):hover {\n background: #f6996a;\n}\n.nps-container .choice:nth-child(5).active, .nps-container .choice:nth-child(5):hover {\n background: #eab268;\n}\n.nps-container .choice:nth-child(6).active, .nps-container .choice:nth-child(6):hover {\n background: #cebb69;\n}\n.nps-container .choice:nth-child(7).active, .nps-container .choice:nth-child(7):hover {\n background: #bdc46c;\n}\n.nps-container .choice:nth-child(8).active, .nps-container .choice:nth-child(8):hover {\n background: #a4cd72;\n}\n.nps-container .choice:nth-child(9).active, .nps-container .choice:nth-child(9):hover {\n background: #77c955;\n}\n.nps-container .choice:nth-child(9).active, .nps-container .choice:nth-child(9):hover {\n background: #37c248;\n}\n\n@media (max-width: 550px) {\n .nps-container .widget .button-container {\n background: transparent;\n }\n .nps-container .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n }\n .nps-container .widget button {\n border-radius: 50%;\n background: #ebeff3;\n }\n}");const o=n=>{const{type_info:{linear_scale:{button_shape:r,button_style:o},score_presets:{start:a,end:i},validation:{min:l},footer_text:c}}=n,s=n=>{switch(n){case n<4:return"detractor";case n<7:return"passive";default:return"promoter"}},d=e.useRef(Array.from({length:10},((n,e)=>e+l)));return t.createElement("div",{className:"nps-container"},t.createElement("div",{className:`widget ${r} ${o}`},t.createElement("div",{className:"button-container"},t.createElement("span",{className:"negative-text"},a),t.createElement("div",{className:"choices"},d.current.map((e=>t.createElement("button",{key:e,onClick:t=>{n.onChangeHandler(e)},className:`choice ${s(e)} ${n.npsValue===e&&"active"}`},e)))),t.createElement("span",{className:"positive-text"},i))),t.createElement("div",{className:"footer"},c))},a=(n,e)=>(n.defaultProps=e,n);r(".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: 0.75rem;\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(--default-error-highlight-color);\n color: var(--error-highlight-color, var(--default-error-highlight-color));\n}\n\n.input-basic {\n width: 100%;\n display: flex;\n align-items: center;\n border-radius: var(--default-border-radius);\n border-radius: var(--border-radius, var(--default-border-radius));\n border: 1px solid var(--default-input-border-color);\n border: 1px solid var(--input-border-color, var(--default-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\n var(--default-error-highlight-color);\n border: 1px solid\n var(--error-highlight-color, var(--default-error-highlight-color));\n}\n.input-basic.error:hover {\n border: 1px solid\n var(--default-error-highlight-color);\n border: 1px solid\n var(--error-highlight-color, var(--default-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(--default-input-hover-border-color)\n ;\n border-color: var(\n --input-hover-border-color,\n var(--default-input-hover-border-color)\n );\n transition: 0.2s linear;\n}\n.input-basic[focus-within] {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px\n var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px\n var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.input-basic:focus-within {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px\n var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px\n var(--input-highlight-color, var(--default-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(--default-error-highlight-color);\n color: var(--error-highlight-color, var(--default-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 border-radius: 4px;\n}\ninput[type='text'],\ntextarea {\n outline: none;\n border: none;\n}\ninput[type='text']::-moz-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\ninput[type='text']:-ms-input-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\ninput[type='text']::placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-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 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=e.forwardRef(((n,e)=>{const{inputStyle:r,style:o,className:a,showCount:i,isErrored:l,startLabel:c,isRequired:s,errorText:d,endLabel:u,maxLength:p,...h}=n;return console.log(n.value),t.createElement("div",{className:"input-container",style:o},n.label&&t.createElement("label",{className:"input-label "+(s?"required":"")},n.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:e,style:r})),i&&p>0&&t.createElement("div",{className:"end-max-length"},`${n.value&&n.value.length||0}/${n.maxLength}`)),u&&t.createElement("div",{className:"end-label"},u)),l&&d&&t.createElement("span",{className:"input-error"},n.errorText))})),c=e.forwardRef(((n,e)=>{const{inputStyle:r,style:o,className:a,showCount:i,maxLength:l,isErrored:c,startLabel:s,isRequired:d,...u}=n;return console.log(n.value),t.createElement(t.Fragment,null,t.createElement("div",{className:"textarea-container",style:o},n.label&&t.createElement("label",{className:"input-label "+(d?"required":"")},n.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"},u,{ref:e,style:r})),i&&l&&l>0&&t.createElement("div",{className:"end-max-length"},`${n.value&&n.value.length||0}/${n.maxLength}`)),n.endLabel&&t.createElement("div",{className:"end-label"},n.endLabel)),n.isErrored&&n.errorText&&t.createElement("span",{className:"input-error"},n.errorText))})),s=a(l,i),d=a(c,i);r(".checkbox-group {\n display: flex;\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 position: absolute;\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(--default-input-highlight-color)\n 0px 0px 0px 2px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color))\n 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 padding: 16px 24px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 6%);\n border-radius: 4px;\n white-space: pre-wrap;\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 min-height: 14px;\n max-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(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\n.checkbox:hover {\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n box-shadow: var(--default-background-color) 0px 0px\n 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px\n 0px 5px;\n}\ninput[type='checkbox']:checked ~ .checkbox {\n background-color: var(--default-input-highlight-color)\n ;\n background-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\ninput[type='checkbox']:checked ~ .checkbox:hover {\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\ninput[type='checkbox']:disabled ~ .checkbox:hover {\n box-shadow: unset;\n border-color: unset;\n}\n");const u=()=>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"})),p=({values:n,options:e,onChangeHandler:r})=>t.createElement("div",{className:"checkbox-group"},e.map(((e,o)=>t.createElement(h,{key:e.id,checked:n?.includes(e.id),name:e.name??e.id,id:e.id,autoFocus:0===o,onChange:(t,o)=>{if(o)r([...n||[],e.id]);else{const t=n.indexOf(e.id);t>-1&&n.splice(t,1),r([...n])}}},e.label)))),h=a(e.forwardRef(((n,e)=>t.createElement("label",{className:`checkbox-label ${n.disabled&&"disabled"}`},t.createElement("input",{ref:e,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)}),t.createElement("div",{className:"checkbox"},n.checked&&t.createElement("div",{className:"icon-container"},t.createElement(u,null)," ")),t.createElement("div",null,n.children)))),{checked:!1});r(".radio-group {\n display: flex;\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(--default-input-border-color);\n border-color: var(--input-border-color, var(--default-input-border-color));\n transition: background-color ease-in 0.2s;\n min-width: 18px;\n max-width: 18px;\n min-height: 18px;\n max-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: 400;\n padding: 16px 24px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 6%);\n border-radius: 4px;\n white-space: pre-wrap;\n}\ninput[type='radio'] {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n width: 0px;\n height: 0px;\n}\ninput[type='radio']:focus ~ .radio {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 3px; */\n box-shadow: var(--default-input-highlight-color)\n 0px 0px 0px 3px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color))\n 0px 0px 0px 3px;\n border-color: transparent;\n}\n\ninput[type='radio']:checked ~ .radio:before {\n background-color: var(--default-input-highlight-color)\n ;\n background-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\n.radio-container:hover .radio {\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n box-shadow: var(--default-background-color) 0px 0px\n 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px\n 0px 5px;\n}\n");const b=({name:n,options:e,value:r,onChangeHandler:o})=>t.createElement("div",{className:"radio-group"},e.map(((e,a)=>t.createElement(g,{key:e.id,value:e.id,name:n,onChange:n=>{o(n.currentTarget.value)},autoFocus:0===a,checked:r===e.id},e.label)))),g=a(e.forwardRef(((n,e)=>t.createElement("label",{className:"radio-label"},t.createElement("input",{ref:e,type:"radio",name:n.name,value:n.value,checked:n.checked,onChange:n.onChange,autoFocus:n.autoFocus}),t.createElement("div",{className:"radio"}),t.createElement("div",null,n.children)))),{checked:!1,autoFocus:!1});r(".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(--default-brand-color);\n background-color: var(--brand-color, var(--default-brand-color));\n}\n");const x=n=>{const{totalSteps:e,completedSteps:r}=n;return t.createElement("div",{className:"progressbar-container"},t.createElement("div",{className:"progressbar",style:{width:(r>0?100/e:0)+"%",transform:`scaleX(${r})`}}))};r(".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(--default-primary-button-color);\n background: var(--primary-button-color, var(--default-primary-button-color));\n border: 1px solid var(--default-primary-button-color);\n border: 1px solid var(--primary-button-color, var(--default-primary-button-color));\n border-radius: 4px;\n min-width: 200px;\n}\n\n@media (max-width: 550px) {\n .action-button {\n min-width: 120px;\n }\n}\n.action-button:not([disabled]):hover {\n background: var(--default-primary-button-hover-color);\n background: var(--primary-button-hover-color, var(--primary-button-color, var(--default-primary-button-hover-color)));\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}");const m=()=>t.createElement(t.Fragment,null,"..."),f=n=>{const{inline:e=!1,children:r,disabled:o,className:a="",htmlType:i,type:l="primary",onClick:c,size:s,overrideStyleClassName:d="",loading:u=!1,...p}=n;return t.createElement("button",Object.assign({style:e?{display:"inline-block"}:{},disabled:o,className:`action-button ${a} ${d}`,type:i,onClick:c},p),u?t.createElement(m,null):r)},v=({question:n,formValues:e,onChangeHandler:r})=>{switch(n.type_info.question_type){case"RANGE":return t.createElement(o,{type_info:n.type_info,onChangeHandler:r,npsValue:e[n.name]});case"CHECKBOX":case"DROPDOWN":return t.createElement(p,{values:e[n.name],options:n.type_info.choices,onChangeHandler:r});case"RADIO":case"MULTICHOICE":return t.createElement(b,{name:n.name,onChangeHandler:r,options:n.type_info.choices,value:e[n.name]});case"INPUT":return t.createElement("div",{className:"responsive-text-field"},t.createElement(s,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:e[n.name]||"",onChange:n=>r(n.target.value)}),t.createElement(d,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:e[n.name]||"",onChange:n=>r(n.target.value)}));case"PARAGRAPH":return t.createElement(d,{autoFocus:!0,label:"",isRequired:n.is_required,value:e[n.name]||"",onChange:n=>r(n.target.value)});case"MESSAGE":return t.createElement("div",{className:"message-container"},n.type_info?.meta?.value);default:return console.error(`Question type ${n.type_info.question_type} not found`),null}};r(":root {\n --default-primary-button-color: #d72d30;\n --default-primary-button-hover-color: #f1171b;\n --default-brand-color: #264966;\n --default-input-highlight-color: #2c5cc5;\n --default-input-border-color: #92a2b1;\n --default-input-hover-border-color: #264966;\n --default-input-placeholder-color: #92a2b1;\n --default-border-radius: 4px;\n --default-background-color: #ebeff3;\n --default-error-highlight-color: #d72d30;\n}\n\n.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: 52px;\n padding: 28px;\n grid-gap: 36px;\n gap: 36px;\n}\n\n.question-text {\n font-size: 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\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\n.submit {\n padding-bottom: 40px;\n display: flex;\n justify-content: center;\n}\n\n.responsive-text-field {\n width: 100%;\n}\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\n .responsive-text-field .textarea-container {\n display: flex;\n }\n}");const y=["RANGE","NPS","RADIO"],w=()=>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=p,exports.Input=s,exports.NPS=o,exports.ProgressBar=x,exports.Radio=g,exports.RadioGroup=b,exports.Survey=({survey:n,onSubmit:r})=>{const{meta:{blocks:o},question_details:{questions:a}}=n,[i,l]=e.useState({}),[c,s]=e.useState(!1),[d,u]=e.useState([]),p=e.useRef(null),h=e.useRef(null),b=e.useRef(null),g=e.useRef(0),m=e.useRef(!1),k=e.useRef([]);e.useEffect((()=>{o&&!p.current&&o.length>0&&N(o[0])}),[o]),e.useEffect((()=>{b.current?.scrollIntoView({block:"center",behavior:"smooth"}),k.current=d}),[d]),e.useEffect((()=>{Object.keys(i).length>0&&h.current&&(y.includes(h.current.type_info.question_type)||m.current)&&!E()&&C()}),[i]);const E=()=>g.current===o.length-1||"end"===p.current.branchOption,N=n=>{let e={};if(n.is_based_on_score){const t=a[0].type_info.choices[i?.[a[0].name]]?.dependent_question_names,r=n.question_names.find((n=>t?.includes(n)));e=a.find((n=>n.name===r))}else e=a.find((e=>e.name===n.question_names[0]));p.current=n,h.current=e;k.current.find((n=>n.question.name===e.name))||u([...k.current,{...n,question:e}])},q=(n,e,t)=>{if(t)if(null!=i[n.question.name]&&n.name!==d[d.length-1].name){const[t,r]=(n=>{const e=d.findIndex((e=>e.name===n.name)),t=d.slice(0,e+1),r=t.reduce(((n,e)=>(n[e.question.name]=i[e.question.name],n)),{});return g.current=o.findIndex((e=>e.name===n.name)),[t,r]})(n);l({...r,...null!=e&&{[n.question.name]:e}}),k.current=t}else l({...i,...null!=e&&{[n.question.name]:e}});else l({...i,...null!=e&&{[n.question.name]:e}})},C=()=>{E()?s(!0):(p.current.nextBlock?g.current=o.findIndex((n=>n.name===p.current.nextBlock)):g.current+=1,N(o[g.current]))},_=n=>{const e=d.findIndex((e=>e.name===n.name)),t=[...d];t.splice(e,1),k.current=t,C()},R=(n,e)=>e.name===h.current.name&&!y.includes(e.type_info.question_type)&&!E(),S=(n,e)=>!n.required&&e.name===h.current.name;return p.current&&h.current?c?t.createElement(w,null):t.createElement(t.Fragment,null,t.createElement(x,{totalSteps:o.length,completedSteps:g.current}),d.map(((n,e)=>t.createElement("div",{className:"question-container",ref:b,id:n.title,key:n.title},t.createElement("div",{className:"question-text"},n.question.text),t.createElement(v,{question:n.question,formValues:i,onChangeHandler:e=>{m.current=!1,g.current=o.findIndex((e=>e.name===n.name)),p.current=n,h.current=n.question,q(n,e,y.includes(n.question.type_info.question_type)&&!E())}}),R(0,n.question)||S(n,n.question)?t.createElement("div",{className:"action-buttons"},R(0,n.question)&&t.createElement(f,{onClick:()=>{m.current=!0,q(n,null,!0)},className:"next-button"},"Next"),S(n,n.question)&&t.createElement("button",{className:"skip-button",onClick:_},"Skip")):null))),E()&&t.createElement("div",{className:"submit"},t.createElement(f,{onClick:()=>{s(!0),r(i)}},"Submit Survey"))):null},exports.TextArea=d;
|
package/lib/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useRef as t,forwardRef as n,useState as a,useEffect as l}from"react";const r=n=>{const{type_info:{linear_scale:{button_shape:a,button_style:l},score_presets:{start:r,end:s},validation:{min:c},footer_text:i}}=n,o=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},u=t(Array.from({length:10},((e,t)=>t+c)));return e.createElement("div",{className:"nps-container"},e.createElement("div",{className:`widget ${a} ${l}`},e.createElement("div",{className:"button-container"},e.createElement("span",{className:"negative-text"},r),e.createElement("div",{className:"choices"},u.current.map((t=>e.createElement("button",{key:t,onClick:e=>{n.onChangeHandler(t)},className:`choice ${o(t)} ${n.npsValue===t&&"active"}`},t)))),e.createElement("span",{className:"positive-text"},s))),e.createElement("div",{className:"footer"},i))},s=(e,t)=>(e.defaultProps=t,e),c={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!1},i=n(((t,n)=>{const{inputStyle:a,style:l,className:r,showCount:s,isErrored:c,startLabel:i,isRequired:o,errorText:u,endLabel:m,maxLength:d,...p}=t;return console.log(t.value),e.createElement("div",{className:"input-container",style:l},t.label&&e.createElement("label",{className:"input-label "+(o?"required":"")},t.label),e.createElement("div",null,i&&e.createElement("div",{className:"start-label"},i),e.createElement("div",{className:`input-basic ${c?"error":""}${r||""}`},e.createElement("input",Object.assign({type:"text",autoComplete:"off"},p,{ref:n,style:a})),s&&d>0&&e.createElement("div",{className:"end-max-length"},`${t.value&&t.value.length||0}/${t.maxLength}`)),m&&e.createElement("div",{className:"end-label"},m)),c&&u&&e.createElement("span",{className:"input-error"},t.errorText))})),o=n(((t,n)=>{const{inputStyle:a,style:l,className:r,showCount:s,maxLength:c,isErrored:i,startLabel:o,isRequired:u,...m}=t;return console.log(t.value),e.createElement(e.Fragment,null,e.createElement("div",{className:"textarea-container",style:l},t.label&&e.createElement("label",{className:"input-label "+(u?"required":"")},t.label),o&&e.createElement("div",{className:"start-label"},o),e.createElement("div",{className:`input-basic ${i?"error":""} ${r||""}`},e.createElement("textarea",Object.assign({autoComplete:"off"},m,{ref:n,style:a})),s&&c&&c>0&&e.createElement("div",{className:"end-max-length"},`${t.value&&t.value.length||0}/${t.maxLength}`)),t.endLabel&&e.createElement("div",{className:"end-label"},t.endLabel)),t.isErrored&&t.errorText&&e.createElement("span",{className:"input-error"},t.errorText))})),u=s(i,c),m=s(o,c),d=()=>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"})),p=({values:t,options:n,onChangeHandler:a})=>e.createElement("div",{className:"checkbox-group"},n.map(((n,l)=>e.createElement(E,{key:n.id,checked:t?.includes(n.id),name:n.name??n.id,id:n.id,autoFocus:0===l,onChange:(e,l)=>{if(l)a([...t||[],n.id]);else{const e=t.indexOf(n.id);e>-1&&t.splice(e,1),a([...t])}}},n.label)))),E=s(n(((t,n)=>e.createElement("label",{className:`checkbox-label ${t.disabled&&"disabled"}`},e.createElement("input",{ref:n,id:t.id,type:"checkbox",name:t.name,readOnly:t.readOnly,disabled:t.disabled,"aria-disabled":t.disabled,value:t.value,checked:t.checked,autoFocus:t.autoFocus,onChange:t.readOnly?()=>{}:e=>t.onChange(e,e.target.checked)}),e.createElement("div",{className:"checkbox"},t.checked&&e.createElement("div",{className:"icon-container"},e.createElement(d,null)," ")),e.createElement("div",null,t.children)))),{checked:!1}),h=({name:t,options:n,value:a,onChangeHandler:l})=>e.createElement("div",{className:"radio-group"},n.map(((n,r)=>e.createElement(v,{key:n.id,value:n.id,name:t,onChange:e=>{l(e.currentTarget.value)},autoFocus:0===r,checked:a===n.id},n.label)))),v=s(n(((t,n)=>e.createElement("label",{className:"radio-label"},e.createElement("input",{ref:n,type:"radio",name:t.name,value:t.value,checked:t.checked,onChange:t.onChange,autoFocus:t.autoFocus}),e.createElement("div",{className:"radio"}),e.createElement("div",null,t.children)))),{checked:!1,autoFocus:!1}),b=t=>{const{totalSteps:n,completedSteps:a}=t;return e.createElement("div",{className:"progressbar-container"},e.createElement("div",{className:"progressbar",style:{width:(a>0?100/n:0)+"%",transform:`scaleX(${a})`}}))},g=()=>e.createElement(e.Fragment,null,"..."),y={LARGE:"large",MINI:"mini",NORMAL:"normal"},N=t=>{const{inline:n=!1,children:a,disabled:l,className:r="",htmlType:s,type:c="primary",onClick:i,size:o,overrideStyleClassName:u="",loading:m=!1,...d}=t;return e.createElement("button",Object.assign({style:n?{display:"inline-block"}:{},disabled:l,className:`action-button ${r} ${u}`,type:s,onClick:i},d),m?e.createElement(g,null):a)},f=({question:t,formValues:n,onChangeHandler:a})=>{switch(t.type_info.question_type){case"RANGE":return e.createElement(r,{type_info:t.type_info,onChangeHandler:a,npsValue:n[t.name]});case"CHECKBOX":case"DROPDOWN":return e.createElement(p,{values:n[t.name],options:t.type_info.choices,onChangeHandler:a});case"RADIO":case"MULTICHOICE":return e.createElement(h,{name:t.name,onChangeHandler:a,options:t.type_info.choices,value:n[t.name]});case"INPUT":return e.createElement("div",{className:"responsive-text-field"},e.createElement(u,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:t.is_required,value:n[t.name]||"",onChange:e=>a(e.target.value)}),e.createElement(m,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:t.is_required,value:n[t.name]||"",onChange:e=>a(e.target.value)}));case"PARAGRAPH":return e.createElement(m,{autoFocus:!0,label:"",isRequired:t.is_required,value:n[t.name]||"",onChange:e=>a(e.target.value)});case"MESSAGE":return e.createElement("div",{className:"message-container"},t.type_info?.meta?.value);default:return console.error(`Question type ${t.type_info.question_type} not found`),null}},q=["RANGE","NPS","RADIO"],x=()=>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.")),k=({survey:n,onSubmit:r})=>{const{meta:{blocks:s},question_details:{questions:c}}=n,[i,o]=a({}),[u,m]=a(!1),[d,p]=a([]),E=t(null),h=t(null),v=t(null),g=t(0),y=t(!1),k=t([]);l((()=>{s&&!E.current&&s.length>0&&_(s[0])}),[s]),l((()=>{v.current?.scrollIntoView({block:"center",behavior:"smooth"}),k.current=d}),[d]),l((()=>{Object.keys(i).length>0&&h.current&&(q.includes(h.current.type_info.question_type)||y.current)&&!C()&&$()}),[i]);const C=()=>g.current===s.length-1||"end"===E.current.branchOption,_=e=>{let t={};if(e.is_based_on_score){const n=c[0].type_info.choices[i?.[c[0].name]]?.dependent_question_names,a=e.question_names.find((e=>n?.includes(e)));t=c.find((e=>e.name===a))}else t=c.find((t=>t.name===e.question_names[0]));E.current=e,h.current=t;k.current.find((e=>e.question.name===t.name))||p([...k.current,{...e,question:t}])},L=(e,t,n)=>{if(n)if(null!=i[e.question.name]&&e.name!==d[d.length-1].name){const[n,a]=(e=>{const t=d.findIndex((t=>t.name===e.name)),n=d.slice(0,t+1),a=n.reduce(((e,t)=>(e[t.question.name]=i[t.question.name],e)),{});return g.current=s.findIndex((t=>t.name===e.name)),[n,a]})(e);o({...a,...null!=t&&{[e.question.name]:t}}),k.current=n}else o({...i,...null!=t&&{[e.question.name]:t}});else o({...i,...null!=t&&{[e.question.name]:t}})},$=()=>{C()?m(!0):(E.current.nextBlock?g.current=s.findIndex((e=>e.name===E.current.nextBlock)):g.current+=1,_(s[g.current]))},O=e=>{const t=d.findIndex((t=>t.name===e.name)),n=[...d];n.splice(t,1),k.current=n,$()},R=(e,t)=>t.name===h.current.name&&!q.includes(t.type_info.question_type)&&!C(),w=(e,t)=>!e.required&&t.name===h.current.name;return E.current&&h.current?u?e.createElement(x,null):e.createElement(e.Fragment,null,e.createElement(b,{totalSteps:s.length,completedSteps:g.current}),d.map(((t,n)=>e.createElement("div",{className:"question-container",ref:v,id:t.title,key:t.title},e.createElement("div",{className:"question-text"},t.question.text),e.createElement(f,{question:t.question,formValues:i,onChangeHandler:e=>{y.current=!1,g.current=s.findIndex((e=>e.name===t.name)),E.current=t,h.current=t.question,L(t,e,q.includes(t.question.type_info.question_type)&&!C())}}),R(0,t.question)||w(t,t.question)?e.createElement("div",{className:"action-buttons"},R(0,t.question)&&e.createElement(N,{onClick:()=>{y.current=!0,L(t,null,!0)},className:"next-button"},"Next"),w(t,t.question)&&e.createElement("button",{className:"skip-button",onClick:O},"Skip")):null))),C()&&e.createElement("div",{className:"submit"},e.createElement(N,{onClick:()=>{m(!0),r(i)}},"Submit Survey"))):null};export{y as BUTTON_SIZE_VARIANTS,N as Button,p as CheckboxGroup,u as Input,r as NPS,b as ProgressBar,v as Radio,h as RadioGroup,k as Survey,m as TextArea};
|
|
1
|
+
import n,{useRef as e,forwardRef as t,useState as r,useEffect as o}from"react";function a(n,e){void 0===e&&(e={});var t=e.insertAt;if(n&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}a(".nps-container {\n margin: 0 auto;\n width: 100%;\n display: flex;\n flex-direction: column;\n grid-gap: 52px;\n gap: 52px;\n}\n.nps-container .footer {\n border-top: 1px solid var(--default-background-color);\n border-top: 1px solid var(--background-color, var(--default-background-color));\n padding-top: 20px;\n display: flex;\n justify-content: center;\n font-size: 0.75rem;\n}\n.nps-container .widget {\n position: relative;\n}\n.nps-container .widget .button-container {\n display: flex;\n justify-content: space-between;\n background: var(--default-background-color);\n background: var(--background-color, var(--default-background-color));\n}\n.nps-container .widget .positive-text {\n position: absolute;\n color: var(--color-elephant-500);\n bottom: -28px;\n right: 0px;\n text-align: right;\n}\n.nps-container .widget .negative-text {\n position: absolute;\n color: var(--color-elephant-500);\n bottom: -28px;\n left: 0;\n text-align: left;\n}\n.nps-container .widget span {\n color: #aaa;\n font-size: 0.75rem;\n}\n.nps-container .widget button {\n display: inline-block;\n font-size: 1rem;\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: 400;\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, border-color 0.2s ease-in, transform 0.2s cubic-bezier(0.5, 2, 0.5, 0.75);\n}\n.nps-container .widget button:hover {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.nps-container .widget button.active {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.nps-container .widget.highlighted button:hover, .nps-container .widget.highlighted button.active {\n background: var(--default-brand-color) !important;\n background: var(--brand-color, var(--default-brand-color)) !important;\n}\n.nps-container .widget.rounded button {\n border-radius: 50%;\n}\n.nps-container .widget.rounded.boxed button {\n border-radius: 0;\n}\n.nps-container .choices {\n width: 100%;\n display: flex;\n justify-content: space-between;\n}\n.nps-container .choice:nth-child(1).active, .nps-container .choice:nth-child(1):hover {\n background: #eb5b56;\n}\n.nps-container .choice:nth-child(2).active, .nps-container .choice:nth-child(2):hover {\n background: #fb8774;\n}\n.nps-container .choice:nth-child(3).active, .nps-container .choice:nth-child(3):hover {\n background: #f58f6b;\n}\n.nps-container .choice:nth-child(4).active, .nps-container .choice:nth-child(4):hover {\n background: #f6996a;\n}\n.nps-container .choice:nth-child(5).active, .nps-container .choice:nth-child(5):hover {\n background: #eab268;\n}\n.nps-container .choice:nth-child(6).active, .nps-container .choice:nth-child(6):hover {\n background: #cebb69;\n}\n.nps-container .choice:nth-child(7).active, .nps-container .choice:nth-child(7):hover {\n background: #bdc46c;\n}\n.nps-container .choice:nth-child(8).active, .nps-container .choice:nth-child(8):hover {\n background: #a4cd72;\n}\n.nps-container .choice:nth-child(9).active, .nps-container .choice:nth-child(9):hover {\n background: #77c955;\n}\n.nps-container .choice:nth-child(9).active, .nps-container .choice:nth-child(9):hover {\n background: #37c248;\n}\n\n@media (max-width: 550px) {\n .nps-container .widget .button-container {\n background: transparent;\n }\n .nps-container .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n }\n .nps-container .widget button {\n border-radius: 50%;\n background: #ebeff3;\n }\n}");const i=t=>{const{type_info:{linear_scale:{button_shape:r,button_style:o},score_presets:{start:a,end:i},validation:{min:l},footer_text:c}}=t,d=n=>{switch(n){case n<4:return"detractor";case n<7:return"passive";default:return"promoter"}},s=e(Array.from({length:10},((n,e)=>e+l)));return n.createElement("div",{className:"nps-container"},n.createElement("div",{className:`widget ${r} ${o}`},n.createElement("div",{className:"button-container"},n.createElement("span",{className:"negative-text"},a),n.createElement("div",{className:"choices"},s.current.map((e=>n.createElement("button",{key:e,onClick:n=>{t.onChangeHandler(e)},className:`choice ${d(e)} ${t.npsValue===e&&"active"}`},e)))),n.createElement("span",{className:"positive-text"},i))),n.createElement("div",{className:"footer"},c))},l=(n,e)=>(n.defaultProps=e,n);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: 0.75rem;\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(--default-error-highlight-color);\n color: var(--error-highlight-color, var(--default-error-highlight-color));\n}\n\n.input-basic {\n width: 100%;\n display: flex;\n align-items: center;\n border-radius: var(--default-border-radius);\n border-radius: var(--border-radius, var(--default-border-radius));\n border: 1px solid var(--default-input-border-color);\n border: 1px solid var(--input-border-color, var(--default-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\n var(--default-error-highlight-color);\n border: 1px solid\n var(--error-highlight-color, var(--default-error-highlight-color));\n}\n.input-basic.error:hover {\n border: 1px solid\n var(--default-error-highlight-color);\n border: 1px solid\n var(--error-highlight-color, var(--default-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(--default-input-hover-border-color)\n ;\n border-color: var(\n --input-hover-border-color,\n var(--default-input-hover-border-color)\n );\n transition: 0.2s linear;\n}\n.input-basic[focus-within] {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px\n var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px\n var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.input-basic:focus-within {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px\n var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px\n var(--input-highlight-color, var(--default-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(--default-error-highlight-color);\n color: var(--error-highlight-color, var(--default-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 border-radius: 4px;\n}\ninput[type='text'],\ntextarea {\n outline: none;\n border: none;\n}\ninput[type='text']::-moz-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\ninput[type='text']:-ms-input-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\ninput[type='text']::placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-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 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},d=t(((e,t)=>{const{inputStyle:r,style:o,className:a,showCount:i,isErrored:l,startLabel:c,isRequired:d,errorText:s,endLabel:p,maxLength:u,...h}=e;return console.log(e.value),n.createElement("div",{className:"input-container",style:o},e.label&&n.createElement("label",{className:"input-label "+(d?"required":"")},e.label),n.createElement("div",null,c&&n.createElement("div",{className:"start-label"},c),n.createElement("div",{className:`input-basic ${l?"error":""}${a||""}`},n.createElement("input",Object.assign({type:"text",autoComplete:"off"},h,{ref:t,style:r})),i&&u>0&&n.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),p&&n.createElement("div",{className:"end-label"},p)),l&&s&&n.createElement("span",{className:"input-error"},e.errorText))})),s=t(((e,t)=>{const{inputStyle:r,style:o,className:a,showCount:i,maxLength:l,isErrored:c,startLabel:d,isRequired:s,...p}=e;return console.log(e.value),n.createElement(n.Fragment,null,n.createElement("div",{className:"textarea-container",style:o},e.label&&n.createElement("label",{className:"input-label "+(s?"required":"")},e.label),d&&n.createElement("div",{className:"start-label"},d),n.createElement("div",{className:`input-basic ${c?"error":""} ${a||""}`},n.createElement("textarea",Object.assign({autoComplete:"off"},p,{ref:t,style:r})),i&&l&&l>0&&n.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),e.endLabel&&n.createElement("div",{className:"end-label"},e.endLabel)),e.isErrored&&e.errorText&&n.createElement("span",{className:"input-error"},e.errorText))})),p=l(d,c),u=l(s,c);a(".checkbox-group {\n display: flex;\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 position: absolute;\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(--default-input-highlight-color)\n 0px 0px 0px 2px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color))\n 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 padding: 16px 24px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 6%);\n border-radius: 4px;\n white-space: pre-wrap;\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 min-height: 14px;\n max-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(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\n.checkbox:hover {\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n box-shadow: var(--default-background-color) 0px 0px\n 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px\n 0px 5px;\n}\ninput[type='checkbox']:checked ~ .checkbox {\n background-color: var(--default-input-highlight-color)\n ;\n background-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\ninput[type='checkbox']:checked ~ .checkbox:hover {\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\ninput[type='checkbox']:disabled ~ .checkbox:hover {\n box-shadow: unset;\n border-color: unset;\n}\n");const h=()=>n.createElement("svg",{id:"tick",className:"tick-icon",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"title",viewBox:"0 0 10 10"},n.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"})),b=({values:e,options:t,onChangeHandler:r})=>n.createElement("div",{className:"checkbox-group"},t.map(((t,o)=>n.createElement(g,{key:t.id,checked:e?.includes(t.id),name:t.name??t.id,id:t.id,autoFocus:0===o,onChange:(n,o)=>{if(o)r([...e||[],t.id]);else{const n=e.indexOf(t.id);n>-1&&e.splice(n,1),r([...e])}}},t.label)))),g=l(t(((e,t)=>n.createElement("label",{className:`checkbox-label ${e.disabled&&"disabled"}`},n.createElement("input",{ref:t,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)}),n.createElement("div",{className:"checkbox"},e.checked&&n.createElement("div",{className:"icon-container"},n.createElement(h,null)," ")),n.createElement("div",null,e.children)))),{checked:!1});a(".radio-group {\n display: flex;\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(--default-input-border-color);\n border-color: var(--input-border-color, var(--default-input-border-color));\n transition: background-color ease-in 0.2s;\n min-width: 18px;\n max-width: 18px;\n min-height: 18px;\n max-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: 400;\n padding: 16px 24px;\n min-width: 200px;\n border: 1px solid #ebeff3;\n box-shadow: 0px 2px 5px rgb(18 52 77 / 6%);\n border-radius: 4px;\n white-space: pre-wrap;\n}\ninput[type='radio'] {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n width: 0px;\n height: 0px;\n}\ninput[type='radio']:focus ~ .radio {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 3px; */\n box-shadow: var(--default-input-highlight-color)\n 0px 0px 0px 3px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color))\n 0px 0px 0px 3px;\n border-color: transparent;\n}\n\ninput[type='radio']:checked ~ .radio:before {\n background-color: var(--default-input-highlight-color)\n ;\n background-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n}\n.radio-container:hover .radio {\n border-color: var(--default-input-highlight-color)\n ;\n border-color: var(\n --input-highlight-color,\n var(--default-input-highlight-color)\n );\n box-shadow: var(--default-background-color) 0px 0px\n 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px\n 0px 5px;\n}\n");const x=({name:e,options:t,value:r,onChangeHandler:o})=>n.createElement("div",{className:"radio-group"},t.map(((t,a)=>n.createElement(m,{key:t.id,value:t.id,name:e,onChange:n=>{o(n.currentTarget.value)},autoFocus:0===a,checked:r===t.id},t.label)))),m=l(t(((e,t)=>n.createElement("label",{className:"radio-label"},n.createElement("input",{ref:t,type:"radio",name:e.name,value:e.value,checked:e.checked,onChange:e.onChange,autoFocus:e.autoFocus}),n.createElement("div",{className:"radio"}),n.createElement("div",null,e.children)))),{checked:!1,autoFocus:!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(--default-brand-color);\n background-color: var(--brand-color, var(--default-brand-color));\n}\n");const f=e=>{const{totalSteps:t,completedSteps:r}=e;return n.createElement("div",{className:"progressbar-container"},n.createElement("div",{className:"progressbar",style:{width:(r>0?100/t:0)+"%",transform:`scaleX(${r})`}}))};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(--default-primary-button-color);\n background: var(--primary-button-color, var(--default-primary-button-color));\n border: 1px solid var(--default-primary-button-color);\n border: 1px solid var(--primary-button-color, var(--default-primary-button-color));\n border-radius: 4px;\n min-width: 200px;\n}\n\n@media (max-width: 550px) {\n .action-button {\n min-width: 120px;\n }\n}\n.action-button:not([disabled]):hover {\n background: var(--default-primary-button-hover-color);\n background: var(--primary-button-hover-color, var(--primary-button-color, var(--default-primary-button-hover-color)));\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}");const v=()=>n.createElement(n.Fragment,null,"..."),y={LARGE:"large",MINI:"mini",NORMAL:"normal"},k=e=>{const{inline:t=!1,children:r,disabled:o,className:a="",htmlType:i,type:l="primary",onClick:c,size:d,overrideStyleClassName:s="",loading:p=!1,...u}=e;return n.createElement("button",Object.assign({style:t?{display:"inline-block"}:{},disabled:o,className:`action-button ${a} ${s}`,type:i,onClick:c},u),p?n.createElement(v,null):r)},w=({question:e,formValues:t,onChangeHandler:r})=>{switch(e.type_info.question_type){case"RANGE":return n.createElement(i,{type_info:e.type_info,onChangeHandler:r,npsValue:t[e.name]});case"CHECKBOX":case"DROPDOWN":return n.createElement(b,{values:t[e.name],options:e.type_info.choices,onChangeHandler:r});case"RADIO":case"MULTICHOICE":return n.createElement(x,{name:e.name,onChangeHandler:r,options:e.type_info.choices,value:t[e.name]});case"INPUT":return n.createElement("div",{className:"responsive-text-field"},n.createElement(p,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:t[e.name]||"",onChange:n=>r(n.target.value)}),n.createElement(u,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:t[e.name]||"",onChange:n=>r(n.target.value)}));case"PARAGRAPH":return n.createElement(u,{autoFocus:!0,label:"",isRequired:e.is_required,value:t[e.name]||"",onChange:n=>r(n.target.value)});case"MESSAGE":return n.createElement("div",{className:"message-container"},e.type_info?.meta?.value);default:return console.error(`Question type ${e.type_info.question_type} not found`),null}};a(":root {\n --default-primary-button-color: #d72d30;\n --default-primary-button-hover-color: #f1171b;\n --default-brand-color: #264966;\n --default-input-highlight-color: #2c5cc5;\n --default-input-border-color: #92a2b1;\n --default-input-hover-border-color: #264966;\n --default-input-placeholder-color: #92a2b1;\n --default-border-radius: 4px;\n --default-background-color: #ebeff3;\n --default-error-highlight-color: #d72d30;\n}\n\n.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: 52px;\n padding: 28px;\n grid-gap: 36px;\n gap: 36px;\n}\n\n.question-text {\n font-size: 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\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\n.submit {\n padding-bottom: 40px;\n display: flex;\n justify-content: center;\n}\n\n.responsive-text-field {\n width: 100%;\n}\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\n .responsive-text-field .textarea-container {\n display: flex;\n }\n}");const E=["RANGE","NPS","RADIO"],N=()=>n.createElement("div",{className:"question-container",style:{gap:"16px"}},n.createElement("h4",null,"Thank you for taking our survey!."),n.createElement("p",null," Your response is very important to us.")),q=({survey:t,onSubmit:a})=>{const{meta:{blocks:i},question_details:{questions:l}}=t,[c,d]=r({}),[s,p]=r(!1),[u,h]=r([]),b=e(null),g=e(null),x=e(null),m=e(0),v=e(!1),y=e([]);o((()=>{i&&!b.current&&i.length>0&&C(i[0])}),[i]),o((()=>{x.current?.scrollIntoView({block:"center",behavior:"smooth"}),y.current=u}),[u]),o((()=>{Object.keys(c).length>0&&g.current&&(E.includes(g.current.type_info.question_type)||v.current)&&!q()&&z()}),[c]);const q=()=>m.current===i.length-1||"end"===b.current.branchOption,C=n=>{let e={};if(n.is_based_on_score){const t=l[0].type_info.choices[c?.[l[0].name]]?.dependent_question_names,r=n.question_names.find((n=>t?.includes(n)));e=l.find((n=>n.name===r))}else e=l.find((e=>e.name===n.question_names[0]));b.current=n,g.current=e;y.current.find((n=>n.question.name===e.name))||h([...y.current,{...n,question:e}])},_=(n,e,t)=>{if(t)if(null!=c[n.question.name]&&n.name!==u[u.length-1].name){const[t,r]=(n=>{const e=u.findIndex((e=>e.name===n.name)),t=u.slice(0,e+1),r=t.reduce(((n,e)=>(n[e.question.name]=c[e.question.name],n)),{});return m.current=i.findIndex((e=>e.name===n.name)),[t,r]})(n);d({...r,...null!=e&&{[n.question.name]:e}}),y.current=t}else d({...c,...null!=e&&{[n.question.name]:e}});else d({...c,...null!=e&&{[n.question.name]:e}})},z=()=>{q()?p(!0):(b.current.nextBlock?m.current=i.findIndex((n=>n.name===b.current.nextBlock)):m.current+=1,C(i[m.current]))},$=n=>{const e=u.findIndex((e=>e.name===n.name)),t=[...u];t.splice(e,1),y.current=t,z()},L=(n,e)=>e.name===g.current.name&&!E.includes(e.type_info.question_type)&&!q(),S=(n,e)=>!n.required&&e.name===g.current.name;return b.current&&g.current?s?n.createElement(N,null):n.createElement(n.Fragment,null,n.createElement(f,{totalSteps:i.length,completedSteps:m.current}),u.map(((e,t)=>n.createElement("div",{className:"question-container",ref:x,id:e.title,key:e.title},n.createElement("div",{className:"question-text"},e.question.text),n.createElement(w,{question:e.question,formValues:c,onChangeHandler:n=>{v.current=!1,m.current=i.findIndex((n=>n.name===e.name)),b.current=e,g.current=e.question,_(e,n,E.includes(e.question.type_info.question_type)&&!q())}}),L(0,e.question)||S(e,e.question)?n.createElement("div",{className:"action-buttons"},L(0,e.question)&&n.createElement(k,{onClick:()=>{v.current=!0,_(e,null,!0)},className:"next-button"},"Next"),S(e,e.question)&&n.createElement("button",{className:"skip-button",onClick:$},"Skip")):null))),q()&&n.createElement("div",{className:"submit"},n.createElement(k,{onClick:()=>{p(!0),a(c)}},"Submit Survey"))):null};export{y as BUTTON_SIZE_VARIANTS,k as Button,b as CheckboxGroup,p as Input,i as NPS,f as ProgressBar,m as Radio,x as RadioGroup,q as Survey,u as TextArea};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './survey';
|
|
2
|
-
export * from './components';
|
|
1
|
+
export * from './src/survey';
|
|
2
|
+
export * from './src/components';
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freemium-survey-components",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2-beta.4",
|
|
4
4
|
"description": "React Survey Ui Components",
|
|
5
5
|
"main": "lib/index.cjs.js",
|
|
6
6
|
"module": "lib/index.esm.js",
|
|
7
7
|
"types": "lib/types",
|
|
8
|
+
"directories": {
|
|
9
|
+
"lib": "lib"
|
|
10
|
+
},
|
|
8
11
|
"scripts": {
|
|
9
12
|
"storybook": "start-storybook -p 6006",
|
|
10
13
|
"build-storybook": "build-storybook",
|
|
@@ -12,8 +15,7 @@
|
|
|
12
15
|
"start": "webpack-dev-server --config webpack.config.js",
|
|
13
16
|
"build:dev": "webpack --config webpack.config.js",
|
|
14
17
|
"build": "rollup -c rollup.config.ts",
|
|
15
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
-
"preconstruct:init": "yarn run preconstruct init"
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
19
|
},
|
|
18
20
|
"repository": {
|
|
19
21
|
"type": "git",
|
|
@@ -38,9 +40,6 @@
|
|
|
38
40
|
"react-dom": ">=17.0.2"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
|
-
"@babel/preset-env": "^7.16.4",
|
|
42
|
-
"@babel/preset-react": "^7.16.0",
|
|
43
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
44
43
|
"@rollup/plugin-commonjs": "13.0.0",
|
|
45
44
|
"@rollup/plugin-node-resolve": "8.1.0",
|
|
46
45
|
"@storybook/addon-actions": "~6.3.12",
|
|
@@ -80,18 +79,15 @@
|
|
|
80
79
|
"jest": "25.2.0",
|
|
81
80
|
"postcss": "^8.3.11",
|
|
82
81
|
"postcss-preset-env": "^6.7.0",
|
|
83
|
-
"preconstruct": "^1.0.0",
|
|
84
82
|
"prettier": "^2.0.5",
|
|
85
83
|
"react": "^17.0.2",
|
|
86
84
|
"react-docgen-typescript-loader": "3.7.1",
|
|
87
85
|
"react-dom": "^17.0.2",
|
|
88
86
|
"rollup": "2.18.0",
|
|
89
87
|
"rollup-plugin-postcss": "^4.0.1",
|
|
90
|
-
"rollup-plugin-scss": "3",
|
|
91
88
|
"rollup-plugin-terser": "^7.0.2",
|
|
92
89
|
"rollup-plugin-typescript2": "0.27.1",
|
|
93
90
|
"sass": "^1.44.0",
|
|
94
|
-
"sass-loader": "<11.0.0",
|
|
95
91
|
"style-loader": "<3.0.0",
|
|
96
92
|
"ts-jest": "25.2.1",
|
|
97
93
|
"ts-loader": "^7.0.5",
|
|
@@ -99,8 +95,5 @@
|
|
|
99
95
|
"webpack": "^4.43.0",
|
|
100
96
|
"webpack-cli": "^3.3.11",
|
|
101
97
|
"webpack-dev-server": "^3.11.0"
|
|
102
|
-
},
|
|
103
|
-
"dependencies": {
|
|
104
|
-
"freemium-survey-components": "^0.5.1"
|
|
105
98
|
}
|
|
106
99
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare const BUTTON_SIZE_VARIANTS: {
|
|
3
|
-
LARGE: string;
|
|
4
|
-
MINI: string;
|
|
5
|
-
NORMAL: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type ButtonSizeKey = 'large' | 'mini' | 'normal' | undefined;
|
|
8
|
-
export declare type buttonHTMLType = 'button' | 'reset' | 'submit' | undefined;
|
|
9
|
-
export declare type buttonType = 'primary' | 'secondary' | 'danger' | 'link';
|
|
10
|
-
export declare type ButtonProps = {
|
|
11
|
-
type?: buttonType;
|
|
12
|
-
htmlType?: buttonHTMLType;
|
|
13
|
-
size?: ButtonSizeKey;
|
|
14
|
-
inline?: boolean;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
large?: boolean;
|
|
17
|
-
className?: string;
|
|
18
|
-
ref?: any;
|
|
19
|
-
onClick?: any;
|
|
20
|
-
overrideStyleClassName?: string;
|
|
21
|
-
loading?: boolean;
|
|
22
|
-
children: any;
|
|
23
|
-
};
|
|
24
|
-
export declare const Button: (props: ButtonProps & React.HTMLAttributes<HTMLButtonElement>) => JSX.Element;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare type Option = {
|
|
3
|
-
id: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
label: string;
|
|
6
|
-
};
|
|
7
|
-
interface CheckboxGroupInterface {
|
|
8
|
-
options: Array<Option>;
|
|
9
|
-
values: string[];
|
|
10
|
-
onChangeHandler: (newValues: string[]) => void;
|
|
11
|
-
}
|
|
12
|
-
declare const CheckboxGroup: ({ values, options, onChangeHandler, }: CheckboxGroupInterface) => JSX.Element;
|
|
13
|
-
export { CheckboxGroup };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare type ButtonShapeType = 'rounded' | 'square' | 'curved';
|
|
3
|
-
declare type NPSProps = {
|
|
4
|
-
type_info: {
|
|
5
|
-
linear_scale: {
|
|
6
|
-
button_shape: ButtonShapeType;
|
|
7
|
-
button_style: any;
|
|
8
|
-
};
|
|
9
|
-
validation: {
|
|
10
|
-
min: number;
|
|
11
|
-
};
|
|
12
|
-
score_presets: {
|
|
13
|
-
start: string;
|
|
14
|
-
end: string;
|
|
15
|
-
};
|
|
16
|
-
footer_text: string;
|
|
17
|
-
};
|
|
18
|
-
onChangeHandler: (value: number) => void;
|
|
19
|
-
npsValue: number;
|
|
20
|
-
};
|
|
21
|
-
declare const NPS: (props: NPSProps) => JSX.Element;
|
|
22
|
-
export { NPS };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface RadioButtonProps {
|
|
3
|
-
checked: boolean;
|
|
4
|
-
children: string;
|
|
5
|
-
value: string | number;
|
|
6
|
-
name: string;
|
|
7
|
-
onChange: (e: any) => void;
|
|
8
|
-
id?: string;
|
|
9
|
-
autoFocus?: boolean;
|
|
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
|
-
autoFocus: boolean;
|
|
25
|
-
}> & Pick<RadioButtonProps & React.RefAttributes<HTMLInputElement>, "name" | "value" | "ref" | "children" | "onChange" | "id" | "key">>;
|
|
26
|
-
export { Radio, RadioGroup };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface InputProps extends React.HTMLAttributes<HTMLInputElement> {
|
|
3
|
-
isErrored?: boolean;
|
|
4
|
-
showCount?: boolean;
|
|
5
|
-
errorText?: string;
|
|
6
|
-
maxLength?: any;
|
|
7
|
-
type?: string;
|
|
8
|
-
label: string;
|
|
9
|
-
style?: any;
|
|
10
|
-
value?: any;
|
|
11
|
-
inputStyle?: any;
|
|
12
|
-
className?: string;
|
|
13
|
-
startLabel?: React.ReactNode | any;
|
|
14
|
-
endLabel?: React.ReactNode | any;
|
|
15
|
-
isRequired?: boolean;
|
|
16
|
-
inline?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface TextAreaProps extends React.HTMLAttributes<HTMLTextAreaElement> {
|
|
19
|
-
isErrored: boolean;
|
|
20
|
-
showCount?: boolean;
|
|
21
|
-
maxLength?: any;
|
|
22
|
-
errorText?: string;
|
|
23
|
-
style?: any;
|
|
24
|
-
value?: any;
|
|
25
|
-
inputStyle?: any;
|
|
26
|
-
className?: string;
|
|
27
|
-
label: string;
|
|
28
|
-
startLabel?: React.ReactNode | any;
|
|
29
|
-
startAdornment?: React.ReactNode | any;
|
|
30
|
-
endLabel?: React.ReactNode | any;
|
|
31
|
-
endAdornment?: React.ReactNode | any;
|
|
32
|
-
isRequired?: boolean;
|
|
33
|
-
inline?: boolean;
|
|
34
|
-
}
|
|
35
|
-
declare const Input: React.ComponentType<Partial<{
|
|
36
|
-
isRequired: boolean;
|
|
37
|
-
showCount: boolean;
|
|
38
|
-
isErrored: boolean;
|
|
39
|
-
inline: boolean;
|
|
40
|
-
spellCheck: boolean;
|
|
41
|
-
autoFocus: boolean;
|
|
42
|
-
}> & 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">>;
|
|
43
|
-
declare const TextArea: React.ComponentType<Partial<{
|
|
44
|
-
isRequired: boolean;
|
|
45
|
-
showCount: boolean;
|
|
46
|
-
isErrored: boolean;
|
|
47
|
-
inline: boolean;
|
|
48
|
-
spellCheck: boolean;
|
|
49
|
-
autoFocus: boolean;
|
|
50
|
-
}> & 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">>;
|
|
51
|
-
export { Input, TextArea };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
interface SurveyProps {
|
|
3
|
-
survey: {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
};
|
|
6
|
-
onSubmit: (data: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}) => void;
|
|
9
|
-
}
|
|
10
|
-
declare const Survey: ({ survey, onSubmit }: SurveyProps) => JSX.Element | null;
|
|
11
|
-
export { Survey };
|
package/lib/types/utils.d.ts
DELETED