UNPKG

openstack-uicore-foundation

Version:

ui reactjs components for openstack marketing site

2 lines 8.1 kB
!function(e,l){"object"==typeof exports&&"object"==typeof module?module.exports=l():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],l):"object"==typeof exports?exports["openstack-uicore-foundation"]=l():e["openstack-uicore-foundation"]=l()}(this,(()=>(()=>{"use strict";var e={5028:(e,l,r)=>{r.d(l,{default:()=>d});var t=r(6031),a=r.n(t),n=r(2462),o=r.n(n),i=r(2015),s=r.n(i);const u=["children","replaceNewLine","className"],d=e=>{let{children:l,replaceNewLine:r=!1,className:t=""}=e,n=o()(e,u);return s().createElement("span",a()({className:t,dangerouslySetInnerHTML:{__html:r?null==l?void 0:l.replace(/\n/g,"<br />"):l}},n))}},6031:e=>{e.exports=require("@babel/runtime/helpers/extends")},2462:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},2015:e=>{e.exports=require("react")}},l={};function r(t){var a=l[t];if(void 0!==a)return a.exports;var n=l[t]={exports:{}};return e[t](n,n.exports,r),n.exports}(()=>{r.n=e=>{var l=e&&e.__esModule?()=>e.default:()=>e;return r.d(l,{a:l}),l}})(),(()=>{r.d=(e,l)=>{for(var t in l)r.o(l,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:l[t]})}})(),(()=>{r.o=(e,l)=>Object.prototype.hasOwnProperty.call(e,l)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var t={};r.r(t),r.d(t,{default:()=>L});var a=r(6031),n=r.n(a),o=r(2015),i=r.n(o);const s=require("prop-types");var u=r.n(s),d=r(2462),c=r.n(d);const m=(e,l)=>`${e.toLowerCase().replace(/[^a-zA-Z0-9]+/g,"_")}_${l}`,b=e=>{var l;return null==e||null===(l=e.label)||void 0===l?void 0:l.replace(/\n/g," ").replace(/<p>(.*)<\/p>/gi,"$1")},p=require("@mui/material"),v=["question","questionClassName","isDisabled","children","setFieldValue"],h=e=>{let{question:l,questionClassName:r="",isDisabled:t=!1,children:a,setFieldValue:o}=e,s=c()(e,v);const u=m(l.name,l.id),d=b(l),h=l.mandatory;return i().createElement("div",{key:u,id:`${u}_container`,className:r},i().createElement(p.FormGroup,null,i().createElement(p.TextField,n()({name:u,label:d,disabled:t,required:h,fullWidth:!0,margin:"normal"},s)),a))};h.propTypes={question:u().object.isRequired,questionClassName:u().string,isDisabled:u().bool,children:u().node,setFieldValue:u().func};const q=h;var y=r(5028);const f=["question","questionClassName","isDisabled","children","value","error","helperText","setFieldValue"],x=e=>{let{question:l,questionClassName:r="",isDisabled:t=!1,children:a,value:o,error:s,helperText:u,setFieldValue:d}=e,v=c()(e,f);const h=m(l.name,l.id),q=b(l),x=l.mandatory;return i().createElement("div",{key:h,id:`${h}_container`,className:r},i().createElement(p.FormControl,{fullWidth:!0,margin:"normal",error:s},i().createElement(p.FormControlLabel,{sx:{alignItems:"flex-start"},control:i().createElement(p.Checkbox,n()({name:h,checked:!!o,label:i().createElement(y.default,null,q),sx:{marginTop:-1}},v)),label:i().createElement(y.default,null,q),disabled:t,required:x}),a,s&&i().createElement(p.FormHelperText,null,u??" ")))};x.propTypes={question:u().object.isRequired,value:u().bool,questionClassName:u().string,isDisabled:u().bool,children:u().node,setFieldValue:u().func,error:u().bool,helperText:u().string};const g=x,C=["question","questionClassName","isDisabled","children","error","helperText","setFieldValue"],E=e=>{var l;let{question:r,questionClassName:t="",isDisabled:a=!1,children:o,error:s,helperText:u,setFieldValue:d}=e,v=c()(e,C);const h=m(r.name,r.id),q=b(r),y=r.mandatory,f=(null===(l=r.values)||void 0===l?void 0:l.map((e=>({label:e.label,value:e.id.toString()}))))||[];return i().createElement("div",{key:h,id:`${h}_container`,className:t},i().createElement(p.FormControl,{disabled:a,required:y,fullWidth:!0,margin:"normal",error:s},i().createElement(p.FormLabel,{id:`${h}_label`},q),s&&i().createElement(p.FormHelperText,null,u??" "),i().createElement(p.RadioGroup,n()({"aria-labelledby":`${h}_label`,name:h},v),f.map((e=>i().createElement(p.FormControlLabel,{key:e.label,value:e.value,control:i().createElement(p.Radio,null),label:e.label})))),o))};E.propTypes={question:u().object.isRequired,questionClassName:u().string,isDisabled:u().bool,children:u().node,error:u().bool,helperText:u().string,setFieldValue:u().func};const F=E,N=["question","questionClassName","isDisabled","children","value","onChange","setFieldValue","error","helperText"],T=e=>{var l;let{question:r,questionClassName:t="",isDisabled:a=!1,children:o,value:s,onChange:u,setFieldValue:d,error:v,helperText:h}=e,q=c()(e,N);const y=m(r.name,r.id),f=b(r),x=r.mandatory,g=r.max_selected_values,C=(null===(l=r.values)||void 0===l?void 0:l.map((e=>({label:e.label,value:e.id.toString()}))))||[];return i().createElement("div",{key:y,id:`${y}_container`,className:t},i().createElement(p.FormControl,{disabled:a,required:x,fullWidth:!0,margin:"normal",error:v},i().createElement(p.FormLabel,null,f),v&&i().createElement(p.FormHelperText,null,h??" "),i().createElement(p.FormGroup,null,C.map((e=>i().createElement(p.FormControlLabel,{key:e.label,name:y,control:i().createElement(p.Checkbox,n()({checked:null==s?void 0:s.includes(e.value),onChange:l=>((e,l)=>{const r=s||[],t=0!==g&&r.length===g;let a;a=e?t?r:[...r,l]:r.filter((e=>e!==l)),d(y,a)})(l.target.checked,e.value)},q)),label:e.label})))),o))};T.propTypes={question:u().object.isRequired,value:u().array,questionClassName:u().string,isDisabled:u().bool,onChange:u().func.isRequired,children:u().node,setFieldValue:u().func,error:u().bool,helperText:u().string};const _=T,k=["question","questionClassName","isDisabled","setFieldValue","children","error","helperText"],V=e=>{var l;let{question:r,questionClassName:t="",isDisabled:a=!1,setFieldValue:o,children:s,error:u,helperText:d}=e,v=c()(e,k);const h=m(r.name,r.id),q=b(r),y=r.mandatory,f=(null===(l=r.values)||void 0===l?void 0:l.map((e=>({label:e.label,value:e.id}))))||[];return i().createElement("div",{key:h,id:`${h}_container`,className:t},i().createElement(p.FormControl,{disabled:a,required:y,fullWidth:!0,margin:"normal",error:u},i().createElement(p.InputLabel,{id:`${h}_label`},q),i().createElement(p.Select,n()({labelId:`${h}_label`,name:h,id:h,label:q},v,{style:{marginBottom:20}}),f.map((e=>i().createElement(p.MenuItem,{key:e.label,value:e.value},e.label)))),s))};V.propTypes={question:u().object.isRequired,questionClassName:u().string,isDisabled:u().bool,children:u().node,error:u().bool,helperText:u().string,setFieldValue:u().func};const D=V,j=({extraQuestions:e,className:l="extraQuestions",questionClassName:r="extraQuestion",readOnly:t=!1,allowEdit:a=!0,formik:o})=>{const s=(e,l)=>{const r=((e,l)=>{const r=l.answer_values;if(!e)return!1;if(Array.isArray(e)){if(!e.length)return!1;let t="And"===l.answer_values_operator;return r.forEach((r=>{t="And"===l.answer_values_operator?t&&e.includes(r):t||e.includes(r)})),t}return r.includes(null==e?void 0:e.toString())})(o.values[l],e),t=((e,l)=>"Visible"===e.visibility?"Equal"===e.visibility_condition?!!l:!l:"Equal"===e.visibility_condition?!l:!!l)(e,r);return t?u(e.sub_question):null},u=e=>{var l;const u=m(e.name,e.id),d=!a&&(e=>!!e&&(Array.isArray(e)||"string"==typeof e?e.length>0:"number"==typeof e?e>0:"boolean"==typeof e&&e))(o.values[u])||t,c=(e=>{switch(e){case"TextArea":case"Text":return q;case"CheckBox":return g;case"RadioButtonList":return F;case"CheckBoxList":return _;case"CountryComboBox":case"ComboBox":return D;default:return i().Fragment}})(e.type),b={value:o.values[u],onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched[u]&&Boolean(o.errors[u]),helperText:o.touched[u]&&o.errors[u],setFieldValue:o.setFieldValue};return i().createElement(c,n()({key:u,question:e,questionClassName:r,isDisabled:d},b),null===(l=e.sub_question_rules)||void 0===l?void 0:l.map((e=>s(e,u))))};return i().createElement("div",{className:l},e.map(u))};j.propTypes={extraQuestions:u().array.isRequired,className:u().string,questionClassName:u().string,allowEdit:u().bool,readOnly:u().bool};const L=j;return t})())); //# sourceMappingURL=extra-questions-mui.js.map