| 1 |
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("preact/compat"));else if("function"==typeof define&&define.amd)define(["preact/compat"],t);else{var c="object"==typeof exports?t(require("preact/compat")):t(e.PreactCompat);for(var r in c)("object"==typeof exports?exports:e)[r]=c[r]}}(Depicter,(e=>(()=>{var t={263:e=>{e.exports="data:image/svg+xml,%3csvg width='159' height='159' viewBox='0 0 159 159' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cg clip-path='url(%23clip0_6117_19588)'%3e %3crect width='159' height='159' fill='%23EFEFEF'/%3e %3cpath d='M113.717 87.3656C117.987 80.8457 127.543 80.8457 131.814 87.3656L175.028 153.344C179.739 160.538 174.579 170.087 165.98 170.087H79.551C70.9519 170.087 65.7912 160.537 70.5027 153.344L113.717 87.3656Z' fill='%23DBDBDB'/%3e %3cpath d='M30.3394 51.292C34.6683 45.6179 43.2092 45.6179 47.5382 51.292L129.657 158.929C135.089 166.048 130.012 176.306 121.058 176.306H-43.1805C-52.1346 176.306 -57.2111 166.048 -51.7799 158.929L30.3394 51.292Z' fill='%23DBDBDB'/%3e %3ccircle cx='90.3163' cy='45.9694' r='16.7653' fill='%23DBDBDB'/%3e %3c/g%3e %3cdefs%3e %3cclipPath id='clip0_6117_19588'%3e %3crect width='159' height='159' fill='white'/%3e %3c/clipPath%3e %3c/defs%3e %3c/svg%3e"},585:t=>{"use strict";t.exports=e},987:e=>{e.exports="data:image/svg+xml,%3csvg width='159' height='159' viewBox='0 0 159 159' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cg clip-path='url(%23clip0_6117_19588)'%3e %3crect width='159' height='159' fill='%23EFEFEF'/%3e %3cpath d='M113.717 87.3656C117.987 80.8457 127.543 80.8457 131.814 87.3656L175.028 153.344C179.739 160.538 174.579 170.087 165.98 170.087H79.551C70.9519 170.087 65.7912 160.537 70.5027 153.344L113.717 87.3656Z' fill='%23DBDBDB'/%3e %3cpath d='M30.3394 51.292C34.6683 45.6179 43.2092 45.6179 47.5382 51.292L129.657 158.929C135.089 166.048 130.012 176.306 121.058 176.306H-43.1805C-52.1346 176.306 -57.2111 166.048 -51.7799 158.929L30.3394 51.292Z' fill='%23DBDBDB'/%3e %3ccircle cx='90.3163' cy='45.9694' r='16.7653' fill='%23DBDBDB'/%3e %3c/g%3e %3cdefs%3e %3cclipPath id='clip0_6117_19588'%3e %3crect width='159' height='159' fill='white'/%3e %3c/clipPath%3e %3c/defs%3e %3c/svg%3e"}},c={};function r(e){var i=c[e];if(void 0!==i)return i.exports;var a=c[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var c in t)r.o(t,c)&&!r.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:t[c]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{dpcChoice:()=>h});var e=r(585),t=r(987),c=r.n(t);const a=(0,e.memo)((t=>{const{className:r="dpc-radio-button",name:i,value:a,children:n,label:l,id:o,isSelected:p=!1,displayOtherInput:s=!1,displayMedia:d=!1,disableInputFocus:u=!1,media:h,srcSet:m,onChange:g,onInputOtherChange:f}=t,v=(0,e.useRef)(`choice-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,15)}`),D=(0,e.useRef)(null),[b,y]=(0,e.useState)(""),x="other"===o,C=(0,e.useCallback)((e=>{g?.(o,!p,e.currentTarget.value)}),[o,p,g]),w=(0,e.useCallback)((e=>{y(e.currentTarget.value),f?.(e.currentTarget.value)}),[f]);return Depicter.h("div",{className:r},Depicter.h("label",{className:"depicter-choice-label",htmlFor:u?"none":v.current},d&&Depicter.h("div",{className:"depicter-choice-media"},Depicter.h("img",{alt:i,src:h||c(),srcSet:m})),Depicter.h("div",{className:"depicter-choice-container"},n||Depicter.h("span",{className:"depicter-choice-text"},l),Depicter.h("input",{className:"depicter-choice-input depicter-choice-radio-input",id:v.current,type:"radio",name:i,value:a,defaultChecked:p,onInput:C})),x&&(p||s)&&Depicter.h("input",{className:"depicter-other-choice-input depicter-radio-button-other-input",type:"text",value:b,onInput:w,ref:D})))}));var n;function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var c=arguments[t];for(var r in c)({}).hasOwnProperty.call(c,r)&&(e[r]=c[r])}return e},l.apply(null,arguments)}const o=t=>e.createElement("svg",l({width:14,height:11,viewBox:"0 0 14 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),n||(n=e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.05542 10.253L0.459229 5.65685L2.227 3.88909L5.05544 6.71753L11.773 0L13.5407 1.76777L5.05542 10.253Z"})));var p=r(263),s=r.n(p);const d=(0,e.memo)((t=>{const{className:c="dpc-checkbox",name:r,value:i,children:a,label:n,id:l,isSelected:p=!1,displayOtherInput:d=!1,displayMedia:u=!1,disableInputFocus:h=!1,onInputOtherChange:m,media:g,srcSet:f,onChange:v}=t,D=(0,e.useRef)(`choice-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,15)}`),b=(0,e.useRef)(null),[y,x]=(0,e.useState)(""),C="other"===l,w=(0,e.useCallback)((e=>{v?.(l,!p,e.currentTarget.value)}),[l,p,v]),S=(0,e.useCallback)((e=>{x(e.currentTarget.value),m?.(e.currentTarget.value)}),[m]);return Depicter.h("div",{className:c},Depicter.h("label",{className:"depicter-choice-label",htmlFor:h?"none":D.current},u&&Depicter.h("div",{className:"depicter-choice-media"},Depicter.h("img",{alt:r,src:g||s(),srcSet:f})),Depicter.h("div",{className:"depicter-choice-container"},a||Depicter.h("span",{className:"depicter-choice-text"},n),Depicter.h("div",{className:"depicter-checkbox-input-wrapper"},Depicter.h("input",{className:"depicter-choice-input depicter-choice-checkbox-input",id:D.current,type:"checkbox",name:i,defaultChecked:p,onInput:w}),Depicter.h(o,null))),C&&(p||d)&&Depicter.h("input",{className:"depicter-other-choice-input depicter-checkbox-other-input",type:"text",value:y,onInput:S,ref:b})))}));function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var c=arguments[t];for(var r in c)({}).hasOwnProperty.call(c,r)&&(e[r]=c[r])}return e},u.apply(null,arguments)}const h={component:t=>{const{composer:c,className:r="dpc-choice",choices:i=[],name:n,type:l="single",required:o,layer:p}=t,[s,h]=(0,e.useState)(i),[m,g]=(0,e.useState)([]),f=(0,e.useCallback)(((e,t)=>{g("single"===l?[e]:t?[...m,e]:m.filter((t=>t!==e)))}),[l,m]),v=(0,e.useCallback)((e=>{h((t=>t.map((t=>"other"===t.id?{...t,otherInputValue:e}:t))))}),[]),D=(0,e.useCallback)((e=>{const{id:t}=e;return Depicter.h("div",{className:"dpc-choice-item",key:t},"single"===l?Depicter.h(a,u({name:n,onChange:f,isSelected:m.includes(t),onInputOtherChange:v},e)):Depicter.h(d,u({onChange:f,isSelected:m.includes(t),onInputOtherChange:v},e)))}),[n,f,v,l,m]),b=0===m.length;return(0,e.useEffect)((()=>{c.survey&&(o&&b?c.survey.preventProceed(p.holder.index):c.survey.resolveProceed(p.holder.index))}),[c,b,o,p.holder.index]),Depicter.h("div",{className:`${r}`},s.map(D),Depicter.h("input",{form:c.survey?.formId,name:n,type:"hidden",value:JSON.stringify(s.filter((e=>m.includes(e.id))).map((e=>e.value))),readOnly:!0}))},async:!1,pureScript:!1}})(),i})())); |