freemium-survey-components 0.6.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/components/checkbox/index.d.ts +6 -4
- package/lib/types/components/progressbar/index.d.ts +1 -1
- package/lib/types/components/radio-button/index.d.ts +1 -1
- package/lib/types/components/text-input/index.d.ts +1 -1
- package/lib/types/survey/index.d.ts +3 -1
- package/package.json +1 -1
package/lib/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 r(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"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=e:o.appendChild(document.createTextNode(e))}}r(".freemium-survey-components .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.freemium-survey-components .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.875rem;\n line-height: 1.5;\n}\n.freemium-survey-components .nps-container .widget {\n position: relative;\n}\n.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .nps-container .widget span {\n color: #aaa;\n font-size: 0.75rem;\n}\n.freemium-survey-components .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.freemium-survey-components .nps-container .widget button:hover {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.freemium-survey-components .nps-container .widget button.active {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.freemium-survey-components .nps-container .widget.highlighted button:hover, .freemium-survey-components .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.freemium-survey-components .nps-container .widget.rounded button {\n border-radius: 50%;\n}\n.freemium-survey-components .nps-container .widget.rounded.boxed button {\n border-radius: 0;\n}\n.freemium-survey-components .nps-container .choices {\n width: 100%;\n display: flex;\n justify-content: space-between;\n}\n.freemium-survey-components .nps-container .choice:nth-child(1).active, .freemium-survey-components .nps-container .choice:nth-child(1):hover {\n background: #eb5b56;\n}\n.freemium-survey-components .nps-container .choice:nth-child(2).active, .freemium-survey-components .nps-container .choice:nth-child(2):hover {\n background: #fb8774;\n}\n.freemium-survey-components .nps-container .choice:nth-child(3).active, .freemium-survey-components .nps-container .choice:nth-child(3):hover {\n background: #f58f6b;\n}\n.freemium-survey-components .nps-container .choice:nth-child(4).active, .freemium-survey-components .nps-container .choice:nth-child(4):hover {\n background: #f6996a;\n}\n.freemium-survey-components .nps-container .choice:nth-child(5).active, .freemium-survey-components .nps-container .choice:nth-child(5):hover {\n background: #eab268;\n}\n.freemium-survey-components .nps-container .choice:nth-child(6).active, .freemium-survey-components .nps-container .choice:nth-child(6):hover {\n background: #cebb69;\n}\n.freemium-survey-components .nps-container .choice:nth-child(7).active, .freemium-survey-components .nps-container .choice:nth-child(7):hover {\n background: #bdc46c;\n}\n.freemium-survey-components .nps-container .choice:nth-child(8).active, .freemium-survey-components .nps-container .choice:nth-child(8):hover {\n background: #a4cd72;\n}\n.freemium-survey-components .nps-container .choice:nth-child(9).active, .freemium-survey-components .nps-container .choice:nth-child(9):hover {\n background: #77c955;\n}\n.freemium-survey-components .nps-container .choice:nth-child(9).active, .freemium-survey-components .nps-container .choice:nth-child(9):hover {\n background: #37c248;\n}\n\n@media (max-width: 550px) {\n .freemium-survey-components .nps-container .widget .button-container {\n background: transparent;\n }\n .freemium-survey-components .nps-container .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n }\n .freemium-survey-components .nps-container .widget button {\n border-radius: 50%;\n background: #ebeff3;\n }\n}\n.widget-survey-components .nps-container .widget .button-container {\n background: transparent;\n}\n.widget-survey-components .nps-container .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n}\n.widget-survey-components .nps-container .widget button {\n border-radius: 50%;\n background: #ebeff3;\n}");const o=e=>{const{type_info:{linear_scale:{button_shape:r,button_style:o},score_presets:{start:i,end:a},validation:{min:c},footer_text:s}}=e,l=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},u=n.useRef(Array.from({length:10},((e,n)=>n+c)));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"},i),t.createElement("div",{className:"choices"},u.current.map((n=>t.createElement("button",{key:n,onClick:t=>{e.onChangeHandler(n)},className:`choice ${l(n)} ${e.npsValue===n&&"active"}`},n)))),t.createElement("span",{className:"positive-text"},a))),t.createElement("div",{className:"footer"},s))},i=(e,n)=>(e.defaultProps=n,e);r('.freemium-survey-components .input-container,\n.freemium-survey-components .textarea-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n border-radius: 4px;\n position: relative;\n}\n.freemium-survey-components label.input-label {\n display: inline-block;\n padding-bottom: 8px;\n padding-left: 2px;\n font-size: 0.75rem;\n font-weight: 400;\n}\n.freemium-survey-components label.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.freemium-survey-components .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.freemium-survey-components .textarea-container .input-basic {\n flex-direction: column;\n align-items: unset;\n}\n.freemium-survey-components .input-basic.error {\n border: 1px solid var(--default-error-highlight-color);\n border: 1px solid var(--error-highlight-color, var(--default-error-highlight-color));\n}\n.freemium-survey-components .input-basic.error:hover {\n border: 1px solid var(--default-error-highlight-color);\n border: 1px solid var(--error-highlight-color, var(--default-error-highlight-color));\n}\n.freemium-survey-components .input-basic.error[focus-within] {\n box-shadow: none;\n}\n.freemium-survey-components .input-basic.error:focus-within {\n box-shadow: none;\n}\n.freemium-survey-components .input-basic:hover {\n border-color: var(--default-input-hover-border-color);\n border-color: var(--input-hover-border-color, var(--default-input-hover-border-color));\n transition: 0.2s linear;\n}\n.freemium-survey-components .input-basic[focus-within] {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .input-basic:focus-within {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .end-max-length {\n padding: 0 8px;\n font-size: 0.85rem;\n}\n.freemium-survey-components .textarea-container .end-max-length {\n padding: 8px;\n align-self: flex-end;\n}\n.freemium-survey-components span.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}\n.freemium-survey-components input[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}\n.freemium-survey-components input[type=text],\n.freemium-survey-components textarea {\n outline: none;\n border: none;\n}\n.freemium-survey-components input[type=text]::-moz-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\n.freemium-survey-components input[type=text]:-ms-input-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\n.freemium-survey-components input[type=text]::placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\n.freemium-survey-components textarea {\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}\n.freemium-survey-components textarea::-moz-placeholder {\n color: var(--input-placeholder-color);\n}\n.freemium-survey-components textarea:-ms-input-placeholder {\n color: var(--input-placeholder-color);\n}\n.freemium-survey-components textarea::placeholder {\n color: var(--input-placeholder-color);\n}');const a={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!1},c=n.forwardRef(((e,n)=>{const{inputStyle:r,style:o,className:i,showCount:a,isErrored:c,startLabel:s,isRequired:l,errorText:u,endLabel:p,maxLength:d,...m}=e;return t.createElement("div",{className:"input-container",style:o},e.label&&t.createElement("label",{className:"input-label "+(l?"required":"")},e.label),t.createElement("div",null,s&&t.createElement("div",{className:"start-label"},s),t.createElement("div",{className:`input-basic ${c?"error":""}${i||""}`},t.createElement("input",Object.assign({type:"text",autoComplete:"off"},m,{ref:n,style:r})),a&&d>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),p&&t.createElement("div",{className:"end-label"},p)),c&&u&&t.createElement("span",{className:"input-error"},e.errorText))})),s=n.forwardRef(((e,n)=>{const{inputStyle:r,style:o,className:i,showCount:a,maxLength:c,isErrored:s,startLabel:l,isRequired:u,...p}=e;return t.createElement(t.Fragment,null,t.createElement("div",{className:"textarea-container",style:o},e.label&&t.createElement("label",{className:"input-label "+(u?"required":"")},e.label),l&&t.createElement("div",{className:"start-label"},l),t.createElement("div",{className:`input-basic ${s?"error":""} ${i||""}`},t.createElement("textarea",Object.assign({autoComplete:"off"},p,{ref:n,style:r})),a&&c&&c>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))})),l=i(c,a),u=i(s,a);r('.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .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}\n.freemium-survey-components input[type=checkbox] {\n position: absolute;\n clip: rect(0px 0px 0px 0px);\n width: 0px;\n height: 0px;\n}\n.freemium-survey-components input[type=checkbox]:focus ~ .checkbox {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 2px; */\n box-shadow: var(--default-input-highlight-color) 0px 0px 0px 2px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color)) 0px 0px 0px 2px;\n border-color: transparent;\n}\n.freemium-survey-components .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 rgba(18, 52, 77, 0.06);\n border-radius: 4px;\n white-space: pre-wrap;\n}\n.freemium-survey-components .checkbox-label.disabled {\n opacity: 0.5;\n cursor: "not-allowed";\n}\n.freemium-survey-components .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 border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .checkbox:hover {\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n box-shadow: var(--default-background-color) 0px 0px 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px 0px 5px;\n}\n.freemium-survey-components input[type=checkbox]:checked ~ .checkbox {\n background-color: var(--default-input-highlight-color);\n background-color: var(--input-highlight-color, var(--default-input-highlight-color));\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components input[type=checkbox]:checked ~ .checkbox:hover {\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components input[type=checkbox]:disabled ~ .checkbox:hover {\n box-shadow: unset;\n border-color: unset;\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"})),d=({values:e,options:n,onChangeHandler:r})=>t.createElement("div",{className:"checkbox-group"},n.map(((n,o)=>t.createElement(m,{key:n.value,checked:e?.includes(n.value),name:n.value,id:n.value,autoFocus:0===o,onChange:(t,o)=>{if(o)r([...e||[],n.value]);else{const t=e.indexOf(n.value);t>-1&&e.splice(t,1),r([...e])}}},n.meta.label)))),m=i(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});r('.freemium-survey-components .radio-group {\n display: flex;\n grid-gap: 12px;\n gap: 12px;\n white-space: nowrap;\n flex-direction: column;\n}\n.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .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 rgba(18, 52, 77, 0.06);\n border-radius: 4px;\n white-space: pre-wrap;\n}\n.freemium-survey-components input[type=radio] {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n width: 0px;\n height: 0px;\n}\n.freemium-survey-components input[type=radio]:focus ~ .radio {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 3px; */\n box-shadow: var(--default-input-highlight-color) 0px 0px 0px 3px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color)) 0px 0px 0px 3px;\n border-color: transparent;\n}\n.freemium-survey-components input[type=radio]:checked ~ .radio:before {\n background-color: var(--default-input-highlight-color);\n background-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .radio-container:hover .radio {\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n box-shadow: var(--default-background-color) 0px 0px 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px 0px 5px;\n}');const h=({name:e,options:n,value:r,onChangeHandler:o})=>t.createElement("div",{className:"radio-group"},n.map(((n,i)=>t.createElement(f,{key:n.id,value:n.id,name:e,onChange:e=>{o(e.currentTarget.value)},autoFocus:0===i,checked:r===n.id},n.label)))),f=i(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,onChange:e.onChange,autoFocus:e.autoFocus}),t.createElement("div",{className:"radio"}),t.createElement("div",null,e.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\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}");const v=e=>{const{totalSteps:n,completedSteps:r}=e;return t.createElement("div",{className:"progressbar-container"},t.createElement("div",{className:"progressbar",style:{width:(r>0?100/n:0)+"%",transform:`scaleX(${r})`}}))};r(".freemium-survey-components .action-button {\n width: auto;\n display: block;\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.freemium-survey-components .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.freemium-survey-components .action-button[disabled] {\n cursor: not-allowed;\n opacity: 0.6;\n}\n.freemium-survey-components button:focus:not(:active) {\n border: 1px solid transparent;\n /* box-shadow: 0 0 0 2px ${pseudo.focus}; */\n}\n\n@media (max-width: 550px) {\n .freemium-survey-components .action-button {\n min-width: 120px;\n }\n}\n.widget-survey-components .action-button {\n min-width: 120px;\n}");const g=()=>t.createElement(t.Fragment,null,"..."),b=e=>{const{inline:n=!1,children:r,disabled:o,className:i="",htmlType:a,type:c="primary",onClick:s,size:l,overrideStyleClassName:u="",loading:p=!1,...d}=e;return t.createElement("button",Object.assign({style:n?{display:"inline-block"}:{},disabled:o,className:`action-button ${i} ${u}`,type:a,onClick:s},d),p?t.createElement(g,null):r)},x=({question:e,formValues:n,onChangeHandler:r})=>{switch(e.type_info.question_type){case"RANGE":return t.createElement(o,{type_info:e.type_info,onChangeHandler:r,npsValue:n[e.name]});case"CHECKBOX":case"DROPDOWN":return t.createElement(d,{values:n[e.name],options:e.type_info.choices,onChangeHandler:r});case"RADIO":case"MULTICHOICE":return t.createElement(h,{name:e.name,onChangeHandler:r,options:e.type_info.choices,value:n[e.name]});case"INPUT":return t.createElement("div",{className:"responsive-text-field"},t.createElement(l,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)}),t.createElement(u,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return t.createElement(u,{autoFocus:!0,label:"",isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)});case"TEXT":return t.createElement("div",{className:"message-container"},e.type_info?.meta?.value);default:return console.error(`Question type ${e.type_info.question_type} not found`),null}};r(":root {\n --widget-container-width: 350px;\n --widget-container-height: 400px;\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.freemium-survey-components .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 position: relative;\n}\n.freemium-survey-components .question-text {\n font-size: 1rem;\n line-height: 1.5;\n}\n.freemium-survey-components .action-buttons {\n display: flex;\n justify-content: center;\n width: 100%;\n align-items: center;\n}\n.freemium-survey-components .skip-button {\n position: absolute;\n right: 12px;\n font-weight: 300;\n font-size: 0.9rem;\n cursor: pointer;\n background: transparent;\n border: none;\n min-width: 40px;\n padding: 4px 12px;\n border-radius: 4px;\n}\n.freemium-survey-components .skip-button:hover {\n text-decoration: underline;\n}\n.freemium-survey-components .next-button {\n margin: 0 auto;\n}\n.freemium-survey-components .prev-button {\n display: none;\n}\n.freemium-survey-components .submit {\n padding-bottom: 40px;\n display: flex;\n justify-content: center;\n}\n.freemium-survey-components .responsive-text-field {\n width: 100%;\n}\n.freemium-survey-components .responsive-text-field .textarea-container {\n display: none;\n}\n\n@media (max-width: 550px) {\n .freemium-survey-components .responsive-text-field .input-container {\n display: none;\n }\n .freemium-survey-components .responsive-text-field .textarea-container {\n display: flex;\n }\n}\n.widget-survey-components {\n display: flex;\n width: 350px;\n width: var(--widget-container-width);\n height: 400px;\n height: var(--widget-container-height);\n font-size: 0.875rem;\n overflow: hidden;\n}\n.widget-survey-components .responsive-text-field .input-container {\n display: none;\n}\n.widget-survey-components .responsive-text-field .textarea-container {\n display: flex;\n}\n.widget-survey-components .questions {\n min-width: 100%;\n max-width: 100%;\n display: flex;\n height: 100%;\n}\n.widget-survey-components .question-text {\n font-size: 0.875rem;\n}\n.widget-survey-components .question-container {\n height: 100%;\n min-width: 100%;\n max-width: 100%;\n}\n.widget-survey-components .prev-button {\n position: absolute;\n left: 12px;\n display: inline;\n display: initial;\n cursor: pointer;\n padding: 4px 12px;\n}\n.widget-survey-components .prev-button:hover {\n text-decoration: underline;\n}\n.widget-survey-components .submit {\n padding-bottom: 0;\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=b,exports.CheckboxGroup=d,exports.Input=l,exports.NPS=o,exports.ProgressBar=v,exports.Radio=f,exports.RadioGroup=h,exports.Survey=({survey:e,onSubmit:r,widget:o,surveyContainerWidth:i=0})=>{const{meta:{blocks:a},question_details:{questions:c}}=e,[s,l]=n.useState({}),[u,p]=n.useState(!1),[d,m]=n.useState([]),[h,f]=n.useState(0),g=n.useRef(null),k=n.useRef(null),E=n.useRef(null),N=n.useRef(0),q=n.useRef(!1),C=n.useRef([]);n.useEffect((()=>{a&&!g.current&&a.length>0&&R(a[0])}),[a]),n.useEffect((()=>{o||E.current?.scrollIntoView({block:"center",behavior:"smooth"}),C.current=d,f(d.length)}),[d]),n.useEffect((()=>{Object.keys(s).length>0&&k.current&&(y.includes(k.current.type_info.question_type)||q.current)&&!_()&&S()}),[s]);const _=()=>N.current===a.length-1||"end"===g.current.branchOption,R=e=>{let n={};if(e.is_based_on_score){const t=c[0].type_info.choices[s?.[c[0].name]]?.dependent_question_names,r=e.question_names.find((e=>t?.includes(e)));n=c.find((e=>e.name===r))}else n=c.find((n=>n.name===e.question_names[0]));g.current=e,k.current=n;C.current.find((e=>e.question.name===n.name))||m([...C.current,{...e,question:n}])},z=(e,n,t)=>{if(t)if(null!=s[e.question.name]&&e.name!==d[d.length-1].name){const[t,r]=(e=>{const n=d.findIndex((n=>n.name===e.name)),t=d.slice(0,n+1),r=t.reduce(((e,n)=>(e[n.question.name]=s[n.question.name],e)),{});return N.current=a.findIndex((n=>n.name===e.name)),[t,r]})(e);l({...r,...null!=n&&{[e.question.name]:n}}),C.current=t}else l({...s,...null!=n&&{[e.question.name]:n}});else l({...s,...null!=n&&{[e.question.name]:n}})},S=()=>{_()?p(!0):(g.current.nextBlock?N.current=a.findIndex((e=>e.name===g.current.nextBlock)):N.current+=1,R(a[N.current]))},$=e=>{const n=d.findIndex((n=>n.name===e.name)),t=[...d];t.splice(n,1),C.current=t,S()};return g.current&&k.current?u?t.createElement("div",{className:"freemium-survey-components "+(o?"widget-survey-components":"")},t.createElement(w,null)):t.createElement("div",{className:"freemium-survey-components "+(o?"widget-survey-components":"")},!o&&t.createElement(v,{totalSteps:a.length,completedSteps:N.current}),t.createElement("div",{style:o?{transform:`translateX(-${(h-1)*i}px)`}:{},className:"questions"},d.map(((e,n)=>{return t.createElement("div",{className:"question-container",ref:E,id:e.title,key:e.title},t.createElement("div",{className:"question-text"},e.question.text),t.createElement(x,{question:e.question,formValues:s,onChangeHandler:n=>{q.current=!1,N.current=a.findIndex((n=>n.name===e.name)),g.current=e,k.current=e.question,z(e,n,y.includes(e.question.type_info.question_type)&&!_())}}),t.createElement("div",{className:"action-buttons",style:o?{margin:"0 auto"}:{}},(c=n,!!(o&&N.current>0&&0!=c)&&t.createElement("div",{onClick:()=>{N.current=Math.max(N.current-1,0),f(Math.max(h-1,1))},className:"prev-button"},"Prev")),(i=e.question,i.name===k.current.name&&!y.includes(i.type_info.question_type)&&!_()&&t.createElement(b,{onClick:()=>{q.current=!0,z(e,null,!0)},disabled:void 0===s[k.current.name],className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===k.current.name&&!_())(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:$},"Skip"),o&&_()&&t.createElement("div",{className:"submit",style:{margin:"0 auto"}},t.createElement(b,{disabled:k.current.required&&void 0===s[k.current.name],onClick:()=>{p(!0),r(s)}},"Submit Survey"))));var i,c})),!o&&_()&&t.createElement("div",{className:"submit"},t.createElement(b,{disabled:k.current.required&&void 0===s[k.current.name],onClick:()=>{p(!0),r(s)}},"Submit Survey")))):null},exports.TextArea=u;
|
package/lib/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
import e,{useRef as n,forwardRef as t,useState as r,useEffect as o}from"react";function i(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"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=e:o.appendChild(document.createTextNode(e))}}i(".freemium-survey-components .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.freemium-survey-components .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.875rem;\n line-height: 1.5;\n}\n.freemium-survey-components .nps-container .widget {\n position: relative;\n}\n.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .nps-container .widget span {\n color: #aaa;\n font-size: 0.75rem;\n}\n.freemium-survey-components .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.freemium-survey-components .nps-container .widget button:hover {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.freemium-survey-components .nps-container .widget button.active {\n color: white;\n transform: scale(1.15);\n z-index: 2;\n position: relative;\n}\n.freemium-survey-components .nps-container .widget.highlighted button:hover, .freemium-survey-components .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.freemium-survey-components .nps-container .widget.rounded button {\n border-radius: 50%;\n}\n.freemium-survey-components .nps-container .widget.rounded.boxed button {\n border-radius: 0;\n}\n.freemium-survey-components .nps-container .choices {\n width: 100%;\n display: flex;\n justify-content: space-between;\n}\n.freemium-survey-components .nps-container .choice:nth-child(1).active, .freemium-survey-components .nps-container .choice:nth-child(1):hover {\n background: #eb5b56;\n}\n.freemium-survey-components .nps-container .choice:nth-child(2).active, .freemium-survey-components .nps-container .choice:nth-child(2):hover {\n background: #fb8774;\n}\n.freemium-survey-components .nps-container .choice:nth-child(3).active, .freemium-survey-components .nps-container .choice:nth-child(3):hover {\n background: #f58f6b;\n}\n.freemium-survey-components .nps-container .choice:nth-child(4).active, .freemium-survey-components .nps-container .choice:nth-child(4):hover {\n background: #f6996a;\n}\n.freemium-survey-components .nps-container .choice:nth-child(5).active, .freemium-survey-components .nps-container .choice:nth-child(5):hover {\n background: #eab268;\n}\n.freemium-survey-components .nps-container .choice:nth-child(6).active, .freemium-survey-components .nps-container .choice:nth-child(6):hover {\n background: #cebb69;\n}\n.freemium-survey-components .nps-container .choice:nth-child(7).active, .freemium-survey-components .nps-container .choice:nth-child(7):hover {\n background: #bdc46c;\n}\n.freemium-survey-components .nps-container .choice:nth-child(8).active, .freemium-survey-components .nps-container .choice:nth-child(8):hover {\n background: #a4cd72;\n}\n.freemium-survey-components .nps-container .choice:nth-child(9).active, .freemium-survey-components .nps-container .choice:nth-child(9):hover {\n background: #77c955;\n}\n.freemium-survey-components .nps-container .choice:nth-child(9).active, .freemium-survey-components .nps-container .choice:nth-child(9):hover {\n background: #37c248;\n}\n\n@media (max-width: 550px) {\n .freemium-survey-components .nps-container .widget .button-container {\n background: transparent;\n }\n .freemium-survey-components .nps-container .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n }\n .freemium-survey-components .nps-container .widget button {\n border-radius: 50%;\n background: #ebeff3;\n }\n}\n.widget-survey-components .nps-container .widget .button-container {\n background: transparent;\n}\n.widget-survey-components .nps-container .widget .choices {\n flex-wrap: wrap;\n justify-content: center;\n grid-gap: 16px;\n gap: 16px;\n background: transparent;\n}\n.widget-survey-components .nps-container .widget button {\n border-radius: 50%;\n background: #ebeff3;\n}");const a=t=>{const{type_info:{linear_scale:{button_shape:r,button_style:o},score_presets:{start:i,end:a},validation:{min:c},footer_text:s}}=t,l=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},u=n(Array.from({length:10},((e,n)=>n+c)));return e.createElement("div",{className:"nps-container"},e.createElement("div",{className:`widget ${r} ${o}`},e.createElement("div",{className:"button-container"},e.createElement("span",{className:"negative-text"},i),e.createElement("div",{className:"choices"},u.current.map((n=>e.createElement("button",{key:n,onClick:e=>{t.onChangeHandler(n)},className:`choice ${l(n)} ${t.npsValue===n&&"active"}`},n)))),e.createElement("span",{className:"positive-text"},a))),e.createElement("div",{className:"footer"},s))},c=(e,n)=>(e.defaultProps=n,e);i('.freemium-survey-components .input-container,\n.freemium-survey-components .textarea-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n border-radius: 4px;\n position: relative;\n}\n.freemium-survey-components label.input-label {\n display: inline-block;\n padding-bottom: 8px;\n padding-left: 2px;\n font-size: 0.75rem;\n font-weight: 400;\n}\n.freemium-survey-components label.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.freemium-survey-components .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.freemium-survey-components .textarea-container .input-basic {\n flex-direction: column;\n align-items: unset;\n}\n.freemium-survey-components .input-basic.error {\n border: 1px solid var(--default-error-highlight-color);\n border: 1px solid var(--error-highlight-color, var(--default-error-highlight-color));\n}\n.freemium-survey-components .input-basic.error:hover {\n border: 1px solid var(--default-error-highlight-color);\n border: 1px solid var(--error-highlight-color, var(--default-error-highlight-color));\n}\n.freemium-survey-components .input-basic.error[focus-within] {\n box-shadow: none;\n}\n.freemium-survey-components .input-basic.error:focus-within {\n box-shadow: none;\n}\n.freemium-survey-components .input-basic:hover {\n border-color: var(--default-input-hover-border-color);\n border-color: var(--input-hover-border-color, var(--default-input-hover-border-color));\n transition: 0.2s linear;\n}\n.freemium-survey-components .input-basic[focus-within] {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .input-basic:focus-within {\n border: 1px solid transparent;\n box-shadow: 0 0 0 2px var(--default-input-highlight-color);\n box-shadow: 0 0 0 2px var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .end-max-length {\n padding: 0 8px;\n font-size: 0.85rem;\n}\n.freemium-survey-components .textarea-container .end-max-length {\n padding: 8px;\n align-self: flex-end;\n}\n.freemium-survey-components span.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}\n.freemium-survey-components input[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}\n.freemium-survey-components input[type=text],\n.freemium-survey-components textarea {\n outline: none;\n border: none;\n}\n.freemium-survey-components input[type=text]::-moz-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\n.freemium-survey-components input[type=text]:-ms-input-placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\n.freemium-survey-components input[type=text]::placeholder {\n color: var(--default-input-placeholder-color);\n color: var(--input-placeholder-color, var(--default-input-placeholder-color));\n}\n.freemium-survey-components textarea {\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}\n.freemium-survey-components textarea::-moz-placeholder {\n color: var(--input-placeholder-color);\n}\n.freemium-survey-components textarea:-ms-input-placeholder {\n color: var(--input-placeholder-color);\n}\n.freemium-survey-components textarea::placeholder {\n color: var(--input-placeholder-color);\n}');const s={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!1},l=t(((n,t)=>{const{inputStyle:r,style:o,className:i,showCount:a,isErrored:c,startLabel:s,isRequired:l,errorText:u,endLabel:p,maxLength:d,...m}=n;return e.createElement("div",{className:"input-container",style:o},n.label&&e.createElement("label",{className:"input-label "+(l?"required":"")},n.label),e.createElement("div",null,s&&e.createElement("div",{className:"start-label"},s),e.createElement("div",{className:`input-basic ${c?"error":""}${i||""}`},e.createElement("input",Object.assign({type:"text",autoComplete:"off"},m,{ref:t,style:r})),a&&d>0&&e.createElement("div",{className:"end-max-length"},`${n.value&&n.value.length||0}/${n.maxLength}`)),p&&e.createElement("div",{className:"end-label"},p)),c&&u&&e.createElement("span",{className:"input-error"},n.errorText))})),u=t(((n,t)=>{const{inputStyle:r,style:o,className:i,showCount:a,maxLength:c,isErrored:s,startLabel:l,isRequired:u,...p}=n;return e.createElement(e.Fragment,null,e.createElement("div",{className:"textarea-container",style:o},n.label&&e.createElement("label",{className:"input-label "+(u?"required":"")},n.label),l&&e.createElement("div",{className:"start-label"},l),e.createElement("div",{className:`input-basic ${s?"error":""} ${i||""}`},e.createElement("textarea",Object.assign({autoComplete:"off"},p,{ref:t,style:r})),a&&c&&c>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=c(l,s),d=c(u,s);i('.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .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}\n.freemium-survey-components input[type=checkbox] {\n position: absolute;\n clip: rect(0px 0px 0px 0px);\n width: 0px;\n height: 0px;\n}\n.freemium-survey-components input[type=checkbox]:focus ~ .checkbox {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 2px; */\n box-shadow: var(--default-input-highlight-color) 0px 0px 0px 2px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color)) 0px 0px 0px 2px;\n border-color: transparent;\n}\n.freemium-survey-components .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 rgba(18, 52, 77, 0.06);\n border-radius: 4px;\n white-space: pre-wrap;\n}\n.freemium-survey-components .checkbox-label.disabled {\n opacity: 0.5;\n cursor: "not-allowed";\n}\n.freemium-survey-components .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 border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .checkbox:hover {\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n box-shadow: var(--default-background-color) 0px 0px 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px 0px 5px;\n}\n.freemium-survey-components input[type=checkbox]:checked ~ .checkbox {\n background-color: var(--default-input-highlight-color);\n background-color: var(--input-highlight-color, var(--default-input-highlight-color));\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components input[type=checkbox]:checked ~ .checkbox:hover {\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components input[type=checkbox]:disabled ~ .checkbox:hover {\n box-shadow: unset;\n border-color: unset;\n}');const m=()=>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"})),h=({values:n,options:t,onChangeHandler:r})=>e.createElement("div",{className:"checkbox-group"},t.map(((t,o)=>e.createElement(f,{key:t.value,checked:n?.includes(t.value),name:t.value,id:t.value,autoFocus:0===o,onChange:(e,o)=>{if(o)r([...n||[],t.value]);else{const e=n.indexOf(t.value);e>-1&&n.splice(e,1),r([...n])}}},t.meta.label)))),f=c(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(m,null)," ")),e.createElement("div",null,n.children)))),{checked:!1});i('.freemium-survey-components .radio-group {\n display: flex;\n grid-gap: 12px;\n gap: 12px;\n white-space: nowrap;\n flex-direction: column;\n}\n.freemium-survey-components .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.freemium-survey-components .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.freemium-survey-components .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 rgba(18, 52, 77, 0.06);\n border-radius: 4px;\n white-space: pre-wrap;\n}\n.freemium-survey-components input[type=radio] {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n width: 0px;\n height: 0px;\n}\n.freemium-survey-components input[type=radio]:focus ~ .radio {\n /* box-shadow: ${pseudo.focus} 0px 0px 0px 3px; */\n box-shadow: var(--default-input-highlight-color) 0px 0px 0px 3px;\n box-shadow: var(--input-highlight-color, var(--default-input-highlight-color)) 0px 0px 0px 3px;\n border-color: transparent;\n}\n.freemium-survey-components input[type=radio]:checked ~ .radio:before {\n background-color: var(--default-input-highlight-color);\n background-color: var(--input-highlight-color, var(--default-input-highlight-color));\n}\n.freemium-survey-components .radio-container:hover .radio {\n border-color: var(--default-input-highlight-color);\n border-color: var(--input-highlight-color, var(--default-input-highlight-color));\n box-shadow: var(--default-background-color) 0px 0px 0px 5px;\n box-shadow: var(--background-color, var(--default-background-color)) 0px 0px 0px 5px;\n}');const v=({name:n,options:t,value:r,onChangeHandler:o})=>e.createElement("div",{className:"radio-group"},t.map(((t,i)=>e.createElement(g,{key:t.id,value:t.id,name:n,onChange:e=>{o(e.currentTarget.value)},autoFocus:0===i,checked:r===t.id},t.label)))),g=c(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,onChange:n.onChange,autoFocus:n.autoFocus}),e.createElement("div",{className:"radio"}),e.createElement("div",null,n.children)))),{checked:!1,autoFocus:!1});i(".progressbar-container {\n width: 100%;\n height: 6px;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1;\n}\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}");const b=n=>{const{totalSteps:t,completedSteps:r}=n;return e.createElement("div",{className:"progressbar-container"},e.createElement("div",{className:"progressbar",style:{width:(r>0?100/t:0)+"%",transform:`scaleX(${r})`}}))};i(".freemium-survey-components .action-button {\n width: auto;\n display: block;\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.freemium-survey-components .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.freemium-survey-components .action-button[disabled] {\n cursor: not-allowed;\n opacity: 0.6;\n}\n.freemium-survey-components button:focus:not(:active) {\n border: 1px solid transparent;\n /* box-shadow: 0 0 0 2px ${pseudo.focus}; */\n}\n\n@media (max-width: 550px) {\n .freemium-survey-components .action-button {\n min-width: 120px;\n }\n}\n.widget-survey-components .action-button {\n min-width: 120px;\n}");const x=()=>e.createElement(e.Fragment,null,"..."),y={LARGE:"large",MINI:"mini",NORMAL:"normal"},w=n=>{const{inline:t=!1,children:r,disabled:o,className:i="",htmlType:a,type:c="primary",onClick:s,size:l,overrideStyleClassName:u="",loading:p=!1,...d}=n;return e.createElement("button",Object.assign({style:t?{display:"inline-block"}:{},disabled:o,className:`action-button ${i} ${u}`,type:a,onClick:s},d),p?e.createElement(x,null):r)},k=({question:n,formValues:t,onChangeHandler:r})=>{switch(n.type_info.question_type){case"RANGE":return e.createElement(a,{type_info:n.type_info,onChangeHandler:r,npsValue:t[n.name]});case"CHECKBOX":case"DROPDOWN":return e.createElement(h,{values:t[n.name],options:n.type_info.choices,onChangeHandler:r});case"RADIO":case"MULTICHOICE":return e.createElement(v,{name:n.name,onChangeHandler:r,options:n.type_info.choices,value:t[n.name]});case"INPUT":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=>r(e.target.value)}),e.createElement(d,{autoFocus:!0,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return e.createElement(d,{autoFocus:!0,label:"",isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)});case"TEXT":return e.createElement("div",{className:"message-container"},n.type_info?.meta?.value);default:return console.error(`Question type ${n.type_info.question_type} not found`),null}};i(":root {\n --widget-container-width: 350px;\n --widget-container-height: 400px;\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.freemium-survey-components .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 position: relative;\n}\n.freemium-survey-components .question-text {\n font-size: 1rem;\n line-height: 1.5;\n}\n.freemium-survey-components .action-buttons {\n display: flex;\n justify-content: center;\n width: 100%;\n align-items: center;\n}\n.freemium-survey-components .skip-button {\n position: absolute;\n right: 12px;\n font-weight: 300;\n font-size: 0.9rem;\n cursor: pointer;\n background: transparent;\n border: none;\n min-width: 40px;\n padding: 4px 12px;\n border-radius: 4px;\n}\n.freemium-survey-components .skip-button:hover {\n text-decoration: underline;\n}\n.freemium-survey-components .next-button {\n margin: 0 auto;\n}\n.freemium-survey-components .prev-button {\n display: none;\n}\n.freemium-survey-components .submit {\n padding-bottom: 40px;\n display: flex;\n justify-content: center;\n}\n.freemium-survey-components .responsive-text-field {\n width: 100%;\n}\n.freemium-survey-components .responsive-text-field .textarea-container {\n display: none;\n}\n\n@media (max-width: 550px) {\n .freemium-survey-components .responsive-text-field .input-container {\n display: none;\n }\n .freemium-survey-components .responsive-text-field .textarea-container {\n display: flex;\n }\n}\n.widget-survey-components {\n display: flex;\n width: 350px;\n width: var(--widget-container-width);\n height: 400px;\n height: var(--widget-container-height);\n font-size: 0.875rem;\n overflow: hidden;\n}\n.widget-survey-components .responsive-text-field .input-container {\n display: none;\n}\n.widget-survey-components .responsive-text-field .textarea-container {\n display: flex;\n}\n.widget-survey-components .questions {\n min-width: 100%;\n max-width: 100%;\n display: flex;\n height: 100%;\n}\n.widget-survey-components .question-text {\n font-size: 0.875rem;\n}\n.widget-survey-components .question-container {\n height: 100%;\n min-width: 100%;\n max-width: 100%;\n}\n.widget-survey-components .prev-button {\n position: absolute;\n left: 12px;\n display: inline;\n display: initial;\n cursor: pointer;\n padding: 4px 12px;\n}\n.widget-survey-components .prev-button:hover {\n text-decoration: underline;\n}\n.widget-survey-components .submit {\n padding-bottom: 0;\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.")),q=({survey:t,onSubmit:i,widget:a,surveyContainerWidth:c=0})=>{const{meta:{blocks:s},question_details:{questions:l}}=t,[u,p]=r({}),[d,m]=r(!1),[h,f]=r([]),[v,g]=r(0),x=n(null),y=n(null),q=n(null),C=n(0),_=n(!1),z=n([]);o((()=>{s&&!x.current&&s.length>0&&L(s[0])}),[s]),o((()=>{a||q.current?.scrollIntoView({block:"center",behavior:"smooth"}),z.current=h,g(h.length)}),[h]),o((()=>{Object.keys(u).length>0&&y.current&&(E.includes(y.current.type_info.question_type)||_.current)&&!$()&&S()}),[u]);const $=()=>C.current===s.length-1||"end"===x.current.branchOption,L=e=>{let n={};if(e.is_based_on_score){const t=l[0].type_info.choices[u?.[l[0].name]]?.dependent_question_names,r=e.question_names.find((e=>t?.includes(e)));n=l.find((e=>e.name===r))}else n=l.find((n=>n.name===e.question_names[0]));x.current=e,y.current=n;z.current.find((e=>e.question.name===n.name))||f([...z.current,{...e,question:n}])},R=(e,n,t)=>{if(t)if(null!=u[e.question.name]&&e.name!==h[h.length-1].name){const[t,r]=(e=>{const n=h.findIndex((n=>n.name===e.name)),t=h.slice(0,n+1),r=t.reduce(((e,n)=>(e[n.question.name]=u[n.question.name],e)),{});return C.current=s.findIndex((n=>n.name===e.name)),[t,r]})(e);p({...r,...null!=n&&{[e.question.name]:n}}),z.current=t}else p({...u,...null!=n&&{[e.question.name]:n}});else p({...u,...null!=n&&{[e.question.name]:n}})},S=()=>{$()?m(!0):(x.current.nextBlock?C.current=s.findIndex((e=>e.name===x.current.nextBlock)):C.current+=1,L(s[C.current]))},O=e=>{const n=h.findIndex((n=>n.name===e.name)),t=[...h];t.splice(n,1),z.current=t,S()};return x.current&&y.current?d?e.createElement("div",{className:"freemium-survey-components "+(a?"widget-survey-components":"")},e.createElement(N,null)):e.createElement("div",{className:"freemium-survey-components "+(a?"widget-survey-components":"")},!a&&e.createElement(b,{totalSteps:s.length,completedSteps:C.current}),e.createElement("div",{style:a?{transform:`translateX(-${(v-1)*c}px)`}:{},className:"questions"},h.map(((n,t)=>{return e.createElement("div",{className:"question-container",ref:q,id:n.title,key:n.title},e.createElement("div",{className:"question-text"},n.question.text),e.createElement(k,{question:n.question,formValues:u,onChangeHandler:e=>{_.current=!1,C.current=s.findIndex((e=>e.name===n.name)),x.current=n,y.current=n.question,R(n,e,E.includes(n.question.type_info.question_type)&&!$())}}),e.createElement("div",{className:"action-buttons",style:a?{margin:"0 auto"}:{}},(o=t,!!(a&&C.current>0&&0!=o)&&e.createElement("div",{onClick:()=>{C.current=Math.max(C.current-1,0),g(Math.max(v-1,1))},className:"prev-button"},"Prev")),(r=n.question,r.name===y.current.name&&!E.includes(r.type_info.question_type)&&!$()&&e.createElement(w,{onClick:()=>{_.current=!0,R(n,null,!0)},disabled:void 0===u[y.current.name],className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===y.current.name&&!$())(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:O},"Skip"),a&&$()&&e.createElement("div",{className:"submit",style:{margin:"0 auto"}},e.createElement(w,{disabled:y.current.required&&void 0===u[y.current.name],onClick:()=>{m(!0),i(u)}},"Submit Survey"))));var r,o})),!a&&$()&&e.createElement("div",{className:"submit"},e.createElement(w,{disabled:y.current.required&&void 0===u[y.current.name],onClick:()=>{m(!0),i(u)}},"Submit Survey")))):null};export{y as BUTTON_SIZE_VARIANTS,w as Button,h as CheckboxGroup,p as Input,a as NPS,b as ProgressBar,g as Radio,v as RadioGroup,q as Survey,d as TextArea};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import './style.
|
|
2
|
+
import './style.scss';
|
|
3
3
|
declare type Option = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
position?: number;
|
|
5
|
+
value: string;
|
|
6
|
+
meta: {
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
7
9
|
};
|
|
8
10
|
interface CheckboxGroupInterface {
|
|
9
11
|
options: Array<Option>;
|
|
@@ -4,9 +4,11 @@ interface SurveyProps {
|
|
|
4
4
|
survey: {
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
};
|
|
7
|
+
widget?: boolean;
|
|
7
8
|
onSubmit: (data: {
|
|
8
9
|
[key: string]: any;
|
|
9
10
|
}) => void;
|
|
11
|
+
surveyContainerWidth?: number;
|
|
10
12
|
}
|
|
11
|
-
declare const Survey: ({ survey, onSubmit }: SurveyProps) => JSX.Element | null;
|
|
13
|
+
declare const Survey: ({ survey, onSubmit, widget, surveyContainerWidth, }: SurveyProps) => JSX.Element | null;
|
|
12
14
|
export { Survey };
|