freemium-survey-components 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/types/mock.d.ts +1 -1
- package/package.json +1 -1
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:c},footer_text:s}}=e,l=e=>{switch(e){case e<4:return"detractor";case e<7:return"passive";default:return"promoter"}},u=n.useRef(Array.from({length:10},((e,n)=>n+c)));return t.createElement("div",{className:"nps-container"},t.createElement("div",{className:`widget ${r} ${o}`},t.createElement("div",{className:"button-container"},t.createElement("span",{className:"negative-text"},i),t.createElement("div",{className:"choices"},u.current.map((n=>t.createElement("button",{key:n,onClick:t=>{e.onChangeHandler(n)},className:`choice ${l(n)} ${e.npsValue===n&&"active"}`},n)))),t.createElement("span",{className:"positive-text"},a))),t.createElement("div",{className:"footer"},s))},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 c={isRequired:!1,showCount:!1,isErrored:!1,inline:!1,spellCheck:!1,autoFocus:!0},s=n.forwardRef(((e,r)=>{const o=n.useRef(null);n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{o.current?.focus()}),C+20)}),[e.autoFocus]);const{inputStyle:i,style:a,className:c,showCount:s,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":""}${c||""}`},t.createElement("input",Object.assign({type:"text",autoComplete:"off",ref:o,style:i},g)),s&&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()}),C+20)}),[]);const{inputStyle:i,style:a,className:c,showCount:s,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":""} ${c||""}`},t.createElement("textarea",Object.assign({autoComplete:"off",ref:o,style:i},h)),s&&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(s,c),p=a(l,c);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()}),C+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:c,othersRequired:s})=>{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))),c&&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:s&&0===l.length,onClick:()=>a(l)},"Next")))},g=a((e=>{const r=n.useRef(null);return n.useEffect((()=>{e.autoFocus&&setTimeout((()=>{r.current?.focus()}),C+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 x=()=>t.createElement(t.Fragment,null,"..."),b=e=>{const{inline:n=!1,children:r,disabled:o,className:i="",htmlType:a,type:c="primary",onClick:s,size:l,overrideStyleClassName:u="",loading:p=!1,...d}=e;return t.createElement("button",Object.assign({style:n?{display:"inline-block"}:{},disabled:o,className:`action-button ${i} ${u}`,type:a,onClick:s},d),p?t.createElement(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"],C=200,q=({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=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:c,widgetStyle:s,widgetNavigatorQuerySelector:l})=>{const{meta:{blocks:u},question_details:{questions:p}}=e,[d,m]=n.useState({}),[h,f]=n.useState(!1),[g,x]=n.useState([]),[N,_]=n.useState(0),[R,S]=n.useState(!1),L=n.useRef(null),z=n.useRef(null),T=n.useRef(null),O=n.useRef(0),F=n.useRef(!1),$=n.useRef([]),A=n.useRef(null);n.useEffect((()=>{if(!u)return;z.current=p.find((e=>e.pivot_question))??p.find((e=>"RANGE"===e.type_info.question_type))??p[0];const e=u.find((e=>"T_1"===e.name));if(A.current=p.find((n=>n.name===e?.question_names[0])),c){const e=p.find((e=>e.name===u[0].question_names[0]));L.current=u[0],$.current=[...$.current,{...u[0],question:e}],m({Q_1:c})}else if(!L.current&&u.length>0)return L.current=u[0],void I(u[0])}),[u,c]),n.useEffect((()=>{i||T.current?.scrollIntoView({block:"center",behavior:"smooth"}),g.length&&($.current=g),_(g.length-1)}),[g]),n.useEffect((()=>{Object.keys(d).length>0&&L.current.question&&(E.includes(L.current.question.type_info.question_type)||F.current)&&!B()&&P()}),[d]);const B=()=>O.current===u.length-2||"end"===L.current.branchOption,I=e=>{let n={};if(e.is_based_on_score){const t=z.current?.type_info?.choices[d?.[z.current?.name]]?.dependent_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]));L.current.question=n;const t=$.current.find((e=>e.question.name===n.name));x(t?[...$.current]:[...$.current,{...e,question:n}])},P=()=>{if(B())f(!0);else{if(L.current.nextBlock)O.current=u.findIndex((e=>e.name===L.current.nextBlock));else if(L.current.question.type_info?.meta?.branches){const e=L.current.question.type_info?.meta?.branches,n=d[L.current.question.name];let t;t="RANGE"===L.current.type?e.find((e=>n>=e.min&&n<=e.max)):e.find((e=>n===e.value)),t?.nextBlock?O.current=u.findIndex((e=>e.name===t.nextBlock)):O.current+=1}else O.current+=1;L.current=u[O.current],I(u[O.current])}},j=(e,n)=>{F.current=!0,delete d[n.name],m({...d})},H=(e,n,t)=>{if(t)if(F.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 O.current=u.findIndex((n=>n.name===e.name)),[t,r]})(e);m({...r,...null!=n&&{[e.question.name]:n}}),$.current=t}else m({...d,...null!=n&&{[e.question.name]:n}});else m({...d,...null!=n&&{[e.question.name]:n}})};return L.current&&L.current.question?h?t.createElement("div",{className:"freemium-survey-components "+(i?"widget-survey-components":"")},t.createElement(q,{thankyouQuestion:A.current})):t.createElement("div",{className:`freemium-survey-components ${i?"widget-survey-components":""} ${s}-style`,style:{"--widget-container-width":a}},!i&&t.createElement(v,{totalSteps:u.length,completedSteps:O.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==O.current?{visibility:"hidden"}:{},className:"navigate-button",onClick:()=>{O.current=Math.max(O.current-1,0),_(O.current)}},t.createElement(k,null)),t.createElement("span",{className:"navigation-text"}," Question ",O.current+1," of"," ",g.length," ")," ",t.createElement("button",{className:"navigate-button",style:O.current>=g.length-1?{visibility:"hidden"}:{},onClick:()=>{O.current=Math.min(O.current+1,g.length-1),_(O.current)}},t.createElement(w,null))),document.querySelector(l))),t.createElement("div",{style:i?{transform:`translateX(-${N*a}px)`,transition:`transform ${C}ms linear`}:{},className:"questions"},g.map(((e,n)=>{return t.createElement("div",{className:"question-container",ref:T,id:e.title,key:e.title},t.createElement("div",{className:"question-text"},e.question.text),t.createElement(y,{question:e.question,formValues:d,autoFocus:L.current.name===e.name,onChangeHandler:n=>{F.current=!1,O.current=u.findIndex((n=>n.name===e.name)),L.current=e,H(e,n,E.includes(e.question.type_info.question_type)&&!B())}}),t.createElement("div",{className:"action-buttons",style:i?{margin:"0 auto"}:{}},(r=e.question,r.name===L.current.question.name&&!E.includes(r.type_info.question_type)&&!B()&&t.createElement(b,{onClick:()=>{F.current?(O.current=Math.min(O.current+1,g.length-1),L.current=g[n+1],_(O.current)):H(e,null,!0)},disabled:!d[L.current.question.name]||Array.isArray(d[L.current.question.name])&&0===d[L.current.question.name].length,className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===L.current.question.name&&!B())(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:()=>j(0,e.question)},"Skip"),((e,n)=>!("DROPDOWN"!==n.type_info.question_type||n.name===L.current.question.name||n.required||!d[n.name]))(0,e.question)&&t.createElement("button",{className:"skip-button",onClick:()=>{L.current=e,O.current=u.findIndex((n=>n.name===e.name)),j(0,e.question)}},"Clear selection"),i&&(e=>B()&&e.name===L.current.question.name)(e.question)&&t.createElement("div",{className:"submit",style:{margin:"0 auto"}},t.createElement(b,{disabled:L.current.question.required&&void 0===d[L.current.question.name]||R,onClick:()=>{S(!0),o(d),A.current?.type_info.meta.skipThankYouPage||f(!0)}},R?"Submitting":"Submit Survey"))));var r})),!i&&B()&&t.createElement("div",{className:"submit"},t.createElement(b,{disabled:L.current.question.required&&void 0===d[L.current.question.name]||R,onClick:()=>{S(!0),o(d,(()=>{A.current?.type_info.meta.skipThankYouPage&&(window.location.href=A.current?.type_info.meta.redirectUrl)})),A.current?.type_info.meta.skipThankYouPage||f(!0)}},R?"Submitting":"Submit Survey")))):null},exports.TRANSITION_DELAY=C,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(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;
|
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 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:"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"})),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:"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=n(null),O=n(null),S=n(null),T=n(0),A=n(!1),B=n([]),H=n(null);r((()=>{if(!d)return;O.current=m.find((e=>e.pivot_question))??m.find((e=>"RANGE"===e.type_info.question_type))??m[0];const e=d.find((e=>"T_1"===e.name));if(H.current=m.find((n=>n.name===e?.question_names[0])),l){const e=m.find((e=>e.name===d[0].question_names[0]));R.current=d[0],B.current=[...B.current,{...d[0],question:e}],f({Q_1:l})}else if(!R.current&&d.length>0)return R.current=d[0],void P(d[0])}),[d,l]),r((()=>{c||S.current?.scrollIntoView({block:"center",behavior:"smooth"}),b.length&&(B.current=b),z(b.length-1)}),[b]),r((()=>{Object.keys(h).length>0&&R.current.question&&(N.includes(R.current.question.type_info.question_type)||A.current)&&!I()&&j()}),[h]);const I=()=>T.current===d.length-2||"end"===R.current.branchOption,P=e=>{let n={};if(e.is_based_on_score){const t=O.current?.type_info?.choices[h?.[O.current?.name]]?.dependent_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]));R.current.question=n;const t=B.current.find((e=>e.question.name===n.name));y(t?[...B.current]:[...B.current,{...e,question:n}])},j=()=>{if(I())v(!0);else{if(R.current.nextBlock)T.current=d.findIndex((e=>e.name===R.current.nextBlock));else if(R.current.question.type_info?.meta?.branches){const e=R.current.question.type_info?.meta?.branches,n=h[R.current.question.name];let t;t="RANGE"===R.current.type?e.find((e=>n>=e.min&&n<=e.max)):e.find((e=>n===e.value)),t?.nextBlock?T.current=d.findIndex((e=>e.name===t.nextBlock)):T.current+=1}else T.current+=1;R.current=d[T.current],P(d[T.current])}},D=(e,n)=>{A.current=!0,delete h[n.name],f({...h})},M=(e,n,t)=>{if(t)if(A.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 T.current=d.findIndex((n=>n.name===e.name)),[t,r]})(e);f({...r,...null!=n&&{[e.question.name]:n}}),B.current=t}else f({...h,...null!=n&&{[e.question.name]:n}});else f({...h,...null!=n&&{[e.question.name]:n}})};return R.current&&R.current.question?g?e.createElement("div",{className:"freemium-survey-components "+(c?"widget-survey-components":"")},e.createElement(L,{thankyouQuestion:H.current})):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:T.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==T.current?{visibility:"hidden"}:{},className:"navigate-button",onClick:()=>{T.current=Math.max(T.current-1,0),z(T.current)}},e.createElement(q,null)),e.createElement("span",{className:"navigation-text"}," Question ",T.current+1," of"," ",b.length," ")," ",e.createElement("button",{className:"navigate-button",style:T.current>=b.length-1?{visibility:"hidden"}:{},onClick:()=>{T.current=Math.min(T.current+1,b.length-1),z(T.current)}},e.createElement(C,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:S,id:n.title,key:n.title},e.createElement("div",{className:"question-text"},n.question.text),e.createElement(E,{question:n.question,formValues:h,autoFocus:R.current.name===n.name,onChangeHandler:e=>{A.current=!1,T.current=d.findIndex((e=>e.name===n.name)),R.current=n,M(n,e,N.includes(n.question.type_info.question_type)&&!I())}}),e.createElement("div",{className:"action-buttons",style:c?{margin:"0 auto"}:{}},(r=n.question,r.name===R.current.question.name&&!N.includes(r.type_info.question_type)&&!I()&&e.createElement(k,{onClick:()=>{A.current?(T.current=Math.min(T.current+1,b.length-1),R.current=b[t+1],z(T.current)):M(n,null,!0)},disabled:!h[R.current.question.name]||Array.isArray(h[R.current.question.name])&&0===h[R.current.question.name].length,className:"next-button"},"Next")),((e,n)=>"RANGE"!==n.type_info.question_type&&!n.required&&n.name===R.current.question.name&&!I())(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:()=>D(0,n.question)},"Skip"),((e,n)=>!("DROPDOWN"!==n.type_info.question_type||n.name===R.current.question.name||n.required||!h[n.name]))(0,n.question)&&e.createElement("button",{className:"skip-button",onClick:()=>{R.current=n,T.current=d.findIndex((e=>e.name===n.name)),D(0,n.question)}},"Clear selection"),c&&(e=>I()&&e.name===R.current.question.name)(n.question)&&e.createElement("div",{className:"submit",style:{margin:"0 auto"}},e.createElement(k,{disabled:R.current.question.required&&void 0===h[R.current.question.name]||F,onClick:()=>{$(!0),a(h),H.current?.type_info.meta.skipThankYouPage||v(!0)}},F?"Submitting":"Submit Survey"))));var r})),!c&&I()&&e.createElement("div",{className:"submit"},e.createElement(k,{disabled:R.current.question.required&&void 0===h[R.current.question.name]||F,onClick:()=>{$(!0),a(h,(()=>{H.current?.type_info.meta.skipThankYouPage&&(window.location.href=H.current?.type_info.meta.redirectUrl)})),H.current?.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}\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};
|
package/lib/types/mock.d.ts
CHANGED
|
@@ -57,12 +57,12 @@ declare const _default: {
|
|
|
57
57
|
question_type: string;
|
|
58
58
|
meta: {
|
|
59
59
|
placeholder: string;
|
|
60
|
+
readOnly: boolean;
|
|
60
61
|
autoProceed: boolean;
|
|
61
62
|
autoProceedDelay: number;
|
|
62
63
|
proceedBtnText: string;
|
|
63
64
|
othersOption: boolean;
|
|
64
65
|
othersRequired: boolean;
|
|
65
|
-
readOnly?: undefined;
|
|
66
66
|
redirectUrl?: undefined;
|
|
67
67
|
skipThankYouPage?: undefined;
|
|
68
68
|
};
|