@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.
- package/dist/core/Form.js +1 -1
- package/dist/core/compiler/FormCompiler.js +1 -1
- package/dist/core/compiler/common/CompilerProgress.js +1 -1
- package/dist/core/compiler/common/NavigationButtonsCompiler.js +1 -1
- package/dist/core/compiler/common/QuestionCompiler.js +1 -1
- package/dist/core/compiler/common/SidebarCompiler.js +1 -1
- package/dist/core/compiler/containers/PageCompiler.js +1 -1
- package/dist/core/compiler/containers/SectionCompiler.js +1 -1
- package/dist/core/compiler/question_forms/ItemConditionalCompiler.js +1 -1
- package/dist/core/compiler/question_forms/ItemFunctionCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionCheckCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionDateCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionListCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionMultipleSelectCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionNumberCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionSelectCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionTableCompiler.js +1 -1
- package/dist/core/compiler/question_forms/QuestionTextCompiler.js +1 -1
- package/dist/core/compiler/question_forms/UploadFormCompiler.js +1 -1
- package/dist/core/components/animations/MotionTabUtils.js +1 -0
- package/dist/core/components/animations/MotionWrappers.js +1 -0
- package/dist/core/components/common/DrawerCommon.js +1 -1
- package/dist/core/components/common/ImageInput.js +1 -1
- package/dist/core/components/common/ModalCommon.js +1 -1
- package/dist/core/components/common/ResponsiveDrawer.js +1 -1
- package/dist/core/components/common/Skeletons.js +1 -1
- package/dist/core/components/forms/QuestionAlertCommon.js +1 -1
- package/dist/core/components/forms/QuestionCheckCommon.js +1 -1
- package/dist/core/components/forms/QuestionCommon.js +1 -1
- package/dist/core/components/forms/QuestionDateCommon.js +1 -1
- package/dist/core/components/forms/QuestionListCommon.js +1 -1
- package/dist/core/components/forms/QuestionMultipleSelectCommon.js +1 -1
- package/dist/core/components/forms/QuestionNumberCommon.js +1 -1
- package/dist/core/components/forms/QuestionSelectCommon.js +1 -1
- package/dist/core/components/forms/QuestionSignatureCommon.js +1 -0
- package/dist/core/components/forms/QuestionTableCommon.js +1 -1
- package/dist/core/components/forms/QuestionTextCommon.js +1 -1
- package/dist/core/components/forms/QuestionUploadCommon.js +1 -1
- package/dist/core/components/parsers/MathParserRenderer.js +1 -1
- package/dist/core/editor/FormEditor.js +1 -1
- package/dist/core/editor/common/CommonEditor.js +1 -1
- package/dist/core/editor/common/EditorHistoryDrawer.js +1 -1
- package/dist/core/editor/common/HierarchyEditor.js +1 -1
- package/dist/core/editor/common/OptionsEditor.js +1 -1
- package/dist/core/editor/common/ScoreSelectModal.js +1 -1
- package/dist/core/editor/common/SnapshotDrawer.js +1 -1
- package/dist/core/editor/common/SurveyCreateNew.js +1 -1
- package/dist/core/editor/common/sidebar/SidebarEditor.js +1 -1
- package/dist/core/editor/common/sidebar/SidebarPageStructure.js +1 -1
- package/dist/core/editor/common/sidebar/SidebarQuestionStructure.js +1 -1
- package/dist/core/editor/common/sidebar/SidebarSettingsView.js +1 -1
- package/dist/core/editor/containers/FolderEditor.js +1 -1
- package/dist/core/editor/containers/LandingPageEditor.js +1 -1
- package/dist/core/editor/containers/PageEditor.js +1 -1
- package/dist/core/editor/containers/RenderPageEditModal.js +1 -1
- package/dist/core/editor/containers/RenderPageHeader.js +1 -1
- package/dist/core/editor/containers/RenderSectionEditModal.js +1 -1
- package/dist/core/editor/containers/SectionEditor.js +1 -1
- package/dist/core/editor/containers/SectionPreview.js +1 -1
- package/dist/core/editor/question_editor/QuestionCommonEditor.js +1 -1
- package/dist/core/editor/question_editor/QuestionMainComponent.js +1 -1
- package/dist/core/editor/question_editor/QuestionPreviewRender.js +1 -1
- package/dist/core/editor/question_editor/QuestionTypeEdit.js +1 -1
- package/dist/core/editor/question_editor/QuestionTypePreview.js +1 -1
- package/dist/core/editor/question_forms/ItemConditionalEditor.js +1 -1
- package/dist/core/editor/question_forms/ItemFunctionEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionCheckEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionDateEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionListEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionMultipleSelectEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionNumberEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionSelectEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionSignatureEditor.js +1 -0
- package/dist/core/editor/question_forms/QuestionTableEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionTextEditor.js +1 -1
- package/dist/core/editor/question_forms/QuestionTimeEditor.js +1 -0
- package/dist/core/editor/question_forms/UploadFormEditor.js +1 -1
- package/dist/core/hooks/common/FormLoaderHookV2.js +1 -1
- package/dist/core/hooks/common/NavigationHook.js +1 -1
- package/dist/core/hooks/compiler/InitCompiler.js +1 -1
- package/dist/core/hooks/editor/EditorHistory.js +1 -1
- package/dist/core/hooks/editor/EditorLocalMutations.js +1 -1
- package/dist/core/hooks/editor/EditorOperations.js +1 -1
- package/dist/core/hooks/editor/QuestionOperations.js +1 -1
- package/dist/core/presenter/FormPresenter.js +1 -1
- package/dist/core/presenter/common/QuestionPresenter.js +1 -1
- package/dist/core/presenter/containers/FolderPresenter.js +1 -1
- package/dist/core/presenter/containers/PagePresenter.js +1 -1
- package/dist/core/presenter/containers/SectionPresenter.js +1 -1
- package/dist/core/types/FormEditorTypes.d.ts +3 -2
- package/dist/core/types/FormEditorTypes.js +1 -1
- package/dist/core/types/FormGlobalTypes.d.ts +6 -4
- package/dist/core/types/FormGlobalTypes.js +1 -1
- package/dist/core/types/ResultTypes.js +1 -1
- package/dist/core/utils/config-map.d.ts +14 -14
- package/dist/core/utils/config-map.js +1 -1
- package/dist/core/utils/format-utils.js +1 -1
- package/dist/core/utils/locale.d.ts +530 -7
- package/dist/core/utils/locale.js +1 -1
- package/dist/core/utils/parsers/ConditionParser.js +1 -1
- package/dist/core/utils/parsers/LegacyConditionParser.js +1 -1
- package/dist/core/utils/time-utils.js +1 -0
- package/dist/core/validators/compiler/CompilerValidators.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- 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
|
|
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{
|
|
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{
|
|
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
|
|
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{
|
|
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/
|
|
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/
|
|
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"
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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};
|