freemium-survey-components 0.8.4 → 0.8.5

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 CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),r=e(require("react-dom"));function o(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))}}o(".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 i=e=>{const{type_info:{linear_scale:{button_shape:r,button_style:o},score_presets:{start:i,end:a},validation:{min:s},footer_text:c}}=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+s)));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"},c))},a=(e,n)=>(e.defaultProps=n,e);o('.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:!0},c=n.forwardRef(((e,r)=>{const o=n.useRef(null);n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{o.current?.focus()}),q+20)}),[e.autoFocus]);const{inputStyle:i,style:a,className:s,showCount:c,isErrored:l,startLabel:u,isRequired:p,errorText:d,endLabel:m,maxLength:h,autoFocus:f,...g}=e;return t.createElement("div",{className:"input-container",style:a},e.label&&t.createElement("label",{className:"input-label "+(p?"required":"")},e.label),t.createElement("div",null,u&&t.createElement("div",{className:"start-label"},u),t.createElement("div",{className:`input-basic ${l?"error":""}${s||""}`},t.createElement("input",Object.assign({type:"text",autoComplete:"off",ref:o,style:i},g)),c&&h>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),m&&t.createElement("div",{className:"end-label"},m)),l&&d&&t.createElement("span",{className:"input-error"},e.errorText))})),l=n.forwardRef(((e,r)=>{const o=n.useRef(null);n.useEffect((()=>{console.log("props.autoFocus...",e.autoFocus),e.autoFocus&&setTimeout((()=>{o.current?.focus()}),q+20)}),[]);const{inputStyle:i,style:a,className:s,showCount:c,maxLength:l,isErrored:u,startLabel:p,isRequired:d,autoFocus:m,...h}=e;return t.createElement(t.Fragment,null,t.createElement("div",{className:"textarea-container",style:a},e.label&&t.createElement("label",{className:"input-label "+(d?"required":"")},e.label),p&&t.createElement("div",{className:"start-label"},p),t.createElement("div",{className:`input-basic ${u?"error":""} ${s||""}`},t.createElement("textarea",Object.assign({autoComplete:"off",ref:o,style:i},h)),c&&l&&l>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),e.endLabel&&t.createElement("div",{className:"end-label"},e.endLabel)),e.isErrored&&e.errorText&&t.createElement("span",{className:"input-error"},e.errorText))})),u=a(c,s),p=a(l,s);o('.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: 16px;\n background-color: #fff;\n border: 1px solid;\n text-align: left;\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 d=()=>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"})),m=({values:e,options:n,onChangeHandler:r,autoFocus:o})=>t.createElement("div",{className:"checkbox-group"},n.map(((n,i)=>t.createElement(h,{key:n.value,checked:e?.includes(n.value),name:n.value,id:n.value,autoFocus:0===i&&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.value)))),h=a((e=>{const r=n.useRef(null);return n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{r.current?.focus()}),q+20)}),[]),t.createElement("label",{className:`checkbox-label ${e.disabled&&"disabled"}`},t.createElement("input",{ref:r,id:e.id,type:"checkbox",name:e.name,readOnly:e.readOnly,disabled:e.disabled,"aria-disabled":e.disabled,checked:e.checked,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(d,null)," ")),t.createElement("div",null,e.children))}),{checked:!1});o('.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: 16px;\n text-align: left;\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 f=({name:e,options:r,value:o,autoFocus:i,onChangeHandler:a,othersOption:s,othersRequired:c})=>{const[l,p]=n.useState(""),[d,m]=n.useState("");return n.useEffect((()=>{o||(m(""),p(""))}),[o]),n.useEffect((()=>{d&&r.find((e=>e.value===d))&&a(d)}),[d]),t.createElement("div",{className:"radio-group"},r.map(((n,r)=>t.createElement(g,{key:n.value,value:n.value,name:e,onChange:e=>{m(e.currentTarget.value)},autoFocus:0===r&&i,checked:d===n.value},n.value))),s&&t.createElement(g,{key:"others",value:"others",name:e,onChange:e=>{m("others")},checked:"others"===d},"others"),"others"===d&&t.createElement(t.Fragment,null,t.createElement(u,{placeholder:"",value:l,onChange:e=>p(e.target.value),label:""}),l!==o&&t.createElement(x,{disabled:c&&0===l.length,onClick:()=>a(l)},"Next")))},g=a((e=>{const r=n.useRef(null);return n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{r.current?.focus()}),q+20)}),[]),t.createElement("label",{className:"radio-label"},t.createElement("input",{ref:r,type:"radio",name:e.name,value:e.value,checked:e.checked,onChange:e.onChange}),t.createElement("div",{className:"radio"}),t.createElement("div",null,e.children))}),{checked:!1,autoFocus:!1});o(".progressbar-container {\n width: 100%;\n height: 6px;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1;\n}\n\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})`}}))};o(".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 /* 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 b=()=>t.createElement(t.Fragment,null,"..."),x=e=>{const{inline:n=!1,children:r,disabled:o,className:i="",htmlType:a,type:s="primary",onClick:c,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:c},d),p?t.createElement(b,null):r)},y=({question:e,formValues:n,onChangeHandler:r,autoFocus:o})=>{switch(e.type_info.question_type){case"RANGE":return t.createElement(i,{type_info:e.type_info,onChangeHandler:r,npsValue:n[e.name]});case"CHECKBOX":return t.createElement(m,{autoFocus:o,values:n[e.name],options:e.type_info.choices,onChangeHandler:r});case"RADIO":case"DROPDOWN":return t.createElement(f,{autoFocus:o,name:e.name,onChangeHandler:r,options:e.type_info.choices,value:n[e.name],othersOption:e.type_info.meta.othersOption,othersRequired:e.type_info.meta.othersRequired});case"INPUT":case"TEXT":return e.type_info?.meta?.readOnly?t.createElement("div",{className:"message-container"},e.type_info?.meta?.value):t.createElement("div",{className:"responsive-text-field"},t.createElement(u,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)}),t.createElement(p,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return t.createElement(p,{autoFocus:o,label:"",isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)});default:return console.error(`Question type ${e.type_info.question_type} not found`),null}};o(":root {\n --widget-container-width: 350px;\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 .thankyou .text {\n white-space: pre-wrap;\n font-weight: 500;\n font-size: 1.2rem;\n line-height: 2;\n color: #12344d;\n}\n.freemium-survey-components .thankyou .redirection-text {\n color: #929292;\n margin-bottom: 12px;\n font-weight: 300;\n}\n.freemium-survey-components .thankyou .link {\n width: 100%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: #666;\n font-weight: 500;\n text-decoration: underline;\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 .action-buttons:empty {\n display: none;\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: 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.freemium-survey-components .message-container:empty {\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 height: 100%;\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 margin-bottom: 0;\n}\n.widget-survey-components .prev-button {\n border: none;\n background: transparent;\n position: absolute;\n left: 12px;\n display: inline;\n display: initial;\n cursor: pointer;\n padding: 12px;\n}\n.widget-survey-components .prev-button:hover {\n text-decoration: underline;\n}\n.widget-survey-components .submit {\n padding-bottom: 0;\n}\n\n.widget-survey-components.default-style .question-container {\n grid-gap: 24px;\n gap: 24px;\n padding: 16px 28px;\n}\n.widget-survey-components.default-style .action-button {\n line-height: 1.2;\n}\n.widget-survey-components.default-style .radio-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .radio-group .radio-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style .checkbox-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .checkbox-group .checkbox-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style textarea {\n min-height: 84px;\n}\n.widget-survey-components.default-style .end-max-length {\n font-size: 0.8rem;\n font-weight: 300;\n}");const w=()=>t.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{d:"M7.82585 6.15754C7.98999 6.32147 8.08232 6.54389 8.08252 6.77587L8.08252 7.2192C8.07983 7.45069 7.98788 7.6722 7.82585 7.83754L1.82919 13.8225C1.77496 13.8772 1.71044 13.9206 1.63936 13.9502C1.56827 13.9798 1.49203 13.9951 1.41502 13.9951C1.33801 13.9951 1.26177 13.9798 1.19068 13.9502C1.1196 13.9206 1.05508 13.8772 1.00085 13.8225L0.172521 12.9942C0.118197 12.941 0.0750381 12.8774 0.0455752 12.8073C0.0161124 12.7372 0.000937578 12.6619 0.000937585 12.5859C0.000937592 12.5098 0.0161125 12.4345 0.0455753 12.3644C0.0750381 12.2943 0.118197 12.2308 0.172521 12.1775L5.36419 6.99754L0.172522 1.81754C0.117847 1.76331 0.0744506 1.69879 0.0448352 1.62771C0.0152208 1.55662 -2.75162e-05 1.48038 -2.75094e-05 1.40337C-2.75027e-05 1.32636 0.0152208 1.25012 0.0448353 1.17904C0.0744507 1.10795 0.117847 1.04343 0.172522 0.989205L1.00086 0.172537C1.05508 0.117862 1.1196 0.0744661 1.19069 0.0448507C1.26177 0.0152353 1.33801 -1.20337e-05 1.41502 -1.2027e-05C1.49203 -1.20203e-05 1.56827 0.0152353 1.63936 0.0448507C1.71044 0.0744661 1.77496 0.117862 1.82919 0.172537L7.82585 6.15754Z",fill:"#6B6B6B"})),k=()=>t.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{d:"M0.256667 7.83755C0.0925257 7.67361 0.000204227 7.4512 0 7.21921V6.77588C0.00268801 6.5444 0.0946357 6.32289 0.256667 6.15755L6.25333 0.172549C6.30756 0.117874 6.37208 0.0744776 6.44316 0.0448625C6.51425 0.0152474 6.59049 0 6.6675 0C6.74451 0 6.82075 0.0152474 6.89184 0.0448625C6.96292 0.0744776 7.02744 0.117874 7.08167 0.172549L7.91 1.00088C7.96432 1.05411 8.00748 1.11764 8.03694 1.18776C8.06641 1.25787 8.08158 1.33316 8.08158 1.40922C8.08158 1.48527 8.06641 1.56056 8.03694 1.63067C8.00748 1.70079 7.96432 1.76432 7.91 1.81755L2.71833 6.99755L7.91 12.1775C7.96467 12.2318 8.00807 12.2963 8.03769 12.3674C8.0673 12.4385 8.08255 12.5147 8.08255 12.5917C8.08255 12.6687 8.0673 12.745 8.03769 12.8161C8.00807 12.8871 7.96467 12.9517 7.91 13.0059L7.08167 13.8225C7.02744 13.8772 6.96292 13.9206 6.89184 13.9502C6.82075 13.9799 6.74451 13.9951 6.6675 13.9951C6.59049 13.9951 6.51425 13.9799 6.44316 13.9502C6.37208 13.9206 6.30756 13.8772 6.25333 13.8225L0.256667 7.83755Z",fill:"#6B6B6B"})),E=["RANGE","NPS","RADIO","DROPDOWN"],q=200,C=({thankYouQuestion:e})=>(n.useEffect((()=>{setTimeout((()=>{window.location.href=e.type_info.meta.redirectUrl}),1e4)}),[]),t.createElement("div",{className:"question-container thankyou"},t.createElement("div",{className:"text"},e.text),t.createElement("div",{style:{width:"100%"}},t.createElement("div",{className:"redirection-text"},"You will be redirected to the below URL automatically in 10 seconds.",t.createElement("br",null)),t.createElement("a",{className:"link",href:e.type_info.meta.redirectUrl},e?.type_info.meta.redirectUrl))));exports.AUTO_REDIRECT_DELAY=1e4,exports.BUTTON_SIZE_VARIANTS={LARGE:"large",MINI:"mini",NORMAL:"normal"},exports.Button=x,exports.CheckboxGroup=m,exports.Input=u,exports.NPS=i,exports.ProgressBar=v,exports.Radio=g,exports.RadioGroup=f,exports.Survey=({survey:e,onSubmit:o,widget:i,surveyContainerWidth:a=0,npsValue:s,widgetStyle:c,widgetNavigatorQuerySelector:l})=>{const{meta:{blocks:u},question_details:{questions:p}}=e,[d,m]=n.useState({}),[h,f]=n.useState(!1),[g,b]=n.useState([]),[N,_]=n.useState(0),[R,S]=n.useState(!1),[L,z]=n.useState(null),T=n.useRef(null),O=n.useRef(null),F=n.useRef(null),$=n.useRef(0),A=n.useRef(!1),B=n.useRef([]);n.useEffect((()=>{if(u)if(O.current=p.find((e=>e.pivot_question))??p.find((e=>"RANGE"===e.type_info.question_type))??p[0],s){const e=p.find((e=>e.name===u[0].question_names[0]));T.current=u[0],B.current=[...B.current,{...u[0],question:e}],b(B.current),m({Q_1:s})}else if(!T.current&&u.length>0)return T.current=u[0],void P(u[0])}),[u,s]),n.useEffect((()=>{i||F.current?.scrollIntoView({block:"center",behavior:"smooth"}),g.length&&(B.current=g),_(g.length-1)}),[g]),n.useEffect((()=>{Object.keys(d).length>0&&T.current.question&&(E.includes(T.current.question.type_info.question_type)||A.current)&&!I()&&j()}),[d]),n.useEffect((()=>{if(d?.[O.current?.name]){const e=u.find((e=>"T_1"===e.name));if(e.is_based_on_score){const n=O.current?.type_info?.choices[d?.[O.current?.name]]?.dependent_question_names,t=e.question_names.find((e=>n?.includes(e))),r=p.find((e=>e.name===t));z(r)}}}),[d?.[O.current?.name]]);const I=()=>$.current===u.filter((e=>"T_1"!==e.name)).length-1||"end"===T.current.branchOption,P=e=>{let n={};if(e.is_based_on_score){const t=O.current?.type_info?.choices[d?.[O.current?.name]]?.dependent_question_names,r=e.question_names.find((e=>t?.includes(e)));n=p.find((e=>e.name===r))}else n=p.find((n=>n.name===e.question_names[0]));T.current.question=n;const t=B.current.find((e=>e.question.name===n.name));b(t?[...B.current]:[...B.current,{...e,question:n}])},j=()=>{if(I())f(!0);else{if(T.current.nextBlock)$.current=u.findIndex((e=>e.name===T.current.nextBlock));else if(T.current.question.type_info?.meta?.branches){const e=T.current.question.type_info?.meta?.branches,n=d[T.current.question.name];let t;t="RANGE"===T.current.type?e.find((e=>n>=e.min&&n<=e.max)):e.find((e=>n===e.value)),t?.nextBlock?$.current=u.findIndex((e=>e.name===t.nextBlock)):$.current+=1}else $.current+=1;T.current=u[$.current],P(u[$.current])}},H=(e,n)=>{A.current=!0,delete d[n.name],m({...d})},D=(e,n,t)=>{if(t)if(A.current=!0,null!=d[e.question.name]&&e.name!==g[g.length-1].name){const[t,r]=(e=>{const n=g.findIndex((n=>n.name===e.name)),t=g.slice(0,n+1),r=t.reduce(((e,n)=>(e[n.question.name]=d[n.question.name],e)),{});return $.current=u.findIndex((n=>n.name===e.name)),[t,r]})(e);m({...r,...null!=n&&{[e.question.name]:n}}),B.current=t}else m({...d,...null!=n&&{[e.question.name]:n}});else m({...d,...null!=n&&{[e.question.name]:n}})};return T.current&&T.current.question?h?t.createElement("div",{className:"freemium-survey-components "+(i?"widget-survey-components":"")},t.createElement(C,{thankYouQuestion:L})):t.createElement("div",{className:`freemium-survey-components ${i?"widget-survey-components":""} ${c}-style`,style:{"--widget-container-width":a}},!i&&t.createElement(v,{totalSteps:u.length,completedSteps:$.current}),i&&document.querySelector(l)&&t.createElement(t.Fragment,null,r.createPortal(t.createElement("div",{className:"navigation","data-navigation-element":"1"},t.createElement("button",{style:0==$.current?{visibility:"hidden"}:{},className:"navigate-button",onClick:()=>{$.current=Math.max($.current-1,0),_($.current)}},t.createElement(k,null)),t.createElement("span",{className:"navigation-text"}," Question ",$.current+1," of"," ",g.length," ")," ",t.createElement("button",{className:"navigate-button",style:$.current>=g.length-1?{visibility:"hidden"}:{},onClick:()=>{$.current=Math.min($.current+1,g.length-1),_($.current)}},t.createElement(w,null))),document.querySelector(l))),t.createElement("div",{style:i?{transform:`translateX(-${N*a}px)`,transition:`transform ${q}ms linear`}:{},className:"questions"},g.map(((e,n)=>{return t.createElement("div",{className:"question-container",ref:F,id:e.title,key:e.title},t.createElement("div",{className:"question-text"},e.question.text),t.createElement(y,{question:e.question,formValues:d,autoFocus:T.current.name===e.name,onChangeHandler:n=>{A.current=!1,$.current=u.findIndex((n=>n.name===e.name)),T.current=e,D(e,n,E.includes(e.question.type_info.question_type)&&!I())}}),t.createElement("div",{className:"action-buttons",style:i?{margin:"0 auto"}:{}},(r=e.question,r.name===T.current.question.name&&!E.includes(r.type_info.question_type)&&!I()&&t.createElement(x,{onClick:()=>{A.current?($.current=Math.min($.current+1,g.length-1),T.current=g[n+1],_($.current)):D(e,null,!0)},disabled:!d[T.current.question.name]||Array.isArray(d[T.current.question.name])&&0===d[T.current.question.name].length,className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===T.current.question.name&&!I())(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:()=>H(0,e.question)},"Skip"),((e,n)=>!("DROPDOWN"!==n.type_info.question_type||n.name===T.current.question.name||n.required||!d[n.name]))(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:()=>{T.current=e,$.current=u.findIndex((n=>n.name===e.name)),H(0,e.question)}},"Clear selection"),i&&(e=>I()&&e.name===T.current.question.name)(e.question)&&t.createElement("div",{className:"submit",style:{margin:"0 auto"}},t.createElement(x,{disabled:T.current.question.required&&void 0===d[T.current.question.name]||R,onClick:()=>{S(!0),o(d),L?.type_info.meta.skipThankYouPage||f(!0)}},R?"Submitting":"Submit Survey"))));var r})),!i&&I()&&t.createElement("div",{className:"submit"},t.createElement(x,{disabled:T.current.question.required&&void 0===d[T.current.question.name]||R,onClick:()=>{S(!0),o(d,(()=>{L?.type_info.meta.skipThankYouPage&&(window.location.href=L?.type_info.meta.redirectUrl)})),L?.type_info.meta.skipThankYouPage||f(!0)}},R?"Submitting":"Submit Survey")))):null},exports.TRANSITION_DELAY=q,exports.TextArea=p;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),r=e(require("react-dom"));function o(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))}}o(".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 i=e=>{const{type_info:{linear_scale:{button_shape:r,button_style:o},score_presets:{start:i,end:a},validation:{min:s},footer_text:c}}=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+s)));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"},c))},a=(e,n)=>(e.defaultProps=n,e);o('.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:!0},c=n.forwardRef(((e,r)=>{const o=n.useRef(null);n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{o.current?.focus()}),q+20)}),[e.autoFocus]);const{inputStyle:i,style:a,className:s,showCount:c,isErrored:l,startLabel:u,isRequired:p,errorText:d,endLabel:m,maxLength:h,autoFocus:f,...g}=e;return t.createElement("div",{className:"input-container",style:a},e.label&&t.createElement("label",{className:"input-label "+(p?"required":"")},e.label),t.createElement("div",null,u&&t.createElement("div",{className:"start-label"},u),t.createElement("div",{className:`input-basic ${l?"error":""}${s||""}`},t.createElement("input",Object.assign({type:"text",autoComplete:"off",ref:o,style:i},g)),c&&h>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),m&&t.createElement("div",{className:"end-label"},m)),l&&d&&t.createElement("span",{className:"input-error"},e.errorText))})),l=n.forwardRef(((e,r)=>{const o=n.useRef(null);n.useEffect((()=>{console.log("props.autoFocus...",e.autoFocus),e.autoFocus&&setTimeout((()=>{o.current?.focus()}),q+20)}),[]);const{inputStyle:i,style:a,className:s,showCount:c,maxLength:l,isErrored:u,startLabel:p,isRequired:d,autoFocus:m,...h}=e;return t.createElement(t.Fragment,null,t.createElement("div",{className:"textarea-container",style:a},e.label&&t.createElement("label",{className:"input-label "+(d?"required":"")},e.label),p&&t.createElement("div",{className:"start-label"},p),t.createElement("div",{className:`input-basic ${u?"error":""} ${s||""}`},t.createElement("textarea",Object.assign({autoComplete:"off",ref:o,style:i},h)),c&&l&&l>0&&t.createElement("div",{className:"end-max-length"},`${e.value&&e.value.length||0}/${e.maxLength}`)),e.endLabel&&t.createElement("div",{className:"end-label"},e.endLabel)),e.isErrored&&e.errorText&&t.createElement("span",{className:"input-error"},e.errorText))})),u=a(c,s),p=a(l,s);o('.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: 16px;\n background-color: #fff;\n border: 1px solid;\n text-align: left;\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 d=()=>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"})),m=({values:e,options:n,onChangeHandler:r,autoFocus:o})=>t.createElement("div",{className:"checkbox-group"},n.map(((n,i)=>t.createElement(h,{key:n.value,checked:e?.includes(n.value),name:n.value,id:n.value,autoFocus:0===i&&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.value)))),h=a((e=>{const r=n.useRef(null);return n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{r.current?.focus()}),q+20)}),[]),t.createElement("label",{className:`checkbox-label ${e.disabled&&"disabled"}`},t.createElement("input",{ref:r,id:e.id,type:"checkbox",name:e.name,readOnly:e.readOnly,disabled:e.disabled,"aria-disabled":e.disabled,checked:e.checked,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(d,null)," ")),t.createElement("div",null,e.children))}),{checked:!1});o('.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: 16px;\n text-align: left;\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 f=({name:e,options:r,value:o,autoFocus:i,onChangeHandler:a,othersOption:s,othersRequired:c})=>{const[l,p]=n.useState(""),[d,m]=n.useState("");return n.useEffect((()=>{o||(m(""),p(""))}),[o]),n.useEffect((()=>{d&&r.find((e=>e.value===d))&&a(d)}),[d]),t.createElement("div",{className:"radio-group"},r.map(((n,r)=>t.createElement(g,{key:n.value,value:n.value,name:e,onChange:e=>{m(e.currentTarget.value)},autoFocus:0===r&&i,checked:d===n.value},n.value))),s&&t.createElement(g,{key:"others",value:"others",name:e,onChange:e=>{m("others")},checked:"others"===d},"others"),"others"===d&&t.createElement(t.Fragment,null,t.createElement(u,{placeholder:"",value:l,onChange:e=>p(e.target.value),label:""}),l!==o&&t.createElement(b,{disabled:c&&0===l.length,onClick:()=>a(l)},"Next")))},g=a((e=>{const r=n.useRef(null);return n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{r.current?.focus()}),q+20)}),[]),t.createElement("label",{className:"radio-label"},t.createElement("input",{ref:r,type:"radio",name:e.name,value:e.value,checked:e.checked,onChange:e.onChange}),t.createElement("div",{className:"radio"}),t.createElement("div",null,e.children))}),{checked:!1,autoFocus:!1});o(".progressbar-container {\n width: 100%;\n height: 6px;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1;\n text-align: left;\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})`}}))};o(".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 /* 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=()=>t.createElement(t.Fragment,null,"..."),b=e=>{const{inline:n=!1,children:r,disabled:o,className:i="",htmlType:a,type:s="primary",onClick:c,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:c},d),p?t.createElement(x,null):r)},y=({question:e,formValues:n,onChangeHandler:r,autoFocus:o})=>{switch(e.type_info.question_type){case"RANGE":return t.createElement(i,{type_info:e.type_info,onChangeHandler:r,npsValue:n[e.name]});case"CHECKBOX":return t.createElement(m,{autoFocus:o,values:n[e.name],options:e.type_info.choices,onChangeHandler:r});case"RADIO":case"DROPDOWN":return t.createElement(f,{autoFocus:o,name:e.name,onChangeHandler:r,options:e.type_info.choices,value:n[e.name],othersOption:e.type_info.meta.othersOption,othersRequired:e.type_info.meta.othersRequired});case"INPUT":case"TEXT":return e.type_info?.meta?.readOnly?t.createElement("div",{className:"message-container"},e.type_info?.meta?.value):t.createElement("div",{className:"responsive-text-field"},t.createElement(u,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)}),t.createElement(p,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return t.createElement(p,{autoFocus:o,label:"",isRequired:e.is_required,value:n[e.name]||"",onChange:e=>r(e.target.value)});default:return console.error(`Question type ${e.type_info.question_type} not found`),null}};o(":root {\n --widget-container-width: 350px;\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 .thankyou .text {\n white-space: pre-wrap;\n font-weight: 500;\n font-size: 1.2rem;\n line-height: 2;\n color: #12344d;\n}\n.freemium-survey-components .thankyou .redirection-text {\n color: #929292;\n margin-bottom: 12px;\n font-weight: 300;\n}\n.freemium-survey-components .thankyou .link {\n width: 100%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: #666;\n font-weight: 500;\n text-decoration: underline;\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 .action-buttons:empty {\n display: none;\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: 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.freemium-survey-components .message-container:empty {\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 height: 100%;\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 margin-bottom: 0;\n}\n.widget-survey-components .prev-button {\n border: none;\n background: transparent;\n position: absolute;\n left: 12px;\n display: inline;\n display: initial;\n cursor: pointer;\n padding: 12px;\n}\n.widget-survey-components .prev-button:hover {\n text-decoration: underline;\n}\n.widget-survey-components .submit {\n padding-bottom: 0;\n}\n\n.widget-survey-components.default-style .question-container {\n grid-gap: 24px;\n gap: 24px;\n padding: 16px 28px;\n}\n.widget-survey-components.default-style .action-button {\n line-height: 1.2;\n}\n.widget-survey-components.default-style .radio-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .radio-group .radio-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style .checkbox-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .checkbox-group .checkbox-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style textarea {\n min-height: 84px;\n}\n.widget-survey-components.default-style .end-max-length {\n font-size: 0.8rem;\n font-weight: 300;\n}");const w=()=>t.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{d:"M7.82585 6.15754C7.98999 6.32147 8.08232 6.54389 8.08252 6.77587L8.08252 7.2192C8.07983 7.45069 7.98788 7.6722 7.82585 7.83754L1.82919 13.8225C1.77496 13.8772 1.71044 13.9206 1.63936 13.9502C1.56827 13.9798 1.49203 13.9951 1.41502 13.9951C1.33801 13.9951 1.26177 13.9798 1.19068 13.9502C1.1196 13.9206 1.05508 13.8772 1.00085 13.8225L0.172521 12.9942C0.118197 12.941 0.0750381 12.8774 0.0455752 12.8073C0.0161124 12.7372 0.000937578 12.6619 0.000937585 12.5859C0.000937592 12.5098 0.0161125 12.4345 0.0455753 12.3644C0.0750381 12.2943 0.118197 12.2308 0.172521 12.1775L5.36419 6.99754L0.172522 1.81754C0.117847 1.76331 0.0744506 1.69879 0.0448352 1.62771C0.0152208 1.55662 -2.75162e-05 1.48038 -2.75094e-05 1.40337C-2.75027e-05 1.32636 0.0152208 1.25012 0.0448353 1.17904C0.0744507 1.10795 0.117847 1.04343 0.172522 0.989205L1.00086 0.172537C1.05508 0.117862 1.1196 0.0744661 1.19069 0.0448507C1.26177 0.0152353 1.33801 -1.20337e-05 1.41502 -1.2027e-05C1.49203 -1.20203e-05 1.56827 0.0152353 1.63936 0.0448507C1.71044 0.0744661 1.77496 0.117862 1.82919 0.172537L7.82585 6.15754Z",fill:"#6B6B6B"})),k=()=>t.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{d:"M0.256667 7.83755C0.0925257 7.67361 0.000204227 7.4512 0 7.21921V6.77588C0.00268801 6.5444 0.0946357 6.32289 0.256667 6.15755L6.25333 0.172549C6.30756 0.117874 6.37208 0.0744776 6.44316 0.0448625C6.51425 0.0152474 6.59049 0 6.6675 0C6.74451 0 6.82075 0.0152474 6.89184 0.0448625C6.96292 0.0744776 7.02744 0.117874 7.08167 0.172549L7.91 1.00088C7.96432 1.05411 8.00748 1.11764 8.03694 1.18776C8.06641 1.25787 8.08158 1.33316 8.08158 1.40922C8.08158 1.48527 8.06641 1.56056 8.03694 1.63067C8.00748 1.70079 7.96432 1.76432 7.91 1.81755L2.71833 6.99755L7.91 12.1775C7.96467 12.2318 8.00807 12.2963 8.03769 12.3674C8.0673 12.4385 8.08255 12.5147 8.08255 12.5917C8.08255 12.6687 8.0673 12.745 8.03769 12.8161C8.00807 12.8871 7.96467 12.9517 7.91 13.0059L7.08167 13.8225C7.02744 13.8772 6.96292 13.9206 6.89184 13.9502C6.82075 13.9799 6.74451 13.9951 6.6675 13.9951C6.59049 13.9951 6.51425 13.9799 6.44316 13.9502C6.37208 13.9206 6.30756 13.8772 6.25333 13.8225L0.256667 7.83755Z",fill:"#6B6B6B"})),E=["RANGE","NPS","RADIO","DROPDOWN"],q=200,C=({thankYouQuestion:e,preview:r})=>(n.useEffect((()=>{r||e.type_info.meta.redirectUrl&&setTimeout((()=>{window.location.href=e.type_info.meta.redirectUrl}),1e4)}),[]),t.createElement("div",{className:"question-container thankyou"},t.createElement("div",{className:"text"},e.text),e.type_info.meta.redirectUrl&&t.createElement("div",{style:{width:"100%"}},t.createElement("div",{className:"redirection-text"},"You will be redirected to the below URL automatically in 10 seconds.",t.createElement("br",null)),t.createElement("a",{className:"link",href:e.type_info.meta.redirectUrl},e?.type_info.meta.redirectUrl))));exports.AUTO_REDIRECT_DELAY=1e4,exports.BUTTON_SIZE_VARIANTS={LARGE:"large",MINI:"mini",NORMAL:"normal"},exports.Button=b,exports.CheckboxGroup=m,exports.Input=u,exports.NPS=i,exports.ProgressBar=v,exports.Radio=g,exports.RadioGroup=f,exports.Survey=({survey:e,onSubmit:o,widget:i,surveyContainerWidth:a=0,npsValue:s,widgetStyle:c,widgetNavigatorQuerySelector:l,preview:u})=>{const{meta:{blocks:p},question_details:{questions:d}}=e,[m,h]=n.useState({}),[f,g]=n.useState(!1),[x,N]=n.useState([]),[_,R]=n.useState(0),[S,L]=n.useState(!1),[z,T]=n.useState(null),O=n.useRef(null),F=n.useRef(null),$=n.useRef(null),A=n.useRef(0),B=n.useRef(!1),I=n.useRef([]);n.useEffect((()=>{if(p)if(F.current=d.find((e=>e.pivot_question))??d.find((e=>"RANGE"===e.type_info.question_type))??d[0],s){const e=d.find((e=>e.name===p[0].question_names[0]));O.current=p[0],I.current=[...I.current,{...p[0],question:e}],N(I.current),h({Q_1:s})}else if(!O.current&&p.length>0)return O.current=p[0],void j(p[0])}),[p,s]),n.useEffect((()=>{i||$.current?.scrollIntoView({block:"center",behavior:"smooth"}),x.length&&(I.current=x),R(x.length-1)}),[x]),n.useEffect((()=>{Object.keys(m).length>0&&O.current.question&&(E.includes(O.current.question.type_info.question_type)||B.current)&&!P()&&H()}),[m]),n.useEffect((()=>{const e=p.find((e=>"T_1"===e.name));if(m?.[F.current?.name])if(e.is_based_on_score){const n=F.current?.type_info?.choices[m?.[F.current?.name]]?.dependent_question_names,t=e.question_names.find((e=>n?.includes(e))),r=d.find((e=>e.name===t));T(r)}else{const n=d.find((n=>n.name===e.question_names[0]));T(n)}}),[m?.[F.current?.name]]);const P=()=>A.current===p.filter((e=>"T_1"!==e.name)).length-1||"end"===O.current.branchOption,j=e=>{let n={};if(e.is_based_on_score){const t=F.current?.type_info?.choices[m?.[F.current?.name]]?.dependent_question_names,r=e.question_names.find((e=>t?.includes(e)));n=d.find((e=>e.name===r))}else n=d.find((n=>n.name===e.question_names[0]));O.current.question=n;const t=I.current.find((e=>e.question.name===n.name));N(t?[...I.current]:[...I.current,{...e,question:n}])},H=()=>{if(P())g(!0);else{if(O.current.nextBlock)A.current=p.findIndex((e=>e.name===O.current.nextBlock));else if(O.current.question.type_info?.meta?.branches){const e=O.current.question.type_info?.meta?.branches,n=m[O.current.question.name];let t;t="RANGE"===O.current.type?e.find((e=>n>=e.min&&n<=e.max)):e.find((e=>n===e.value)),t?.nextBlock?A.current=p.findIndex((e=>e.name===t.nextBlock)):A.current+=1}else A.current+=1;O.current=p[A.current],j(p[A.current])}},D=(e,n)=>{B.current=!0,delete m[n.name],h({...m})},U=(e,n,t)=>{if(t)if(B.current=!0,null!=m[e.question.name]&&e.name!==x[x.length-1].name){const[t,r]=(e=>{const n=x.findIndex((n=>n.name===e.name)),t=x.slice(0,n+1),r=t.reduce(((e,n)=>(e[n.question.name]=m[n.question.name],e)),{});return A.current=p.findIndex((n=>n.name===e.name)),[t,r]})(e);h({...r,...null!=n&&{[e.question.name]:n}}),I.current=t}else h({...m,...null!=n&&{[e.question.name]:n}});else h({...m,...null!=n&&{[e.question.name]:n}})};return O.current&&O.current.question?f?t.createElement("div",{className:"freemium-survey-components "+(i?"widget-survey-components":"")},t.createElement(C,{thankYouQuestion:z,preview:u})):t.createElement("div",{className:`freemium-survey-components ${i?"widget-survey-components":""} ${c}-style`,style:{"--widget-container-width":a}},!i&&t.createElement(v,{totalSteps:p.length,completedSteps:A.current}),i&&document.querySelector(l)&&t.createElement(t.Fragment,null,r.createPortal(t.createElement("div",{className:"navigation","data-navigation-element":"1"},t.createElement("button",{style:0==A.current?{visibility:"hidden"}:{},className:"navigate-button",onClick:()=>{A.current=Math.max(A.current-1,0),R(A.current)}},t.createElement(k,null)),t.createElement("span",{className:"navigation-text"}," Question ",A.current+1," of"," ",x.length," ")," ",t.createElement("button",{className:"navigate-button",style:A.current>=x.length-1?{visibility:"hidden"}:{},onClick:()=>{A.current=Math.min(A.current+1,x.length-1),R(A.current)}},t.createElement(w,null))),document.querySelector(l))),t.createElement("div",{style:i?{transform:`translateX(-${_*a}px)`,transition:`transform ${q}ms linear`}:{},className:"questions"},x.map(((e,n)=>{return t.createElement("div",{className:"question-container",ref:$,id:e.title,key:e.title},t.createElement("div",{className:"question-text"},e.question.text),t.createElement(y,{question:e.question,formValues:m,autoFocus:O.current.name===e.name,onChangeHandler:n=>{B.current=!1,A.current=p.findIndex((n=>n.name===e.name)),O.current=e,U(e,n,E.includes(e.question.type_info.question_type)&&!P())}}),t.createElement("div",{className:"action-buttons",style:i?{margin:"0 auto"}:{}},(r=e.question,r.name===O.current.question.name&&!E.includes(r.type_info.question_type)&&!P()&&t.createElement(b,{onClick:()=>{B.current?(A.current=Math.min(A.current+1,x.length-1),O.current=x[n+1],R(A.current)):U(e,null,!0)},disabled:!m[O.current.question.name]||Array.isArray(m[O.current.question.name])&&0===m[O.current.question.name].length,className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===O.current.question.name&&!P())(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:()=>D(0,e.question)},"Skip"),((e,n)=>!("DROPDOWN"!==n.type_info.question_type||n.name===O.current.question.name||n.required||!m[n.name]))(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:()=>{O.current=e,A.current=p.findIndex((n=>n.name===e.name)),D(0,e.question)}},"Clear selection"),i&&(e=>P()&&e.name===O.current.question.name)(e.question)&&t.createElement("div",{className:"submit",style:{margin:"0 auto"}},t.createElement(b,{disabled:O.current.question.required&&void 0===m[O.current.question.name]||S,onClick:()=>{L(!0),o(m),z?.type_info.meta.skipThankYouPage||g(!0)}},S?"Submitting":"Submit Survey"))));var r})),!i&&P()&&t.createElement("div",{className:"submit"},t.createElement(b,{disabled:O.current.question.required&&void 0===m[O.current.question.name]||S,onClick:()=>{L(!0),o(m,(()=>{u||z?.type_info.meta.skipThankYouPage&&(window.location.href=z?.type_info.meta.redirectUrl)})),z?.type_info.meta.skipThankYouPage||g(!0)}},S?"Submitting":"Submit Survey")))):null},exports.TRANSITION_DELAY=q,exports.TextArea=p;
package/lib/index.esm.js CHANGED
@@ -1 +1 @@
1
- import e,{useRef as n,forwardRef as t,useEffect as r,useState as o}from"react";import i from"react-dom";function a(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))}}a(".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 c=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))},s=(e,n)=>(e.defaultProps=n,e);a('.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 l={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!0},u=t(((t,o)=>{const i=n(null);r((()=>{t.autoFocus&&setTimeout((()=>{i.current?.focus()}),_+20)}),[t.autoFocus]);const{inputStyle:a,style:c,className:s,showCount:l,isErrored:u,startLabel:p,isRequired:d,errorText:m,endLabel:h,maxLength:f,autoFocus:g,...v}=t;return e.createElement("div",{className:"input-container",style:c},t.label&&e.createElement("label",{className:"input-label "+(d?"required":"")},t.label),e.createElement("div",null,p&&e.createElement("div",{className:"start-label"},p),e.createElement("div",{className:`input-basic ${u?"error":""}${s||""}`},e.createElement("input",Object.assign({type:"text",autoComplete:"off",ref:i,style:a},v)),l&&f>0&&e.createElement("div",{className:"end-max-length"},`${t.value&&t.value.length||0}/${t.maxLength}`)),h&&e.createElement("div",{className:"end-label"},h)),u&&m&&e.createElement("span",{className:"input-error"},t.errorText))})),p=t(((t,o)=>{const i=n(null);r((()=>{console.log("props.autoFocus...",t.autoFocus),t.autoFocus&&setTimeout((()=>{i.current?.focus()}),_+20)}),[]);const{inputStyle:a,style:c,className:s,showCount:l,maxLength:u,isErrored:p,startLabel:d,isRequired:m,autoFocus:h,...f}=t;return e.createElement(e.Fragment,null,e.createElement("div",{className:"textarea-container",style:c},t.label&&e.createElement("label",{className:"input-label "+(m?"required":"")},t.label),d&&e.createElement("div",{className:"start-label"},d),e.createElement("div",{className:`input-basic ${p?"error":""} ${s||""}`},e.createElement("textarea",Object.assign({autoComplete:"off",ref:i,style:a},f)),l&&u&&u>0&&e.createElement("div",{className:"end-max-length"},`${t.value&&t.value.length||0}/${t.maxLength}`)),t.endLabel&&e.createElement("div",{className:"end-label"},t.endLabel)),t.isErrored&&t.errorText&&e.createElement("span",{className:"input-error"},t.errorText))})),d=s(u,l),m=s(p,l);a('.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: 16px;\n background-color: #fff;\n border: 1px solid;\n text-align: left;\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 h=()=>e.createElement("svg",{id:"tick",className:"tick-icon",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"title",viewBox:"0 0 10 10"},e.createElement("path",{d:"M3 5.87c-.18666814.00267463-.36667109-.06932655-.5-.2L.21 3.41c-.1786328-.17863279-.24839684-.43899577-.1830127-.6830127.06538414-.24401694.25598306-.43461586.5-.5C.77100423 2.16160316 1.0313672 2.23136721 1.21 2.41L3 4.18 6.8.33c.27679776-.27455556.72320224-.27455556 1 0 .13696438.13025306.21450026.31098915.21450026.5S7.93696438 1.19974694 7.8 1.33L3.45 5.67c-.12082534.11896945-.28072735.19003701-.45.2Z",fill:"#fff",fillRule:"evenodd"})),f=({values:n,options:t,onChangeHandler:r,autoFocus:o})=>e.createElement("div",{className:"checkbox-group"},t.map(((t,i)=>e.createElement(g,{key:t.value,checked:n?.includes(t.value),name:t.value,id:t.value,autoFocus:0===i&&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.value)))),g=s((t=>{const o=n(null);return r((()=>{t.autoFocus&&setTimeout((()=>{o.current?.focus()}),_+20)}),[]),e.createElement("label",{className:`checkbox-label ${t.disabled&&"disabled"}`},e.createElement("input",{ref:o,id:t.id,type:"checkbox",name:t.name,readOnly:t.readOnly,disabled:t.disabled,"aria-disabled":t.disabled,checked:t.checked,onChange:t.readOnly?()=>{}:e=>t.onChange(e,e.target.checked)}),e.createElement("div",{className:"checkbox"},t.checked&&e.createElement("div",{className:"icon-container"},e.createElement(h,null)," ")),e.createElement("div",null,t.children))}),{checked:!1});a('.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: 16px;\n text-align: left;\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:i,autoFocus:a,onChangeHandler:c,othersOption:s,othersRequired:l})=>{const[u,p]=o(""),[m,h]=o("");return r((()=>{i||(h(""),p(""))}),[i]),r((()=>{m&&t.find((e=>e.value===m))&&c(m)}),[m]),e.createElement("div",{className:"radio-group"},t.map(((t,r)=>e.createElement(b,{key:t.value,value:t.value,name:n,onChange:e=>{h(e.currentTarget.value)},autoFocus:0===r&&a,checked:m===t.value},t.value))),s&&e.createElement(b,{key:"others",value:"others",name:n,onChange:e=>{h("others")},checked:"others"===m},"others"),"others"===m&&e.createElement(e.Fragment,null,e.createElement(d,{placeholder:"",value:u,onChange:e=>p(e.target.value),label:""}),u!==i&&e.createElement(k,{disabled:l&&0===u.length,onClick:()=>c(u)},"Next")))},b=s((t=>{const o=n(null);return r((()=>{t.autoFocus&&setTimeout((()=>{o.current?.focus()}),_+20)}),[]),e.createElement("label",{className:"radio-label"},e.createElement("input",{ref:o,type:"radio",name:t.name,value:t.value,checked:t.checked,onChange:t.onChange}),e.createElement("div",{className:"radio"}),e.createElement("div",null,t.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\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 x=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})`}}))};a(".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 /* 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 y=()=>e.createElement(e.Fragment,null,"..."),w={LARGE:"large",MINI:"mini",NORMAL:"normal"},k=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(y,null):r)},E=({question:n,formValues:t,onChangeHandler:r,autoFocus:o})=>{switch(n.type_info.question_type){case"RANGE":return e.createElement(c,{type_info:n.type_info,onChangeHandler:r,npsValue:t[n.name]});case"CHECKBOX":return e.createElement(f,{autoFocus:o,values:t[n.name],options:n.type_info.choices,onChangeHandler:r});case"RADIO":case"DROPDOWN":return e.createElement(v,{autoFocus:o,name:n.name,onChangeHandler:r,options:n.type_info.choices,value:t[n.name],othersOption:n.type_info.meta.othersOption,othersRequired:n.type_info.meta.othersRequired});case"INPUT":case"TEXT":return n.type_info?.meta?.readOnly?e.createElement("div",{className:"message-container"},n.type_info?.meta?.value):e.createElement("div",{className:"responsive-text-field"},e.createElement(d,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)}),e.createElement(m,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return e.createElement(m,{autoFocus:o,label:"",isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)});default:return console.error(`Question type ${n.type_info.question_type} not found`),null}};a(":root {\n --widget-container-width: 350px;\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 .thankyou .text {\n white-space: pre-wrap;\n font-weight: 500;\n font-size: 1.2rem;\n line-height: 2;\n color: #12344d;\n}\n.freemium-survey-components .thankyou .redirection-text {\n color: #929292;\n margin-bottom: 12px;\n font-weight: 300;\n}\n.freemium-survey-components .thankyou .link {\n width: 100%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: #666;\n font-weight: 500;\n text-decoration: underline;\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 .action-buttons:empty {\n display: none;\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: 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.freemium-survey-components .message-container:empty {\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 height: 100%;\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 margin-bottom: 0;\n}\n.widget-survey-components .prev-button {\n border: none;\n background: transparent;\n position: absolute;\n left: 12px;\n display: inline;\n display: initial;\n cursor: pointer;\n padding: 12px;\n}\n.widget-survey-components .prev-button:hover {\n text-decoration: underline;\n}\n.widget-survey-components .submit {\n padding-bottom: 0;\n}\n\n.widget-survey-components.default-style .question-container {\n grid-gap: 24px;\n gap: 24px;\n padding: 16px 28px;\n}\n.widget-survey-components.default-style .action-button {\n line-height: 1.2;\n}\n.widget-survey-components.default-style .radio-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .radio-group .radio-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style .checkbox-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .checkbox-group .checkbox-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style textarea {\n min-height: 84px;\n}\n.widget-survey-components.default-style .end-max-length {\n font-size: 0.8rem;\n font-weight: 300;\n}");const q=()=>e.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M7.82585 6.15754C7.98999 6.32147 8.08232 6.54389 8.08252 6.77587L8.08252 7.2192C8.07983 7.45069 7.98788 7.6722 7.82585 7.83754L1.82919 13.8225C1.77496 13.8772 1.71044 13.9206 1.63936 13.9502C1.56827 13.9798 1.49203 13.9951 1.41502 13.9951C1.33801 13.9951 1.26177 13.9798 1.19068 13.9502C1.1196 13.9206 1.05508 13.8772 1.00085 13.8225L0.172521 12.9942C0.118197 12.941 0.0750381 12.8774 0.0455752 12.8073C0.0161124 12.7372 0.000937578 12.6619 0.000937585 12.5859C0.000937592 12.5098 0.0161125 12.4345 0.0455753 12.3644C0.0750381 12.2943 0.118197 12.2308 0.172521 12.1775L5.36419 6.99754L0.172522 1.81754C0.117847 1.76331 0.0744506 1.69879 0.0448352 1.62771C0.0152208 1.55662 -2.75162e-05 1.48038 -2.75094e-05 1.40337C-2.75027e-05 1.32636 0.0152208 1.25012 0.0448353 1.17904C0.0744507 1.10795 0.117847 1.04343 0.172522 0.989205L1.00086 0.172537C1.05508 0.117862 1.1196 0.0744661 1.19069 0.0448507C1.26177 0.0152353 1.33801 -1.20337e-05 1.41502 -1.2027e-05C1.49203 -1.20203e-05 1.56827 0.0152353 1.63936 0.0448507C1.71044 0.0744661 1.77496 0.117862 1.82919 0.172537L7.82585 6.15754Z",fill:"#6B6B6B"})),C=()=>e.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M0.256667 7.83755C0.0925257 7.67361 0.000204227 7.4512 0 7.21921V6.77588C0.00268801 6.5444 0.0946357 6.32289 0.256667 6.15755L6.25333 0.172549C6.30756 0.117874 6.37208 0.0744776 6.44316 0.0448625C6.51425 0.0152474 6.59049 0 6.6675 0C6.74451 0 6.82075 0.0152474 6.89184 0.0448625C6.96292 0.0744776 7.02744 0.117874 7.08167 0.172549L7.91 1.00088C7.96432 1.05411 8.00748 1.11764 8.03694 1.18776C8.06641 1.25787 8.08158 1.33316 8.08158 1.40922C8.08158 1.48527 8.06641 1.56056 8.03694 1.63067C8.00748 1.70079 7.96432 1.76432 7.91 1.81755L2.71833 6.99755L7.91 12.1775C7.96467 12.2318 8.00807 12.2963 8.03769 12.3674C8.0673 12.4385 8.08255 12.5147 8.08255 12.5917C8.08255 12.6687 8.0673 12.745 8.03769 12.8161C8.00807 12.8871 7.96467 12.9517 7.91 13.0059L7.08167 13.8225C7.02744 13.8772 6.96292 13.9206 6.89184 13.9502C6.82075 13.9799 6.74451 13.9951 6.6675 13.9951C6.59049 13.9951 6.51425 13.9799 6.44316 13.9502C6.37208 13.9206 6.30756 13.8772 6.25333 13.8225L0.256667 7.83755Z",fill:"#6B6B6B"})),N=["RANGE","NPS","RADIO","DROPDOWN"],_=200,z=1e4,L=({thankYouQuestion:n})=>(r((()=>{setTimeout((()=>{window.location.href=n.type_info.meta.redirectUrl}),1e4)}),[]),e.createElement("div",{className:"question-container thankyou"},e.createElement("div",{className:"text"},n.text),e.createElement("div",{style:{width:"100%"}},e.createElement("div",{className:"redirection-text"},"You will be redirected to the below URL automatically in 10 seconds.",e.createElement("br",null)),e.createElement("a",{className:"link",href:n.type_info.meta.redirectUrl},n?.type_info.meta.redirectUrl)))),F=({survey:t,onSubmit:a,widget:c,surveyContainerWidth:s=0,npsValue:l,widgetStyle:u,widgetNavigatorQuerySelector:p})=>{const{meta:{blocks:d},question_details:{questions:m}}=t,[h,f]=o({}),[g,v]=o(!1),[b,y]=o([]),[w,z]=o(0),[F,$]=o(!1),[R,O]=o(null),S=n(null),T=n(null),A=n(null),B=n(0),H=n(!1),I=n([]);r((()=>{if(d)if(T.current=m.find((e=>e.pivot_question))??m.find((e=>"RANGE"===e.type_info.question_type))??m[0],l){const e=m.find((e=>e.name===d[0].question_names[0]));S.current=d[0],I.current=[...I.current,{...d[0],question:e}],y(I.current),f({Q_1:l})}else if(!S.current&&d.length>0)return S.current=d[0],void j(d[0])}),[d,l]),r((()=>{c||A.current?.scrollIntoView({block:"center",behavior:"smooth"}),b.length&&(I.current=b),z(b.length-1)}),[b]),r((()=>{Object.keys(h).length>0&&S.current.question&&(N.includes(S.current.question.type_info.question_type)||H.current)&&!P()&&D()}),[h]),r((()=>{if(h?.[T.current?.name]){const e=d.find((e=>"T_1"===e.name));if(e.is_based_on_score){const n=T.current?.type_info?.choices[h?.[T.current?.name]]?.dependent_question_names,t=e.question_names.find((e=>n?.includes(e))),r=m.find((e=>e.name===t));O(r)}}}),[h?.[T.current?.name]]);const P=()=>B.current===d.filter((e=>"T_1"!==e.name)).length-1||"end"===S.current.branchOption,j=e=>{let n={};if(e.is_based_on_score){const t=T.current?.type_info?.choices[h?.[T.current?.name]]?.dependent_question_names,r=e.question_names.find((e=>t?.includes(e)));n=m.find((e=>e.name===r))}else n=m.find((n=>n.name===e.question_names[0]));S.current.question=n;const t=I.current.find((e=>e.question.name===n.name));y(t?[...I.current]:[...I.current,{...e,question:n}])},D=()=>{if(P())v(!0);else{if(S.current.nextBlock)B.current=d.findIndex((e=>e.name===S.current.nextBlock));else if(S.current.question.type_info?.meta?.branches){const e=S.current.question.type_info?.meta?.branches,n=h[S.current.question.name];let t;t="RANGE"===S.current.type?e.find((e=>n>=e.min&&n<=e.max)):e.find((e=>n===e.value)),t?.nextBlock?B.current=d.findIndex((e=>e.name===t.nextBlock)):B.current+=1}else B.current+=1;S.current=d[B.current],j(d[B.current])}},M=(e,n)=>{H.current=!0,delete h[n.name],f({...h})},G=(e,n,t)=>{if(t)if(H.current=!0,null!=h[e.question.name]&&e.name!==b[b.length-1].name){const[t,r]=(e=>{const n=b.findIndex((n=>n.name===e.name)),t=b.slice(0,n+1),r=t.reduce(((e,n)=>(e[n.question.name]=h[n.question.name],e)),{});return B.current=d.findIndex((n=>n.name===e.name)),[t,r]})(e);f({...r,...null!=n&&{[e.question.name]:n}}),I.current=t}else f({...h,...null!=n&&{[e.question.name]:n}});else f({...h,...null!=n&&{[e.question.name]:n}})};return S.current&&S.current.question?g?e.createElement("div",{className:"freemium-survey-components "+(c?"widget-survey-components":"")},e.createElement(L,{thankYouQuestion:R})):e.createElement("div",{className:`freemium-survey-components ${c?"widget-survey-components":""} ${u}-style`,style:{"--widget-container-width":s}},!c&&e.createElement(x,{totalSteps:d.length,completedSteps:B.current}),c&&document.querySelector(p)&&e.createElement(e.Fragment,null,i.createPortal(e.createElement("div",{className:"navigation","data-navigation-element":"1"},e.createElement("button",{style:0==B.current?{visibility:"hidden"}:{},className:"navigate-button",onClick:()=>{B.current=Math.max(B.current-1,0),z(B.current)}},e.createElement(C,null)),e.createElement("span",{className:"navigation-text"}," Question ",B.current+1," of"," ",b.length," ")," ",e.createElement("button",{className:"navigate-button",style:B.current>=b.length-1?{visibility:"hidden"}:{},onClick:()=>{B.current=Math.min(B.current+1,b.length-1),z(B.current)}},e.createElement(q,null))),document.querySelector(p))),e.createElement("div",{style:c?{transform:`translateX(-${w*s}px)`,transition:`transform ${_}ms linear`}:{},className:"questions"},b.map(((n,t)=>{return e.createElement("div",{className:"question-container",ref:A,id:n.title,key:n.title},e.createElement("div",{className:"question-text"},n.question.text),e.createElement(E,{question:n.question,formValues:h,autoFocus:S.current.name===n.name,onChangeHandler:e=>{H.current=!1,B.current=d.findIndex((e=>e.name===n.name)),S.current=n,G(n,e,N.includes(n.question.type_info.question_type)&&!P())}}),e.createElement("div",{className:"action-buttons",style:c?{margin:"0 auto"}:{}},(r=n.question,r.name===S.current.question.name&&!N.includes(r.type_info.question_type)&&!P()&&e.createElement(k,{onClick:()=>{H.current?(B.current=Math.min(B.current+1,b.length-1),S.current=b[t+1],z(B.current)):G(n,null,!0)},disabled:!h[S.current.question.name]||Array.isArray(h[S.current.question.name])&&0===h[S.current.question.name].length,className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===S.current.question.name&&!P())(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:()=>M(0,n.question)},"Skip"),((e,n)=>!("DROPDOWN"!==n.type_info.question_type||n.name===S.current.question.name||n.required||!h[n.name]))(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:()=>{S.current=n,B.current=d.findIndex((e=>e.name===n.name)),M(0,n.question)}},"Clear selection"),c&&(e=>P()&&e.name===S.current.question.name)(n.question)&&e.createElement("div",{className:"submit",style:{margin:"0 auto"}},e.createElement(k,{disabled:S.current.question.required&&void 0===h[S.current.question.name]||F,onClick:()=>{$(!0),a(h),R?.type_info.meta.skipThankYouPage||v(!0)}},F?"Submitting":"Submit Survey"))));var r})),!c&&P()&&e.createElement("div",{className:"submit"},e.createElement(k,{disabled:S.current.question.required&&void 0===h[S.current.question.name]||F,onClick:()=>{$(!0),a(h,(()=>{R?.type_info.meta.skipThankYouPage&&(window.location.href=R?.type_info.meta.redirectUrl)})),R?.type_info.meta.skipThankYouPage||v(!0)}},F?"Submitting":"Submit Survey")))):null};export{z as AUTO_REDIRECT_DELAY,w as BUTTON_SIZE_VARIANTS,k as Button,f as CheckboxGroup,d as Input,c as NPS,x as ProgressBar,b as Radio,v as RadioGroup,F as Survey,_ as TRANSITION_DELAY,m as TextArea};
1
+ import e,{useRef as n,forwardRef as t,useEffect as r,useState as o}from"react";import i from"react-dom";function a(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))}}a(".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 c=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))},s=(e,n)=>(e.defaultProps=n,e);a('.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 l={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!0},u=t(((t,o)=>{const i=n(null);r((()=>{t.autoFocus&&setTimeout((()=>{i.current?.focus()}),_+20)}),[t.autoFocus]);const{inputStyle:a,style:c,className:s,showCount:l,isErrored:u,startLabel:p,isRequired:d,errorText:m,endLabel:h,maxLength:f,autoFocus:g,...v}=t;return e.createElement("div",{className:"input-container",style:c},t.label&&e.createElement("label",{className:"input-label "+(d?"required":"")},t.label),e.createElement("div",null,p&&e.createElement("div",{className:"start-label"},p),e.createElement("div",{className:`input-basic ${u?"error":""}${s||""}`},e.createElement("input",Object.assign({type:"text",autoComplete:"off",ref:i,style:a},v)),l&&f>0&&e.createElement("div",{className:"end-max-length"},`${t.value&&t.value.length||0}/${t.maxLength}`)),h&&e.createElement("div",{className:"end-label"},h)),u&&m&&e.createElement("span",{className:"input-error"},t.errorText))})),p=t(((t,o)=>{const i=n(null);r((()=>{console.log("props.autoFocus...",t.autoFocus),t.autoFocus&&setTimeout((()=>{i.current?.focus()}),_+20)}),[]);const{inputStyle:a,style:c,className:s,showCount:l,maxLength:u,isErrored:p,startLabel:d,isRequired:m,autoFocus:h,...f}=t;return e.createElement(e.Fragment,null,e.createElement("div",{className:"textarea-container",style:c},t.label&&e.createElement("label",{className:"input-label "+(m?"required":"")},t.label),d&&e.createElement("div",{className:"start-label"},d),e.createElement("div",{className:`input-basic ${p?"error":""} ${s||""}`},e.createElement("textarea",Object.assign({autoComplete:"off",ref:i,style:a},f)),l&&u&&u>0&&e.createElement("div",{className:"end-max-length"},`${t.value&&t.value.length||0}/${t.maxLength}`)),t.endLabel&&e.createElement("div",{className:"end-label"},t.endLabel)),t.isErrored&&t.errorText&&e.createElement("span",{className:"input-error"},t.errorText))})),d=s(u,l),m=s(p,l);a('.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: 16px;\n background-color: #fff;\n border: 1px solid;\n text-align: left;\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 h=()=>e.createElement("svg",{id:"tick",className:"tick-icon",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"title",viewBox:"0 0 10 10"},e.createElement("path",{d:"M3 5.87c-.18666814.00267463-.36667109-.06932655-.5-.2L.21 3.41c-.1786328-.17863279-.24839684-.43899577-.1830127-.6830127.06538414-.24401694.25598306-.43461586.5-.5C.77100423 2.16160316 1.0313672 2.23136721 1.21 2.41L3 4.18 6.8.33c.27679776-.27455556.72320224-.27455556 1 0 .13696438.13025306.21450026.31098915.21450026.5S7.93696438 1.19974694 7.8 1.33L3.45 5.67c-.12082534.11896945-.28072735.19003701-.45.2Z",fill:"#fff",fillRule:"evenodd"})),f=({values:n,options:t,onChangeHandler:r,autoFocus:o})=>e.createElement("div",{className:"checkbox-group"},t.map(((t,i)=>e.createElement(g,{key:t.value,checked:n?.includes(t.value),name:t.value,id:t.value,autoFocus:0===i&&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.value)))),g=s((t=>{const o=n(null);return r((()=>{t.autoFocus&&setTimeout((()=>{o.current?.focus()}),_+20)}),[]),e.createElement("label",{className:`checkbox-label ${t.disabled&&"disabled"}`},e.createElement("input",{ref:o,id:t.id,type:"checkbox",name:t.name,readOnly:t.readOnly,disabled:t.disabled,"aria-disabled":t.disabled,checked:t.checked,onChange:t.readOnly?()=>{}:e=>t.onChange(e,e.target.checked)}),e.createElement("div",{className:"checkbox"},t.checked&&e.createElement("div",{className:"icon-container"},e.createElement(h,null)," ")),e.createElement("div",null,t.children))}),{checked:!1});a('.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: 16px;\n text-align: left;\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:i,autoFocus:a,onChangeHandler:c,othersOption:s,othersRequired:l})=>{const[u,p]=o(""),[m,h]=o("");return r((()=>{i||(h(""),p(""))}),[i]),r((()=>{m&&t.find((e=>e.value===m))&&c(m)}),[m]),e.createElement("div",{className:"radio-group"},t.map(((t,r)=>e.createElement(b,{key:t.value,value:t.value,name:n,onChange:e=>{h(e.currentTarget.value)},autoFocus:0===r&&a,checked:m===t.value},t.value))),s&&e.createElement(b,{key:"others",value:"others",name:n,onChange:e=>{h("others")},checked:"others"===m},"others"),"others"===m&&e.createElement(e.Fragment,null,e.createElement(d,{placeholder:"",value:u,onChange:e=>p(e.target.value),label:""}),u!==i&&e.createElement(k,{disabled:l&&0===u.length,onClick:()=>c(u)},"Next")))},b=s((t=>{const o=n(null);return r((()=>{t.autoFocus&&setTimeout((()=>{o.current?.focus()}),_+20)}),[]),e.createElement("label",{className:"radio-label"},e.createElement("input",{ref:o,type:"radio",name:t.name,value:t.value,checked:t.checked,onChange:t.onChange}),e.createElement("div",{className:"radio"}),e.createElement("div",null,t.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 text-align: left;\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 x=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})`}}))};a(".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 /* 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 y=()=>e.createElement(e.Fragment,null,"..."),w={LARGE:"large",MINI:"mini",NORMAL:"normal"},k=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(y,null):r)},E=({question:n,formValues:t,onChangeHandler:r,autoFocus:o})=>{switch(n.type_info.question_type){case"RANGE":return e.createElement(c,{type_info:n.type_info,onChangeHandler:r,npsValue:t[n.name]});case"CHECKBOX":return e.createElement(f,{autoFocus:o,values:t[n.name],options:n.type_info.choices,onChangeHandler:r});case"RADIO":case"DROPDOWN":return e.createElement(v,{autoFocus:o,name:n.name,onChangeHandler:r,options:n.type_info.choices,value:t[n.name],othersOption:n.type_info.meta.othersOption,othersRequired:n.type_info.meta.othersRequired});case"INPUT":case"TEXT":return n.type_info?.meta?.readOnly?e.createElement("div",{className:"message-container"},n.type_info?.meta?.value):e.createElement("div",{className:"responsive-text-field"},e.createElement(d,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)}),e.createElement(m,{autoFocus:o,label:"",maxLength:300,showCount:!0,isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)}));case"PARAGRAPH":return e.createElement(m,{autoFocus:o,label:"",isRequired:n.is_required,value:t[n.name]||"",onChange:e=>r(e.target.value)});default:return console.error(`Question type ${n.type_info.question_type} not found`),null}};a(":root {\n --widget-container-width: 350px;\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 .thankyou .text {\n white-space: pre-wrap;\n font-weight: 500;\n font-size: 1.2rem;\n line-height: 2;\n color: #12344d;\n}\n.freemium-survey-components .thankyou .redirection-text {\n color: #929292;\n margin-bottom: 12px;\n font-weight: 300;\n}\n.freemium-survey-components .thankyou .link {\n width: 100%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: #666;\n font-weight: 500;\n text-decoration: underline;\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 .action-buttons:empty {\n display: none;\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: 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.freemium-survey-components .message-container:empty {\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 height: 100%;\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 margin-bottom: 0;\n}\n.widget-survey-components .prev-button {\n border: none;\n background: transparent;\n position: absolute;\n left: 12px;\n display: inline;\n display: initial;\n cursor: pointer;\n padding: 12px;\n}\n.widget-survey-components .prev-button:hover {\n text-decoration: underline;\n}\n.widget-survey-components .submit {\n padding-bottom: 0;\n}\n\n.widget-survey-components.default-style .question-container {\n grid-gap: 24px;\n gap: 24px;\n padding: 16px 28px;\n}\n.widget-survey-components.default-style .action-button {\n line-height: 1.2;\n}\n.widget-survey-components.default-style .radio-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .radio-group .radio-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style .checkbox-group {\n flex-direction: row;\n flex-wrap: wrap;\n overflow: auto;\n}\n.widget-survey-components.default-style .checkbox-group .checkbox-label {\n padding: 12px 16px;\n min-width: 160px;\n font-size: 0.9rem;\n}\n.widget-survey-components.default-style textarea {\n min-height: 84px;\n}\n.widget-survey-components.default-style .end-max-length {\n font-size: 0.8rem;\n font-weight: 300;\n}");const q=()=>e.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M7.82585 6.15754C7.98999 6.32147 8.08232 6.54389 8.08252 6.77587L8.08252 7.2192C8.07983 7.45069 7.98788 7.6722 7.82585 7.83754L1.82919 13.8225C1.77496 13.8772 1.71044 13.9206 1.63936 13.9502C1.56827 13.9798 1.49203 13.9951 1.41502 13.9951C1.33801 13.9951 1.26177 13.9798 1.19068 13.9502C1.1196 13.9206 1.05508 13.8772 1.00085 13.8225L0.172521 12.9942C0.118197 12.941 0.0750381 12.8774 0.0455752 12.8073C0.0161124 12.7372 0.000937578 12.6619 0.000937585 12.5859C0.000937592 12.5098 0.0161125 12.4345 0.0455753 12.3644C0.0750381 12.2943 0.118197 12.2308 0.172521 12.1775L5.36419 6.99754L0.172522 1.81754C0.117847 1.76331 0.0744506 1.69879 0.0448352 1.62771C0.0152208 1.55662 -2.75162e-05 1.48038 -2.75094e-05 1.40337C-2.75027e-05 1.32636 0.0152208 1.25012 0.0448353 1.17904C0.0744507 1.10795 0.117847 1.04343 0.172522 0.989205L1.00086 0.172537C1.05508 0.117862 1.1196 0.0744661 1.19069 0.0448507C1.26177 0.0152353 1.33801 -1.20337e-05 1.41502 -1.2027e-05C1.49203 -1.20203e-05 1.56827 0.0152353 1.63936 0.0448507C1.71044 0.0744661 1.77496 0.117862 1.82919 0.172537L7.82585 6.15754Z",fill:"#6B6B6B"})),C=()=>e.createElement("svg",{style:{display:"block"},width:"9",height:"14",viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M0.256667 7.83755C0.0925257 7.67361 0.000204227 7.4512 0 7.21921V6.77588C0.00268801 6.5444 0.0946357 6.32289 0.256667 6.15755L6.25333 0.172549C6.30756 0.117874 6.37208 0.0744776 6.44316 0.0448625C6.51425 0.0152474 6.59049 0 6.6675 0C6.74451 0 6.82075 0.0152474 6.89184 0.0448625C6.96292 0.0744776 7.02744 0.117874 7.08167 0.172549L7.91 1.00088C7.96432 1.05411 8.00748 1.11764 8.03694 1.18776C8.06641 1.25787 8.08158 1.33316 8.08158 1.40922C8.08158 1.48527 8.06641 1.56056 8.03694 1.63067C8.00748 1.70079 7.96432 1.76432 7.91 1.81755L2.71833 6.99755L7.91 12.1775C7.96467 12.2318 8.00807 12.2963 8.03769 12.3674C8.0673 12.4385 8.08255 12.5147 8.08255 12.5917C8.08255 12.6687 8.0673 12.745 8.03769 12.8161C8.00807 12.8871 7.96467 12.9517 7.91 13.0059L7.08167 13.8225C7.02744 13.8772 6.96292 13.9206 6.89184 13.9502C6.82075 13.9799 6.74451 13.9951 6.6675 13.9951C6.59049 13.9951 6.51425 13.9799 6.44316 13.9502C6.37208 13.9206 6.30756 13.8772 6.25333 13.8225L0.256667 7.83755Z",fill:"#6B6B6B"})),N=["RANGE","NPS","RADIO","DROPDOWN"],_=200,z=1e4,L=({thankYouQuestion:n,preview:t})=>(r((()=>{t||n.type_info.meta.redirectUrl&&setTimeout((()=>{window.location.href=n.type_info.meta.redirectUrl}),1e4)}),[]),e.createElement("div",{className:"question-container thankyou"},e.createElement("div",{className:"text"},n.text),n.type_info.meta.redirectUrl&&e.createElement("div",{style:{width:"100%"}},e.createElement("div",{className:"redirection-text"},"You will be redirected to the below URL automatically in 10 seconds.",e.createElement("br",null)),e.createElement("a",{className:"link",href:n.type_info.meta.redirectUrl},n?.type_info.meta.redirectUrl)))),F=({survey:t,onSubmit:a,widget:c,surveyContainerWidth:s=0,npsValue:l,widgetStyle:u,widgetNavigatorQuerySelector:p,preview:d})=>{const{meta:{blocks:m},question_details:{questions:h}}=t,[f,g]=o({}),[v,b]=o(!1),[y,w]=o([]),[z,F]=o(0),[$,R]=o(!1),[O,S]=o(null),T=n(null),A=n(null),B=n(null),H=n(0),I=n(!1),P=n([]);r((()=>{if(m)if(A.current=h.find((e=>e.pivot_question))??h.find((e=>"RANGE"===e.type_info.question_type))??h[0],l){const e=h.find((e=>e.name===m[0].question_names[0]));T.current=m[0],P.current=[...P.current,{...m[0],question:e}],w(P.current),g({Q_1:l})}else if(!T.current&&m.length>0)return T.current=m[0],void D(m[0])}),[m,l]),r((()=>{c||B.current?.scrollIntoView({block:"center",behavior:"smooth"}),y.length&&(P.current=y),F(y.length-1)}),[y]),r((()=>{Object.keys(f).length>0&&T.current.question&&(N.includes(T.current.question.type_info.question_type)||I.current)&&!j()&&M()}),[f]),r((()=>{const e=m.find((e=>"T_1"===e.name));if(f?.[A.current?.name])if(e.is_based_on_score){const n=A.current?.type_info?.choices[f?.[A.current?.name]]?.dependent_question_names,t=e.question_names.find((e=>n?.includes(e))),r=h.find((e=>e.name===t));S(r)}else{const n=h.find((n=>n.name===e.question_names[0]));S(n)}}),[f?.[A.current?.name]]);const j=()=>H.current===m.filter((e=>"T_1"!==e.name)).length-1||"end"===T.current.branchOption,D=e=>{let n={};if(e.is_based_on_score){const t=A.current?.type_info?.choices[f?.[A.current?.name]]?.dependent_question_names,r=e.question_names.find((e=>t?.includes(e)));n=h.find((e=>e.name===r))}else n=h.find((n=>n.name===e.question_names[0]));T.current.question=n;const t=P.current.find((e=>e.question.name===n.name));w(t?[...P.current]:[...P.current,{...e,question:n}])},M=()=>{if(j())b(!0);else{if(T.current.nextBlock)H.current=m.findIndex((e=>e.name===T.current.nextBlock));else if(T.current.question.type_info?.meta?.branches){const e=T.current.question.type_info?.meta?.branches,n=f[T.current.question.name];let t;t="RANGE"===T.current.type?e.find((e=>n>=e.min&&n<=e.max)):e.find((e=>n===e.value)),t?.nextBlock?H.current=m.findIndex((e=>e.name===t.nextBlock)):H.current+=1}else H.current+=1;T.current=m[H.current],D(m[H.current])}},U=(e,n)=>{I.current=!0,delete f[n.name],g({...f})},G=(e,n,t)=>{if(t)if(I.current=!0,null!=f[e.question.name]&&e.name!==y[y.length-1].name){const[t,r]=(e=>{const n=y.findIndex((n=>n.name===e.name)),t=y.slice(0,n+1),r=t.reduce(((e,n)=>(e[n.question.name]=f[n.question.name],e)),{});return H.current=m.findIndex((n=>n.name===e.name)),[t,r]})(e);g({...r,...null!=n&&{[e.question.name]:n}}),P.current=t}else g({...f,...null!=n&&{[e.question.name]:n}});else g({...f,...null!=n&&{[e.question.name]:n}})};return T.current&&T.current.question?v?e.createElement("div",{className:"freemium-survey-components "+(c?"widget-survey-components":"")},e.createElement(L,{thankYouQuestion:O,preview:d})):e.createElement("div",{className:`freemium-survey-components ${c?"widget-survey-components":""} ${u}-style`,style:{"--widget-container-width":s}},!c&&e.createElement(x,{totalSteps:m.length,completedSteps:H.current}),c&&document.querySelector(p)&&e.createElement(e.Fragment,null,i.createPortal(e.createElement("div",{className:"navigation","data-navigation-element":"1"},e.createElement("button",{style:0==H.current?{visibility:"hidden"}:{},className:"navigate-button",onClick:()=>{H.current=Math.max(H.current-1,0),F(H.current)}},e.createElement(C,null)),e.createElement("span",{className:"navigation-text"}," Question ",H.current+1," of"," ",y.length," ")," ",e.createElement("button",{className:"navigate-button",style:H.current>=y.length-1?{visibility:"hidden"}:{},onClick:()=>{H.current=Math.min(H.current+1,y.length-1),F(H.current)}},e.createElement(q,null))),document.querySelector(p))),e.createElement("div",{style:c?{transform:`translateX(-${z*s}px)`,transition:`transform ${_}ms linear`}:{},className:"questions"},y.map(((n,t)=>{return e.createElement("div",{className:"question-container",ref:B,id:n.title,key:n.title},e.createElement("div",{className:"question-text"},n.question.text),e.createElement(E,{question:n.question,formValues:f,autoFocus:T.current.name===n.name,onChangeHandler:e=>{I.current=!1,H.current=m.findIndex((e=>e.name===n.name)),T.current=n,G(n,e,N.includes(n.question.type_info.question_type)&&!j())}}),e.createElement("div",{className:"action-buttons",style:c?{margin:"0 auto"}:{}},(r=n.question,r.name===T.current.question.name&&!N.includes(r.type_info.question_type)&&!j()&&e.createElement(k,{onClick:()=>{I.current?(H.current=Math.min(H.current+1,y.length-1),T.current=y[t+1],F(H.current)):G(n,null,!0)},disabled:!f[T.current.question.name]||Array.isArray(f[T.current.question.name])&&0===f[T.current.question.name].length,className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===T.current.question.name&&!j())(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:()=>U(0,n.question)},"Skip"),((e,n)=>!("DROPDOWN"!==n.type_info.question_type||n.name===T.current.question.name||n.required||!f[n.name]))(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:()=>{T.current=n,H.current=m.findIndex((e=>e.name===n.name)),U(0,n.question)}},"Clear selection"),c&&(e=>j()&&e.name===T.current.question.name)(n.question)&&e.createElement("div",{className:"submit",style:{margin:"0 auto"}},e.createElement(k,{disabled:T.current.question.required&&void 0===f[T.current.question.name]||$,onClick:()=>{R(!0),a(f),O?.type_info.meta.skipThankYouPage||b(!0)}},$?"Submitting":"Submit Survey"))));var r})),!c&&j()&&e.createElement("div",{className:"submit"},e.createElement(k,{disabled:T.current.question.required&&void 0===f[T.current.question.name]||$,onClick:()=>{R(!0),a(f,(()=>{d||O?.type_info.meta.skipThankYouPage&&(window.location.href=O?.type_info.meta.redirectUrl)})),O?.type_info.meta.skipThankYouPage||b(!0)}},$?"Submitting":"Submit Survey")))):null};export{z as AUTO_REDIRECT_DELAY,w as BUTTON_SIZE_VARIANTS,k as Button,f as CheckboxGroup,d as Input,c as NPS,x as ProgressBar,b as Radio,v as RadioGroup,F as Survey,_ as TRANSITION_DELAY,m as TextArea};
@@ -1,43 +1,25 @@
1
1
  declare const _default: {
2
+ id: string;
2
3
  name: string;
3
4
  desc: string;
4
5
  type: string;
5
- header_message: string;
6
- gratitude_message: string;
7
- ui_branding: {
8
- footer_html: string;
9
- logo_url: string;
10
- };
11
- meta: {
12
- blocks: {
13
- name: string;
14
- title: string;
15
- order: number;
16
- question_names: string[];
17
- type: string;
18
- required: boolean;
19
- is_based_on_score: boolean;
20
- is_same_for_all: boolean;
21
- jump_logic: null;
22
- }[];
23
- };
6
+ state: string;
7
+ is_active: boolean;
24
8
  question_details: {
25
9
  questions: ({
10
+ id: string;
26
11
  text: string;
27
12
  name: string;
28
13
  position: number;
29
14
  type_info: {
30
- pivot_question: boolean;
31
15
  question_type: string;
32
16
  validation: {
33
17
  min: number;
34
18
  max: number;
35
19
  };
36
- choices: {
37
- value: number;
38
- position: number;
39
- }[];
40
20
  linear_scale: {
21
+ point_scale: null;
22
+ scale_order: null;
41
23
  button_style: string;
42
24
  button_shape: string;
43
25
  };
@@ -45,80 +27,113 @@ declare const _default: {
45
27
  start: string;
46
28
  end: string;
47
29
  };
30
+ choices: {
31
+ position: string;
32
+ value: string;
33
+ }[];
48
34
  footer_text: string;
49
- meta?: undefined;
35
+ meta: null;
36
+ pivot_question: boolean;
50
37
  };
38
+ required: boolean;
51
39
  } | {
40
+ id: string;
52
41
  text: string;
53
42
  name: string;
54
43
  position: number;
55
44
  type_info: {
56
- pivot_question: boolean;
57
45
  question_type: string;
46
+ validation: null;
47
+ linear_scale: null;
48
+ score_presets: null;
49
+ choices: null;
50
+ footer_text: null;
58
51
  meta: {
59
52
  placeholder: string;
60
- readOnly: boolean;
61
- autoProceed: boolean;
62
- autoProceedDelay: number;
63
- proceedBtnText: string;
64
- othersOption: boolean;
65
- othersRequired: boolean;
66
- redirectUrl?: undefined;
67
- skipThankYouPage?: undefined;
53
+ readOnly?: undefined;
68
54
  };
69
- choices: {
70
- value: string;
71
- position: number;
72
- }[];
73
- validation?: undefined;
74
- linear_scale?: undefined;
75
- score_presets?: undefined;
76
- footer_text?: undefined;
55
+ pivot_question: boolean;
77
56
  };
57
+ required: boolean;
78
58
  } | {
59
+ id: string;
79
60
  text: string;
80
61
  name: string;
81
62
  position: number;
82
63
  type_info: {
83
- pivot_question: boolean;
84
64
  question_type: string;
65
+ validation: null;
66
+ linear_scale: null;
67
+ score_presets: null;
68
+ choices: null;
69
+ footer_text: null;
85
70
  meta: {
86
71
  readOnly: boolean;
87
- redirectUrl: string;
88
- skipThankYouPage: boolean;
89
72
  placeholder?: undefined;
90
- autoProceed?: undefined;
91
- autoProceedDelay?: undefined;
92
- proceedBtnText?: undefined;
93
- othersOption?: undefined;
94
- othersRequired?: undefined;
95
73
  };
96
- validation?: undefined;
97
- choices?: undefined;
98
- linear_scale?: undefined;
99
- score_presets?: undefined;
100
- footer_text?: undefined;
74
+ pivot_question: boolean;
101
75
  };
76
+ required: boolean;
102
77
  })[];
103
78
  };
79
+ created_at: string;
80
+ updated_at: string;
81
+ gratitude_message: string;
82
+ schedule_info: null;
83
+ throttle_info: null;
84
+ contact_info: null;
85
+ ui_branding: {
86
+ logo_url: string;
87
+ footer_html: string;
88
+ };
89
+ ui_theme: {
90
+ body_background_color: null;
91
+ primary_font: null;
92
+ secondary_font: null;
93
+ primary_background_color: null;
94
+ secondary_background_color: null;
95
+ primary_button_color: null;
96
+ secondary_button_color: null;
97
+ brand_color: null;
98
+ primary_button_text_color: null;
99
+ button_style: null;
100
+ secondary_button_text_color: null;
101
+ question_background_color: null;
102
+ question_text_color: null;
103
+ css_url: null;
104
+ };
105
+ meta: {
106
+ blocks: {
107
+ name: string;
108
+ title: string;
109
+ order: number;
110
+ question_names: string[];
111
+ type: string;
112
+ required: boolean;
113
+ is_based_on_score: boolean;
114
+ is_same_for_all: boolean;
115
+ jump_logic: null;
116
+ }[];
117
+ };
104
118
  channels: string[];
105
- state: string;
106
- ui_theme: {};
107
119
  channel_info: {
108
120
  email_channel_info: {
109
- dkim_settings: null;
110
- email_body: string;
111
- footer: string;
112
- from_email: string;
113
121
  from_name: string;
114
- preheader: string;
122
+ from_email: string;
123
+ subject: string;
115
124
  reply_to: string;
116
125
  reply_to_name: string;
117
- subject: string;
126
+ preheader: string;
127
+ email_body: string;
128
+ footer: string;
118
129
  unsubscribe: string;
130
+ dkim_settings: null;
119
131
  };
120
- link_channel_info: null;
121
132
  web_in_app_info: null;
133
+ link_channel_info: null;
122
134
  };
135
+ header_message: string;
136
+ product_client_id: string;
137
+ is_recurring: boolean;
123
138
  };
124
139
  export default _default;
@@ -14,6 +14,7 @@ interface SurveyProps {
14
14
  }, callback?: Function) => void;
15
15
  surveyContainerWidth?: number;
16
16
  widgetStyle?: 'default' | 'cozy' | 'compact';
17
+ preview?: boolean;
17
18
  }
18
- declare const Survey: ({ survey, onSubmit, widget, surveyContainerWidth, npsValue, widgetStyle, widgetNavigatorQuerySelector, }: SurveyProps) => JSX.Element | null;
19
+ declare const Survey: ({ survey, onSubmit, widget, surveyContainerWidth, npsValue, widgetStyle, widgetNavigatorQuerySelector, preview, }: SurveyProps) => JSX.Element | null;
19
20
  export { Survey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freemium-survey-components",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "React Survey Ui Components",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.esm.js",
@@ -93,6 +93,7 @@
93
93
  "typescript": "^3.9.3",
94
94
  "webpack": "^4.43.0",
95
95
  "webpack-cli": "^3.3.11",
96
- "webpack-dev-server": "^3.11.0"
96
+ "webpack-dev-server": "^3.11.0",
97
+ "sass-loader": "^10"
97
98
  }
98
99
  }