@famalabs/web-form 1.0.0-beta.2 → 1.0.0-beta.21

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.
Files changed (106) hide show
  1. package/dist/core/Form.js +1 -1
  2. package/dist/core/compiler/FormCompiler.js +1 -1
  3. package/dist/core/compiler/common/CompilerProgress.js +1 -1
  4. package/dist/core/compiler/common/NavigationButtonsCompiler.js +1 -1
  5. package/dist/core/compiler/common/QuestionCompiler.js +1 -1
  6. package/dist/core/compiler/common/SidebarCompiler.js +1 -1
  7. package/dist/core/compiler/containers/PageCompiler.js +1 -1
  8. package/dist/core/compiler/containers/SectionCompiler.js +1 -1
  9. package/dist/core/compiler/question_forms/ItemConditionalCompiler.js +1 -1
  10. package/dist/core/compiler/question_forms/ItemFunctionCompiler.js +1 -1
  11. package/dist/core/compiler/question_forms/QuestionCheckCompiler.js +1 -1
  12. package/dist/core/compiler/question_forms/QuestionDateCompiler.js +1 -1
  13. package/dist/core/compiler/question_forms/QuestionListCompiler.js +1 -1
  14. package/dist/core/compiler/question_forms/QuestionMultipleSelectCompiler.js +1 -1
  15. package/dist/core/compiler/question_forms/QuestionNumberCompiler.js +1 -1
  16. package/dist/core/compiler/question_forms/QuestionSelectCompiler.js +1 -1
  17. package/dist/core/compiler/question_forms/QuestionTableCompiler.js +1 -1
  18. package/dist/core/compiler/question_forms/QuestionTextCompiler.js +1 -1
  19. package/dist/core/compiler/question_forms/UploadFormCompiler.js +1 -1
  20. package/dist/core/components/animations/MotionTabUtils.js +1 -0
  21. package/dist/core/components/animations/MotionWrappers.js +1 -0
  22. package/dist/core/components/common/DrawerCommon.js +1 -1
  23. package/dist/core/components/common/ImageInput.js +1 -1
  24. package/dist/core/components/common/ModalCommon.js +1 -1
  25. package/dist/core/components/common/ResponsiveDrawer.js +1 -1
  26. package/dist/core/components/common/Skeletons.js +1 -1
  27. package/dist/core/components/forms/QuestionAlertCommon.js +1 -1
  28. package/dist/core/components/forms/QuestionCheckCommon.js +1 -1
  29. package/dist/core/components/forms/QuestionCommon.js +1 -1
  30. package/dist/core/components/forms/QuestionDateCommon.js +1 -1
  31. package/dist/core/components/forms/QuestionListCommon.js +1 -1
  32. package/dist/core/components/forms/QuestionMultipleSelectCommon.js +1 -1
  33. package/dist/core/components/forms/QuestionNumberCommon.js +1 -1
  34. package/dist/core/components/forms/QuestionSelectCommon.js +1 -1
  35. package/dist/core/components/forms/QuestionSignatureCommon.js +1 -0
  36. package/dist/core/components/forms/QuestionTableCommon.js +1 -1
  37. package/dist/core/components/forms/QuestionTextCommon.js +1 -1
  38. package/dist/core/components/forms/QuestionUploadCommon.js +1 -1
  39. package/dist/core/components/parsers/MathParserRenderer.js +1 -1
  40. package/dist/core/editor/FormEditor.js +1 -1
  41. package/dist/core/editor/common/CommonEditor.js +1 -1
  42. package/dist/core/editor/common/EditorHistoryDrawer.js +1 -1
  43. package/dist/core/editor/common/HierarchyEditor.js +1 -1
  44. package/dist/core/editor/common/OptionsEditor.js +1 -1
  45. package/dist/core/editor/common/ScoreSelectModal.js +1 -1
  46. package/dist/core/editor/common/SnapshotDrawer.js +1 -1
  47. package/dist/core/editor/common/SurveyCreateNew.js +1 -1
  48. package/dist/core/editor/common/sidebar/SidebarEditor.js +1 -1
  49. package/dist/core/editor/common/sidebar/SidebarPageStructure.js +1 -1
  50. package/dist/core/editor/common/sidebar/SidebarQuestionStructure.js +1 -1
  51. package/dist/core/editor/common/sidebar/SidebarSettingsView.js +1 -1
  52. package/dist/core/editor/containers/FolderEditor.js +1 -1
  53. package/dist/core/editor/containers/LandingPageEditor.js +1 -1
  54. package/dist/core/editor/containers/PageEditor.js +1 -1
  55. package/dist/core/editor/containers/RenderPageEditModal.js +1 -1
  56. package/dist/core/editor/containers/RenderPageHeader.js +1 -1
  57. package/dist/core/editor/containers/RenderSectionEditModal.js +1 -1
  58. package/dist/core/editor/containers/SectionEditor.js +1 -1
  59. package/dist/core/editor/containers/SectionPreview.js +1 -1
  60. package/dist/core/editor/question_editor/QuestionCommonEditor.js +1 -1
  61. package/dist/core/editor/question_editor/QuestionMainComponent.js +1 -1
  62. package/dist/core/editor/question_editor/QuestionPreviewRender.js +1 -1
  63. package/dist/core/editor/question_editor/QuestionTypeEdit.js +1 -1
  64. package/dist/core/editor/question_editor/QuestionTypePreview.js +1 -1
  65. package/dist/core/editor/question_forms/ItemConditionalEditor.js +1 -1
  66. package/dist/core/editor/question_forms/ItemFunctionEditor.js +1 -1
  67. package/dist/core/editor/question_forms/QuestionCheckEditor.js +1 -1
  68. package/dist/core/editor/question_forms/QuestionDateEditor.js +1 -1
  69. package/dist/core/editor/question_forms/QuestionListEditor.js +1 -1
  70. package/dist/core/editor/question_forms/QuestionMultipleSelectEditor.js +1 -1
  71. package/dist/core/editor/question_forms/QuestionNumberEditor.js +1 -1
  72. package/dist/core/editor/question_forms/QuestionSelectEditor.js +1 -1
  73. package/dist/core/editor/question_forms/QuestionSignatureEditor.js +1 -0
  74. package/dist/core/editor/question_forms/QuestionTableEditor.js +1 -1
  75. package/dist/core/editor/question_forms/QuestionTextEditor.js +1 -1
  76. package/dist/core/editor/question_forms/QuestionTimeEditor.js +1 -0
  77. package/dist/core/editor/question_forms/UploadFormEditor.js +1 -1
  78. package/dist/core/hooks/common/FormLoaderHookV2.js +1 -1
  79. package/dist/core/hooks/common/NavigationHook.js +1 -1
  80. package/dist/core/hooks/compiler/InitCompiler.js +1 -1
  81. package/dist/core/hooks/editor/EditorHistory.js +1 -1
  82. package/dist/core/hooks/editor/EditorLocalMutations.js +1 -1
  83. package/dist/core/hooks/editor/EditorOperations.js +1 -1
  84. package/dist/core/hooks/editor/QuestionOperations.js +1 -1
  85. package/dist/core/presenter/FormPresenter.js +1 -1
  86. package/dist/core/presenter/common/QuestionPresenter.js +1 -1
  87. package/dist/core/presenter/containers/FolderPresenter.js +1 -1
  88. package/dist/core/presenter/containers/PagePresenter.js +1 -1
  89. package/dist/core/presenter/containers/SectionPresenter.js +1 -1
  90. package/dist/core/types/FormEditorTypes.d.ts +3 -2
  91. package/dist/core/types/FormEditorTypes.js +1 -1
  92. package/dist/core/types/FormGlobalTypes.d.ts +6 -4
  93. package/dist/core/types/FormGlobalTypes.js +1 -1
  94. package/dist/core/types/ResultTypes.js +1 -1
  95. package/dist/core/utils/config-map.d.ts +14 -14
  96. package/dist/core/utils/config-map.js +1 -1
  97. package/dist/core/utils/format-utils.js +1 -1
  98. package/dist/core/utils/locale.d.ts +530 -7
  99. package/dist/core/utils/locale.js +1 -1
  100. package/dist/core/utils/parsers/ConditionParser.js +1 -1
  101. package/dist/core/utils/parsers/LegacyConditionParser.js +1 -1
  102. package/dist/core/utils/time-utils.js +1 -0
  103. package/dist/core/validators/compiler/CompilerValidators.js +1 -1
  104. package/dist/index.d.ts +3 -3
  105. package/dist/index.js +1 -1
  106. package/package.json +24 -18
@@ -1 +1 @@
1
- import{c as t}from"react/compiler-runtime";import{useQuestionStateContext as e}from"../../providers/editor/QuestionStateProvider.js";import i from"@mui/material/Checkbox";import o from"@mui/material/FormControl";import a from"@mui/material/FormControlLabel";import l from"@mui/material/FormLabel";import n from"@mui/material/Grid";import m from"@mui/material/Stack";import{QuestionDateAdapter as r}from"../../utils/config-map.js";import{getLocale as s,LocaleMap as d}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as u}from"../common/OptionsEditor.js";import{CommonQuestionEditor as p}from"../question_editor/QuestionCommonEditor.js";import{jsxs as c,jsx as f}from"react/jsx-runtime";function h(h){const x=t(25),{index:y,question:b,readonlyMode:g}=h,v=void 0!==g&&g,z=e(),w=z.value,C=w.name,j=w.options.min,I=w.options.max;let O;x[0]!==j||x[1]!==z?(O=t=>{const e=new r(t,"it").ts;j&&e&&e<=(new r(j,"it")?.ts??0)||z.updateItem("options.max",new r(t,"it").dt)},x[0]=j,x[1]=z,x[2]=O):O=x[2];const V=O;let S;x[3]!==I||x[4]!==z?(S=t=>{const e=new r(t,"it").ts;I&&e&&e>=(new r(I,"it")?.ts??0)||z.updateItem("options.min",new r(t,"it").dt)},x[3]=I,x[4]=z,x[5]=S):S=x[5];const k=S;let q;x[6]!==z?(q=t=>{z.updateItem("name",t)},x[6]=z,x[7]=q):q=x[7];const E=q;let F;x[8]!==V||x[9]!==k||x[10]!==E||x[11]!==C||x[12]!==I||x[13]!==j||x[14]!==w.layout||x[15]!==z||x[16]!==v?(F=()=>c(m,{spacing:2,children:[f(n,{container:!0,size:{xs:12,md:6},children:f(u,{label:"min",text:s(d.items.date.min),value:j?.toString()||"",handleOnChange:k,showToggle:!0,type:"date",fullWidth:!0,toggleValue:new Date,maxValue:I,size:"small",disabled:v})}),f(n,{container:!0,size:{xs:12,md:6},children:f(u,{label:"max",text:s(d.items.date.max),value:I?.toString()||"",handleOnChange:V,showToggle:!0,type:"date",fullWidth:!0,toggleValue:new Date,minValue:j,size:"small",disabled:v})}),f(n,{container:!0,display:"flex",size:{xs:12,md:6},children:c(o,{component:"fieldset",variant:"standard",children:[f(l,{children:"Visibilità"}),f(a,{label:"Nascosto",control:f(i,{checked:0===w.layout?.visibility,disabled:v,onChange:()=>{z.updateItem("layout",0===w.layout?.visibility?{...w.layout,visibility:1}:{...w.layout,visibility:0})}})})]})}),f(n,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:f(u,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:C,size:"small",handleOnChange:E,disabled:v})})]}),x[8]=V,x[9]=k,x[10]=E,x[11]=C,x[12]=I,x[13]=j,x[14]=w.layout,x[15]=z,x[16]=v,x[17]=F):F=x[17];const N=F;let W,D;return x[18]!==N?(W=N(),x[18]=N,x[19]=W):W=x[19],x[20]!==y||x[21]!==b||x[22]!==v||x[23]!==W?(D=f(p,{index:y,question:b,contentOptions:W,readonlyMode:v}),x[20]=y,x[21]=b,x[22]=v,x[23]=W,x[24]=D):D=x[24],D}export{h as QuestionDateEditorForm};
1
+ import{c as t}from"react/compiler-runtime";import{useQuestionStateContext as e}from"../../providers/editor/QuestionStateProvider.js";import n from"@mui/material/Grid";import o from"@mui/material/Stack";import i from"dayjs";import a from"dayjs/plugin/customParseFormat";import"../../utils/config-map.js";import{getLocale as l,LocaleMap as s}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as r}from"../common/OptionsEditor.js";import{CommonQuestionEditor as m}from"../question_editor/QuestionCommonEditor.js";import{jsxs as d,jsx as u}from"react/jsx-runtime";i.extend(a);const p="YYYY-MM-DD",c=[p,"DD/MM/YYYY","DD-MM-YYYY","YYYY/MM/DD"];function f(t,e){if(null==t)return null;if(t instanceof Date){const e=i(t);return e.isValid()?e.format(p):null}if("string"==typeof t){const n=t.trim();if(0===n.length)return null;const o=i(n,c,e,!0);return o.isValid()?o.format(p):null}const n=i(t);return n.isValid()?n.format(p):null}function g(a){const c=t(27),{index:g,question:x,readonlyMode:h}=a,Y=void 0!==h&&h,v=e(),y=v.value,D=y.name,z=y.options.min,M=y.options.max;let j;c[0]!==v?(j=t=>{const e=f(t,"it");v.updateItem("options.max",e)},c[0]=v,c[1]=j):j=c[1];const I=j;let V;c[2]!==v?(V=t=>{const e=f(t,"it");if(v.updateItem("options.max",e),!e)return;const n=f(v.getQuestionValue("options.min"),"it");var o;n&&(o=n,i(e,p,!0).isBefore(i(o,p,!0)))&&v.updateItem("options.min",e)},c[2]=v,c[3]=V):V=c[3];const b=V;let O;c[4]!==v?(O=t=>{const e=f(t,"it");v.updateItem("options.min",e)},c[4]=v,c[5]=O):O=c[5];const S=O;let C;c[6]!==v?(C=t=>{const e=f(t,"it");if(v.updateItem("options.min",e),!e)return;const n=f(v.getQuestionValue("options.max"),"it");var o;n&&(o=n,i(e,p,!0).isAfter(i(o,p,!0)))&&v.updateItem("options.max",e)},c[6]=v,c[7]=C):C=c[7];const w=C;let Q;c[8]!==v?(Q=t=>{v.updateItem("name",t)},c[8]=v,c[9]=Q):Q=c[9];const q=Q;let E;c[10]!==I||c[11]!==S||c[12]!==q||c[13]!==b||c[14]!==w||c[15]!==D||c[16]!==M||c[17]!==z||c[18]!==Y?(E=()=>d(o,{spacing:2,children:[u(n,{container:!0,size:{xs:12,md:6},children:u(r,{label:"min",text:l(s.items.date.min),value:"string"==typeof z?z:z?.toString()||null,handleOnChange:S,handleOnSave:w,showToggle:!0,type:"date",fullWidth:!0,toggleValue:new Date,maxValue:M,size:"small",disabled:Y})}),u(n,{container:!0,size:{xs:12,md:6},children:u(r,{label:"max",text:l(s.items.date.max),value:"string"==typeof M?M:M?.toString()||null,handleOnChange:I,handleOnSave:b,showToggle:!0,type:"date",fullWidth:!0,toggleValue:new Date,minValue:z,size:"small",disabled:Y})}),u(n,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:u(r,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:D,size:"small",handleOnChange:q,disabled:Y})})]}),c[10]=I,c[11]=S,c[12]=q,c[13]=b,c[14]=w,c[15]=D,c[16]=M,c[17]=z,c[18]=Y,c[19]=E):E=c[19];const W=E;let N,P;return c[20]!==W?(N=W(),c[20]=W,c[21]=N):N=c[21],c[22]!==g||c[23]!==x||c[24]!==Y||c[25]!==N?(P=u(m,{index:g,question:x,contentOptions:N,readonlyMode:Y}),c[22]=g,c[23]=x,c[24]=Y,c[25]=N,c[26]=P):P=c[26],P}export{g as QuestionDateEditorForm};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{useFormStateContext as t}from"../../providers/common/FormStateProvider.js";import{useEditorStateContext as o}from"../../providers/editor/EditorStateProvider.js";import r,{useEffectEvent as a}from"react";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useQuestionStateContext as l}from"../../providers/editor/QuestionStateProvider.js";import s from"@mui/material/Button";import c from"@mui/material/Grid";import m from"@mui/material/Stack";import u from"@mui/material/ToggleButton";import d from"@mui/material/ToggleButtonGroup";import p from"@mui/material/Typography";import{DatabaseZapIcon as h,ImageUpIcon as f}from"lucide-react";import{Mapper as g}from"../../utils/config-map.js";import{getLocale as y,LocaleMap as S}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as b,OptionSelect as v}from"../common/OptionsEditor.js";import{CommonQuestionEditor as x}from"../question_editor/QuestionCommonEditor.js";function C(s){const u=e(59),{index:d,question:p,readonlyMode:h}=s,f=void 0!==h&&h,{formInstance:C,globalConfig:_}=t(),{editorState:j}=o(),w=l(),E=w.value,T=E.name,A=E.options?.min,K=E.options?.max,M=E.options?.source;let N;u[0]!==_.sourceConfig?.staticSources?(N=_.sourceConfig?.staticSources??[],u[0]=_.sourceConfig?.staticSources,u[1]=N):N=u[1];const O=N;let W;u[2]!==O?(W=()=>O.length>0?O:[],u[2]=O,u[3]=W):W=u[3];const[D,V]=r.useState(W);let k;u[4]!==_.sourceConfig?.sourceUrl?(k=async()=>{if(!_.sourceConfig?.sourceUrl)return;const e=await(async e=>{try{if(!e)throw new Error("API_URL is not defined");const t=await fetch(e,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return await t.json()}catch(e){return console.error("Error fetching sources",e),[]}})(_.sourceConfig?.sourceUrl);e&&e.length>0&&V(e)},u[4]=_.sourceConfig?.sourceUrl,u[5]=k):k=u[5];const L=a(k);let q,P,U;u[6]!==D.length||u[7]!==L?(q=()=>{0===D.length&&L()},u[6]=D.length,u[7]=L,u[8]=q):q=u[8],u[9]!==D.length?(P=[D.length],u[9]=D.length,u[10]=P):P=u[10],r.useEffect(q,P),u[11]!==w?(U=e=>{w.updateItem("name",e)},u[11]=w,u[12]=U):U=u[12];const B=U;let Q;u[13]!==B||u[14]!==T||u[15]!==K||u[16]!==A||u[17]!==w||u[18]!==f?(Q=()=>i(m,{spacing:2,children:[n(c,{container:!0,size:{xs:12,md:6},children:n(b,{label:"min",text:y(S.items.sourceList.min),value:A,defaultValue:g.sourceList.defaults.min,handleOnChange:e=>{void 0!==K&&K&&Number(e)>=Number(K)||w.updateItem("options.min",Number(e))},showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:f})}),n(c,{container:!0,size:{xs:12,md:6},children:n(b,{label:"max",text:y(S.items.sourceList.max),value:K,defaultValue:g.sourceList.defaults.max,handleOnChange:e=>{void 0!==A&&A&&Number(e)<=Number(A)||w.updateItem("options.max",Number(e))},showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:f})}),n(c,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:n(b,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:T,size:"small",handleOnChange:B,disabled:f})})]}),u[13]=B,u[14]=T,u[15]=K,u[16]=A,u[17]=w,u[18]=f,u[19]=Q):Q=u[19];const R=Q,G=_.sourceConfig?.onSaveSources;let F;u[20]!==j||u[21]!==C.root||u[22]!==G||u[23]!==w?(F=async(e,t)=>{w.updateItem("options.source",e.templateKey);const o=C.root.layout?.dynamicSources,r=o?.some(t=>t.path===e.templateKey||t.id===e.key);if(r)return void console.warn("Source already exists:",e.templateKey);const a=[...o??[],{id:e.templateKey,type:t,path:e.templateKey,label:e.label}];j.updateItem(C.root,"layout",{...C.root.layout,dynamicSources:a}),await(G?.({id:e.templateKey,type:t,path:e.templateKey}))},u[20]=j,u[21]=C.root,u[22]=G,u[23]=w,u[24]=F):F=u[24];const H=F,J=C.root.layout?.dynamicSources,X=w.value.options?.source;let Y;u[25]!==D?(Y=Object.fromEntries(D.map(z)),u[25]=D,u[26]=Y):Y=u[26];const Z=Y;let $;u[27]!==j||u[28]!==C.root||u[29]!==w?($=e=>{j.updateItem(C.root,"layout",{...C.root.layout,sources:{...C.root.layout?.sources??{},[e]:e}}),w.updateItem("options.source",e),console.log("handleOnSource",e,w.value)},u[27]=j,u[28]=C.root,u[29]=w,u[30]=$):$=u[30];const ee=$;let te,oe;u[31]===Symbol.for("react.memo_cache_sentinel")?(te=y(S.items.sourceList.source),u[31]=te):te=u[31],u[32]!==j?(oe=j.getSurveySources(),u[32]=j,u[33]=oe):oe=u[33];const re=null===oe,ae=null===j.getSurveySources()?"Inserisci prima le Sorgenti dati nelle opzioni del Modulo":"";let ne;u[34]!==ee||u[35]!==M||u[36]!==f||u[37]!==Z||u[38]!==re||u[39]!==ae?(ne=n(v,{options:Z,text:te,value:M,handleOnChange:ee,fullWidth:!0,error:re,disabled:f,helperText:ae}),u[34]=ee,u[35]=M,u[36]=f,u[37]=Z,u[38]=re,u[39]=ae,u[40]=ne):ne=u[40];const ie=ne;let le,se;u[41]===Symbol.for("react.memo_cache_sentinel")?(le={py:4,px:2,backgroundColor:"background.paper"},u[41]=le):le=u[41],u[42]!==ie||u[43]!==_.AssetManager||u[44]!==_.VariableSelector||u[45]!==H||u[46]!==X||u[47]!==w||u[48]!==J||u[49]!==O.length?(se=n(m,{sx:le,children:O.length>0?ie:n(I,{questionSource:X,setQuestionSource:e=>w.updateItem("options.source",e),savedDynamicSources:J,handleSaveDynamicSource:H,AssetManager:_.AssetManager,VariableSelector:_.VariableSelector})}),u[42]=ie,u[43]=_.AssetManager,u[44]=_.VariableSelector,u[45]=H,u[46]=X,u[47]=w,u[48]=J,u[49]=O.length,u[50]=se):se=u[50];const ce=se;let me,ue;return u[51]!==R?(me=R(),u[51]=R,u[52]=me):me=u[52],u[53]!==d||u[54]!==p||u[55]!==f||u[56]!==ce||u[57]!==me?(ue=n(x,{contentEdit:ce,contentOptions:me,index:d,question:p,readonlyMode:f}),u[53]=d,u[54]=p,u[55]=f,u[56]=ce,u[57]=me,u[58]=ue):ue=u[58],ue}function z(e){return[e.data?.id??e.value,e.data?.label??e.label]}const I=t=>{const o=e(29),{questionSource:a,setQuestionSource:l,savedDynamicSources:m,handleSaveDynamicSource:g,AssetManager:y,VariableSelector:S}=t;let b;o[0]!==a||o[1]!==m?(b=m?.find(e=>e.path===a),o[0]=a,o[1]=m,o[2]=b):b=o[2];const v=b,x=v&&"asset"===v.type?"asset":"data",C=v?.label??"Seleziona Sorgente Dati",[z,I]=r.useState(x),[_,j]=r.useState(!1);let w;o[3]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{j(!0)},o[3]=w):w=o[3];const E=w;let T,A,K,M,N,O,W,D,V;return o[4]===Symbol.for("react.memo_cache_sentinel")?(T=n(p,{variant:"body2",gutterBottom:!0,fontWeight:"normal",color:"text.secondary",children:"Tipo di Sorgente Dati"}),o[4]=T):T=o[4],o[5]!==l?(A=(e,t)=>{t&&(I(t),l(""))},o[5]=l,o[6]=A):A=o[6],o[7]===Symbol.for("react.memo_cache_sentinel")?(K=i(u,{value:"data",children:[n(h,{style:{width:16,height:16,marginRight:6}}),"Dato"]}),o[7]=K):K=o[7],o[8]===Symbol.for("react.memo_cache_sentinel")?(M=i(u,{value:"asset",children:[n(f,{style:{width:16,height:16,marginRight:6}}),"Asset"]}),o[8]=M):M=o[8],o[9]!==z||o[10]!==A?(N=i(c,{size:12,children:[T,i(d,{value:z,color:"primary",exclusive:!0,size:"small",fullWidth:!0,onChange:A,children:[K,M]})]}),o[9]=z,o[10]=A,o[11]=N):N=o[11],o[12]!==S||o[13]!==g||o[14]!==C||o[15]!==z?(O="data"===z&&S&&n(c,{size:12,children:n(S,{mode:"source",buttonProps:{fullWidth:!0,text:C,startIcon:n(h,{size:16})},onConfirm:e=>{console.log("Selected sourceResult:",e),g(e,"data")},environment:"education"})}),o[12]=S,o[13]=g,o[14]=C,o[15]=z,o[16]=O):O=o[16],o[17]!==C||o[18]!==z?(W="asset"===z&&n(c,{size:12,children:n(s,{fullWidth:!0,variant:"outlined",onClick:E,children:C})}),o[17]=C,o[18]=z,o[19]=W):W=o[19],o[20]!==y||o[21]!==g||o[22]!==_?(D=y&&n(y,{title:"Seleziona Asset",open:_,onClose:()=>j(!1),onConfirm:e=>g({key:e,templateKey:e,label:e},"asset")}),o[20]=y,o[21]=g,o[22]=_,o[23]=D):D=o[23],o[24]!==N||o[25]!==O||o[26]!==W||o[27]!==D?(V=i(c,{container:!0,size:12,spacing:2,children:[N,O,W,D]}),o[24]=N,o[25]=O,o[26]=W,o[27]=D,o[28]=V):V=o[28],V};export{C as QuestionListEditorForm};
1
+ import{c as e}from"react/compiler-runtime";import{MotionButton as t}from"../../components/animations/MotionWrappers.js";import{useFormStateContext as o}from"../../providers/common/FormStateProvider.js";import{useEditorStateContext as r}from"../../providers/editor/EditorStateProvider.js";import a,{useEffectEvent as i}from"react";import{jsx as n,jsxs as s}from"react/jsx-runtime";import{useQuestionStateContext as l}from"../../providers/editor/QuestionStateProvider.js";import c from"@mui/material/Grid";import m from"@mui/material/Stack";import u from"@mui/material/ToggleButton";import d from"@mui/material/ToggleButtonGroup";import p from"@mui/material/Typography";import{DatabaseZapIcon as h,ImageUpIcon as f}from"lucide-react";import{Mapper as g}from"../../utils/config-map.js";import{getLocale as y,LocaleMap as S}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as b,OptionSelect as v}from"../common/OptionsEditor.js";import{CommonQuestionEditor as x}from"../question_editor/QuestionCommonEditor.js";function C(t){const u=e(63),{index:d,question:p,readonlyMode:h}=t,f=void 0!==h&&h,{formInfo:C,formInstance:j,globalConfig:_}=o(),{editorState:w}=r(),E=l(),M=E.value,T=M.name,W=M.options?.min,k=M.options?.max,K=M.options?.source;let N;u[0]!==_.sourceConfig?.staticSources?(N=_.sourceConfig?.staticSources??[],u[0]=_.sourceConfig?.staticSources,u[1]=N):N=u[1];const A=N;let D;u[2]!==A?(D=()=>A.length>0?A:[],u[2]=A,u[3]=D):D=u[3];const[O,V]=a.useState(D);let L;u[4]!==_.sourceConfig?.sourceUrl?(L=async()=>{if(!_.sourceConfig?.sourceUrl)return;const e=await(async e=>{if(!e)return console.error("Source URL is not defined"),[];try{const t=await fetch(e,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return await t.json()}catch(e){return console.error("Error fetching sources",e),[]}})(_.sourceConfig?.sourceUrl);e&&e.length>0&&V(e)},u[4]=_.sourceConfig?.sourceUrl,u[5]=L):L=u[5];const q=i(L);let U,P,Q;u[6]!==O.length||u[7]!==q?(U=()=>{0===O.length&&q()},u[6]=O.length,u[7]=q,u[8]=U):U=u[8],u[9]!==O.length?(P=[O.length],u[9]=O.length,u[10]=P):P=u[10],a.useEffect(U,P),u[11]!==E?(Q=e=>{E.updateItem("name",e)},u[11]=E,u[12]=Q):Q=u[12];const B=Q;let G;u[13]!==B||u[14]!==T||u[15]!==k||u[16]!==W||u[17]!==E||u[18]!==f?(G=()=>s(m,{spacing:2,children:[n(c,{container:!0,size:{xs:12,md:6},children:n(b,{label:"min",text:y(S.items.sourceList.min),value:W,defaultValue:g.sourceList.defaults.min,handleOnChange:e=>{void 0!==k&&k&&Number(e)>=Number(k)||E.updateItem("options.min",Number(e))},showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:f})}),n(c,{container:!0,size:{xs:12,md:6},children:n(b,{label:"max",text:y(S.items.sourceList.max),value:k,defaultValue:g.sourceList.defaults.max,handleOnChange:e=>{void 0!==W&&W&&Number(e)<=Number(W)||E.updateItem("options.max",Number(e))},showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:f})}),n(c,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:n(b,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:T,size:"small",handleOnChange:B,disabled:f})})]}),u[13]=B,u[14]=T,u[15]=k,u[16]=W,u[17]=E,u[18]=f,u[19]=G):G=u[19];const R=G,F=_.sourceConfig?.onSaveSources;let H;u[20]!==w||u[21]!==j.root||u[22]!==F||u[23]!==E?(H=async(e,t)=>{E.updateItem("options.source",e.templateKey);const o=j.root.layout?.dynamicSources,r=o?.some(t=>t.path===e.templateKey||t.id===e.key);if(r)return void console.warn("Source already exists:",e.templateKey);const a=[...o??[],{id:e.templateKey,type:t,path:e.templateKey,label:e.label}];w.updateItem({item:j.root,key:"layout",data:{...j.root.layout,dynamicSources:a}}),await(F?.({id:e.templateKey,type:t,path:e.templateKey}))},u[20]=w,u[21]=j.root,u[22]=F,u[23]=E,u[24]=H):H=u[24];const J=H,X=j.root.layout?.dynamicSources,Y=E.value.options?.source;let Z;u[25]!==O?(Z=Object.fromEntries(O.map(z)),u[25]=O,u[26]=Z):Z=u[26];const $=Z,ee=j.root.layout?.sources,te=j?.root.layout?.score||C?.score;let oe;u[27]!==w||u[28]!==j.root||u[29]!==F||u[30]!==E||u[31]!==te||u[32]!==ee?(oe=async e=>{w.updateItem({item:j.root,key:"layout",data:{...j.root.layout,sources:{...ee||{},[e]:e}}}),E.updateItem("options.source",e),await(F?.({...ee,[e]:e},te))},u[27]=w,u[28]=j.root,u[29]=F,u[30]=E,u[31]=te,u[32]=ee,u[33]=oe):oe=u[33];const re=oe;let ae,ie;u[34]===Symbol.for("react.memo_cache_sentinel")?(ae=y(S.items.sourceList.source),u[34]=ae):ae=u[34],u[35]!==w?(ie=w.getSurveySources(),u[35]=w,u[36]=ie):ie=u[36];const ne=null===ie,se=null===w.getSurveySources()?"Inserisci prima le Sorgenti dati nelle opzioni del Modulo":"";let le;u[37]!==re||u[38]!==K||u[39]!==f||u[40]!==$||u[41]!==ne||u[42]!==se?(le=n(v,{options:$,text:ae,value:K,handleOnChange:re,fullWidth:!0,error:ne,disabled:f,helperText:se}),u[37]=re,u[38]=K,u[39]=f,u[40]=$,u[41]=ne,u[42]=se,u[43]=le):le=u[43];const ce=le;let me,ue;u[44]===Symbol.for("react.memo_cache_sentinel")?(me={py:4,px:2,backgroundColor:"background.default"},u[44]=me):me=u[44],u[45]!==ce||u[46]!==_.AssetManager||u[47]!==_.VariableSelector||u[48]!==J||u[49]!==Y||u[50]!==E||u[51]!==f||u[52]!==X||u[53]!==A.length?(ue=n(m,{sx:me,children:A.length>0?ce:n(I,{questionSource:Y,setQuestionSource:e=>E.updateItem("options.source",e),savedDynamicSources:X,handleSaveDynamicSource:J,AssetManager:_.AssetManager,VariableSelector:_.VariableSelector,disabled:f})}),u[45]=ce,u[46]=_.AssetManager,u[47]=_.VariableSelector,u[48]=J,u[49]=Y,u[50]=E,u[51]=f,u[52]=X,u[53]=A.length,u[54]=ue):ue=u[54];const de=ue;let pe,he;return u[55]!==R?(pe=R(),u[55]=R,u[56]=pe):pe=u[56],u[57]!==d||u[58]!==p||u[59]!==f||u[60]!==de||u[61]!==pe?(he=n(x,{contentEdit:de,contentOptions:pe,index:d,question:p,readonlyMode:f}),u[57]=d,u[58]=p,u[59]=f,u[60]=de,u[61]=pe,u[62]=he):he=u[62],he}function z(e){const t=e.data;return["string"==typeof t?.id?t.id:e.value||"","string"==typeof t?.label?t.label:e.label||""]}const I=o=>{const r=e(33),{questionSource:i,setQuestionSource:l,savedDynamicSources:m,handleSaveDynamicSource:g,disabled:y,AssetManager:S,VariableSelector:b}=o,v=void 0!==y&&y;let x;r[0]!==i||r[1]!==m?(x=m?.find(e=>e.path===i),r[0]=i,r[1]=m,r[2]=x):x=r[2];const C=x,z=C&&"asset"===C.type?"asset":"data",I="string"==typeof C?.label?C?.label:"Seleziona Sorgente Dati",[j,_]=a.useState(z),[w,E]=a.useState(!1);let M;r[3]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{E(!0)},r[3]=M):M=r[3];const T=M;let W,k,K,N,A,D,O,V,L;return r[4]===Symbol.for("react.memo_cache_sentinel")?(W=n(p,{variant:"body2",gutterBottom:!0,fontWeight:"normal",color:"text.secondary",children:"Tipo di Sorgente Dati"}),r[4]=W):W=r[4],r[5]!==l?(k=(e,t)=>{t&&(_(t),l(""))},r[5]=l,r[6]=k):k=r[6],r[7]===Symbol.for("react.memo_cache_sentinel")?(K=s(u,{value:"data",children:[n(h,{style:{width:16,height:16,marginRight:6}}),"Dato"]}),r[7]=K):K=r[7],r[8]===Symbol.for("react.memo_cache_sentinel")?(N=s(u,{value:"asset",children:[n(f,{style:{width:16,height:16,marginRight:6}}),"Asset"]}),r[8]=N):N=r[8],r[9]!==v||r[10]!==j||r[11]!==k?(A=s(c,{size:12,children:[W,s(d,{value:j,color:"primary",exclusive:!0,size:"small",fullWidth:!0,disabled:v,onChange:k,children:[K,N]})]}),r[9]=v,r[10]=j,r[11]=k,r[12]=A):A=r[12],r[13]!==b||r[14]!==v||r[15]!==g||r[16]!==I||r[17]!==j?(D="data"===j&&b&&!v&&n(c,{size:12,children:n(b,{mode:"source",buttonProps:{fullWidth:!0,text:I,startIcon:n(h,{size:16})},onConfirm:e=>{g(e,"data")},environment:"education"})}),r[13]=b,r[14]=v,r[15]=g,r[16]=I,r[17]=j,r[18]=D):D=r[18],r[19]!==v||r[20]!==I||r[21]!==j?(O="asset"===j&&n(c,{size:12,children:n(t,{fullWidth:!0,variant:"outlined",onClick:T,disabled:v,children:I})}),r[19]=v,r[20]=I,r[21]=j,r[22]=O):O=r[22],r[23]!==S||r[24]!==v||r[25]!==g||r[26]!==w?(V=S&&!v&&n(S,{title:"Seleziona Asset",open:w,onClose:()=>E(!1),onConfirm:e=>g({key:e,templateKey:e,label:e},"asset")}),r[23]=S,r[24]=v,r[25]=g,r[26]=w,r[27]=V):V=r[27],r[28]!==V||r[29]!==A||r[30]!==D||r[31]!==O?(L=s(c,{container:!0,size:12,spacing:2,children:[A,D,O,V]}),r[28]=V,r[29]=A,r[30]=D,r[31]=O,r[32]=L):L=r[32],L};export{C as QuestionListEditorForm};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import i from"@mui/material/Box";import r from"@mui/material/Button";import o from"@mui/material/Checkbox";import n from"@mui/material/FormControl";import m from"@mui/material/FormControlLabel";import a from"@mui/material/Grid";import l from"@mui/material/IconButton";import d from"@mui/material/RadioGroup";import s from"@mui/material/Stack";import u from"@mui/material/TextField";import c from"@mui/material/Typography";import{CircleArrowUp as p,CircleArrowDown as f,Trash2 as h,PlusCircle as x}from"lucide-react";import b from"react";import{calculateLatestId as g}from"../../hooks/editor/QuestionOperations.js";import{getMapType as y,Mapper as I,getDefaultData as v}from"../../utils/config-map.js";import"../../utils/locale.js";import{acornExtractMinMax as z,LegacyConditionParser as C,acornUpdateMinMax as $}from"../../utils/parsers/LegacyConditionParser.js";import{OptionTextField as k}from"../common/OptionsEditor.js";import{CommonQuestionEditor as j}from"../question_editor/QuestionCommonEditor.js";import{jsx as O,jsxs as E}from"react/jsx-runtime";function w(y){const w=e(17),{index:M,question:P,readonlyMode:R}=y,V=void 0!==R&&R,W=t(),_=W.value,D=_?_.items?.sort(L):[],H=D?.length>0?D?.filter(G):[],[J,K]=b.useState(Array(H?.length).fill(null));let U;w[0]!==J?(U=J.filter(A),w[0]=J,w[1]=U):U=w[1];const X=Boolean(U.length);let Y;w[2]!==P?(Y=g(P),w[2]=P,w[3]=Y):Y=w[3];const Z=b.useRef(Y),ee=()=>{const e=D.map(Q).reduce(F,0),t={...{...v(I.check.type),text:`Opzione ${e+1}`,name:`opzione_${e+1}`},id:(Z.current+1).toString()},i=D.findIndex(q);W.updateItem(`items[${i}].parameters`,[...D[i].parameters,t.id]);const r=D.findIndex(T);if(-1!==r){const e=C(D[r]);W.updateItem(`items[${r}].parameters`,[...e.parameters,t.id])}W.addItem("items",t),Z.current=Z.current+1};let te;w[4]!==W?(te=(e,t)=>{W.moveItem("items",e,t)},w[4]=W,w[5]=te):te=w[5];const ie=te,re=_.items?.find(B),{min:oe}=z(re?re.condition:void 0),ne=e=>{if(!re||!e)return;const t=$(re.condition,{min:Number(e)});W.updateItem(`items[${D.indexOf(re)}].condition`,t)},me=_.name;let ae;w[6]!==W?(ae=e=>{W.updateItem("name",e)},w[6]=W,w[7]=ae):ae=w[7];const le=ae,de=()=>E(s,{spacing:2,children:[re&&O(a,{size:12,children:O(k,{label:"min",text:"Numero minimo di opzioni selezionabili",value:oe,handleOnChange:ne,showToggle:!1,type:"number",size:"small",minValue:1,maxValue:H.length,fullWidth:!0,disabled:V})}),O(k,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:me,size:"small",handleOnChange:le,disabled:V})]}),se=j,ue=O(i,{sx:{py:4,px:2,backgroundColor:"background.default"},children:E(n,{sx:{width:"100%"},children:[O(d,{name:_.id,"aria-label":_.id,style:{margin:"0.25rem"},children:H.map((e,t)=>E(s,{direction:"row",spacing:1,style:{margin:"0.25rem",alignItems:"center"},children:[O(m,{disabled:!0,value:"disabled",control:O(o,{}),label:""},t),O(u,{label:J[t]?J[t]:"Testo",value:e.text,onChange:t=>((e,t)=>{const i=H.findIndex(t=>t.id===e.id),r=H.some((e,r)=>i!==r&&e.text===t),o=[...J];o[i]=r?"Errore: valore duplicato":""===t?"Errore: il campo non può essere vuoto":null,K(o);const n=D.findIndex(t=>t.id===e.id);W.updateItem(`items[${n}].text`,t)})(e,t.target.value),error:Boolean(J[t]),size:"small",disabled:V,sx:{width:"100%"}}),O(l,{"aria-label":`move-up-button-${e.text}`,disabled:0===t||X,color:"inherit",onClick:()=>ie(t,t-1),children:O(p,{size:20})}),O(l,{"aria-label":`move-down-button-${e.text}`,disabled:t===H.length-1||X||V,color:"inherit",onClick:()=>ie(t,t+1),children:O(f,{size:20})}),O(l,{"aria-label":`delete-button-${e.text}`,disabled:H.length<=1||X||V,color:"inherit",onClick:()=>(e=>{if(H?.length<=1)return;K(J.filter((t,i)=>i!==D.indexOf(e)));const t=D.findIndex(S);W.updateItem(`items[${t}].parameters`,[...D[t].parameters.filter(t=>t!==e.id)]);const i=D.findIndex(N);if(-1!==i){const t=C(D[i]);W.updateItem(`items[${i}].parameters`,[...t.parameters.filter(t=>t!==e.id)])}W.removeItem("items",e)})(e),children:O(h,{size:20})})]},t))}),O(i,{sx:{mt:2},children:E(r,{variant:"outlined",color:"inherit",onClick:ee,disabled:V,children:[O(x,{size:20})," ",O(c,{sx:{ml:1},children:"Aggiungi opzione"})]})})]})});let ce,pe;return w[8]!==de?(ce=de(),w[8]=de,w[9]=ce):ce=w[9],w[10]!==se||w[11]!==M||w[12]!==P||w[13]!==V||w[14]!==ue||w[15]!==ce?(pe=O(se,{contentEdit:ue,index:M,question:P,contentOptions:ce,readonlyMode:V}),w[10]=se,w[11]=M,w[12]=P,w[13]=V,w[14]=ue,w[15]=ce,w[16]=pe):pe=w[16],pe}function B(e){return y(e)===I.cond.type}function N(e){return"cond"===e.type}function S(e){return"fn"===e.type}function T(e){return y(e)===I.cond.type}function q(e){return y(e)===I.fn.type}function F(e,t){return t>e?t:e}function Q(e){const t=e.text?.match(/\d+/);return t?parseInt(t[0],10):0}function A(e){return e}function G(e){return"fn"!==e.type&&"cond"!==e.type}function L(e,t){const i={fn:1,cond:2};return(i[e.type]||3)-(i[t.type]||3)}export{w as QuestionMultipleSelectEditorForm};
1
+ import{c as e}from"react/compiler-runtime";import{MotionButton as t}from"../../components/animations/MotionWrappers.js";import{useQuestionStateContext as i}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Box";import r from"@mui/material/Checkbox";import n from"@mui/material/FormControl";import a from"@mui/material/FormControlLabel";import m from"@mui/material/Grid";import l from"@mui/material/IconButton";import d from"@mui/material/RadioGroup";import s from"@mui/material/Stack";import c from"@mui/material/TextField";import u from"@mui/material/Typography";import{CircleArrowUp as p,CircleArrowDown as f,Trash2 as h,PlusCircle as x}from"lucide-react";import{AnimatePresence as b}from"motion/react";import*as g from"motion/react-m";import y from"react";import{jsx as I,jsxs as v}from"react/jsx-runtime";import{useEditorStateContext as z}from"../../providers/editor/EditorStateProvider.js";import{getMapType as C,Mapper as $,getDefaultData as j}from"../../utils/config-map.js";import"../../utils/locale.js";import{formatName as k}from"../../utils/format-utils.js";import{acornExtractMinMax as E,LegacyConditionParser as O,acornUpdateMinMax as S}from"../../utils/parsers/LegacyConditionParser.js";import{OptionTextField as w}from"../common/OptionsEditor.js";import{CommonQuestionEditor as B}from"../question_editor/QuestionCommonEditor.js";function N(C){const N=e(17),{index:V,question:_,readonlyMode:R}=C,D=void 0!==R&&R,{editorState:H}=z(),J=i(),K=J.value,U=K?K.items?.sort(Q):[],X=U?.length>0?U?.filter(G):[],[Y,Z]=y.useState(Array(X?.length).fill(null));let ee;N[0]!==Y?(ee=Y.filter(A),N[0]=Y,N[1]=ee):ee=N[1];const te=Boolean(ee.length);let ie;N[2]!==H?(ie=H.getLatestId(),N[2]=H,N[3]=ie):ie=N[3];const[oe,re]=y.useState(ie),ne=()=>{const e=U.map(W).reduce(P,0),t={...{...j($.check.type),text:`Opzione ${e+1}`,name:`opzione_${e+1}`},id:(oe+1).toString()},i=U.findIndex(M),o=U[i];J.updateItem(`items[${i}].parameters`,[...o.parameters,t.id]);const r=U.findIndex(L);if(-1!==r){const e=O(U[r]),i=e?.parameters||[];J.updateItem(`items[${r}].parameters`,[...i,t.id])}J.addItem("items",t),re(oe+1)};let ae;N[4]!==J?(ae=(e,t)=>{J.moveItem("items",e,t)},N[4]=J,N[5]=ae):ae=N[5];const me=ae,le=K?.items?.find(T),{min:de}=E(le?le.condition:void 0),se=e=>{if(!le||!e)return;const t=S(le.condition,{min:Number(e)}),i=U.findIndex(e=>e.id===le.id);J.updateItem(`items[${i}].condition`,t)},ce=K?.name;let ue;N[6]!==J?(ue=e=>{J.updateItem("name",e)},N[6]=J,N[7]=ue):ue=N[7];const pe=ue,fe=()=>v(s,{spacing:2,children:[le&&I(m,{size:12,children:I(w,{label:"min",text:"Numero minimo di opzioni selezionabili",value:de,handleOnChange:se,showToggle:!1,type:"number",size:"small",minValue:1,maxValue:X.length,fullWidth:!0,disabled:D})}),I(w,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:ce,size:"small",handleOnChange:pe,disabled:D})]}),he=B,xe=I(o,{sx:{py:4,px:2,backgroundColor:"background.default"},children:v(n,{sx:{width:"100%"},children:[I(d,{name:K?.id,"aria-label":K?.id,style:{margin:"0.25rem"},children:I(b,{initial:!1,children:X.map((e,t)=>I(g.div,{layout:!0,initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.18,ease:"easeInOut"},children:v(s,{direction:"row",spacing:1,sx:{mb:1.5,alignItems:"center"},children:[I(a,{disabled:!0,value:"disabled",control:I(r,{}),label:""}),I(c,{label:Y[t]?Y[t]:"Testo",value:e.text,onChange:t=>((e,t)=>{const i=X.findIndex(t=>t.id===e.id),o=X.some((e,o)=>i!==o&&e.text===t),r=[...Y];r[i]=o?"Errore: valore duplicato":""===t?"Errore: il campo non può essere vuoto":null,Z(r);const n=U.findIndex(t=>t.id===e.id);J.updateItem(`items[${n}].text`,t),J.updateItem(`items[${n}].name`,k(t))})(e,t.target.value),error:Boolean(Y[t]),size:"small",disabled:D,sx:{width:"100%"}}),I(l,{"aria-label":`move-up-button-${e.text}`,disabled:0===t||te,color:"primary",onClick:()=>me(t,t-1),children:I(p,{size:20})}),I(l,{"aria-label":`move-down-button-${e.text}`,disabled:t===X.length-1||te||D,color:"primary",onClick:()=>me(t,t+1),children:I(f,{size:20})}),I(l,{"aria-label":`delete-button-${e.text}`,disabled:X.length<=1||te||D,color:"error",onClick:()=>(e=>{if(X?.length<=1)return;Z(Y.filter((t,i)=>i!==U.indexOf(e)));const t=U.findIndex(F),i=U[t];J.updateItem(`items[${t}].parameters`,[...i.parameters.filter(t=>t!==e.id)]);const o=U.findIndex(q);if(-1!==o){const t=O(U[o]),i=t?.parameters||[];J.updateItem(`items[${o}].parameters`,[...i.filter(t=>t!==e.id)])}J.removeItem("items",e)})(e),children:I(h,{size:20})})]})},e.id))})}),I(o,{sx:{mt:2},children:v(t,{variant:"outlined",color:"inherit",onClick:ne,disabled:D,children:[I(x,{size:20})," ",I(u,{sx:{ml:1},children:"Aggiungi opzione"})]})})]})});let be,ge;return N[8]!==fe?(be=fe(),N[8]=fe,N[9]=be):be=N[9],N[10]!==he||N[11]!==V||N[12]!==_||N[13]!==D||N[14]!==xe||N[15]!==be?(ge=I(he,{contentEdit:xe,index:V,question:_,contentOptions:be,readonlyMode:D}),N[10]=he,N[11]=V,N[12]=_,N[13]=D,N[14]=xe,N[15]=be,N[16]=ge):ge=N[16],ge}function T(e){return C(e)===$.cond.type}function q(e){return"cond"===e.type}function F(e){return"fn"===e.type}function L(e){return C(e)===$.cond.type}function M(e){return C(e)===$.fn.type}function P(e,t){return t>e?t:e}function W(e){const t=e.text?.match(/\d+/);return t?parseInt(t[0],10):0}function A(e){return e}function G(e){return"fn"!==e.type&&"cond"!==e.type}function Q(e,t){const i={fn:1,cond:2};return(i[e.type]||3)-(i[t.type]||3)}export{N as QuestionMultipleSelectEditorForm};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import l from"@mui/material/Box";import i from"@mui/material/Checkbox";import a from"@mui/material/FormControl";import n from"@mui/material/FormControlLabel";import o from"@mui/material/FormLabel";import r from"@mui/material/Grid";import m from"@mui/material/InputLabel";import u from"@mui/material/MenuItem";import s from"@mui/material/Select";import d from"@mui/material/Stack";import p from"@mui/material/Typography";import{getMapType as c,Mapper as h,QuestionNumberMap as b}from"../../utils/config-map.js";import{getLocale as f,LocaleMap as y}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as x}from"../common/OptionsEditor.js";import{CommonQuestionEditor as g}from"../question_editor/QuestionCommonEditor.js";import{jsx as v,jsxs as z}from"react/jsx-runtime";function I(l){const p=e(44),{index:I,question:N,readonlyMode:V}=l,j=void 0!==V&&V,O=t(),W=O.value,S=W.name,T=W.options.min,k=W.options.max,M=W.options.step,E=W.options.unit,q=W.layout?.icon||"star";let w;p[0]!==O?(w=e=>{O.updateItem("options.unit",e)},p[0]=O,p[1]=w):w=p[1];const F=w;let L;p[2]!==T||p[3]!==O?(L=e=>{null!==e&&""!==e?T&&Number(e)<=Number(T)?O.updateItem("options.max",Number(T)):O.updateItem("options.max",e?Number(e):e):O.updateItem("options.max",e)},p[2]=T,p[3]=O,p[4]=L):L=p[4];const Q=L;let B;p[5]!==k||p[6]!==O?(B=e=>{null!==e&&""!==e?k&&Number(e)>=Number(k)?O.updateItem("options.min",Number(k)):O.updateItem("options.min",e?Number(e):e):O.updateItem("options.min",e)},p[5]=k,p[6]=O,p[7]=B):B=p[7];const G=B;let P;p[8]!==O?(P=e=>{O.updateItem("options.step",e?Number(e):e)},p[8]=O,p[9]=P):P=p[9];const _=P;let A;p[10]!==O?(A=e=>{O.updateItem("layout.icon",e)},p[10]=O,p[11]=A):A=p[11];const D=A;let H;p[12]!==O?(H=e=>{O.updateItem("name",e)},p[12]=O,p[13]=H):H=p[13];const J=H;let K;p[14]!==F||p[15]!==E||p[16]!==N||p[17]!==j?(K=()=>{if(c(N)!==h.rating.type)return v(d,{sx:{pt:4,pl:2,pr:2,pb:4,backgroundColor:"background.default"},children:v(x,{label:"unit",defaultValue:null,text:f(y.items.number.unit),value:E,handleOnChange:F,fullWidth:!0,disabled:j})})},p[14]=F,p[15]=E,p[16]=N,p[17]=j,p[18]=K):K=p[18];const R=K;let U;p[19]!==D||p[20]!==Q||p[21]!==G||p[22]!==J||p[23]!==_||p[24]!==S||p[25]!==q||p[26]!==k||p[27]!==T||p[28]!==M||p[29]!==N||p[30]!==W.layout||p[31]!==O||p[32]!==j?(U=()=>z(d,{spacing:2,children:[N.layout?.style===h.rating.type&&v(r,{container:!0,size:{xs:12,md:6},children:z(a,{fullWidth:!0,children:[v(m,{id:"formType-label",children:"Icona"}),v(s,{label:"Icona",size:"small",value:q,defaultValue:"star",onChange:e=>D(e.target.value),disabled:j,children:Object.values(b.layout.icon).map(C)})]})}),v(r,{container:!0,size:{xs:12,md:6},children:N.layout?.style!==h.rating.type?v(x,{label:"max",text:f(y.items.number.maxValue),value:k,defaultValue:h.number.defaults.max,handleOnChange:Q,showToggle:c(N)!==h.range.type,type:"number",fullWidth:!0,size:"small",disabled:j}):z(a,{fullWidth:!0,children:[v(m,{id:"max-select",children:"Massimo"}),z(s,{id:"max-select",size:"small",label:"Massimo",value:k,defaultValue:5,onChange:e=>_(e.target.value?.toString()),disabled:j,children:[v(u,{value:3,children:"3"}),v(u,{value:5,children:"5"}),v(u,{value:10,children:"10"})]})]})}),N.layout?.style!==h.rating.type&&v(r,{container:!0,size:{xs:12,md:6},children:v(x,{label:"min",text:f(y.items.number.minValue),value:T,defaultValue:h.number.defaults.min,handleOnChange:G,showToggle:c(N)!==h.range.type,type:"number",fullWidth:!0,size:"small",disabled:j})}),v(r,{container:!0,size:{xs:12,md:6},children:N.layout?.style!==h.rating.type?v(x,{label:"step",text:f(y.items.number.step),value:M,defaultValue:h.number.defaults.step,handleOnChange:_,showToggle:c(N)!==h.range.type,type:"number",fullWidth:!0,size:"small",minValue:.5,maxValue:1,disabled:j}):z(a,{fullWidth:!0,children:[v(m,{id:"formType-label",children:"Step"}),z(s,{size:"small",label:"Step",value:M,defaultValue:1,onChange:e=>_(e.target.value?.toString()),disabled:j,children:[v(u,{value:.5,children:"0.5"}),v(u,{value:1,children:"1"})]})]})}),v(r,{container:!0,display:"flex",size:{xs:12,md:6},children:z(a,{component:"fieldset",variant:"standard",children:[v(o,{children:"Visibilità"}),v(n,{label:"Nascosto",control:v(i,{checked:0===W.layout?.visibility,disabled:j,onChange:()=>{O.updateItem("layout",0===W.layout?.visibility?{...W.layout,visibility:1}:{...W.layout,visibility:0})}})})]})}),v(r,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:v(x,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:S,size:"small",handleOnChange:J,disabled:j})})]}),p[19]=D,p[20]=Q,p[21]=G,p[22]=J,p[23]=_,p[24]=S,p[25]=q,p[26]=k,p[27]=T,p[28]=M,p[29]=N,p[30]=W.layout,p[31]=O,p[32]=j,p[33]=U):U=p[33];const X=U;let Y,Z,$;return p[34]!==R?(Y=R(),p[34]=R,p[35]=Y):Y=p[35],p[36]!==X?(Z=X(),p[36]=X,p[37]=Z):Z=p[37],p[38]!==I||p[39]!==N||p[40]!==j||p[41]!==Y||p[42]!==Z?($=v(g,{contentEdit:Y,contentOptions:Z,index:I,question:N,readonlyMode:j}),p[38]=I,p[39]=N,p[40]=j,p[41]=Y,p[42]=Z,p[43]=$):$=p[43],$}function C(e){return v(u,{value:e.type,children:z(l,{component:"div",sx:{display:"flex"},children:[e.element.unselected,v(p,{sx:{ml:2},children:f(y.items.number[e.type])})]})},e.type)}export{I as QuestionNumberEditorForm};
1
+ import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import l from"@mui/material/Box";import a from"@mui/material/FormControl";import i from"@mui/material/Grid";import n from"@mui/material/InputLabel";import o from"@mui/material/MenuItem";import r from"@mui/material/Select";import m from"@mui/material/Stack";import u from"@mui/material/Typography";import{getMapType as s,Mapper as d,QuestionNumberMap as p}from"../../utils/config-map.js";import{getLocale as c,LocaleMap as h}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as f}from"../common/OptionsEditor.js";import{CommonQuestionEditor as b}from"../question_editor/QuestionCommonEditor.js";import{jsx as y,jsxs as g}from"react/jsx-runtime";function x(l){const u=e(43),{index:x,question:z,readonlyMode:I}=l,C=void 0!==I&&I,N=t(),V=N.value,j=V.name,O=V.options.min,W=V.options.max,S=V.options.step,T=V.options.unit,M=V.layout?.icon||"star";let E;u[0]!==N?(E=e=>{N.updateItem("options.unit",e)},u[0]=N,u[1]=E):E=u[1];const k=E;let q;u[2]!==O||u[3]!==N?(q=e=>{null!==e&&""!==e?O&&Number(e)<=Number(O)?N.updateItem("options.max",Number(O)):N.updateItem("options.max",e?Number(e):e):N.updateItem("options.max",e)},u[2]=O,u[3]=N,u[4]=q):q=u[4];const w=q;let Q;u[5]!==W||u[6]!==N?(Q=e=>{null!==e&&""!==e?W&&Number(e)>=Number(W)?N.updateItem("options.min",Number(W)):N.updateItem("options.min",e?Number(e):e):N.updateItem("options.min",e)},u[5]=W,u[6]=N,u[7]=Q):Q=u[7];const B=Q;let F;u[8]!==N?(F=e=>{N.updateItem("options.step",e?Number(e):e)},u[8]=N,u[9]=F):F=u[9];const G=F;let L;u[10]!==N?(L=e=>{N.updateItem("layout.icon",e)},u[10]=N,u[11]=L):L=u[11];const P=L;let _;u[12]!==N?(_=e=>{N.updateItem("name",e)},u[12]=N,u[13]=_):_=u[13];const A=_;let D;u[14]!==k||u[15]!==T||u[16]!==z||u[17]!==C?(D=()=>{if(s(z)!==d.rating.type)return y(m,{sx:{pt:4,pl:2,pr:2,pb:4,backgroundColor:"background.default"},children:y(f,{label:"unit",defaultValue:null,text:c(h.items.number.unit),value:T,handleOnChange:k,fullWidth:!0,disabled:C})})},u[14]=k,u[15]=T,u[16]=z,u[17]=C,u[18]=D):D=u[18];const H=D;let J;u[19]!==P||u[20]!==w||u[21]!==B||u[22]!==A||u[23]!==G||u[24]!==j||u[25]!==M||u[26]!==W||u[27]!==O||u[28]!==S||u[29]!==z||u[30]!==V.layout?.style||u[31]!==C?(J=()=>g(m,{spacing:2,children:[V.layout?.style===d.rating.type&&y(i,{container:!0,size:{xs:12,md:6},children:g(a,{fullWidth:!0,children:[y(n,{id:"formType-label",children:"Icona"}),y(r,{label:"Icona",size:"small",value:M,defaultValue:"star",onChange:e=>P(e.target.value),disabled:C,children:Object.values(p.layout.icon).map(v)})]})}),y(i,{container:!0,size:{xs:12,md:6},children:V.layout?.style!==d.rating.type?y(f,{label:"max",text:c(h.items.number.maxValue),value:W,defaultValue:d.number.defaults.max,handleOnChange:w,showToggle:s(z)!==d.range.type,type:"number",fullWidth:!0,size:"small",disabled:C}):g(a,{fullWidth:!0,children:[y(n,{id:"max-select",children:"Massimo"}),g(r,{id:"max-select",size:"small",label:"Massimo",value:W,defaultValue:5,onChange:e=>G(e.target.value?.toString()),disabled:C,children:[y(o,{value:3,children:"3"}),y(o,{value:5,children:"5"}),y(o,{value:10,children:"10"})]})]})}),V.layout?.style!==d.rating.type&&y(i,{container:!0,size:{xs:12,md:6},children:y(f,{label:"min",text:c(h.items.number.minValue),value:O,defaultValue:d.number.defaults.min,handleOnChange:B,showToggle:s(z)!==d.range.type,type:"number",fullWidth:!0,size:"small",disabled:C})}),y(i,{container:!0,size:{xs:12,md:6},children:z.layout?.style!==d.rating.type?y(f,{label:"step",text:c(h.items.number.step),value:S,defaultValue:d.number.defaults.step,handleOnChange:G,showToggle:s(z)!==d.range.type,type:"number",fullWidth:!0,size:"small",minValue:.5,maxValue:1,disabled:C}):g(a,{fullWidth:!0,children:[y(n,{id:"formType-label",children:"Step"}),g(r,{size:"small",label:"Step",value:S,defaultValue:1,onChange:e=>G(e.target.value?.toString()),disabled:C,children:[y(o,{value:.5,children:"0.5"}),y(o,{value:1,children:"1"})]})]})}),y(i,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:y(f,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:j,size:"small",handleOnChange:A,disabled:C})})]}),u[19]=P,u[20]=w,u[21]=B,u[22]=A,u[23]=G,u[24]=j,u[25]=M,u[26]=W,u[27]=O,u[28]=S,u[29]=z,u[30]=V.layout?.style,u[31]=C,u[32]=J):J=u[32];const K=J;let R,U,X;return u[33]!==H?(R=H(),u[33]=H,u[34]=R):R=u[34],u[35]!==K?(U=K(),u[35]=K,u[36]=U):U=u[36],u[37]!==x||u[38]!==z||u[39]!==C||u[40]!==R||u[41]!==U?(X=y(b,{contentEdit:R,contentOptions:U,index:x,question:z,readonlyMode:C}),u[37]=x,u[38]=z,u[39]=C,u[40]=R,u[41]=U,u[42]=X):X=u[42],X}function v(e){return y(o,{value:e.type,children:g(l,{component:"div",sx:{display:"flex"},children:[e.element.unselected,y(u,{sx:{ml:2},children:c(h.items.number[e.type])})]})},e.type)}export{x as QuestionNumberEditorForm};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import i from"@mui/material/Box";import o from"@mui/material/Button";import l from"@mui/material/Checkbox";import r from"@mui/material/FormControl";import n from"@mui/material/FormControlLabel";import a from"@mui/material/FormLabel";import m from"@mui/material/Grid";import s from"@mui/material/IconButton";import d from"@mui/material/Radio";import c from"@mui/material/RadioGroup";import u from"@mui/material/Stack";import p from"@mui/material/TextField";import h from"@mui/material/Typography";import{CircleArrowUp as b,CircleArrowDown as f,Trash2 as x,PlusCircle as g}from"lucide-react";import v from"react";import{OptionTextField as y}from"../common/OptionsEditor.js";import{CommonQuestionEditor as z}from"../question_editor/QuestionCommonEditor.js";import C from"@mui/material/Tooltip";import I from"@mui/material/Chip";import{jsx as k,jsxs as j}from"react/jsx-runtime";function w(w){const B=e(52),{index:E,question:F,readonlyMode:N}=w,O=void 0!==N&&N,T=t(),q=T.value,_=q.name,A=q.options?.select??[],[G,L]=v.useState(Array(A.length||0).fill(null));let M;B[0]===Symbol.for("react.memo_cache_sentinel")?(M=e=>{const t=e.map($),i=t.filter((e,i)=>t.indexOf(e)!==i),o=e.filter(V),l=e.map(e=>i.includes(e.score)?"Valore duplicato":o.includes(e)?"Il campo non può essere vuoto":null);L(l)},B[0]=M):M=B[0];const Q=M;let R;B[1]!==T||B[2]!==A?(R=function(){const e={text:`Selezione ${A.length+1}`,score:A?.length?A[A.length-1].score+1:0},t=[...A,e];T.updateItem("options.select",t),Q(t)},B[1]=T,B[2]=A,B[3]=R):R=B[3];const D=R;let P;B[4]!==T||B[5]!==A?(P=e=>{T.removeItem("options.select",e);const t=A.filter(t=>t!==e);Q(t)},B[4]=T,B[5]=A,B[6]=P):P=B[6];const W=P;let H;B[7]!==T||B[8]!==A?(H=(e,t)=>{t<0||t>=A.length||T.updateItem("options.select",A.map((i,o)=>o===e?A[t]:o===t?A[e]:i))},B[7]=T,B[8]=A,B[9]=H):H=B[9];const J=H;let K;B[10]!==T||B[11]!==A?(K=(e,t)=>{T.updateItem("options.select",A.map((i,o)=>o===e?{text:t,score:i.score}:i))},B[10]=T,B[11]=A,B[12]=K):K=B[12];const U=K;let X;B[13]!==T||B[14]!==A?(X=(e,t)=>{T.updateItem("options.select",A.map((i,o)=>o===e?{text:i.text,score:t}:i))},B[13]=T,B[14]=A,B[15]=X):X=B[15];const Y=X;let Z;B[16]!==G?(Z=G.filter(S),B[16]=G,B[17]=Z):Z=B[17];const ee=Boolean(Z.length);let te;B[18]!==G||B[19]!==Y||B[20]!==A?(te=(e,t)=>{const i=A.some((i,o)=>o!==e&&i.score===t),o=[...G];o[e]=i?"Valore duplicato":null,L(o),Y(e,t)},B[18]=G,B[19]=Y,B[20]=A,B[21]=te):te=B[21];const ie=te;let oe;B[22]!==T?(oe=e=>{T.updateItem("name",e)},B[22]=T,B[23]=oe):oe=B[23];const le=oe;let re;B[24]!==D||B[25]!==G||B[26]!==ie||B[27]!==ee||B[28]!==J||B[29]!==q.id||B[30]!==O||B[31]!==W||B[32]!==A||B[33]!==U?(re=()=>k(i,{sx:{pt:4,pl:2,pr:2,pb:4,backgroundColor:"background.default"},children:j(r,{sx:{width:"100%"},children:[k(c,{name:q.id,"aria-label":q.id,style:{margin:"0.25rem"},children:A.map((e,t)=>j(u,{direction:"row",spacing:1,sx:{mb:"1rem",alignItems:"center"},children:[k(n,{disabled:!0,value:"disabled",control:k(d,{disabled:O}),label:""},t),k(p,{label:""===e.text?"Il campo non può essere vuoto":"Testo",value:e.text,error:""===e.text,onChange:e=>U(t,e.target.value),sx:{width:"100%"},size:"small",disabled:O}),k(p,{label:G[t]?G[t]:"Valore",disabled:O,type:"number",value:e.score,onChange:e=>ie(t,Number(e.target.value)),error:!!G[t],size:"small"}),k(s,{"aria-label":`move-up-button-${e.text}`,disabled:0===t||ee||O,color:"inherit",onClick:()=>J(t,t-1),children:k(b,{size:20})}),k(s,{"aria-label":`move-down-button-${e.text}`,disabled:t===A.length-1||ee||O,color:"inherit",onClick:()=>J(t,t+1),children:k(f,{size:20})}),k(s,{"aria-label":`delete-button-${e.text}`,color:"inherit",disabled:A.length<=1||O,onClick:()=>W(e),children:k(x,{size:20})})]},t))}),k(i,{sx:{mt:2},children:j(o,{variant:"outlined",color:"inherit",onClick:D,disabled:O,children:[k(g,{size:20})," ",k(h,{sx:{ml:1},children:"Aggiungi opzione"})]})})]})}),B[24]=D,B[25]=G,B[26]=ie,B[27]=ee,B[28]=J,B[29]=q.id,B[30]=O,B[31]=W,B[32]=A,B[33]=U,B[34]=re):re=B[34];const ne=re;let ae;B[35]!==le||B[36]!==_||B[37]!==F?.id||B[38]!==q.layout||B[39]!==T||B[40]!==O?(ae=()=>j(u,{children:[k(n,{control:k(l,{checked:q.layout?.score??!1,disabled:O,onChange:e=>{T.updateItem("layout.score",e.target.checked)}}),label:"Valori opzioni visibili"}),k(m,{container:!0,display:"flex",size:{xs:12,md:6},children:j(r,{component:"fieldset",variant:"standard",children:[k(a,{children:"Visibilità"}),k(n,{label:"Nascosto",control:k(l,{checked:0===q.layout?.visibility,disabled:O,onChange:()=>{T.updateItem("layout",0===q.layout?.visibility?{...q.layout,visibility:1}:{...q.layout,visibility:0})}})})]})}),k(m,{container:!0,size:{xs:12,md:6},sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:3},children:k(y,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:_,size:"small",handleOnChange:le,disabled:O})}),k(m,{container:!0,mt:3,size:{xs:12,md:6},children:k(C,{title:"Identificativo domanda",arrow:!0,children:k(I,{label:`ID: ${F?.id}`,variant:"outlined",size:"small"})})})]}),B[35]=le,B[36]=_,B[37]=F?.id,B[38]=q.layout,B[39]=T,B[40]=O,B[41]=ae):ae=B[41];const me=ae;let se,de,ce;return B[42]!==ne?(se=ne(),B[42]=ne,B[43]=se):se=B[43],B[44]!==me?(de=me(),B[44]=me,B[45]=de):de=B[45],B[46]!==E||B[47]!==F||B[48]!==O||B[49]!==se||B[50]!==de?(ce=k(z,{contentEdit:se,contentOptions:de,index:E,question:F,readonlyMode:O}),B[46]=E,B[47]=F,B[48]=O,B[49]=se,B[50]=de,B[51]=ce):ce=B[51],ce}function S(e){return e}function V(e){return""===e.text}function $(e){return e.score}export{w as QuestionSelectEditorForm};
1
+ import{c as e}from"react/compiler-runtime";import{MotionButton as t}from"../../components/animations/MotionWrappers.js";import{useQuestionStateContext as o}from"../../providers/editor/QuestionStateProvider.js";import i from"@mui/material/Box";import r from"@mui/material/Checkbox";import l from"@mui/material/Chip";import n from"@mui/material/FormControl";import a from"@mui/material/FormControlLabel";import m from"@mui/material/Grid";import c from"@mui/material/IconButton";import s from"@mui/material/Radio";import d from"@mui/material/RadioGroup";import p from"@mui/material/Stack";import u from"@mui/material/TextField";import f from"@mui/material/Tooltip";import h from"@mui/material/Typography";import{CircleArrowUp as b,CircleArrowDown as x,Trash2 as g,PlusCircle as y}from"lucide-react";import{AnimatePresence as v}from"motion/react";import*as _ from"motion/react-m";import z from"react";import{OptionTextField as I}from"../common/OptionsEditor.js";import{CommonQuestionEditor as C}from"../question_editor/QuestionCommonEditor.js";import{jsx as S,jsxs as k}from"react/jsx-runtime";const $=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`;function j($){const j=e(87),{index:M,question:q,readonlyMode:D}=$,F=void 0!==D&&D,N=o(),A=N.value,G=A.name,Q=A.options?.select??[],[R,U]=z.useState(()=>Q.map(E)),[V,W]=z.useState(Array(Q.length||0).fill(null));let L;j[0]===Symbol.for("react.memo_cache_sentinel")?(L=e=>{const t=e.map(B),o=t.filter((e,o)=>""!==e&&t.indexOf(e)!==o),i=e.map(e=>{const t=e.text.trim();return""===t?"Il campo non può essere vuoto":o.includes(t)?"Testo duplicato":null});W(i)},j[0]=L):L=j[0];const P=L;let H;j[1]!==N||j[2]!==Q||j[3]!==U?(H=function(){const e=Q.length>0?(Q[Q.length-1]?.score||0)+1:0,t={text:`Selezione ${Q.length+1}`,score:e},o=[...Q,t];N.updateItem("options.select",o),U(T),P(o)},j[1]=N,j[2]=Q,j[3]=U,j[4]=H):H=j[4];const J=H;let K;j[5]!==N||j[6]!==Q||j[7]!==U?(K=e=>{if(Q.length<=1||!e)return;N.removeItem("options.select",e);const t=Q.indexOf(e);-1!==t&&U(e=>e.filter((e,o)=>o!==t));const o=Q.filter(t=>t!==e);P(o)},j[5]=N,j[6]=Q,j[7]=U,j[8]=K):K=j[8];const X=K;let Y;j[9]!==N||j[10]!==Q||j[11]!==U?(Y=(e,t)=>{t<0||t>=Q.length||(U(o=>o.map((i,r)=>r===e?o[t]:r===t?o[e]:i).filter(O)),N.updateItem("options.select",Q.map((o,i)=>i===e?Q[t]:i===t?Q[e]:o)))},j[9]=N,j[10]=Q,j[11]=U,j[12]=Y):Y=j[12];const Z=Y;let ee;j[13]!==N||j[14]!==Q?(ee=(e,t)=>{const o=Q.map((o,i)=>i===e?{text:t,score:o.score}:o);N.updateItem("options.select",o),P(o)},j[13]=N,j[14]=Q,j[15]=ee):ee=j[15];const te=ee;let oe;j[16]!==N||j[17]!==Q?(oe=(e,t)=>{N.updateItem("options.select",Q.map((o,i)=>i===e?{text:o.text,score:t}:o))},j[16]=N,j[17]=Q,j[18]=oe):oe=j[18];const ie=oe;let re;j[19]!==V?(re=V.filter(w),j[19]=V,j[20]=re):re=j[20];const le=Boolean(re.length);let ne;j[21]!==ie?(ne=(e,t)=>{ie(e,t)},j[21]=ie,j[22]=ne):ne=j[22];const ae=ne;let me;j[23]!==N?(me=e=>{N.updateItem("name",e)},j[23]=N,j[24]=me):me=j[24];const ce=me;let se,de;j[25]===Symbol.for("react.memo_cache_sentinel")?(se={pt:4,pl:2,pr:2,pb:4,backgroundColor:"background.default"},j[25]=se):se=j[25],j[26]===Symbol.for("react.memo_cache_sentinel")?(de={width:"100%"},j[26]=de):de=j[26];const pe=A.id,ue=A.id;let fe,he,be,xe,ge,ye,ve,_e,ze;if(j[27]===Symbol.for("react.memo_cache_sentinel")?(fe={margin:"0.25rem"},j[27]=fe):fe=j[27],j[28]!==V||j[29]!==ae||j[30]!==le||j[31]!==Z||j[32]!==F||j[33]!==X||j[34]!==R||j[35]!==Q||j[36]!==te){let e;j[38]!==V||j[39]!==ae||j[40]!==le||j[41]!==Z||j[42]!==F||j[43]!==X||j[44]!==R||j[45]!==Q.length||j[46]!==te?(e=(e,t)=>S(_.div,{layout:!0,initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.18,ease:"easeInOut"},children:k(p,{direction:"row",spacing:1,sx:{mb:1.5,alignItems:"center"},children:[S(a,{disabled:!0,value:"disabled",control:S(s,{disabled:F}),label:""}),S(u,{label:V[t]?V[t]:"Testo",value:e.text,error:!!V[t],onChange:e=>te(t,e.target.value),sx:{width:"100%"},size:"small",disabled:F}),S(u,{label:"Valore",disabled:F,type:"number",value:e.score,onChange:e=>ae(t,Number(e.target.value)),error:!1,size:"small"}),S(c,{"aria-label":`move-up-button-${e.text}`,disabled:0===t||le||F,color:"primary",onClick:()=>Z(t,t-1),children:S(b,{size:20})}),S(c,{"aria-label":`move-down-button-${e.text}`,disabled:t===Q.length-1||le||F,color:"primary",onClick:()=>Z(t,t+1),children:S(x,{size:20})}),S(c,{"aria-label":`delete-button-${e.text}`,color:"error",disabled:Q.length<=1||F,onClick:()=>X(e),children:S(g,{size:20})})]})},R[t]??`select-option-fallback-${t}`),j[38]=V,j[39]=ae,j[40]=le,j[41]=Z,j[42]=F,j[43]=X,j[44]=R,j[45]=Q.length,j[46]=te,j[47]=e):e=j[47],he=Q.map(e),j[28]=V,j[29]=ae,j[30]=le,j[31]=Z,j[32]=F,j[33]=X,j[34]=R,j[35]=Q,j[36]=te,j[37]=he}else he=j[37];j[48]!==he?(be=S(v,{initial:!1,children:he}),j[48]=he,j[49]=be):be=j[49],j[50]!==A.id||j[51]!==be?(xe=S(d,{name:pe,"aria-label":ue,style:fe,children:be}),j[50]=A.id,j[51]=be,j[52]=xe):xe=j[52],j[53]===Symbol.for("react.memo_cache_sentinel")?(ge={mt:2},j[53]=ge):ge=j[53],j[54]===Symbol.for("react.memo_cache_sentinel")?(ye=S(y,{size:20}),j[54]=ye):ye=j[54],j[55]===Symbol.for("react.memo_cache_sentinel")?(ve=S(h,{sx:{ml:1},children:"Aggiungi opzione"}),j[55]=ve):ve=j[55],j[56]!==J||j[57]!==F?(_e=S(i,{sx:ge,children:k(t,{variant:"outlined",color:"inherit",onClick:J,disabled:F,children:[ye," ",ve]})}),j[56]=J,j[57]=F,j[58]=_e):_e=j[58],j[59]!==xe||j[60]!==_e?(ze=S(i,{sx:se,children:k(n,{sx:de,children:[xe,_e]})}),j[59]=xe,j[60]=_e,j[61]=ze):ze=j[61];const Ie=ze,Ce=Boolean(A.layout?.score);let Se,ke,$e,je,we,Oe;j[62]!==N?(Se=e=>{N.updateItem("layout.score",e.target.checked)},j[62]=N,j[63]=Se):Se=j[63],j[64]!==F||j[65]!==Ce||j[66]!==Se?(ke=S(a,{control:S(r,{checked:Ce,disabled:F,onChange:Se}),label:"Valori opzioni visibili"}),j[64]=F,j[65]=Ce,j[66]=Se,j[67]=ke):ke=j[67],j[68]===Symbol.for("react.memo_cache_sentinel")?($e={xs:12,md:6},je={justifyContent:"flex-end",alignItems:"flex-end",pt:3},j[68]=$e,j[69]=je):($e=j[68],je=j[69]),j[70]!==ce||j[71]!==G||j[72]!==F?(we=S(m,{container:!0,size:$e,sx:je,children:S(I,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:G,size:"small",handleOnChange:ce,disabled:F})}),j[70]=ce,j[71]=G,j[72]=F,j[73]=we):we=j[73],j[74]===Symbol.for("react.memo_cache_sentinel")?(Oe={xs:12,md:6},j[74]=Oe):Oe=j[74];const Te=`ID: ${q?.id}`;let Be,Ee;j[75]!==Te?(Be=S(m,{container:!0,mt:3,size:Oe,children:S(f,{title:"Identificativo domanda",arrow:!0,children:S(l,{label:Te,variant:"outlined",size:"small"})})}),j[75]=Te,j[76]=Be):Be=j[76],j[77]!==ke||j[78]!==we||j[79]!==Be?(Ee=k(p,{children:[ke,we,Be]}),j[77]=ke,j[78]=we,j[79]=Be,j[80]=Ee):Ee=j[80];const Me=Ee;let qe;return j[81]!==M||j[82]!==q||j[83]!==F||j[84]!==Ie||j[85]!==Me?(qe=S(C,{contentEdit:Ie,contentOptions:Me,index:M,question:q,readonlyMode:F}),j[81]=M,j[82]=q,j[83]=F,j[84]=Ie,j[85]=Me,j[86]=qe):qe=j[86],qe}function w(e){return e}function O(e){return"string"==typeof e}function T(e){return[...e,$()]}function B(e){return e.text.trim()}function E(){return $()}export{j as QuestionSelectEditorForm};
@@ -0,0 +1 @@
1
+ import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Grid";import i from"@mui/material/Stack";import{OptionTextField as n}from"../common/OptionsEditor.js";import{CommonQuestionEditor as r}from"../question_editor/QuestionCommonEditor.js";import{jsx as m}from"react/jsx-runtime";const a=a=>{const l=e(13),{index:s,question:d,readonlyMode:c}=a,p=void 0!==c&&c,u=t(),f=u.value.name;let x;l[0]!==u?(x=e=>{u.updateItem("name",e)},l[0]=u,l[1]=x):x=l[1];const h=x;let v,z,j;l[2]===Symbol.for("react.memo_cache_sentinel")?(v={xs:12,md:6},z={justifyContent:"flex-end",alignItems:"flex-end",pt:1},l[2]=v,l[3]=z):(v=l[2],z=l[3]),l[4]!==h||l[5]!==f||l[6]!==p?(j=m(i,{spacing:2,children:m(o,{container:!0,size:v,sx:z,children:m(n,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:f,size:"small",handleOnChange:h,disabled:p})})}),l[4]=h,l[5]=f,l[6]=p,l[7]=j):j=l[7];const y=j;let b;return l[8]!==s||l[9]!==d||l[10]!==p||l[11]!==y?(b=m(r,{index:s,contentOptions:y,question:d,readonlyMode:p}),l[8]=s,l[9]=d,l[10]=p,l[11]=y,l[12]=b):b=l[12],b};export{a as QuestionSignatureEditor};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Grid";import r from"@mui/material/IconButton";import n from"@mui/material/Radio";import l from"@mui/material/Stack";import i from"@mui/material/TextField";import a from"@mui/material/Typography";import{Trash2Icon as s,CirclePlus as c}from"lucide-react";import m from"react";import{calculateLatestId as d}from"../../hooks/editor/QuestionOperations.js";import{getDefaultData as p,Mapper as u}from"../../utils/config-map.js";import"../../utils/locale.js";import{formatName as h}from"../../utils/format-utils.js";import"@famalabs/survey";import"acorn";import{CommonQuestionEditor as g}from"../question_editor/QuestionCommonEditor.js";import{jsx as f,jsxs as x}from"react/jsx-runtime";function b(n){const b=e(80),{index:I,question:_,readonlyMode:C}=n,S=void 0!==C&&C,$=t(),k=$.value.items||[],j=k?$.value.items?.[0]:null,w=j?.options?.select||[],[A,B]=m.useState(Array(w?.length).fill(null));let F;b[0]!==A?(F=A.filter(z),b[0]=A,b[1]=F):F=b[1];const q=Boolean(F.length),[R,T]=m.useState(Array(k?.length).fill(null));let V;b[2]!==R?(V=R.filter(v),b[2]=R,b[3]=V):V=b[3];const W=Boolean(V.length);let G;b[4]!==w.length||b[5]!==$||b[6]!==k?(G=()=>{const e={text:`Selezione ${w.length+1}`,score:w.length};for(let t=0;t<k.length;t++)$.updateItem(`items[${t}].options.select`,[...k[t].options?.select??[],e])},b[4]=w.length,b[5]=$,b[6]=k,b[7]=G):G=b[7];const P=G;let Q;b[8]!==w||b[9]!==$||b[10]!==k.length?(Q=e=>{const t=w.filter((t,o)=>o!==e);for(let e=0;e<k.length;e++)$.updateItem(`items[${e}].options.select`,t)},b[8]=w,b[9]=$,b[10]=k.length,b[11]=Q):Q=b[11];const D=Q;let E;b[12]!==A||b[13]!==w||b[14]!==$||b[15]!==B?(E=(e,t)=>{const o=w.some((o,r)=>t!==r&&o.text===e),r=[...A];r[t]=o?"Valore duplicato":""===e?"Valore non può essere vuoto":null,B(r),$.updateItem(`items[0].options.select[${t}].text`,e)},b[12]=A,b[13]=w,b[14]=$,b[15]=B,b[16]=E):E=b[16];const M=E;let O;b[17]!==_?(O=d(_),b[17]=_,b[18]=O):O=b[18];const H=m.useRef(O);let J;b[19]!==w||b[20]!==_.name||b[21]!==$||b[22]!==k.length?(J=()=>{const e={...{...p(u.select.type)},id:(H.current+1).toString(),text:`Domanda ${k.length+1}`,name:`${_.name}_domanda_${k.length+1}`,index:k?.length||1,options:{required:!0,select:w}};$.addItem("items",e),H.current=H.current+1},b[19]=w,b[20]=_.name,b[21]=$,b[22]=k.length,b[23]=J):J=b[23];const K=J;let L;b[24]!==$||b[25]!==k?(L=e=>{const t=k.filter((t,o)=>o!==e);$.updateItem("items",t)},b[24]=$,b[25]=k,b[26]=L):L=b[26];const N=L;let U;b[27]!==_.name||b[28]!==$||b[29]!==R||b[30]!==k?(U=(e,t)=>{const o=k.some((o,r)=>t!==r&&o.text===e),r=[...R];r[t]=o?"Valore duplicato":""===e?"Valore non può essere vuoto":null,T(r),$.updateItem(`items[${t}].text`,e),$.updateItem(`items[${t}].name`,`${_.name}_${h(e)}`)},b[27]=_.name,b[28]=$,b[29]=R,b[30]=k,b[31]=U):U=b[31];const X=U;let Y;b[32]!==A||b[33]!==S||b[34]!==D||b[35]!==M?(Y=(e,t)=>f(i,{size:"small",value:e.text,onChange:e=>M(e.target.value,t),error:Boolean(A[t]),helperText:A[t],disabled:S,sx:{flex:"1 1 180px",minWidth:160,bgcolor:"background.default"},slotProps:{input:{endAdornment:f(r,{color:"error","aria-label":"drag-handle",size:"small",onClick:()=>D(t),children:f(s,{size:18})})},htmlInput:{"aria-label":"select-text-field"}}}),b[32]=A,b[33]=S,b[34]=D,b[35]=M,b[36]=Y):Y=b[36];const Z=Y;let ee;b[37]!==w||b[38]!==S||b[39]!==N||b[40]!==R||b[41]!==X?(ee=(e,t)=>x(l,{spacing:1.5,sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[f(i,{size:"small","aria-label":"select-text-field",value:e.text,onChange:e=>X(e.target.value,t),error:Boolean(R[t]),helperText:R[t],disabled:S,sx:{minWidth:200,bgcolor:"background.default"},slotProps:{input:{endAdornment:f(r,{color:"error","aria-label":"drag-handle",size:"small",onClick:()=>N(t),children:f(s,{size:18})})},htmlInput:{"aria-label":"option-text-field"}}}),w.length>0&&f(l,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",children:w.map(y)})]}),b[37]=w,b[38]=S,b[39]=N,b[40]=R,b[41]=X,b[42]=ee):ee=b[42];const te=ee;let oe,re;b[43]===Symbol.for("react.memo_cache_sentinel")?(oe={pt:4,pl:2,pr:2,pb:4,backgroundColor:"background.default"},b[43]=oe):oe=b[43],b[44]===Symbol.for("react.memo_cache_sentinel")?(re=f(o,{children:f(a,{variant:"body1",color:"text.secondary",children:"Opzioni di risposta"})}),b[44]=re):re=b[44];const ne=q||S;let le,ie,ae,se,ce,me;if(b[45]===Symbol.for("react.memo_cache_sentinel")?(le=f(c,{size:18}),b[45]=le):le=b[45],b[46]!==P||b[47]!==ne?(ie=x(o,{container:!0,size:12,alignItems:"center",justifyContent:"space-between",children:[re,f(o,{children:f(r,{title:"Aggiungi opzione","aria-label":"add-select-button",color:"primary",onClick:P,disabled:ne,children:le})})]}),b[46]=P,b[47]=ne,b[48]=ie):ie=b[48],b[49]!==w||b[50]!==Z){let e;b[52]!==Z?(e=(e,t)=>f(m.Fragment,{children:Z(e,t)},t),b[52]=Z,b[53]=e):e=b[53],ae=w.map(e),b[49]=w,b[50]=Z,b[51]=ae}else ae=b[51];b[54]!==ae?(se=f(l,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",alignItems:"flex-start",children:ae}),b[54]=ae,b[55]=se):se=b[55],b[56]!==ie||b[57]!==se?(ce=x(l,{spacing:1.5,children:[ie,se]}),b[56]=ie,b[57]=se,b[58]=ce):ce=b[58],b[59]===Symbol.for("react.memo_cache_sentinel")?(me=f(o,{children:f(a,{variant:"body1",color:"text.secondary",children:"Domande"})}),b[59]=me):me=b[59];const de=W||S;let pe,ue,he,ge,fe;if(b[60]===Symbol.for("react.memo_cache_sentinel")?(pe=f(c,{size:18}),b[60]=pe):pe=b[60],b[61]!==K||b[62]!==de?(ue=x(o,{container:!0,size:12,alignItems:"center",justifyContent:"space-between",children:[me,f(o,{children:f(r,{title:"Aggiungi domanda","aria-label":"add-option-button",color:"primary",onClick:K,disabled:de,children:pe})})]}),b[61]=K,b[62]=de,b[63]=ue):ue=b[63],b[64]!==te||b[65]!==k){let e;b[67]!==te?(e=(e,t)=>f(m.Fragment,{children:te(e,t)},e.id??t),b[67]=te,b[68]=e):e=b[68],he=k.map(e),b[64]=te,b[65]=k,b[66]=he}else he=b[66];b[69]!==ue||b[70]!==he?(ge=x(l,{spacing:2,children:[ue,he]}),b[69]=ue,b[70]=he,b[71]=ge):ge=b[71],b[72]!==ce||b[73]!==ge?(fe=x(l,{sx:oe,spacing:3,children:[ce,ge]}),b[72]=ce,b[73]=ge,b[74]=fe):fe=b[74];const xe=fe;let be;return b[75]!==I||b[76]!==_||b[77]!==S||b[78]!==xe?(be=f(g,{contentEdit:xe,index:I,question:_,readonlyMode:S}),b[75]=I,b[76]=_,b[77]=S,b[78]=xe,b[79]=be):be=b[79],be}function y(e,t){return x(l,{direction:"row",spacing:.5,alignItems:"center",sx:{px:1,py:.5,borderRadius:1,bgcolor:"action.hover"},children:[f(n,{disabled:!0,size:"small",sx:{p:0}}),f(a,{variant:"body2",color:"text.secondary",children:e.text})]},t)}function v(e){return e}function z(e){return e}export{b as QuestionTableEditorForm};
1
+ import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Button";import r from"@mui/material/Grid";import n from"@mui/material/IconButton";import i from"@mui/material/Radio";import l from"@mui/material/Stack";import a from"@mui/material/TextField";import s from"@mui/material/Typography";import{Trash2Icon as c,CirclePlus as m}from"lucide-react";import d from"react";import{calculateLatestId as p}from"../../hooks/editor/QuestionOperations.js";import{useFormStateContext as u}from"../../providers/common/FormStateProvider.js";import{jsx as h,jsxs as g}from"react/jsx-runtime";import{getDefaultData as f,Mapper as b}from"../../utils/config-map.js";import"../../utils/locale.js";import{formatName as x}from"../../utils/format-utils.js";import"@famalabs/survey";import"acorn";import{CommonQuestionEditor as y}from"../question_editor/QuestionCommonEditor.js";function v(i){const v=e(86),{index:S,question:C,readonlyMode:$}=i,j=void 0!==$&&$,{formInstance:k}=u(),w=t(),A=w.value.items||[],B=A?w.value.items?.[0]:null,F=B?.options?.select||[],[W,q]=d.useState(Array(F?.length).fill(null));let P;v[0]!==W?(P=W.filter(z),v[0]=W,v[1]=P):P=v[1];const T=Boolean(P.length),[V,G]=d.useState(Array(A?.length).fill(null));let Q;v[2]!==V?(Q=V.filter(I),v[2]=V,v[3]=Q):Q=v[3];const R=Boolean(Q.length);let D;v[4]!==F.length||v[5]!==w||v[6]!==A?(D=()=>{const e={text:`Selezione ${F.length+1}`,score:F.length};for(let t=0;t<A.length;t++)w.updateItem(`items[${t}].options.select`,[...A[t]?.options?.select??[],e])},v[4]=F.length,v[5]=w,v[6]=A,v[7]=D):D=v[7];const E=D;let M;v[8]!==F||v[9]!==w||v[10]!==A.length?(M=e=>{const t=F.filter((t,o)=>o!==e);for(let e=0;e<A.length;e++)w.updateItem(`items[${e}].options.select`,t)},v[8]=F,v[9]=w,v[10]=A.length,v[11]=M):M=v[11];const O=M;let H;v[12]!==W||v[13]!==F||v[14]!==w||v[15]!==q?(H=(e,t)=>{const o=F.some((o,r)=>t!==r&&o.text===e),r=[...W];r[t]=o?"Valore duplicato":""===e?"Valore non può essere vuoto":null,q(r),w.updateItem(`items[0].options.select[${t}].text`,e)},v[12]=W,v[13]=F,v[14]=w,v[15]=q,v[16]=H):H=v[16];const Y=H;let J;v[17]!==k?(J=p(k),v[17]=k,v[18]=J):J=v[18];const[K,L]=d.useState(J);let N;v[19]!==K||v[20]!==F||v[21]!==C.name||v[22]!==w||v[23]!==A.length?(N=()=>{const e={...{...f(b.select.type)},id:(K+1).toString(),text:`Domanda ${A.length+1}`,name:`${C.name}_domanda_${A.length+1}`,index:A?.length||1,options:{required:!0,select:F}};w.addItem("items",e),L(K+1)},v[19]=K,v[20]=F,v[21]=C.name,v[22]=w,v[23]=A.length,v[24]=N):N=v[24];const U=N;let X;v[25]!==w||v[26]!==A?(X=e=>{const t=A.filter((t,o)=>o!==e);w.updateItem("items",t)},v[25]=w,v[26]=A,v[27]=X):X=v[27];const Z=X;let ee;v[28]!==C.name||v[29]!==w||v[30]!==V||v[31]!==A?(ee=(e,t)=>{const o=A.some((o,r)=>t!==r&&o.text===e),r=[...V];r[t]=o?"Valore duplicato":""===e?"Valore non può essere vuoto":null,G(r),w.updateItem(`items[${t}].text`,e),w.updateItem(`items[${t}].name`,`${C.name}_${x(e)}`)},v[28]=C.name,v[29]=w,v[30]=V,v[31]=A,v[32]=ee):ee=v[32];const te=ee;let oe;v[33]!==W||v[34]!==j||v[35]!==O||v[36]!==Y?(oe=(e,t)=>h(a,{size:"small",value:e.text,onChange:e=>Y(e.target.value,t),error:Boolean(W[t]),helperText:W[t],disabled:j,sx:{flex:"1 1 180px",minWidth:160,bgcolor:"background.default"},slotProps:{input:{endAdornment:h(n,{color:"error","aria-label":"drag-handle",size:"small",onClick:()=>O(t),disabled:j,children:h(c,{size:18})})},htmlInput:{"aria-label":"select-text-field"}}}),v[33]=W,v[34]=j,v[35]=O,v[36]=Y,v[37]=oe):oe=v[37];const re=oe;let ne;v[38]!==F||v[39]!==j||v[40]!==Z||v[41]!==V||v[42]!==te?(ne=(e,t)=>g(l,{spacing:1.5,sx:{p:2,borderRadius:3,border:"1px solid",borderColor:"divider"},children:[h(a,{size:"small","aria-label":"select-text-field",value:e.text,onChange:e=>te(e.target.value,t),error:Boolean(V[t]),helperText:V[t],disabled:j,sx:{minWidth:200,bgcolor:"background.default"},slotProps:{input:{endAdornment:h(n,{color:"error","aria-label":"drag-handle",size:"small",onClick:()=>Z(t),disabled:j,children:h(c,{size:18})})},htmlInput:{"aria-label":"option-text-field"}}}),F.length>0&&h(l,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",children:F.map(_)})]}),v[38]=F,v[39]=j,v[40]=Z,v[41]=V,v[42]=te,v[43]=ne):ne=v[43];const ie=ne;let le,ae;v[44]===Symbol.for("react.memo_cache_sentinel")?(le={pt:4,pl:2,pr:2,pb:4,backgroundColor:"background.default"},v[44]=le):le=v[44],v[45]===Symbol.for("react.memo_cache_sentinel")?(ae=h(r,{children:h(s,{variant:"body1",color:"text.secondary",children:"Opzioni di risposta"})}),v[45]=ae):ae=v[45];const se=T||j;let ce,me,de,pe,ue,he,ge;if(v[46]===Symbol.for("react.memo_cache_sentinel")?(ce=h(m,{size:18}),v[46]=ce):ce=v[46],v[47]===Symbol.for("react.memo_cache_sentinel")?(me={py:.25},v[47]=me):me=v[47],v[48]!==E||v[49]!==se?(de=g(r,{container:!0,size:12,alignItems:"center",justifyContent:"space-between",children:[ae,h(r,{children:h(o,{title:"Aggiungi opzione","aria-label":"add-select-button",color:"primary",onClick:E,disabled:se,startIcon:ce,variant:"outlined",sx:me,children:"Aggiungi opzione"})})]}),v[48]=E,v[49]=se,v[50]=de):de=v[50],v[51]!==F||v[52]!==re){let e;v[54]!==re?(e=(e,t)=>h(d.Fragment,{children:re(e,t)},t),v[54]=re,v[55]=e):e=v[55],pe=F.map(e),v[51]=F,v[52]=re,v[53]=pe}else pe=v[53];v[56]!==pe?(ue=h(l,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",alignItems:"flex-start",children:pe}),v[56]=pe,v[57]=ue):ue=v[57],v[58]!==de||v[59]!==ue?(he=g(l,{spacing:1.5,children:[de,ue]}),v[58]=de,v[59]=ue,v[60]=he):he=v[60],v[61]===Symbol.for("react.memo_cache_sentinel")?(ge=h(r,{children:h(s,{variant:"body1",color:"text.secondary",children:"Domande"})}),v[61]=ge):ge=v[61];const fe=R||j;let be,xe,ye,ve,_e,Ie,ze,Se;if(v[62]===Symbol.for("react.memo_cache_sentinel")?(be=h(m,{size:18}),xe={py:.25},v[62]=be,v[63]=xe):(be=v[62],xe=v[63]),v[64]!==U||v[65]!==fe?(ye=g(r,{container:!0,size:12,alignItems:"center",justifyContent:"space-between",children:[ge,h(r,{children:h(o,{"aria-label":"add-option-button",color:"primary",variant:"outlined",onClick:U,disabled:fe,startIcon:be,sx:xe,children:"Aggiungi domanda"})})]}),v[64]=U,v[65]=fe,v[66]=ye):ye=v[66],v[67]===Symbol.for("react.memo_cache_sentinel")?(ve={maxHeight:400,overflowY:"auto",pr:1,scrollbarWidth:"thin"},v[67]=ve):ve=v[67],v[68]!==ie||v[69]!==A){let e;v[71]!==ie?(e=(e,t)=>h(d.Fragment,{children:ie(e,t)},e.id??t),v[71]=ie,v[72]=e):e=v[72],_e=A.map(e),v[68]=ie,v[69]=A,v[70]=_e}else _e=v[70];v[73]!==_e?(Ie=h(l,{spacing:2,sx:ve,children:_e}),v[73]=_e,v[74]=Ie):Ie=v[74],v[75]!==ye||v[76]!==Ie?(ze=g(l,{spacing:2,children:[ye,Ie]}),v[75]=ye,v[76]=Ie,v[77]=ze):ze=v[77],v[78]!==he||v[79]!==ze?(Se=g(l,{sx:le,spacing:3,children:[he,ze]}),v[78]=he,v[79]=ze,v[80]=Se):Se=v[80];const Ce=Se;let $e;return v[81]!==S||v[82]!==C||v[83]!==j||v[84]!==Ce?($e=h(y,{contentEdit:Ce,index:S,question:C,readonlyMode:j}),v[81]=S,v[82]=C,v[83]=j,v[84]=Ce,v[85]=$e):$e=v[85],$e}function _(e,t){return g(l,{direction:"row",spacing:.5,alignItems:"center",sx:{px:1,py:.5,borderRadius:3,bgcolor:"action.hover"},children:[h(i,{disabled:!0,size:"small",sx:{p:0}}),h(s,{variant:"body2",color:"text.secondary",children:e.text})]},t)}function I(e){return e}function z(e){return e}export{v as QuestionTableEditorForm};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Checkbox";import i from"@mui/material/FormControl";import m from"@mui/material/FormControlLabel";import l from"@mui/material/FormLabel";import a from"@mui/material/Grid";import n from"@mui/material/Stack";import{Mapper as r}from"../../utils/config-map.js";import{getLocale as s,LocaleMap as d}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as u}from"../common/OptionsEditor.js";import{CommonQuestionEditor as c}from"../question_editor/QuestionCommonEditor.js";import{jsx as p,jsxs as f}from"react/jsx-runtime";function b(b){const h=e(56),{index:x,question:y,readonlyMode:_}=b,v=void 0!==_&&_,g=t(),z=g.value,N=z.name,I=z.options?.min,C=z.options?.max,S=z.options?.format;let j;h[0]!==I||h[1]!==g?(j=e=>{null!==e&&""!==e?I&&Number(e)<=Number(I)?g.updateItem("options.max",Number(I)):g.updateItem("options.max",e?Number(e):e):g.updateItem("options.max",e)},h[0]=I,h[1]=g,h[2]=j):j=h[2];const O=j;let F;h[3]!==C||h[4]!==g?(F=e=>{null!==e&&""!==e?C&&Number(e)>=Number(C)?g.updateItem("options.min",Number(C)):g.updateItem("options.min",e?Number(e):e):g.updateItem("options.min",e)},h[3]=C,h[4]=g,h[5]=F):F=h[5];const W=F;let k;h[6]!==g?(k=e=>{g.updateItem("options.format",e?Number(e):e)},h[6]=g,h[7]=k):k=h[7];const q=k;let w;h[8]!==g?(w=e=>{g.updateItem("name",e)},h[8]=g,h[9]=w):w=h[9];const E=w;let T,V,L,M,Q,G,P,A,B,D;h[10]===Symbol.for("react.memo_cache_sentinel")?(T={xs:12,md:6},h[10]=T):T=h[10],h[11]===Symbol.for("react.memo_cache_sentinel")?(V=s(d.items.text.min),h[11]=V):V=h[11],h[12]!==W||h[13]!==I||h[14]!==v?(L=p(a,{container:!0,size:T,children:p(u,{label:"min",text:V,value:I,defaultValue:r.text.defaults.min,handleOnChange:W,showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:v})}),h[12]=W,h[13]=I,h[14]=v,h[15]=L):L=h[15],h[16]===Symbol.for("react.memo_cache_sentinel")?(M={xs:12,md:6},h[16]=M):M=h[16],h[17]===Symbol.for("react.memo_cache_sentinel")?(Q=s(d.items.text.max),h[17]=Q):Q=h[17],h[18]!==O||h[19]!==C||h[20]!==v?(G=p(a,{container:!0,size:M,children:p(u,{label:"max",text:Q,value:C,defaultValue:r.text.defaults.max,handleOnChange:O,showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:v})}),h[18]=O,h[19]=C,h[20]=v,h[21]=G):G=h[21],h[22]===Symbol.for("react.memo_cache_sentinel")?(P={xs:12,md:6},h[22]=P):P=h[22],h[23]!==q||h[24]!==S||h[25]!==v?(A=p(a,{container:!0,size:P,children:p(u,{label:"format",text:"Formato",value:S,handleOnChange:q,showToggle:!0,type:"text",fullWidth:!0,size:"small",disabled:v})}),h[23]=q,h[24]=S,h[25]=v,h[26]=A):A=h[26],h[27]===Symbol.for("react.memo_cache_sentinel")?(B={xs:12,md:6},h[27]=B):B=h[27],h[28]===Symbol.for("react.memo_cache_sentinel")?(D=p(l,{children:"Visibilità"}),h[28]=D):D=h[28];const H=0===z.layout?.visibility;let J,K,R,U,X,Y,Z;h[29]!==z.layout||h[30]!==g?(J=()=>{g.updateItem("layout",0===z.layout?.visibility?{...z.layout,visibility:1}:{...z.layout,visibility:0})},h[29]=z.layout,h[30]=g,h[31]=J):J=h[31],h[32]!==v||h[33]!==H||h[34]!==J?(K=p(o,{disabled:v,checked:H,onChange:J}),h[32]=v,h[33]=H,h[34]=J,h[35]=K):K=h[35],h[36]!==v||h[37]!==K?(R=p(a,{container:!0,display:"flex",size:B,children:f(i,{component:"fieldset",variant:"standard",children:[D,p(m,{disabled:v,label:"Nascosto",control:K})]})}),h[36]=v,h[37]=K,h[38]=R):R=h[38],h[39]===Symbol.for("react.memo_cache_sentinel")?(U={xs:12,md:6},X={justifyContent:"flex-end",alignItems:"flex-end",pt:1},h[39]=U,h[40]=X):(U=h[39],X=h[40]),h[41]!==E||h[42]!==N||h[43]!==v?(Y=p(a,{container:!0,size:U,sx:X,children:p(u,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:N,size:"small",handleOnChange:E,disabled:v})}),h[41]=E,h[42]=N,h[43]=v,h[44]=Y):Y=h[44],h[45]!==G||h[46]!==A||h[47]!==R||h[48]!==Y||h[49]!==L?(Z=f(n,{spacing:2,children:[L,G,A,R,Y]}),h[45]=G,h[46]=A,h[47]=R,h[48]=Y,h[49]=L,h[50]=Z):Z=h[50];const $=Z;let ee;return h[51]!==x||h[52]!==y||h[53]!==v||h[54]!==$?(ee=p(c,{index:x,contentOptions:$,question:y,readonlyMode:v}),h[51]=x,h[52]=y,h[53]=v,h[54]=$,h[55]=ee):ee=h[55],ee}export{b as QuestionTextEditorForm};
1
+ import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Grid";import i from"@mui/material/Stack";import{Mapper as n}from"../../utils/config-map.js";import{getLocale as m,LocaleMap as r}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as a}from"../common/OptionsEditor.js";import{CommonQuestionEditor as l}from"../question_editor/QuestionCommonEditor.js";import{QuestionSignatureEditor as s}from"./QuestionSignatureEditor.js";import{QuestionTimeEditor as d}from"./QuestionTimeEditor.js";import{jsx as u,jsxs as p}from"react/jsx-runtime";function c(t){const o=e(12),{index:i,question:m,readonlyMode:r}=t,a=void 0!==r&&r,l=m.layout?.style;if(l===n.time.type){let e;return o[0]!==i||o[1]!==m||o[2]!==a?(e=u(d,{index:i,question:m,readonlyMode:a}),o[0]=i,o[1]=m,o[2]=a,o[3]=e):e=o[3],e}if(l===n.signature.type){let e;return o[4]!==i||o[5]!==m||o[6]!==a?(e=u(s,{index:i,question:m,readonlyMode:a}),o[4]=i,o[5]=m,o[6]=a,o[7]=e):e=o[7],e}let p;return o[8]!==i||o[9]!==m||o[10]!==a?(p=u(f,{index:i,question:m,readonlyMode:a}),o[8]=i,o[9]=m,o[10]=a,o[11]=p):p=o[11],p}const f=s=>{const d=e(35),{index:c,question:f,readonlyMode:x}=s,b=void 0!==x&&x,h=t(),y=h.value,g=y.name,_=y.options?.min,v=y.options?.max;let z;d[0]!==_||d[1]!==h?(z=e=>{null!==e&&""!==e?_&&Number(e)<=Number(_)?h.updateItem("options.max",Number(_)):h.updateItem("options.max",e?Number(e):e):h.updateItem("options.max",e)},d[0]=_,d[1]=h,d[2]=z):z=d[2];const N=z;let j;d[3]!==v||d[4]!==h?(j=e=>{null!==e&&""!==e?v&&Number(e)>=Number(v)?h.updateItem("options.min",Number(v)):h.updateItem("options.min",e?Number(e):e):h.updateItem("options.min",e)},d[3]=v,d[4]=h,d[5]=j):j=d[5];const I=j;let S;d[6]!==h?(S=e=>{h.updateItem("name",e)},d[6]=h,d[7]=S):S=d[7];const q=S;let M,C,E,O,Q,T,W,w,V,k;d[8]===Symbol.for("react.memo_cache_sentinel")?(M={xs:12,md:6},d[8]=M):M=d[8],d[9]===Symbol.for("react.memo_cache_sentinel")?(C=m(r.items.text.min),d[9]=C):C=d[9],d[10]!==I||d[11]!==_||d[12]!==b?(E=u(o,{container:!0,size:M,children:u(a,{label:"min",text:C,value:_,defaultValue:n.text.defaults.min,handleOnChange:I,showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:b})}),d[10]=I,d[11]=_,d[12]=b,d[13]=E):E=d[13],d[14]===Symbol.for("react.memo_cache_sentinel")?(O={xs:12,md:6},d[14]=O):O=d[14],d[15]===Symbol.for("react.memo_cache_sentinel")?(Q=m(r.items.text.max),d[15]=Q):Q=d[15],d[16]!==N||d[17]!==v||d[18]!==b?(T=u(o,{container:!0,size:O,children:u(a,{label:"max",text:Q,value:v,defaultValue:n.text.defaults.max,handleOnChange:N,showToggle:!0,type:"number",fullWidth:!0,size:"small",disabled:b})}),d[16]=N,d[17]=v,d[18]=b,d[19]=T):T=d[19],d[20]===Symbol.for("react.memo_cache_sentinel")?(W={xs:12,md:6},w={justifyContent:"flex-end",alignItems:"flex-end",pt:1},d[20]=W,d[21]=w):(W=d[20],w=d[21]),d[22]!==q||d[23]!==g||d[24]!==b?(V=u(o,{container:!0,size:W,sx:w,children:u(a,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:g,size:"small",handleOnChange:q,disabled:b})}),d[22]=q,d[23]=g,d[24]=b,d[25]=V):V=d[25],d[26]!==T||d[27]!==V||d[28]!==E?(k=p(i,{spacing:2,children:[E,T,V]}),d[26]=T,d[27]=V,d[28]=E,d[29]=k):k=d[29];const G=k;let P;return d[30]!==c||d[31]!==f||d[32]!==b||d[33]!==G?(P=u(l,{index:c,contentOptions:G,question:f,readonlyMode:b}),d[30]=c,d[31]=f,d[32]=b,d[33]=G,d[34]=P):P=d[34],P};export{c as QuestionTextEditorForm};
@@ -0,0 +1 @@
1
+ import{c as e}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import{isTimeFormat as o,TIME_FORMAT_OPTIONS as i}from"../../utils/time-utils.js";import m from"@mui/material/FormControl";import n from"@mui/material/FormControlLabel";import r from"@mui/material/FormLabel";import l from"@mui/material/Grid";import a from"@mui/material/InputLabel";import s from"@mui/material/MenuItem";import c from"@mui/material/Select";import d from"@mui/material/Stack";import u from"@mui/material/Switch";import{TimeField as f}from"@mui/x-date-pickers";import p from"dayjs";import"../../utils/config-map.js";import{getLocale as h,LocaleMap as b}from"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{OptionTextField as y}from"../common/OptionsEditor.js";import{CommonQuestionEditor as x}from"../question_editor/QuestionCommonEditor.js";import{jsx as g,jsxs as v}from"react/jsx-runtime";const _=s=>{const _=e(78),{index:j,question:I,readonlyMode:T}=s,k=void 0!==T&&T,V=t(),W=V.value,q=W.layout,B=W.name,E="string"==typeof q?.min?q.min:"",F="string"==typeof q?.max?q.max:"",L="string"==typeof q?.format?q.format:"";let M;_[0]!==L?(M=o(L)?L:"HH:mm",_[0]=L,_[1]=M):M=_[1];const O=M;let w;_[2]!==O?(w=e=>{if(!e)return null;const t=p(e,O);return t.isValid()?t:null},_[2]=O,_[3]=w):w=_[3];const N=w,Q=C;let G;_[4]!==O?(G=(e,t)=>{const o=p(e,O),i=p(t,O);return!o.isValid()||!i.isValid()||o.isBefore(i)},_[4]=O,_[5]=G):G=_[5];const P=G;let A;_[6]!==W.layout||_[7]!==V?(A=(e,t)=>{V.updateItem("layout",{...W.layout,[e]:t})},_[6]=W.layout,_[7]=V,_[8]=A):A=_[8];const D=A,J=S,K=z;let R;_[9]!==P||_[10]!==F||_[11]!==E||_[12]!==O||_[13]!==D?(R=(e,t)=>{if(!t)return void D(e,"");const o=Q(p(t,O),O);if(!o)return;const i="min"===e?F:E;if(i){if(!("min"===e?P(o,i):P(i,o)))return void D(e,i)}D(e,o)},_[9]=P,_[10]=F,_[11]=E,_[12]=O,_[13]=D,_[14]=R):R=_[14];const U=R;let X;_[15]!==F||_[16]!==E||_[17]!==O||_[18]!==W.layout||_[19]!==V?(X=e=>{if(!o(e))return;const t=E?Q(p(E,O),e):"",i=F?Q(p(F,O),e):"";V.updateItem("layout",{...W.layout,min:t,max:i,format:e})},_[15]=F,_[16]=E,_[17]=O,_[18]=W.layout,_[19]=V,_[20]=X):X=_[20];const Y=X;let Z;_[21]!==O||_[22]!==U?(Z=e=>{U("min",e?J(O):"")},_[21]=O,_[22]=U,_[23]=Z):Z=_[23];const $=Z;let ee;_[24]!==O||_[25]!==U?(ee=e=>{U("max",e?K(O):"")},_[24]=O,_[25]=U,_[26]=ee):ee=_[26];const te=ee;let oe;_[27]!==V?(oe=e=>{V.updateItem("name",e)},_[27]=V,_[28]=oe):oe=_[28];const ie=oe;let me;_[29]===Symbol.for("react.memo_cache_sentinel")?(me=h(b.items.text.minTime),_[29]=me):me=_[29];const ne=Boolean(E);let re,le,ae;_[30]!==U?(re=e=>U("min",e),_[30]=U,_[31]=re):re=_[31],_[32]!==$||_[33]!==E||_[34]!==ne||_[35]!==re?(le={key:"min",text:me,enabled:ne,value:E,onToggle:$,onChange:re},_[32]=$,_[33]=E,_[34]=ne,_[35]=re,_[36]=le):le=_[36],_[37]===Symbol.for("react.memo_cache_sentinel")?(ae=h(b.items.text.maxTime),_[37]=ae):ae=_[37];const se=Boolean(F);let ce,de,ue;_[38]!==U?(ce=e=>U("max",e),_[38]=U,_[39]=ce):ce=_[39],_[40]!==te||_[41]!==F||_[42]!==se||_[43]!==ce?(de={key:"max",text:ae,enabled:se,value:F,onToggle:te,onChange:ce},_[40]=te,_[41]=F,_[42]=se,_[43]=ce,_[44]=de):de=_[44],_[45]!==le||_[46]!==de?(ue=[le,de],_[45]=le,_[46]=de,_[47]=ue):ue=_[47];const fe=ue;let pe,he,be,ye,xe,ge,ve,_e,Ce,Se,ze;_[48]!==O||_[49]!==fe||_[50]!==k||_[51]!==N?(pe=fe.map(e=>g(l,{container:!0,size:{xs:12,md:6},children:v(m,{fullWidth:!0,children:[g(r,{component:"legend",sx:{mb:1},children:e.text}),v(d,{direction:"row",spacing:1,alignItems:"center",children:[g(n,{disabled:k,label:e.enabled?h(b.general.yes):h(b.general.no),control:g(u,{checked:e.enabled,onChange:(t,o)=>e.onToggle(o),disabled:k})}),e.enabled&&g(f,{ampm:!1,format:O,value:N(e.value),onChange:t=>{e.onChange(Q(t,O))},fullWidth:!0,size:"small",disabled:k})]})]})},e.key)),_[48]=O,_[49]=fe,_[50]=k,_[51]=N,_[52]=pe):pe=_[52],_[53]===Symbol.for("react.memo_cache_sentinel")?(he={xs:12,md:6},_[53]=he):he=_[53],_[54]===Symbol.for("react.memo_cache_sentinel")?(be=g(a,{id:"time-format-label",children:h(b.items.text.formatTime)}),_[54]=be):be=_[54],_[55]===Symbol.for("react.memo_cache_sentinel")?(ye=h(b.items.text.formatTime),_[55]=ye):ye=_[55],_[56]!==Y?(xe=e=>Y(e.target.value),_[56]=Y,_[57]=xe):xe=_[57],_[58]===Symbol.for("react.memo_cache_sentinel")?(ge=i.map(H),_[58]=ge):ge=_[58],_[59]!==O||_[60]!==k||_[61]!==xe?(ve=g(l,{container:!0,size:he,children:v(m,{fullWidth:!0,children:[be,g(c,{labelId:"time-format-label",label:ye,size:"small",value:O,onChange:xe,disabled:k,children:ge})]})}),_[59]=O,_[60]=k,_[61]=xe,_[62]=ve):ve=_[62],_[63]===Symbol.for("react.memo_cache_sentinel")?(_e={xs:12,md:6},Ce={justifyContent:"flex-end",alignItems:"flex-end",pt:1},_[63]=_e,_[64]=Ce):(_e=_[63],Ce=_[64]),_[65]!==ie||_[66]!==B||_[67]!==k?(Se=g(l,{container:!0,size:_e,sx:Ce,children:g(y,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:B,size:"small",handleOnChange:ie,disabled:k})}),_[65]=ie,_[66]=B,_[67]=k,_[68]=Se):Se=_[68],_[69]!==pe||_[70]!==ve||_[71]!==Se?(ze=v(d,{spacing:2,children:[pe,ve,Se]}),_[69]=pe,_[70]=ve,_[71]=Se,_[72]=ze):ze=_[72];const He=ze;let je;return _[73]!==j||_[74]!==I||_[75]!==k||_[76]!==He?(je=g(x,{index:j,contentOptions:He,question:I,readonlyMode:k}),_[73]=j,_[74]=I,_[75]=k,_[76]=He,_[77]=je):je=_[77],je};function C(e,t){return e&&e.isValid()?e.format(t):""}function S(e){return"HH"===e?"00":"HH:mm"===e?"00:00":"00:00:00"}function z(e){return"HH"===e?"23":"HH:mm"===e?"23:59":"23:59:59"}function H(e){return g(s,{value:e,children:e},e)}export{_ as QuestionTimeEditor};
@@ -1 +1 @@
1
- import{c as i}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Autocomplete";import m from"@mui/material/Checkbox";import e from"@mui/material/FormControl";import r from"@mui/material/FormControlLabel";import a from"@mui/material/FormLabel";import l from"@mui/material/Grid";import n from"@mui/material/TextField";import"react";import{jsxs as p,jsx as u}from"react/jsx-runtime";import"@mui/material/Chip";import"@mui/material/IconButton";import"@mui/material/Stack";import"@mui/material/Tooltip";import"@mui/material/Typography";import"lucide-react";import"../../utils/config-map.js";import"../../utils/locale.js";import"@famalabs/survey";import"acorn";import"../../components/common/DrawerCommon.js";import"@mui/material/Card";import"@mui/material/CardContent";import"@mui/material/Modal";import"../../components/common/Skeletons.js";import"isomorphic-dompurify";import"@mui/material/Box";import"@mui/material/Button";import"@mui/material/SvgIcon";import"@famalabs/web-ui";import"react-hook-form";import"@mui/material/MenuItem";import"@mui/material/Radio";import"@mui/material/RadioGroup";import"@mui/material/Select";import"@mui/material/Switch";import"../../components/forms/QuestionNumberCommon.js";import"@mui/material/Table";import"@mui/material/TableBody";import"@mui/material/TableCell";import"@mui/material/TableContainer";import"@mui/material/TableHead";import"@mui/material/TableRow";import"dayjs";import"@mui/material/FormGroup";import"@mui/material/FormHelperText";import"@mui/material/ListItem";import"../../components/forms/QuestionListCommon.js";import{selectableFileTypes as s}from"../../components/forms/QuestionUploadCommon.js";import"@mui/material/Alert";import"@mui/material/AlertTitle";import{OptionTextField as c}from"../common/OptionsEditor.js";import{CommonQuestionEditor as d}from"../question_editor/QuestionCommonEditor.js";function f(n){const f=i(16),{index:C,question:v,readonlyMode:j}=n,x=void 0!==j&&j,T=t(),I=T.value,g=I.name;let z;f[0]!==T?(z=i=>{T.updateItem("name",i)},f[0]=T,f[1]=z):z=f[1];const k=z;let F;f[2]!==k||f[3]!==g||f[4]!==v.options?.accepts||f[5]!==I.layout||f[6]!==T||f[7]!==x?(F=()=>p(l,{container:!0,size:12,spacing:2,children:[u(l,{size:12,children:u(o,{multiple:!0,defaultValue:v.options?.accepts,disabled:x,options:s.map(h),onChange:(i,t)=>{T.updateItem("options.accepts",t)},getOptionLabel:y,renderInput:b})}),u(l,{container:!0,display:"flex",size:12,children:p(e,{component:"fieldset",variant:"standard",children:[u(a,{children:"Visibilità"}),u(r,{label:"Nascosto",control:u(m,{checked:0===I.layout?.visibility,disabled:x,onChange:()=>{T.updateItem("layout",0===I.layout?.visibility?{...I.layout,visibility:1}:{...I.layout,visibility:0})}})})]})}),u(l,{container:!0,size:12,sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:u(c,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:g,size:"small",handleOnChange:k,disabled:x})})]}),f[2]=k,f[3]=g,f[4]=v.options?.accepts,f[5]=I.layout,f[6]=T,f[7]=x,f[8]=F):F=f[8];const S=F;let L,Q;return f[9]!==S?(L=S(),f[9]=S,f[10]=L):L=f[10],f[11]!==C||f[12]!==v||f[13]!==x||f[14]!==L?(Q=u(d,{index:C,contentOptions:L,question:v,readonlyMode:x}),f[11]=C,f[12]=v,f[13]=x,f[14]=L,f[15]=Q):Q=f[15],Q}function b(i){return u(n,{...i,variant:"outlined",label:"Filtro file validi"})}function y(i){return s.find(t=>t.key===i)?.label||i}function h(i){return i.key}export{f as UploadFormEditor};
1
+ import{c as i}from"react/compiler-runtime";import{useQuestionStateContext as t}from"../../providers/editor/QuestionStateProvider.js";import o from"@mui/material/Autocomplete";import m from"@mui/material/Checkbox";import e from"@mui/material/FormControl";import r from"@mui/material/FormControlLabel";import a from"@mui/material/FormLabel";import l from"@mui/material/Grid";import n from"@mui/material/TextField";import"@mui/material/Chip";import"@mui/material/IconButton";import"@mui/material/Stack";import"@mui/material/Tooltip";import"@mui/material/Typography";import"lucide-react";import"react";import{jsxs as p,jsx as u}from"react/jsx-runtime";import"../../utils/config-map.js";import"../../utils/locale.js";import"@famalabs/survey";import"acorn";import"../../components/common/DrawerCommon.js";import"@mui/material/Card";import"@mui/material/CardContent";import"@mui/material/Modal";import"motion/react-m";import"../../components/common/Skeletons.js";import"isomorphic-dompurify";import"@mui/material/Box";import"@mui/material";import"motion/react";import"@mui/material/SvgIcon";import"dayjs";import"@famalabs/web-ui";import"react-hook-form";import"@mui/material/styles";import"@siamf/react-signature-pad";import"@mui/material/MenuItem";import"@mui/material/Radio";import"@mui/material/RadioGroup";import"@mui/material/Select";import"@mui/material/Switch";import"../../components/forms/QuestionNumberCommon.js";import"@mui/material/Table";import"@mui/material/TableBody";import"@mui/material/TableCell";import"@mui/material/TableContainer";import"@mui/material/TableHead";import"@mui/material/TableRow";import"@mui/material/FormGroup";import"@mui/material/FormHelperText";import"@mui/material/ListItem";import"../../components/forms/QuestionListCommon.js";import{selectableFileTypes as s}from"../../components/forms/QuestionUploadCommon.js";import"@mui/material/Alert";import"@mui/material/AlertTitle";import{OptionTextField as c}from"../common/OptionsEditor.js";import{CommonQuestionEditor as d}from"../question_editor/QuestionCommonEditor.js";function f(n){const f=i(16),{index:C,question:v,readonlyMode:j}=n,x=void 0!==j&&j,T=t(),g=T.value,I=g.name;let z;f[0]!==T?(z=i=>{T.updateItem("name",i)},f[0]=T,f[1]=z):z=f[1];const k=z;let F;f[2]!==k||f[3]!==I||f[4]!==v.options?.accepts||f[5]!==g.layout||f[6]!==T||f[7]!==x?(F=()=>p(l,{container:!0,size:12,spacing:2,children:[u(l,{size:12,children:u(o,{multiple:!0,defaultValue:v.options?.accepts,disabled:x,options:s.map(h),onChange:(i,t)=>{T.updateItem("options.accepts",t)},getOptionLabel:y,renderInput:b})}),u(l,{container:!0,display:"flex",size:12,children:p(e,{component:"fieldset",variant:"standard",children:[u(a,{children:"Visibilità"}),u(r,{label:"Nascosto",control:u(m,{checked:0===g.layout?.visibility,disabled:x,onChange:()=>{T.updateItem("layout",0===g.layout?.visibility?{...g.layout,visibility:1}:{...g.layout,visibility:0})}})})]})}),u(l,{container:!0,size:12,sx:{justifyContent:"flex-end",alignItems:"flex-end",pt:1},children:u(c,{label:"name",className:"titleEditor",fullWidth:!0,text:"Nome esportazione",hint:"Il nome del campo da visualizzare nelle esportazioni",value:I,size:"small",handleOnChange:k,disabled:x})})]}),f[2]=k,f[3]=I,f[4]=v.options?.accepts,f[5]=g.layout,f[6]=T,f[7]=x,f[8]=F):F=f[8];const S=F;let L,Q;return f[9]!==S?(L=S(),f[9]=S,f[10]=L):L=f[10],f[11]!==C||f[12]!==v||f[13]!==x||f[14]!==L?(Q=u(d,{index:C,contentOptions:L,question:v,readonlyMode:x}),f[11]=C,f[12]=v,f[13]=x,f[14]=L,f[15]=Q):Q=f[15],Q}function b(i){return u(n,{...i,variant:"outlined",label:"Filtro file validi"})}function y(i){return s.find(t=>t.key===i)?.label||i}function h(i){return i.key}export{f as UploadFormEditor};
@@ -1 +1 @@
1
- import{c as t}from"react/compiler-runtime";import{Survey as r}from"@famalabs/survey";import{useState as o,useRef as n,useEffectEvent as e,useEffect as c}from"react";function u(t){return new Proxy(t,{get(t,r,o){const n=Reflect.get(t,r,o);return"function"==typeof n?n.bind(t):n}})}function f(f){const m=t(21),{formInfo:i,reloadOnFormChange:a}=f,l=void 0!==a&&a,d=i?.data||i?.root,p="object"==typeof d&&null!=d,[y,g]=o(null),x=n(0);if(!y&&p){const t=new r(structuredClone(d));g({form:t,exposed:u(t)})}let v;m[0]!==y?(v=()=>{y&&g(s)},m[0]=y,m[1]=v):v=m[1];const b=v;let w;m[2]!==y?.form?(w=t=>{const r=y?.form;if(r)try{return t(r)}catch(t){const r=t;return void console.error("Error during form mutation:",r)}},m[2]=y?.form,m[3]=w):w=m[3];const C=w;let I;m[4]!==C||m[5]!==y||m[6]!==b?(I=t=>{const r=C(t);if(void 0!==r||y)return b(),r},m[4]=C,m[5]=y,m[6]=b,m[7]=I):I=m[7];const h=I;let S;m[8]!==d||m[9]!==p||m[10]!==l?(S=()=>{if(!l||!p)return;const t=0===x.current;if(x.current=x.current+1,t)return;const o=new r(structuredClone(d));g({form:o,exposed:u(o)})},m[8]=d,m[9]=p,m[10]=l,m[11]=S):S=m[11];const j=e(S);let A,E;m[12]!==j?(A=()=>{j()},m[12]=j,m[13]=A):A=m[13],m[14]!==i?(E=[i],m[14]=i,m[15]=E):E=m[15],c(A,E);const F=y?.exposed;let M;return m[16]!==h||m[17]!==C||m[18]!==b||m[19]!==F?(M={formInstance:F,mutateAndSync:h,stageMutation:C,syncInstance:b,syncSignature:x},m[16]=h,m[17]=C,m[18]=b,m[19]=F,m[20]=M):M=m[20],M}function s(t){return t?{form:t.form,exposed:u(t.form)}:t}export{f as useFormLoaderV2};
1
+ import{c as t}from"react/compiler-runtime";import{Survey as r}from"@famalabs/survey";import{useState as o,useRef as n,useEffectEvent as e,useEffect as c,startTransition as f}from"react";function u(t){return new Proxy(t,{get(t,r,o){const n=Reflect.get(t,r,o);return"function"==typeof n?n.bind(t):n}})}function s(s){const i=t(21),{formInfo:l,reloadOnFormChange:a}=s,d=void 0!==a&&a,p=l?.data||l?.root,y="object"==typeof p&&null!=p,[x,g]=o(null),v=n(0);if(!x&&y){const t=new r(structuredClone(p));g({form:t,exposed:u(t)})}let b;i[0]!==x?(b=()=>{x&&g(m)},i[0]=x,i[1]=b):b=i[1];const w=b;let C;i[2]!==x?.form?(C=t=>{const r=x?.form;if(r)try{return t(r)}catch(t){const r=t;return void console.error("Error during form mutation:",r)}},i[2]=x?.form,i[3]=C):C=i[3];const I=C;let h;i[4]!==I||i[5]!==x||i[6]!==w?(h=t=>{const r=I(t);if(void 0!==r||x)return w(),r},i[4]=I,i[5]=x,i[6]=w,i[7]=h):h=i[7];const j=h;let A;i[8]!==p||i[9]!==y||i[10]!==d?(A=()=>{if(!d||!y)return;const t=0===v.current;v.current=v.current+1,t||f(()=>{const t=new r(structuredClone(p));g({form:t,exposed:u(t)})})},i[8]=p,i[9]=y,i[10]=d,i[11]=A):A=i[11];const E=e(A);let F,M;i[12]!==E?(F=()=>{E()},i[12]=E,i[13]=F):F=i[13],i[14]!==l?(M=[l],i[14]=l,i[15]=M):M=i[15],c(F,M);const O=x?.exposed;let P;return i[16]!==j||i[17]!==I||i[18]!==w||i[19]!==O?(P={formInstance:O,mutateAndSync:j,stageMutation:I,syncInstance:w},i[16]=j,i[17]=I,i[18]=w,i[19]=O,i[20]=P):P=i[20],P}function m(t){return t?{form:t.form,exposed:u(t.form)}:t}export{s as useFormLoaderV2};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{getMapType as t,Mapper as n}from"../../utils/config-map.js";import"../../utils/locale.js";import"@famalabs/survey";import"acorn";import o,{useEffect as i}from"react";const r=e=>{const o=t(e)===n.alert.type,i=t(e)===n.fn.type&&0===e.layout?.visibility;return o||i},s=e=>{const o=[];let i=0,s=1;const a=(e,l)=>{e.forEach(e=>{if(t(e)===n.page.type||t(e)===n.landing.type){const a=e.items??[],d=t(e.parent())!==n.cond.type||Boolean(e.parent().condition),c=!(t(e.parent())!==n.cond.type||!e.items.length)&&!e.parent().compute(),u=e.items.every(e=>!!("sourceList"===t(e)&&e.text&&e.text.length>0)||e.isValid()),g={id:e.id,folderId:l?.id,globalIndex:r(e)?-1:i++,isValid:u&&d,isDisabled:c,questions:a?.map((e,t)=>{const n=r(e)?-1:s++;return{id:e.id,globalIndex:n,localIndex:t,questions:e.items?.map(e=>({id:e.id,globalIndex:n,localIndex:t}))}})};o.push(g)}else(e.items||void 0===e.layout?.style)&&("cond"===e.type?a(e.items,e.parent()):a(e.items,e))})};return a(e),o},a=e=>{const t=e.root.items;return s(t).every(e=>e.isValid)};function l(t,n){const r=e(33),a=void 0!==n&&n,l=t.root.items,f=s(l),[m,p]=o.useState(0);let y;m>=f.length&&p(f.length-1),r[0]===Symbol.for("react.memo_cache_sentinel")?(y=new Set,r[0]=y):y=r[0];const[h,v]=o.useState(y);let P;r[1]===Symbol.for("react.memo_cache_sentinel")?(P=new Set,r[1]=P):P=r[1];const[x,b]=o.useState(P),S=f[m],I=f.length,V=f.every(g),_=e=>{if(!e)return;const t=f.find(t=>t.id===e);if(t)return t;const n=f.flatMap(u).find(t=>t?.id===e);if(n)return n;const o=f.flatMap(c).flatMap(d).find(t=>t?.id===e);return o||void 0},q=()=>f,w=e=>{if(e>=0&&e<f.length)return f[e]};let D;r[2]!==h?(D=e=>{h.has(e)||v(t=>{const n=new Set(t);return n.add(e),n})},r[2]=h,r[3]=D):D=r[3];const M=D;let j;r[4]!==h?(j=()=>Array.from(h),r[4]=h,r[5]=j):j=r[5];const A=j;let B;r[6]!==x?(B=()=>Array.from(x),r[6]=x,r[7]=B):B=r[7];const C=B;let F;r[8]!==x?(F=e=>{x.has(e)||b(t=>{const n=new Set(t);return n.add(e),n})},r[8]=x,r[9]=F):F=r[9];const L=F,N=e=>{let t=m;if("valid"===(void 0===e?"all":e))for(;t<f.length-1;){t++;const e=f[t]?.isValid,n=f[t]?.isDisabled;if(e&&!n)return p(t),t}else t<f.length-1&&(t++,p(t));return S&&M(S.id),t},E=e=>{let t=m;if("valid"===(void 0===e?"all":e))for(;t>0;){t--;const e=f[t]?.isValid,n=f[t]?.isDisabled;if(e&&!n)return p(t),t}else t>0&&(t--,p(t));return S&&M(S.id),t},[T,k]=o.useState(void 0);let z;r[10]===Symbol.for("react.memo_cache_sentinel")?(z=e=>{k(e)},r[10]=z):z=r[10];const G=z;if("string"==typeof T&&T.length>0){let e;r[11]!==T?(e=e=>e.id===T,r[11]=T,r[12]=e):e=r[12];const t=f.findIndex(e);S&&t>=0&&t<f.length&&(p(t),M(S.id)),k(void 0)}let H,J,K;return r[13]!==S||r[14]!==a||r[15]!==f||r[16]!==I?(H=()=>{a&&(console.log("Flat Pages: ",f),console.log("Current Navigation Page: ",S),console.log("Page count",I))},J=[S,f,I,a],r[13]=S,r[14]=a,r[15]=f,r[16]=I,r[17]=H,r[18]=J):(H=r[17],J=r[18]),i(H,J),r[19]!==L||r[20]!==S||r[21]!==m||r[22]!==_||r[23]!==A||r[24]!==w||r[25]!==q||r[26]!==C||r[27]!==N||r[28]!==E||r[29]!==G||r[30]!==V||r[31]!==I?(K={isFormValid:V,currentPageIndex:m,getItem:_,getPages:q,pageCount:I,currentPage:S,getPageByIndex:w,getLastVisitedPages:A,getValidatedPages:C,addValidatedPage:L,goNextPage:N,goPrevPage:E,goToPage:G},r[19]=L,r[20]=S,r[21]=m,r[22]=_,r[23]=A,r[24]=w,r[25]=q,r[26]=C,r[27]=N,r[28]=E,r[29]=G,r[30]=V,r[31]=I,r[32]=K):K=r[32],K}function d(e){return e?.questions}function c(e){return e.questions}function u(e){return e.questions}function g(e){return e.isValid}export{a as isFormValid,l as useNavigation};
1
+ import{c as e}from"react/compiler-runtime";import{Result as t}from"../../types/ResultTypes.js";import{getMapType as n,Mapper as o}from"../../utils/config-map.js";import"../../utils/locale.js";import"@famalabs/survey";import"acorn";import i,{useEffect as r}from"react";const s=e=>{const t=n(e)===o.alert.type,i=n(e)===o.fn.type&&0===e.layout?.visibility;return t||i},a=e=>{const i=[];let r=0,a=1;const l=(e,d)=>{e.forEach(e=>{if(n(e)===o.page.type||n(e)===o.landing.type){const l=e.items??[],c=n(e.parent())!==o.cond.type||Boolean(e.parent().condition),u=t.try(()=>!(n(e.parent())!==o.cond.type||!e.items.length)&&!e.parent().compute()).unwrap_or(!0),g=e.items.every(e=>!!("sourceList"===n(e)&&e.text&&e.text.length>0)||e.isValid()),m={id:e.id,folderId:d?.id,globalIndex:s(e)?-1:r++,isValid:g&&c,isDisabled:u,questions:l?.map((e,t)=>{const n=s(e)?-1:a++;return{id:e.id,globalIndex:n,localIndex:t,questions:e.items?.map(e=>({id:e.id,globalIndex:n,localIndex:t}))}})};i.push(m)}else(e.items||void 0===e.layout?.style)&&("cond"===e.type?l(e.items,e.parent()):l(e.items,e))})};return l(e),i},l=e=>{const t=e.root.items;return a(t).every(e=>e.isValid)};function d(t,n){const o=e(33),s=void 0!==n&&n,l=t.root.items,d=a(l),[f,p]=i.useState(0);let y;d.length>0&&f>=d.length&&p(d.length-1),o[0]===Symbol.for("react.memo_cache_sentinel")?(y=new Set,o[0]=y):y=o[0];const[h,v]=i.useState(y);let P;o[1]===Symbol.for("react.memo_cache_sentinel")?(P=new Set,o[1]=P):P=o[1];const[x,b]=i.useState(P),S=d[f],I=d.length,V=d.every(m),_=e=>{if(!e)return;const t=d.find(t=>t.id===e);if(t)return t;const n=d.flatMap(g).find(t=>t?.id===e);if(n)return n;const o=d.flatMap(u).flatMap(c).find(t=>t?.id===e);return o||void 0},q=()=>d,w=e=>{if(e>=0&&e<d.length)return d[e]};let j;o[2]!==h?(j=e=>{h.has(e)||v(t=>{const n=new Set(t);return n.add(e),n})},o[2]=h,o[3]=j):j=o[3];const D=j;let M;o[4]!==x?(M=e=>{x.has(e)||b(t=>{const n=new Set(t);return n.add(e),n})},o[4]=x,o[5]=M):M=o[5];const A=M;let B;o[6]!==h?(B=()=>Array.from(h),o[6]=h,o[7]=B):B=o[7];const C=B;let F;o[8]!==x?(F=()=>Array.from(x),o[8]=x,o[9]=F):F=o[9];const L=F,N=e=>{let t=f;if("valid"===(void 0===e?"all":e))for(;t<d.length-1;){t++;const e=d[t]?.isValid,n=d[t]?.isDisabled;if(e&&!n)return p(t),t}else t<d.length-1&&(t++,p(t));return S&&D(S.id),t},T=e=>{let t=f;if("valid"===(void 0===e?"all":e))for(;t>0;){t--;const e=d[t]?.isValid,n=d[t]?.isDisabled;if(e&&!n)return p(t),t}else t>0&&(t--,p(t));return S&&D(S.id),t},[E,R]=i.useState(void 0);let k;o[10]===Symbol.for("react.memo_cache_sentinel")?(k=e=>{R(e)},o[10]=k):k=o[10];const z=k;if("string"==typeof E&&E.length>0){let e;o[11]!==E?(e=e=>e.id===E,o[11]=E,o[12]=e):e=o[12];const t=d.findIndex(e);S&&t>=0&&t<d.length&&(p(t),D(S.id)),R(void 0)}let G,H,J;return o[13]!==S||o[14]!==s||o[15]!==d||o[16]!==I?(G=()=>{s&&(console.log("Flat Pages: ",d),console.log("Current Navigation Page: ",S),console.log("Page count",I))},H=[S,d,I,s],o[13]=S,o[14]=s,o[15]=d,o[16]=I,o[17]=G,o[18]=H):(G=o[17],H=o[18]),r(G,H),o[19]!==A||o[20]!==S||o[21]!==f||o[22]!==_||o[23]!==C||o[24]!==w||o[25]!==q||o[26]!==L||o[27]!==N||o[28]!==T||o[29]!==z||o[30]!==V||o[31]!==I?(J={isFormValid:V,currentPageIndex:f,getItem:_,getPages:q,pageCount:I,currentPage:S,getPageByIndex:w,getLastVisitedPages:C,getValidatedPages:L,addValidatedPage:A,goNextPage:N,goPrevPage:T,goToPage:z},o[19]=A,o[20]=S,o[21]=f,o[22]=_,o[23]=C,o[24]=w,o[25]=q,o[26]=L,o[27]=N,o[28]=T,o[29]=z,o[30]=V,o[31]=I,o[32]=J):J=o[32],J}function c(e){return e?.questions}function u(e){return e.questions}function g(e){return e.questions}function m(e){return e.isValid}export{l as isFormValid,d as useNavigation};
@@ -1 +1 @@
1
- import{c as e}from"react/compiler-runtime";import{DataSource as t,ItemConditional as r}from"@famalabs/survey";import{isEqual as n,get as o}from"lodash-es";import{useEffectEvent as s,useEffect as c}from"react";import{useFormStateContext as i}from"../../providers/common/FormStateProvider.js";import{getMapType as a,Mapper as u}from"../../utils/config-map.js";import"../../utils/locale.js";import"acorn";function l(r){const a=e(38),{initAnswers:u,loadAnswerMethod:l,loading:b}=r,O=void 0===l?"fieldsObject":l,{formInfo:v,formInstance:A,stageMutation:E,syncInstance:q,globalConfig:C}=i(),S=v?.sources,I=C.apiUrl;let P;a[0]!==C.sourceConfig?.staticSources?(P=C.sourceConfig?.staticSources||[],a[0]=C.sourceConfig?.staticSources,a[1]=P):P=a[1];const $=P,k=C.context;let z;a[2]!==I||a[3]!==k?(z=async(e,t)=>{if(!e)return console.error("API_URL is not defined"),null;if(!t)return console.error("Source type is not defined"),null;try{switch(t){case"asset":try{const t=`${I}/organization/assets/download/${e}`,r=await fetch(t,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return await r.json()}catch(e){const t=e;return console.error("Error fetching asset source:",t),null}case"data":try{if(!k)return null;const t=function(e,t){if(!t.includes(".data."))return o(e,t);const[r,n]=t.split(".data."),s=o(e,`${r}.data`);return s&&"object"==typeof s?n in s?s[n]:o(s,n):void 0}(k,e);return t||(console.error(`Remote source not found at path: ${e}`),null)}catch(e){const t=e;return console.error("Error fetching data source:",t),null}case"static":{const t=await fetch(e);return await t.json()}default:return null}}catch(e){const t=e;return console.error("Error fetching sources",t),{}}},a[2]=I,a[3]=k,a[4]=z):z=a[4];const F=z;let x;a[5]!==F||a[6]!==A.questions||a[7]!==A.sources||a[8]!==S||a[9]!==$?(x=async()=>{if(!A?.questions?.find(j)||A?.sources.size)return;const e=S&&!Array.isArray(S)?Object.entries(S).map(g):S,r=Object.values(e||[]).map(async e=>{const r=$?.find(t=>t.value===e.id)??e,n=e.type||"static",o=await F(r?.path,n);if(!o)return;const s=new t("static"===n?Object.entries(o).map(h):Object.entries(o).map(y));A.sources.set(e.id,s)}).filter(Boolean);await Promise.all(r)},a[5]=F,a[6]=A.questions,a[7]=A.sources,a[8]=S,a[9]=$,a[10]=x):x=a[10];const L=x;let M;a[11]!==A.mode||a[12]!==E?(M=()=>{1===A.mode&&E(w)},a[11]=A.mode,a[12]=E,a[13]=M):M=a[13];const R=M;let T;a[14]!==A.questions?(T=()=>{A.questions.forEach(p)},a[14]=A.questions,a[15]=T):T=a[15];const U=T;let B;a[16]!==A.sources||a[17]!==u||a[18]!==O||a[19]!==S||a[20]!==E?(B=()=>{if(u&&Object.values(u).length>0){if(S&&Object.entries(S).length>0&&!A.sources.size)return void console.warn("Warning: Survey sources are defined but not yet loaded");try{e:switch(O){case"fieldsObject":E(e=>e.setFields(u));break e;case"answersObject":try{const e=Object.values(u).map(m).filter(d);E(t=>t.setAnswers(e))}catch(e){const t=e;console.error("Error setting answers",t)}}}catch(e){const t=e;console.error("Error setting initial answers",t)}}},a[16]=A.sources,a[17]=u,a[18]=O,a[19]=S,a[20]=E,a[21]=B):B=a[21];const G=B;let W;a[22]!==G||a[23]!==L||a[24]!==R||a[25]!==q||a[26]!==U?(W=async()=>{R(),await L(),G(),U(),q()},a[22]=G,a[23]=L,a[24]=R,a[25]=q,a[26]=U,a[27]=W):W=a[27];const _=s(W);let D;a[28]!==A||a[29]!==u||a[30]!==O||a[31]!==b?(D=()=>{if(!A||2!==A.mode||b)return!1;if(!u)return!0;if("fieldsObject"===O){const e=A.getFields();console.log("Checking loaded answers against initAnswers:",e,u);return Object.keys(u).some(t=>Object.prototype.hasOwnProperty.call(e,t))}{const e=f,t=Object.values(u);return A.getAnswers().some(r=>{const{id:o,answer:s,score:c}=r;return t.some(t=>t?.id===o&&n(e(t.answer),e(s))&&n(e(t.score),e(c)))})}},a[28]=A,a[29]=u,a[30]=O,a[31]=b,a[32]=D):D=a[32];const H=s(D);let J,K;a[33]!==H||a[34]!==_?(J=()=>{H()||_()},a[33]=H,a[34]=_,a[35]=J):J=a[35],a[36]!==A?(K=[A],a[36]=A,a[37]=K):K=a[37],c(J,K)}function f(e){return null==e?null:e}function d(e){return null!=e}function m(e){return e&&"object"==typeof e&&"id"in e&&"answer"in e&&null!==e.answer&&void 0!==e.answer?e:null}function p(e){const t=e instanceof r,n=a(e)===u.cond.type,o=a(e)===u.alert.type;if(t&&(n||o))try{e.compute()}catch(e){const t=e;console.error("Error computing conditional question:",t)}}function w(e){return e.prepare()}function y(e){const[,t]=e;return[t,t]}function h(e){const[t,r]=e;return[t,r]}function g(e){const[t,r]=e;return{id:t,value:r}}function j(e){return a(e)===u.sourceList.type}export{l as useCompilerInit};
1
+ import{c as t}from"react/compiler-runtime";import{DataSource as e,ItemConditional as r}from"@famalabs/survey";import{isEqual as n,get as o}from"lodash-es";import{useEffectEvent as s,useRef as c,useEffect as i}from"react";import{useFormStateContext as a}from"../../providers/common/FormStateProvider.js";import{getMapType as u,Mapper as l}from"../../utils/config-map.js";import"../../utils/locale.js";import"acorn";function f(r){const u=t(39),{initAnswers:l,loadAnswerMethod:f,dataLoading:O,setValuesLoading:A}=r,E=void 0===f?"fieldsObject":f,{formInfo:S,formInstance:q,stageMutation:C,syncInstance:I,globalConfig:L}=a(),P=S?.sources,$=L.apiUrl;let k;u[0]!==L.sourceConfig?.staticSources?(k=L.sourceConfig?.staticSources||[],u[0]=L.sourceConfig?.staticSources,u[1]=k):k=u[1];const x=k,F=L.context;let M;u[2]!==$||u[3]!==F?(M=async(t,e)=>{if(!t)return console.warn("API_URL is not defined"),null;if(!e)return console.warn("Source type is not defined"),null;try{switch(e){case"asset":try{const e=`${$}/organization/assets/download/${t}`,r=await fetch(e,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return await r.json()}catch(t){const e=t;return console.error("Error fetching asset source:",e),null}case"data":try{if(!F)return null;const e=function(t,e){if(!e.includes(".data."))return o(t,e);const[r,n]=e.split(".data."),s=o(t,`${r}.data`);return s&&"object"==typeof s&&"string"==typeof n?n in s?s[n]:o(s,n):void 0}(F,t);return e||(console.error(`Remote source not found at path: ${t}`),null)}catch(t){const e=t;return console.error("Error fetching data source:",e),null}case"static":{const e=await fetch(t);return await e.json()}default:return null}}catch(t){const e=t;return console.error("Error fetching sources",e),{}}},u[2]=$,u[3]=F,u[4]=M):M=u[4];const z=M;let R;u[5]!==z||u[6]!==q.questions||u[7]!==q.sources||u[8]!==P||u[9]!==C||u[10]!==x?(R=async()=>{if(!P||!q?.questions?.find(v)||q?.sources.size>0)return;const t=P&&!Array.isArray(P)?Object.entries(P).map(b):P,r=Object.values(t||[]).map(async t=>{const r=x.length>0?x.find(e=>e.value===t.id):t,n=String(r?.type)||"static";if(!r)return;const o=await z(String(r?.path),n);if(!o)return;const s=new e("static"===n?Object.entries(o).map(j):Object.entries(o).map(h));C(e=>{t.id?e.sources.set(t.id,s):console.warn("Survey source is missing an id:",t)})}).filter(Boolean);await Promise.all(r)},u[5]=z,u[6]=q.questions,u[7]=q.sources,u[8]=P,u[9]=C,u[10]=x,u[11]=R):R=u[11];const T=R;let U;u[12]!==q.mode||u[13]!==C?(U=()=>{1===q.mode&&C(g)},u[12]=q.mode,u[13]=C,u[14]=U):U=u[14];const B=U;let G;u[15]!==q.questions?(G=()=>{q.questions.forEach(w)},u[15]=q.questions,u[16]=G):G=u[16];const V=G;let _;u[17]!==l||u[18]!==E||u[19]!==C?(_=()=>{if(l&&0!==Object.values(l).length)try{t:switch(E){case"fieldsObject":C(t=>t.setFields(l));break t;case"answersObject":try{const t=Object.values(l).map(y).filter(p);C(e=>e.setAnswers(t))}catch(t){const e=t;console.error("Error setting answers",e)}}}catch(t){const e=t;console.error("Error setting initial answers",e)}},u[17]=l,u[18]=E,u[19]=C,u[20]=_):_=u[20];const D=_;let H;u[21]!==D||u[22]!==T||u[23]!==B||u[24]!==I||u[25]!==V?(H=async()=>{B(),await T(),D(),V(),I()},u[21]=D,u[22]=T,u[23]=B,u[24]=I,u[25]=V,u[26]=H):H=u[26];const J=s(H),K=c(!1),N=c(0);let Q;u[27]!==O||u[28]!==q||u[29]!==l||u[30]!==E?(Q=()=>{if(!q||2!==q.mode||O)return!1;if(!l)return!0;if("fieldsObject"===E){const t=q.getFields();return!("object"!=typeof l&&null==l||Array.isArray(l))&&Object.keys(l).some(e=>Object.prototype.hasOwnProperty.call(t,e))}{const t=m,e=q.getAnswers(),r=Object.values(l);return!r.every(d)||e.some(e=>{const{id:o,answer:s,score:c}=e;return r.some(e=>e?.id===o&&n(t(e.answer),t(s))&&n(t(e.score),t(c)))})}},u[27]=O,u[28]=q,u[29]=l,u[30]=E,u[31]=Q):Q=u[31];const W=s(Q);let X,Y;u[32]!==W||u[33]!==J||u[34]!==A?(X=()=>{if(!K.current){if(N.current>=10)return console.warn("[InitCompiler] Max load attempts reached, marking answers as loaded"),K.current=!0,void A?.(!1);N.current=N.current+1,J(),K.current=W(),A?.(!K.current)}},u[32]=W,u[33]=J,u[34]=A,u[35]=X):X=u[35],u[36]!==q||u[37]!==A?(Y=[q,A],u[36]=q,u[37]=A,u[38]=Y):Y=u[38],i(X,Y)}function d(t){return t&&"object"==typeof t&&"id"in t&&"answer"in t}function m(t){return null==t?null:t}function p(t){return null!=t}function y(t){return t&&"object"==typeof t&&"id"in t&&"answer"in t&&null!==t.answer&&void 0!==t.answer?t:null}function w(t){const e=t instanceof r,n=u(t)===l.cond.type,o=u(t)===l.alert.type;if(e&&(n||o))try{t.compute()}catch(t){const e=t;console.error("Error computing conditional question:",e)}}function g(t){return t.prepare()}function h(t){const[,e]=t;return[e,e]}function j(t){const[e,r]=t;return[e,r]}function b(t){const[e,r]=t;return{id:e,value:r}}function v(t){return u(t)===l.sourceList.type}export{f as useCompilerInit};
@@ -1 +1 @@
1
- import{c as t}from"react/compiler-runtime";import{openDB as e}from"idb";import a from"react";import{useNavigation as o}from"../common/NavigationHook.js";async function s(){try{return e("surveyHistory",1,{upgrade(t){if(!t.objectStoreNames.contains("snapshots")){t.createObjectStore("snapshots",{keyPath:"id",autoIncrement:!0}).createIndex("timestamp","timestamp",{unique:!0})}}})}catch(t){throw console.error("Failed to initialize the database:",t),t}}async function n(t){const e=t.index("timestamp"),a=await e.count();let o=null;const s=await e.openCursor();return s&&(o=s.primaryKey),{count:a,oldestKey:o}}const r=async()=>{const t=(await s()).transaction("snapshots","readonly").objectStore("snapshots").index("timestamp");return(await t.getAll()).map(t=>({key:t.id,timestamp:t.timestamp}))},i=(e,i,c)=>{const p=t(15),l=o(e),[m,u]=a.useState(null);let d;p[0]!==m||p[1]!==e?(d=async()=>{const t=structuredClone(e.toJSON()),a=await r(),o=a[a.length-1]??null,i=(await s()).transaction("snapshots","readwrite"),c=i.objectStore("snapshots"),{count:p,oldestKey:l}=await n(c);if(o&&m!==o.timestamp){const t=a.findIndex(t=>t.timestamp===m),e=a.slice(t+1);for(const t of e)await c.delete(t.key)}p>=10&&null!==l&&await c.delete(l);const d=(new Date).toISOString();await c.put({surveySnapshot:t,timestamp:d}),u(d),await i.done},p[0]=m,p[1]=e,p[2]=d):d=p[2];const y=d;let h;p[3]!==e||p[4]!==c||p[5]!==i||p[6]!==l?(h=async t=>{try{const a=(await s()).transaction("snapshots","readonly"),o=a.objectStore("snapshots").index("timestamp"),n=await o.get(t);if(n){const{surveySnapshot:a}=n;u(t),i(t=>t.replace(t.root.id,a)),await c({type:8,data:null,id:e.root.id},"full"),l.currentPage&&l.goToPage(l.currentPage.id)}await a.done}catch(t){const e=t;console.error("Failed to restore history snapshot:",e)}},p[3]=e,p[4]=c,p[5]=i,p[6]=l,p[7]=h):h=p[7];const w=h;let S;p[8]!==y?(S=async()=>{const t=(await s()).transaction("snapshots","readwrite"),e=t.objectStore("snapshots");await e.clear(),await y(),await t.done},p[8]=y,p[9]=S):S=p[9];const f=S;let g;return p[10]!==f||p[11]!==y||p[12]!==m||p[13]!==w?(g={currentSnapshotTime:m,getHistoryList:r,createHistorySnapshot:y,restoreHistorySnapshot:w,clearHistory:f},p[10]=f,p[11]=y,p[12]=m,p[13]=w,p[14]=g):g=p[14],g};export{n as getSnapshots,s as initDB,i as useEditorHistory};
1
+ import{c as t}from"react/compiler-runtime";import{Result as o}from"../../types/ResultTypes.js";import{openDB as a}from"idb";import e from"react";import{useNavigation as r}from"../common/NavigationHook.js";async function n(){return o.tryAsync(async()=>a("surveyHistory",1,{upgrade(t){if(!t.objectStoreNames.contains("snapshots")){t.createObjectStore("snapshots",{keyPath:"id",autoIncrement:!0}).createIndex("timestamp","timestamp",{unique:!0})}}}))}async function s(t){const a=t.index("timestamp"),e=await a.count();let r=null;const n=(await o.tryAsync(async()=>await a.openCursor())).unwrap_or(void 0);return n&&(r=n.primaryKey),{count:e,oldestKey:r}}const i=async()=>{const t=(await n()).unwrap_or(void 0);if(!t)return console.error("Database initialization failed. Cannot retrieve history list."),[];const a=t.transaction("snapshots","readonly").objectStore("snapshots").index("timestamp");return(await o.tryAsync(async()=>await a.getAll())).unwrap_or([]).map(t=>({key:t.id,timestamp:t.timestamp}))},c=a=>{const c=t(15),{formInstance:l,mutateAndSync:p,handleServerOperation:d}=a,u=r(l),[y,m]=e.useState(null);let w;c[0]!==y||c[1]!==l?(w=async()=>{const t=o.try(()=>structuredClone(l.toJSON())).unwrap_or(void 0);if(!t)return void console.error("Failed to create survey snapshot. Operation aborted.");const a=await i(),e=a[a.length-1]??null,r=(await n()).unwrap_or(void 0);if(!r)return void console.error("Database initialization failed. Cannot create history snapshot.");const c=r.transaction("snapshots","readwrite"),p=c.objectStore("snapshots"),{count:d,oldestKey:u}=await s(p);if(e&&y!==e.timestamp){const t=a.findIndex(t=>t.timestamp===y),o=a.slice(t+1);for(const t of o)await p.delete(t.key)}d>=10&&null!==u&&await p.delete(u);const w=(new Date).toISOString();await p.put({surveySnapshot:t,timestamp:w}),m(w),await c.done},c[0]=y,c[1]=l,c[2]=w):w=c[2];const h=w;let f;c[3]!==l||c[4]!==d||c[5]!==p||c[6]!==u?(f=async t=>{try{const o=(await n()).unwrap_or(void 0);if(!o)return void console.error("Database initialization failed. Cannot restore history snapshot.");const a=o.transaction("snapshots","readonly"),e=a.objectStore("snapshots").index("timestamp"),r=await e.get(t);if(r){const{surveySnapshot:o}=r;m(t),p(t=>t.replace(t.root.id,o)),await d({type:8,data:null,id:l.root.id},"full"),u.currentPage&&u.goToPage(u.currentPage.id)}await a.done}catch(t){const o=t;console.error("Failed to restore history snapshot:",o)}},c[3]=l,c[4]=d,c[5]=p,c[6]=u,c[7]=f):f=c[7];const v=f;let S;c[8]!==h?(S=async()=>{try{const t=(await n()).unwrap_or(void 0);if(!t)return void console.error("Database initialization failed. Cannot clear history.");const o=t.transaction("snapshots","readwrite"),a=o.objectStore("snapshots");await a.clear(),await h(),await o.done}catch(t){const o=t;console.error("Failed to clear history:",o)}},c[8]=h,c[9]=S):S=c[9];const b=S;let g;return c[10]!==b||c[11]!==h||c[12]!==y||c[13]!==v?(g={currentSnapshotTime:y,getHistoryList:i,createHistorySnapshot:h,restoreHistorySnapshot:v,clearHistory:b},c[10]=b,c[11]=h,c[12]=y,c[13]=v,c[14]=g):g=c[14],g};export{s as getSnapshots,c as useEditorHistory};