@viamedici-spc/configurator-framer 1.3.0 → 1.3.1
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/index.cjs +4 -1
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -416,13 +416,16 @@
|
|
|
416
416
|
Please check your internet connection and try again.`)}function xa(){alert(`Failed to reset your configuration.
|
|
417
417
|
Please check your internet connection and try again.`)}const Fn=O.select`
|
|
418
418
|
color: inherit;
|
|
419
|
+
cursor: inherit;
|
|
419
420
|
`,Nn="<reset>",Bn="<nothing>",ii=fe((e,t)=>{if(G()){const I=Fe(e,!0,!1);return f.jsx(Fn,{style:I})}const o=ae(),i=J(e),r=W.useChoiceAttribute(i);if(!r)return f.jsx("span",{children:"Choice Attribute not found"});const{explain:l}=de(),s=qe(i),{attribute:a,makeDecision:u,clearDecisions:x}=r,h=ct(i,s,c.AttributeInterpreter.getAllowedChoiceValues(a)),y=ct(i,s,c.AttributeInterpreter.getBlockedChoiceValues(a)),d=c.AttributeInterpreter.isMultiSelect(a),b=c.AttributeInterpreter.getSelectedChoiceValues(a),w=b.map(I=>I.id),m=w[0]??Bn,g=b.some(I=>{var V;return((V=I.decision)==null?void 0:V.kind)===c.DecisionKind.Explicit}),v=w.length>=1,P=b.some(I=>{var V;return((V=I.decision)==null?void 0:V.kind)===c.DecisionKind.Implicit}),S=h.length===0,E=async I=>{if(I===Nn)try{await x()}catch{ue()}else if(h.some(V=>V.id===I)){const V=w.some(B=>B===I)?void 0:c.ChoiceValueDecisionState.Included;try{await u(I,V)}catch{ue()}}else y.some(V=>V.id===I)&&e.explain!=="disabled"&&await l(V=>V.whyIsStateNotPossible.choice(a.id).choiceValue(I).state(c.ChoiceValueDecisionState.Included),e.explain,o)},R=wa(e,a.isSatisfied,P,S);return f.jsxs(Fn,{ref:t,value:d?w:m,multiple:d,onChange:I=>E(I.currentTarget.value),style:R,children:[!v&&!d&&f.jsx("option",{value:Bn}),g&&f.jsx("option",{value:Nn,children:e.resetLabel}),h.map(I=>{var V;return f.jsxs("option",{value:I.id,children:[((V=I.decision)==null?void 0:V.kind)===c.DecisionKind.Implicit?e.implicitLabelPrefix:"",s[I.id]??I.id]},I.id)}),y.length>0&&f.jsx("optgroup",{label:e.blockedLabel,children:y.map(I=>f.jsx("option",{value:I.id,children:s[I.id]??I.id},I.id))})]})}),Ca=ii,va={...en,noOptionsAvailableColors:{...Nt,title:"No Options Available Colors"}};p.addPropertyControls(ii,va);const wa=(e,t,n,o)=>{var r,l,s;const i=Fe(e,t,n);return{...i,backgroundColor:F.match({noOptionsAvailable:o,noOptionsAvailableFill:(r=e.noOptionsAvailableColors)==null?void 0:r.fill}).with({noOptionsAvailable:!0,noOptionsAvailableFill:F.P.string.minLength(1)},a=>a.noOptionsAvailableFill).otherwise(()=>i.backgroundColor),borderColor:F.match({noOptionsAvailable:o,noOptionsAvailableBorderColor:(l=e.noOptionsAvailableColors)==null?void 0:l.borderColor}).with({noOptionsAvailable:!0,noOptionsAvailableBorderColor:F.P.string.minLength(1)},a=>a.noOptionsAvailableBorderColor).otherwise(()=>i.borderColor),color:F.match({noOptionsAvailable:o,noOptionsAvailableColor:(s=e.noOptionsAvailableColors)==null?void 0:s.color}).with({noOptionsAvailable:!0,noOptionsAvailableColor:F.P.string.minLength(1)},a=>a.noOptionsAvailableColor).otherwise(()=>i.color)}},Ln=O.select`
|
|
420
421
|
color: inherit;
|
|
422
|
+
cursor: inherit;
|
|
421
423
|
`,Mn="<reset>",At="<nothing>",Et="yes",$n="no",ri=fe((e,t)=>{var v,P,S;if(G()){const E=Fe(e,!0,!1);return f.jsx(Ln,{style:E})}const o=ae(),i=J(e),r=W.useBooleanAttribute(i),{explain:l}=de();if(!r)return f.jsx("span",{children:"Boolean Attribute not found"});const{attribute:s,makeDecision:a}=r,u=async E=>{const R=c.AttributeInterpreter.getBooleanDecision(s)!=null;if(E===Mn&&R)try{await a(void 0)}catch{ue()}else{const I=E===Et;if(c.AttributeInterpreter.isBooleanValuePossible(s,I))try{await a(I)}catch{ue()}else e.explain!=="disabled"&&await l(B=>B.whyIsStateNotPossible.boolean(s.id).state(I),e.explain,o)}},x=F.match((v=s.decision)==null?void 0:v.state).with(!0,()=>Et).with(!1,()=>$n).otherwise(()=>At),h=((P=s.decision)==null?void 0:P.kind)===c.DecisionKind.Explicit,y=((S=s.decision)==null?void 0:S.kind)===c.DecisionKind.Implicit,d=Fe(e,s.isSatisfied,y),b=c.AttributeInterpreter.isBooleanValuePossible(s,!0),w=c.AttributeInterpreter.isBooleanValuePossible(s,!1),m=f.jsxs("option",{value:Et,children:[Kn(s,!0,e.implicitLabelPrefix),e.trueLabel]}),g=f.jsxs("option",{value:$n,children:[Kn(s,!1,e.implicitLabelPrefix),e.falseLabel]});return f.jsxs(Ln,{ref:t,value:x,onChange:E=>u(E.currentTarget.value),style:d,children:[x===At&&f.jsx("option",{value:At}),h&&f.jsx("option",{value:Mn,children:e.resetLabel}),b&&m,w&&g,(!b||!w)&&f.jsxs("optgroup",{label:e.blockedLabel,children:[!b&&m,!w&&g]})]})}),Sa=ri,Kn=(e,t,n)=>{var o,i;return((o=e.decision)==null?void 0:o.kind)===c.DecisionKind.Implicit&&((i=e.decision)==null?void 0:i.state)===t?n:""},Ta={...en,trueLabel:{title:"True Label",type:p.ControlType.String,defaultValue:"Yes"},falseLabel:{title:"False Label",type:p.ControlType.String,defaultValue:"No"}};p.addPropertyControls(ri,Ta);const zn=O.select`
|
|
422
424
|
color: inherit;
|
|
425
|
+
cursor: inherit;
|
|
423
426
|
`,Wn="<reset>",It="<nothing>",Rt="included",Pt="excluded",li=fe((e,t)=>{var P,S,E;if(G()){const R=Fe(e,!0,!1);return f.jsx(zn,{style:R})}const o=ae(),i=J(e),r=W.useComponentAttribute(i),{explain:l}=de();if(!r)return f.jsx("span",{children:"Component Attribute not found"});const{attribute:s,makeDecision:a}=r,u=async R=>{if(c.AttributeInterpreter.isComponentStatePossible(s,R))try{await a(R)}catch{ue()}else e.explain!=="disabled"&&await l(V=>V.whyIsStateNotPossible.component(s.id).state(R),e.explain,o)},x=async R=>{var V;const I=((V=s.decision)==null?void 0:V.kind)===c.DecisionKind.Explicit;R===Wn&&I?await a(void 0):R===Rt?await u(c.ComponentDecisionState.Included):R===Pt&&await u(c.ComponentDecisionState.Excluded)},h=F.match((P=s.decision)==null?void 0:P.state).with(c.ComponentDecisionState.Included,()=>Rt).with(c.ComponentDecisionState.Excluded,()=>Pt).otherwise(()=>It),y=((S=s.decision)==null?void 0:S.kind)===c.DecisionKind.Explicit,d=((E=s.decision)==null?void 0:E.kind)===c.DecisionKind.Implicit,b=Fe(e,s.isSatisfied,d),w=c.AttributeInterpreter.isComponentStatePossible(s,c.ComponentDecisionState.Included),m=c.AttributeInterpreter.isComponentStatePossible(s,c.ComponentDecisionState.Excluded),g=f.jsxs("option",{value:Rt,children:[qn(s,c.ComponentDecisionState.Included,e.implicitLabelPrefix),e.includedLabel]}),v=f.jsxs("option",{value:Pt,children:[qn(s,c.ComponentDecisionState.Excluded,e.implicitLabelPrefix),e.excludedLabel]});return f.jsxs(zn,{ref:t,value:h,onChange:R=>x(R.currentTarget.value),style:b,children:[h===It&&f.jsx("option",{value:It}),y&&f.jsx("option",{value:Wn,children:e.resetLabel}),w&&g,m&&v,(!w||!m)&&f.jsxs("optgroup",{label:e.blockedLabel,children:[!w&&g,!m&&v]})]})}),Aa=li,qn=(e,t,n)=>{var o,i;return((o=e.decision)==null?void 0:o.kind)===c.DecisionKind.Implicit&&((i=e.decision)==null?void 0:i.state)===t?n:""},Ea={...en,includedLabel:{title:"Included Label",type:p.ControlType.String,defaultValue:"Included"},excludedLabel:{title:"Excluded Label",type:p.ControlType.String,defaultValue:"Excluded"}};p.addPropertyControls(li,Ea);function si(e,t,n,o,i=1e3){const[r]=Fi.useForceUpdate(),l=ji.useDebouncedCallback(y=>{t(y),r()},i),s=T.useRef(n),a=T.useRef(e),u=l.isPending(),x=T.useRef(u);T.useEffect(()=>{e!==a.current&&(a.current=e,u&&(l.cancel(),r()),e!==n&&o(e)),n!==s.current&&(s.current=n,n!==e?(l(n),r()):u&&(l.cancel(),r())),u!==x.current&&(x.current=u,!u&&e!==n&&o(e))},[e,n,l,u]);const h=T.useCallback(()=>{l.isPending()&&l.flush()},[l]);return T.useEffect(()=>()=>h(),[h]),{flush:h}}const Hn=O(ki)`
|
|
424
427
|
color: inherit;
|
|
425
|
-
`,ai=fe((e,t)=>{var v,P;if(G()){const S=Bt(e,!0,!1);return f.jsx(Hn,{style:S})}const o=ae(),i=J(e),r=W.useNumericAttribute(i),{explain:l}=de();if(!r)return f.jsx("span",{children:"Numeric Attribute not found"});const{attribute:s,makeDecision:a}=r,u=((v=s.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit,x=Bt(e,s.isSatisfied,u),h=(P=s.decision)==null?void 0:P.state,[y,d]=T.useState(h),{min:b,max:w}=s.range,g=si(h,async S=>{if(S<b){alert(`The value must be smaller than or equal to ${b}.`);return}if(S>w){alert(`The value must be greater than or equal to ${w}.`);return}try{await a(S)}catch(E){const R=E;R.type===c.FailureType.ConfigurationModelNotFeasible||R.type===c.FailureType.ConfigurationConflict?e.explain!=="disabled"&&await l(V=>V.whyIsStateNotPossible.numeric(s.id).state(S),e.explain,o):ue()}},y,S=>d(S),e.wait);return f.jsx(Hn,{getInputRef:t,thousandsGroupStyle:"thousand",decimalSeparator:e.decimalSeparator,thousandSeparator:e.thousandSeparator,allowNegative:!0,fixedDecimalScale:!0,decimalScale:s.decimalPlaces,allowEmptyFormatting:!1,displayType:"input",placeholder:e.placeholder,prefix:Ra(s,e.implicitLabelPrefix),onBlur:()=>{g.flush()},onKeyPress:S=>{S.key==="Enter"&&g.flush()},onValueChange:S=>d(S.floatValue),value:y??"",style:x})}),Ia=ai,Ra=(e,t)=>{var n;return((n=e.decision)==null?void 0:n.kind)===c.DecisionKind.Implicit?t:""},Pa={...ti,wait:{title:"Debounce Delay",type:p.ControlType.Number,defaultValue:2e3,min:0,unit:"ms"},decimalSeparator:{title:"Decimal Separator",type:p.ControlType.String,defaultValue:",",maxLength:1},thousandSeparator:{title:"Thousand Separator",type:p.ControlType.String,defaultValue:".",maxLength:1},placeholder:{title:"Placeholder",type:p.ControlType.String,defaultValue:""}};p.addPropertyControls(ai,Pa);const Be={choiceValueId:{title:"Choice Value Id",type:p.ControlType.String}};function pe(e,t){return T.Children.map(e,n=>{if(T.isValidElement(n)){const o=Jn(n.props,t);return T.cloneElement(n,o)}return n})}const ci=fe((e,t)=>{if(G())return e.children;const o=ae(),{makeDecision:i}=W.useDecision(),r=J(e),l=e.choiceValueId??"",s=l.length>0,a=W.useAttributes([r])[0],{explain:u}=de();if(!a)return f.jsx("span",{children:"Attribute not found"});const x=a.type===c.AttributeType.Choice,h=a.type===c.AttributeType.Numeric,y=a.type===c.AttributeType.Boolean,d=a.type===c.AttributeType.Component;if(!x&&s)return f.jsx("span",{children:"Attribute is not a Choice Attribute"});if(h)return f.jsx("span",{children:"Numeric Attribute is not supported"});let b=x?a.values.find(P=>P.id===l):null;if(s&&b==null)return f.jsx("span",{children:"Choice Value not found"});const w=P=>F.match({state:P,attribute:a}).with({attribute:{type:c.AttributeType.Choice},state:"undefined"},()=>b.decision==null).with({attribute:{type:c.AttributeType.Choice},state:"included"},()=>{var S,E;return((S=b.decision)==null?void 0:S.state)===c.ChoiceValueDecisionState.Included&&((E=b.decision)==null?void 0:E.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Choice},state:"excluded"},()=>{var S,E;return((S=b.decision)==null?void 0:S.state)===c.ChoiceValueDecisionState.Excluded&&((E=b.decision)==null?void 0:E.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},state:"undefined"},{attribute:{type:c.AttributeType.Component},state:"undefined"},({attribute:S})=>S.decision==null).with({attribute:{type:c.AttributeType.Boolean},state:"true"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===!0&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},state:"false"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===!1&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},state:"included"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===c.ComponentDecisionState.Included&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},state:"excluded"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===c.ComponentDecisionState.Excluded&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).otherwise(()=>!1),m=P=>F.match({isChoiceAttribute:x,isBooleanAttribute:y,isComponentAttribute:d,state:P}).with({isChoiceAttribute:!0,state:"included"},()=>c.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,state:"excluded"},()=>c.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>c.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>c.ComponentDecisionState.Excluded).otherwise(()=>null);w(e.toggleFrom);const g=w(e.toggleTo),v=async()=>{const P=g?e.toggleFrom:e.toggleTo,S=m(P),E=d?c.AttributeInterpreter.isComponentStatePossible(a,S):!1,R=y?c.AttributeInterpreter.isBooleanValuePossible(a,S):!1;if((x?b.possibleDecisionStates.some(B=>B===S):!1)||R||E||S==null)try{await i({type:a.type,attributeId:r,choiceValueId:l,state:S})}catch{ue()}else if(e.explain!=="disabled"){const B=F.match({isComponentAttribute:d,isBooleanAttribute:y,isChoiceAttribute:x}).returnType().with({isChoiceAttribute:!0},()=>c.ExplainQuestionSubject.choiceValue).with({isBooleanAttribute:!0},()=>c.ExplainQuestionSubject.boolean).with({isComponentAttribute:!0},()=>c.ExplainQuestionSubject.component).otherwise(()=>null);B&&await u({question:c.ExplainQuestionType.whyIsStateNotPossible,subject:B,attributeId:r,choiceValueId:l,state:S},e.explain,o)}};return pe(e.children,{onClick:v,ref:t})}),Va=ci,Da={...re,...Be,children:{title:"Content",type:p.ControlType.ComponentInstance},toggleFrom:{title:"Toggle From",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false"]},toggleTo:{title:"Toggle To",type:p.ControlType.Enum,defaultValue:"included",options:["undefined","included","excluded","true","false"]},...Ne};p.addPropertyControls(ci,Da);const ui=fe((e,t)=>{if(G())return e.children;const o=ae(),{makeDecision:i}=W.useDecision(),r=J(e),l=e.choiceValueId??"",s=l.length>0,a=W.useAttributes([r])[0],u=W.useChoiceAttribute(r),{explain:x}=de();if(!a)return f.jsx("span",{children:"Attribute not found"});const h=a.type===c.AttributeType.Choice,y=a.type===c.AttributeType.Numeric,d=a.type===c.AttributeType.Boolean,b=a.type===c.AttributeType.Component;if(!h&&s)return f.jsx("span",{children:"Attribute is not a Choice Attribute"});let w=h?a.values.find(v=>v.id===l):null;if(s&&w==null)return f.jsx("span",{children:"Choice Value not found"});const m=()=>F.match({isChoiceAttribute:h,isBooleanAttribute:d,isComponentAttribute:b,isNumericAttribute:y,hasChoiceValueId:s,state:e.setSelection}).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"included"},()=>c.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"excluded"},()=>c.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>c.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>c.ComponentDecisionState.Excluded).with({isNumericAttribute:!0,state:"numeric"},()=>e.numericValue).otherwise(()=>null),g=async()=>{if(h&&!s&&e.setSelection==="undefined")try{await u.clearDecisions()}catch{ue()}else{const v=m(),P=b?c.AttributeInterpreter.isComponentStatePossible(a,v):!1,S=d?c.AttributeInterpreter.isBooleanValuePossible(a,v):!1,R=(h?w.possibleDecisionStates.some(I=>I===v):!1)||S||P;if(y||R||v==null)try{await i({type:a.type,attributeId:r,choiceValueId:l,state:v})}catch(I){const V=I;y&&(V.type===c.FailureType.ConfigurationModelNotFeasible||V.type===c.FailureType.ConfigurationConflict)?e.explain!=="disabled"&&await x(k=>k.whyIsStateNotPossible.numeric(a.id).state(v),e.explain,o):ue()}else if(e.explain!=="disabled"){const I=F.match({isComponentAttribute:b,isBooleanAttribute:d,isChoiceAttribute:h}).returnType().with({isChoiceAttribute:!0},()=>c.ExplainQuestionSubject.choiceValue).with({isBooleanAttribute:!0},()=>c.ExplainQuestionSubject.boolean).with({isComponentAttribute:!0},()=>c.ExplainQuestionSubject.component).otherwise(()=>null);I&&await x({question:c.ExplainQuestionType.whyIsStateNotPossible,subject:I,attributeId:r,choiceValueId:l,state:v},e.explain,o)}}};return pe(e.children,{onClick:g,ref:t})}),Oa=ui,ka={...re,...Be,children:{title:"Content",type:p.ControlType.ComponentInstance},setSelection:{title:"Set Selection To",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},numericValue:{title:"Numeric Value",type:p.ControlType.Number,defaultValue:0},...Ne};p.addPropertyControls(ui,ka);const di=fe((e,t)=>{var h;if(G())return e.children;const o=ae(),{setManyDecision:i}=W.useDecision(),{handleExplainAnswer:r}=de(),l=e.attributes.map(J),s=W.useAttributes(l).map((y,d)=>{if(!y)return{error:f.jsx("span",{children:"Attribute not found"})};const b=e.attributes[d],w=b.choiceValueId??"",m=w.length>0,g=y.type===c.AttributeType.Choice,v=y.type===c.AttributeType.Numeric,P=y.type===c.AttributeType.Boolean,S=y.type===c.AttributeType.Component;if(!g&&m)return{error:f.jsx("span",{children:"Attribute is not a Choice Attribute"})};let E=g?y.values.find(I=>I.id===w):null;if(m&&E==null)return{error:f.jsx("span",{children:"Choice Value not found"})};const R=()=>F.match({isChoiceAttribute:g,isBooleanAttribute:P,isComponentAttribute:S,isNumericAttribute:v,hasChoiceValueId:m,state:b.setSelection}).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"included"},()=>c.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"excluded"},()=>c.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>c.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>c.ComponentDecisionState.Excluded).with({isNumericAttribute:!0,state:"numeric"},()=>b.numericValue).otherwise(()=>null);return{getDecisions:()=>g&&!m&&b.setSelection==="undefined"?y.values.filter(I=>{var V;return((V=I.decision)==null?void 0:V.kind)===c.DecisionKind.Explicit}).map(I=>({type:y.type,attributeId:y.id,choiceValueId:I.id,state:null})):[{type:y.type,attributeId:y.id,choiceValueId:w,state:R()}]}}),a=(h=s.find(y=>y.error))==null?void 0:h.error;if(a)return a;const u=async()=>{const y=s.reduce((b,w)=>[...b,...w.getDecisions()],new Array),d=F.match(e.existingSelections).with("keep",()=>({type:"KeepExistingDecisions"})).with("drop",()=>({type:"DropExistingDecisions",conflictHandling:F.match(e.autoResolveConflicts).with(!1,()=>({type:"Manual",includeConstraintsInConflictExplanation:!1})).with(!0,()=>({type:"Automatic"})).exhaustive()})).exhaustive();try{await i(y,d)}catch(b){const w=b;if(console.debug("SetMany failed",w),(w==null?void 0:w.type)===c.FailureType.ConfigurationSetManyConflict&&w.decisionExplanations){e.explain!=="disabled"&&await r(w,e.explain,o);return}ue();return}},x=()=>{e.trigger==="click"&&u()};return T.useEffect(()=>{e.trigger==="auto"&&u()},[]),pe(e.children,{onClick:x,ref:t})}),ja=di,Fa={children:{title:"Content",type:p.ControlType.ComponentInstance},attributes:{title:"Attributes",type:p.ControlType.Array,control:{type:p.ControlType.Object,controls:{...re,...Be,setSelection:{title:"Set Selection To",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},numericValue:{title:"Numeric Value",type:p.ControlType.Number,defaultValue:0}}}},existingSelections:{title:"Existing Selections",type:p.ControlType.Enum,defaultValue:"keep",options:["keep","drop"]},autoResolveConflicts:{title:"Auto Resolve Conflicts",type:p.ControlType.Boolean,defaultValue:!0,hidden:e=>e.existingSelections!=="drop"},trigger:{title:"Trigger",type:p.ControlType.Enum,defaultValue:"click",options:["click","auto"],displaySegmentedControl:!0,segmentedControlDirection:"horizontal"},...Ne};p.addPropertyControls(di,Fa);const fi=se(e=>{if(G())return e.enabledChildren;const{configuration:n}=W.useConfiguration(),{setManyDecision:o}=W.useDecision(),i=n.attributes.some(s=>F.match(s).with({type:c.AttributeType.Choice},a=>a.values.some(u=>{var x;return((x=u.decision)==null?void 0:x.kind)===c.DecisionKind.Explicit})).with({type:c.AttributeType.Boolean},a=>{var u;return((u=a.decision)==null?void 0:u.kind)===c.DecisionKind.Explicit}).with({type:c.AttributeType.Numeric},a=>{var u;return((u=a.decision)==null?void 0:u.kind)===c.DecisionKind.Explicit}).with({type:c.AttributeType.Component},a=>{var u;return((u=a.decision)==null?void 0:u.kind)===c.DecisionKind.Explicit}).exhaustive()),r=()=>{if(i)try{o([],{type:"DropExistingDecisions",conflictHandling:{type:"Manual",includeConstraintsInConflictExplanation:!1}})}catch{xa()}},l=i?e.enabledChildren:e.disabledChildren;return pe(l,{onClick:r})}),Na=fi,Ba={enabledChildren:{title:"Content – Enabled",type:p.ControlType.ComponentInstance},disabledChildren:{title:"Content – Disabled",type:p.ControlType.ComponentInstance}};p.addPropertyControls(fi,Ba);const pi=fe((e,t)=>{if(G())return e.unsatisfiedChildren;const o=ae(),{configuration:i}=W.useConfiguration(),{explain:r}=de(),s=[...e.attributeId.length>0?[J(e)]:[],...e.attributes.map(J)],a=()=>{var d;const h=W.useAttributes(s).map(b=>b?{isSatisfied:b.isSatisfied}:{error:f.jsx("span",{children:"Attribute not found"})}),y=(d=h.find(b=>b.error))==null?void 0:d.error;return y||h.every(b=>b.isSatisfied)},u=async()=>{e.explain!=="disabled"&&(s.length===0?await r(h=>h.whyIsNotSatisfied.configuration,e.explain,o):s.length===1&&await r(h=>h.whyIsNotSatisfied.attribute(s[0]),e.explain,o))};return(s.length>0?a():i.isSatisfied)?e.satisfiedChildren:pe(e.unsatisfiedChildren,{onClick:u,ref:t})}),La=pi,Ma={satisfiedChildren:{title:"Content – Satisfied",type:p.ControlType.ComponentInstance},unsatisfiedChildren:{title:"Content – Unsatisfied",type:p.ControlType.ComponentInstance},...re,attributes:{title:"Attributes",type:p.ControlType.Array,control:{type:p.ControlType.Object,controls:{...re}}},...Ne};p.addPropertyControls(pi,Ma);const hi=se(T.forwardRef(function(t,n){const o=b=>F.match(b).with(1,()=>t.content1).with(2,()=>t.content2).with(3,()=>t.content3).with(4,()=>t.content4).with(5,()=>t.content5).with(6,()=>t.content6).with(7,()=>t.content7).with(8,()=>t.content8).with(9,()=>t.content9).with(10,()=>t.content10).otherwise(()=>null),i=t.variants.find(b=>b.useInDesignTime)||t.variants[0];if(G())return i&&o(i.content);const l=J(t),s=t.choiceValueId??"",a=s.length>0,u=W.useAttributes([l])[0];if(!u)return f.jsx("span",{children:"Attribute not found"});const x=u.type===c.AttributeType.Choice;if(!x&&a)return f.jsx("span",{children:"Attribute is not a Choice Attribute"});let h=x&&a?u.values.find(b=>b.id===s):null;if(a&&h==null)return f.jsx("span",{children:"Choice Value not found"});const y=b=>()=>h?b(h):u.values.some(b),d=[...t.variants].find(({selection:b,condition:w})=>F.match({selection:b,condition:w,attribute:u}).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"blocked"},y(m=>!m.possibleDecisionStates.includes(c.ChoiceValueDecisionState.Included))).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"implicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit})).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"explicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit})).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"none"},y(m=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Included})).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"blocked"},y(m=>!m.possibleDecisionStates.includes(c.ChoiceValueDecisionState.Excluded))).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"implicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit})).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"explicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit})).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"none"},y(m=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Excluded})).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(!0)).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!0&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!0&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===!0}).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(!1)).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!1&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!1&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===!1}).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(c.ComponentDecisionState.Included)).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Included}).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(c.ComponentDecisionState.Excluded)).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Excluded}).with({attribute:{type:c.AttributeType.Numeric},selection:"numeric",condition:"implicit"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Numeric},selection:"numeric",condition:"explicit"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Numeric},selection:"numeric",condition:"none"},({attribute:m})=>m.decision!=null).with({attribute:{type:c.AttributeType.Choice},selection:"undefined"},()=>h.decision==null).with({attribute:{type:c.AttributeType.Boolean},selection:"undefined"},{attribute:{type:c.AttributeType.Component},selection:"undefined"},{attribute:{type:c.AttributeType.Numeric},selection:"undefined"},({attribute:m})=>m.decision==null).otherwise(()=>!1));return d&&pe(o(d.content),{ref:n})})),$a=hi,Ka={...re,...Be,variants:{title:"Variants",type:p.ControlType.Array,maxCount:10,control:{type:p.ControlType.Object,controls:{selection:{title:"Selection",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},condition:{title:"Condition",type:p.ControlType.Enum,defaultValue:"none",options:["none","explicit","implicit","blocked"]},content:{title:"Content",type:p.ControlType.Enum,defaultValue:1,options:[1,2,3,4,5,6,7,8,9,10]},useInDesignTime:{title:"Design Time",type:p.ControlType.Boolean,defaultValue:!1}}}},content1:{title:"Content 1",type:p.ControlType.ComponentInstance},content2:{title:"Content 2",type:p.ControlType.ComponentInstance},content3:{title:"Content 3",type:p.ControlType.ComponentInstance},content4:{title:"Content 4",type:p.ControlType.ComponentInstance},content5:{title:"Content 5",type:p.ControlType.ComponentInstance},content6:{title:"Content 6",type:p.ControlType.ComponentInstance},content7:{title:"Content 7",type:p.ControlType.ComponentInstance},content8:{title:"Content 8",type:p.ControlType.ComponentInstance},content9:{title:"Content 9",type:p.ControlType.ComponentInstance},content10:{title:"Content 10",type:p.ControlType.ComponentInstance}};p.addPropertyControls(hi,Ka);const mi=se(e=>{const t=T.useRef(),[n,o]=T.useState(null),i=T.useRef(n),r=T.useMemo(()=>e.color.startsWith("var"),[e.color]),l=r?n:e.color,s=T.useMemo(()=>{if(!l)return;const a=Bi(l);return Ni.hexToCSSFilter(`#${a}`,{acceptanceLossPercentage:1,maxChecks:30}).filter.replace(";","")},[l]);return T.useLayoutEffect(()=>{if(r){const a=t.current&&getComputedStyle(t.current).color;a!=i.current&&(i.current=a,o(a))}}),f.jsx("div",{ref:t,style:{...e.style,color:e.color,filter:s},children:e.children})}),za=mi,Wa={children:{title:"Content",type:p.ControlType.ComponentInstance},color:{title:"Color",type:p.ControlType.Color,defaultValue:"#0000ff"}};p.addPropertyControls(mi,Wa);const yi=se(e=>{if(G())return e.children;const{error:n}=W.useConfigurationInitialization();return n?pe(e.children,{onClick:n.retry}):null}),qa=yi,Ha={children:{title:"Content",type:p.ControlType.ComponentInstance}};p.addPropertyControls(yi,Ha);function Ua(e){return T.forwardRef((t,n)=>{const o={...t.style,width:"100%",height:"100%"};return f.jsx(e,{...t,ref:n,style:o})})}const _a=O.div`
|
|
428
|
+
`,ai=fe((e,t)=>{var v,P;if(G()){const S=Bt(e,!0,!1);return f.jsx(Hn,{style:S})}const o=ae(),i=J(e),r=W.useNumericAttribute(i),{explain:l}=de();if(!r)return f.jsx("span",{children:"Numeric Attribute not found"});const{attribute:s,makeDecision:a}=r,u=((v=s.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit,x=Bt(e,s.isSatisfied,u),h=(P=s.decision)==null?void 0:P.state,[y,d]=T.useState(h),{min:b,max:w}=s.range,g=si(h,async S=>{if(S<b){alert(`The value must be smaller than or equal to ${b}.`);return}if(S>w){alert(`The value must be greater than or equal to ${w}.`);return}try{await a(S)}catch(E){const R=E;R.type===c.FailureType.ConfigurationModelNotFeasible||R.type===c.FailureType.ConfigurationConflict?e.explain!=="disabled"&&await l(V=>V.whyIsStateNotPossible.numeric(s.id).state(S),e.explain,o):ue()}},y,S=>d(S),e.wait);return f.jsx(Hn,{getInputRef:t,thousandsGroupStyle:"thousand",decimalSeparator:e.decimalSeparator,thousandSeparator:e.thousandSeparator,allowNegative:!0,fixedDecimalScale:!0,decimalScale:s.decimalPlaces,allowEmptyFormatting:!1,displayType:"input",placeholder:e.placeholder,prefix:Ra(s,e.implicitLabelPrefix),onBlur:()=>{g.flush()},onKeyPress:S=>{S.key==="Enter"&&g.flush()},onValueChange:S=>d(S.floatValue),value:y??"",style:x})}),Ia=ai,Ra=(e,t)=>{var n;return((n=e.decision)==null?void 0:n.kind)===c.DecisionKind.Implicit?t:""},Pa={...ti,wait:{title:"Debounce Delay",type:p.ControlType.Number,defaultValue:2e3,min:0,unit:"ms"},decimalSeparator:{title:"Decimal Separator",type:p.ControlType.String,defaultValue:",",maxLength:1},thousandSeparator:{title:"Thousand Separator",type:p.ControlType.String,defaultValue:".",maxLength:1},placeholder:{title:"Placeholder",type:p.ControlType.String,defaultValue:""}};p.addPropertyControls(ai,Pa);const Be={choiceValueId:{title:"Choice Value Id",type:p.ControlType.String}};function pe(e,t){return T.Children.map(e,n=>{if(T.isValidElement(n)){const o=Jn(n.props,t);return T.cloneElement(n,o)}return n})}const ci=fe((e,t)=>{if(G())return e.children;const o=ae(),{makeDecision:i}=W.useDecision(),r=J(e),l=e.choiceValueId??"",s=l.length>0,a=W.useAttributes([r])[0],{explain:u}=de();if(!a)return f.jsx("span",{children:"Attribute not found"});const x=a.type===c.AttributeType.Choice,h=a.type===c.AttributeType.Numeric,y=a.type===c.AttributeType.Boolean,d=a.type===c.AttributeType.Component;if(!x&&s)return f.jsx("span",{children:"Attribute is not a Choice Attribute"});if(h)return f.jsx("span",{children:"Numeric Attribute is not supported"});let b=x?a.values.find(P=>P.id===l):null;if(s&&b==null)return f.jsx("span",{children:"Choice Value not found"});const w=P=>F.match({state:P,attribute:a}).with({attribute:{type:c.AttributeType.Choice},state:"undefined"},()=>b.decision==null).with({attribute:{type:c.AttributeType.Choice},state:"included"},()=>{var S,E;return((S=b.decision)==null?void 0:S.state)===c.ChoiceValueDecisionState.Included&&((E=b.decision)==null?void 0:E.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Choice},state:"excluded"},()=>{var S,E;return((S=b.decision)==null?void 0:S.state)===c.ChoiceValueDecisionState.Excluded&&((E=b.decision)==null?void 0:E.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},state:"undefined"},{attribute:{type:c.AttributeType.Component},state:"undefined"},({attribute:S})=>S.decision==null).with({attribute:{type:c.AttributeType.Boolean},state:"true"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===!0&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},state:"false"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===!1&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},state:"included"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===c.ComponentDecisionState.Included&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},state:"excluded"},({attribute:S})=>{var E,R;return((E=S.decision)==null?void 0:E.state)===c.ComponentDecisionState.Excluded&&((R=S.decision)==null?void 0:R.kind)===c.DecisionKind.Explicit}).otherwise(()=>!1),m=P=>F.match({isChoiceAttribute:x,isBooleanAttribute:y,isComponentAttribute:d,state:P}).with({isChoiceAttribute:!0,state:"included"},()=>c.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,state:"excluded"},()=>c.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>c.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>c.ComponentDecisionState.Excluded).otherwise(()=>null);w(e.toggleFrom);const g=w(e.toggleTo),v=async()=>{const P=g?e.toggleFrom:e.toggleTo,S=m(P),E=d?c.AttributeInterpreter.isComponentStatePossible(a,S):!1,R=y?c.AttributeInterpreter.isBooleanValuePossible(a,S):!1;if((x?b.possibleDecisionStates.includes(S):!1)||R||E||S==null)try{await i({type:a.type,attributeId:r,choiceValueId:l,state:S})}catch{ue()}else if(e.explain!=="disabled"){const B=F.match({isComponentAttribute:d,isBooleanAttribute:y,isChoiceAttribute:x}).returnType().with({isChoiceAttribute:!0},()=>c.ExplainQuestionSubject.choiceValue).with({isBooleanAttribute:!0},()=>c.ExplainQuestionSubject.boolean).with({isComponentAttribute:!0},()=>c.ExplainQuestionSubject.component).otherwise(()=>null);B&&await u({question:c.ExplainQuestionType.whyIsStateNotPossible,subject:B,attributeId:r,choiceValueId:l,state:S},e.explain,o)}};return pe(e.children,{onClick:v,ref:t})}),Va=ci,Da={...re,...Be,children:{title:"Content",type:p.ControlType.ComponentInstance},toggleFrom:{title:"Toggle From",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false"]},toggleTo:{title:"Toggle To",type:p.ControlType.Enum,defaultValue:"included",options:["undefined","included","excluded","true","false"]},...Ne};p.addPropertyControls(ci,Da);const ui=fe((e,t)=>{if(G())return e.children;const o=ae(),{makeDecision:i}=W.useDecision(),r=J(e),l=e.choiceValueId??"",s=l.length>0,a=W.useAttributes([r])[0],u=W.useChoiceAttribute(r),{explain:x}=de();if(!a)return f.jsx("span",{children:"Attribute not found"});const h=a.type===c.AttributeType.Choice,y=a.type===c.AttributeType.Numeric,d=a.type===c.AttributeType.Boolean,b=a.type===c.AttributeType.Component;if(!h&&s)return f.jsx("span",{children:"Attribute is not a Choice Attribute"});let w=h?a.values.find(v=>v.id===l):null;if(s&&w==null)return f.jsx("span",{children:"Choice Value not found"});const m=()=>F.match({isChoiceAttribute:h,isBooleanAttribute:d,isComponentAttribute:b,isNumericAttribute:y,hasChoiceValueId:s,state:e.setSelection}).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"included"},()=>c.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"excluded"},()=>c.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>c.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>c.ComponentDecisionState.Excluded).with({isNumericAttribute:!0,state:"numeric"},()=>e.numericValue).otherwise(()=>null),g=async()=>{if(h&&!s&&e.setSelection==="undefined")try{await u.clearDecisions()}catch{ue()}else{const v=m(),P=b?c.AttributeInterpreter.isComponentStatePossible(a,v):!1,S=d?c.AttributeInterpreter.isBooleanValuePossible(a,v):!1,R=(h?w.possibleDecisionStates.includes(v):!1)||S||P;if(y||R||v==null)try{await i({type:a.type,attributeId:r,choiceValueId:l,state:v})}catch(I){const V=I;y&&(V.type===c.FailureType.ConfigurationModelNotFeasible||V.type===c.FailureType.ConfigurationConflict)?e.explain!=="disabled"&&await x(k=>k.whyIsStateNotPossible.numeric(a.id).state(v),e.explain,o):ue()}else if(e.explain!=="disabled"){const I=F.match({isComponentAttribute:b,isBooleanAttribute:d,isChoiceAttribute:h}).returnType().with({isChoiceAttribute:!0},()=>c.ExplainQuestionSubject.choiceValue).with({isBooleanAttribute:!0},()=>c.ExplainQuestionSubject.boolean).with({isComponentAttribute:!0},()=>c.ExplainQuestionSubject.component).otherwise(()=>null);I&&await x({question:c.ExplainQuestionType.whyIsStateNotPossible,subject:I,attributeId:r,choiceValueId:l,state:v},e.explain,o)}}};return pe(e.children,{onClick:g,ref:t})}),Oa=ui,ka={...re,...Be,children:{title:"Content",type:p.ControlType.ComponentInstance},setSelection:{title:"Set Selection To",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},numericValue:{title:"Numeric Value",type:p.ControlType.Number,defaultValue:0},...Ne};p.addPropertyControls(ui,ka);const di=fe((e,t)=>{var h;if(G())return e.children;const o=ae(),{setManyDecision:i}=W.useDecision(),{handleExplainAnswer:r}=de(),l=e.attributes.map(J),s=W.useAttributes(l).map((y,d)=>{if(!y)return{error:f.jsx("span",{children:"Attribute not found"})};const b=e.attributes[d],w=b.choiceValueId??"",m=w.length>0,g=y.type===c.AttributeType.Choice,v=y.type===c.AttributeType.Numeric,P=y.type===c.AttributeType.Boolean,S=y.type===c.AttributeType.Component;if(!g&&m)return{error:f.jsx("span",{children:"Attribute is not a Choice Attribute"})};let E=g?y.values.find(I=>I.id===w):null;if(m&&E==null)return{error:f.jsx("span",{children:"Choice Value not found"})};const R=()=>F.match({isChoiceAttribute:g,isBooleanAttribute:P,isComponentAttribute:S,isNumericAttribute:v,hasChoiceValueId:m,state:b.setSelection}).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"included"},()=>c.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"excluded"},()=>c.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>c.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>c.ComponentDecisionState.Excluded).with({isNumericAttribute:!0,state:"numeric"},()=>b.numericValue).otherwise(()=>null);return{getDecisions:()=>g&&!m&&b.setSelection==="undefined"?y.values.filter(I=>{var V;return((V=I.decision)==null?void 0:V.kind)===c.DecisionKind.Explicit}).map(I=>({type:y.type,attributeId:y.id,choiceValueId:I.id,state:null})):[{type:y.type,attributeId:y.id,choiceValueId:w,state:R()}]}}),a=(h=s.find(y=>y.error))==null?void 0:h.error;if(a)return a;const u=async()=>{const y=s.reduce((b,w)=>[...b,...w.getDecisions()],new Array),d=F.match(e.existingSelections).with("keep",()=>({type:"KeepExistingDecisions"})).with("drop",()=>({type:"DropExistingDecisions",conflictHandling:F.match(e.autoResolveConflicts).with(!1,()=>({type:"Manual",includeConstraintsInConflictExplanation:!1})).with(!0,()=>({type:"Automatic"})).exhaustive()})).exhaustive();try{await i(y,d)}catch(b){const w=b;if(console.debug("SetMany failed",w),(w==null?void 0:w.type)===c.FailureType.ConfigurationSetManyConflict&&w.decisionExplanations){e.explain!=="disabled"&&await r(w,e.explain,o);return}ue();return}},x=()=>{e.trigger==="click"&&u()};return T.useEffect(()=>{e.trigger==="auto"&&u()},[]),pe(e.children,{onClick:x,ref:t})}),ja=di,Fa={children:{title:"Content",type:p.ControlType.ComponentInstance},attributes:{title:"Attributes",type:p.ControlType.Array,control:{type:p.ControlType.Object,controls:{...re,...Be,setSelection:{title:"Set Selection To",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},numericValue:{title:"Numeric Value",type:p.ControlType.Number,defaultValue:0}}}},existingSelections:{title:"Existing Selections",type:p.ControlType.Enum,defaultValue:"keep",options:["keep","drop"]},autoResolveConflicts:{title:"Auto Resolve Conflicts",type:p.ControlType.Boolean,defaultValue:!0,hidden:e=>e.existingSelections!=="drop"},trigger:{title:"Trigger",type:p.ControlType.Enum,defaultValue:"click",options:["click","auto"],displaySegmentedControl:!0,segmentedControlDirection:"horizontal"},...Ne};p.addPropertyControls(di,Fa);const fi=se(e=>{if(G())return e.enabledChildren;const{configuration:n}=W.useConfiguration(),{setManyDecision:o}=W.useDecision(),i=n.attributes.some(s=>F.match(s).with({type:c.AttributeType.Choice},a=>a.values.some(u=>{var x;return((x=u.decision)==null?void 0:x.kind)===c.DecisionKind.Explicit})).with({type:c.AttributeType.Boolean},a=>{var u;return((u=a.decision)==null?void 0:u.kind)===c.DecisionKind.Explicit}).with({type:c.AttributeType.Numeric},a=>{var u;return((u=a.decision)==null?void 0:u.kind)===c.DecisionKind.Explicit}).with({type:c.AttributeType.Component},a=>{var u;return((u=a.decision)==null?void 0:u.kind)===c.DecisionKind.Explicit}).exhaustive()),r=()=>{if(i)try{o([],{type:"DropExistingDecisions",conflictHandling:{type:"Manual",includeConstraintsInConflictExplanation:!1}})}catch{xa()}},l=i?e.enabledChildren:e.disabledChildren;return pe(l,{onClick:r})}),Na=fi,Ba={enabledChildren:{title:"Content – Enabled",type:p.ControlType.ComponentInstance},disabledChildren:{title:"Content – Disabled",type:p.ControlType.ComponentInstance}};p.addPropertyControls(fi,Ba);const pi=fe((e,t)=>{if(G())return e.unsatisfiedChildren;const o=ae(),{configuration:i}=W.useConfiguration(),{explain:r}=de(),s=[...e.attributeId.length>0?[J(e)]:[],...e.attributes.map(J)],a=()=>{var d;const h=W.useAttributes(s).map(b=>b?{isSatisfied:b.isSatisfied}:{error:f.jsx("span",{children:"Attribute not found"})}),y=(d=h.find(b=>b.error))==null?void 0:d.error;return y||h.every(b=>b.isSatisfied)},u=async()=>{e.explain!=="disabled"&&(s.length===0?await r(h=>h.whyIsNotSatisfied.configuration,e.explain,o):s.length===1&&await r(h=>h.whyIsNotSatisfied.attribute(s[0]),e.explain,o))};return(s.length>0?a():i.isSatisfied)?e.satisfiedChildren:pe(e.unsatisfiedChildren,{onClick:u,ref:t})}),La=pi,Ma={satisfiedChildren:{title:"Content – Satisfied",type:p.ControlType.ComponentInstance},unsatisfiedChildren:{title:"Content – Unsatisfied",type:p.ControlType.ComponentInstance},...re,attributes:{title:"Attributes",type:p.ControlType.Array,control:{type:p.ControlType.Object,controls:{...re}}},...Ne};p.addPropertyControls(pi,Ma);const hi=se(T.forwardRef(function(t,n){const o=b=>F.match(b).with(1,()=>t.content1).with(2,()=>t.content2).with(3,()=>t.content3).with(4,()=>t.content4).with(5,()=>t.content5).with(6,()=>t.content6).with(7,()=>t.content7).with(8,()=>t.content8).with(9,()=>t.content9).with(10,()=>t.content10).otherwise(()=>null),i=t.variants.find(b=>b.useInDesignTime)||t.variants[0];if(G())return i&&o(i.content);const l=J(t),s=t.choiceValueId??"",a=s.length>0,u=W.useAttributes([l])[0];if(!u)return f.jsx("span",{children:"Attribute not found"});const x=u.type===c.AttributeType.Choice;if(!x&&a)return f.jsx("span",{children:"Attribute is not a Choice Attribute"});let h=x&&a?u.values.find(b=>b.id===s):null;if(a&&h==null)return f.jsx("span",{children:"Choice Value not found"});const y=b=>()=>h?b(h):u.values.some(b),d=[...t.variants].find(({selection:b,condition:w})=>F.match({selection:b,condition:w,attribute:u}).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"blocked"},y(m=>!m.possibleDecisionStates.includes(c.ChoiceValueDecisionState.Included))).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"implicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit})).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"explicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit})).with({attribute:{type:c.AttributeType.Choice},selection:"included",condition:"none"},y(m=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Included})).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"blocked"},y(m=>!m.possibleDecisionStates.includes(c.ChoiceValueDecisionState.Excluded))).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"implicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit})).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"explicit"},y(m=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit})).with({attribute:{type:c.AttributeType.Choice},selection:"excluded",condition:"none"},y(m=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ChoiceValueDecisionState.Excluded})).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(!0)).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!0&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!0&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"true",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===!0}).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(!1)).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!1&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===!1&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Boolean},selection:"false",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===!1}).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(c.ComponentDecisionState.Included)).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Included&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},selection:"included",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Included}).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(c.ComponentDecisionState.Excluded)).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"implicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"explicit"},({attribute:m})=>{var g,v;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Excluded&&((v=m.decision)==null?void 0:v.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Component},selection:"excluded",condition:"none"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.state)===c.ComponentDecisionState.Excluded}).with({attribute:{type:c.AttributeType.Numeric},selection:"numeric",condition:"implicit"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.kind)===c.DecisionKind.Implicit}).with({attribute:{type:c.AttributeType.Numeric},selection:"numeric",condition:"explicit"},({attribute:m})=>{var g;return((g=m.decision)==null?void 0:g.kind)===c.DecisionKind.Explicit}).with({attribute:{type:c.AttributeType.Numeric},selection:"numeric",condition:"none"},({attribute:m})=>m.decision!=null).with({attribute:{type:c.AttributeType.Choice},selection:"undefined"},()=>h.decision==null).with({attribute:{type:c.AttributeType.Boolean},selection:"undefined"},{attribute:{type:c.AttributeType.Component},selection:"undefined"},{attribute:{type:c.AttributeType.Numeric},selection:"undefined"},({attribute:m})=>m.decision==null).otherwise(()=>!1));return d&&pe(o(d.content),{ref:n})})),$a=hi,Ka={...re,...Be,variants:{title:"Variants",type:p.ControlType.Array,maxCount:10,control:{type:p.ControlType.Object,controls:{selection:{title:"Selection",type:p.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},condition:{title:"Condition",type:p.ControlType.Enum,defaultValue:"none",options:["none","explicit","implicit","blocked"]},content:{title:"Content",type:p.ControlType.Enum,defaultValue:1,options:[1,2,3,4,5,6,7,8,9,10]},useInDesignTime:{title:"Design Time",type:p.ControlType.Boolean,defaultValue:!1}}}},content1:{title:"Content 1",type:p.ControlType.ComponentInstance},content2:{title:"Content 2",type:p.ControlType.ComponentInstance},content3:{title:"Content 3",type:p.ControlType.ComponentInstance},content4:{title:"Content 4",type:p.ControlType.ComponentInstance},content5:{title:"Content 5",type:p.ControlType.ComponentInstance},content6:{title:"Content 6",type:p.ControlType.ComponentInstance},content7:{title:"Content 7",type:p.ControlType.ComponentInstance},content8:{title:"Content 8",type:p.ControlType.ComponentInstance},content9:{title:"Content 9",type:p.ControlType.ComponentInstance},content10:{title:"Content 10",type:p.ControlType.ComponentInstance}};p.addPropertyControls(hi,Ka);const mi=se(e=>{const t=T.useRef(),[n,o]=T.useState(null),i=T.useRef(n),r=T.useMemo(()=>e.color.startsWith("var"),[e.color]),l=r?n:e.color,s=T.useMemo(()=>{if(!l)return;const a=Bi(l);return Ni.hexToCSSFilter(`#${a}`,{acceptanceLossPercentage:1,maxChecks:30}).filter.replace(";","")},[l]);return T.useLayoutEffect(()=>{if(r){const a=t.current&&getComputedStyle(t.current).color;a!=i.current&&(i.current=a,o(a))}}),f.jsx("div",{ref:t,style:{...e.style,color:e.color,filter:s},children:e.children})}),za=mi,Wa={children:{title:"Content",type:p.ControlType.ComponentInstance},color:{title:"Color",type:p.ControlType.Color,defaultValue:"#0000ff"}};p.addPropertyControls(mi,Wa);const yi=se(e=>{if(G())return e.children;const{error:n}=W.useConfigurationInitialization();return n?pe(e.children,{onClick:n.retry}):null}),qa=yi,Ha={children:{title:"Content",type:p.ControlType.ComponentInstance}};p.addPropertyControls(yi,Ha);function Ua(e){return T.forwardRef((t,n)=>{const o={...t.style,width:"100%",height:"100%"};return f.jsx(e,{...t,ref:n,style:o})})}const _a=O.div`
|
|
426
429
|
width: 10px;
|
|
427
430
|
height: 10px;
|
|
428
431
|
background-color: greenyellow;
|
package/dist/index.js
CHANGED
|
@@ -4272,6 +4272,7 @@ Please check your internet connection and try again.`);
|
|
|
4272
4272
|
}
|
|
4273
4273
|
const xo = O.select`
|
|
4274
4274
|
color: inherit;
|
|
4275
|
+
cursor: inherit;
|
|
4275
4276
|
`, vo = "<reset>", Co = "<nothing>", Ki = Oe((e, t) => {
|
|
4276
4277
|
if (ne()) {
|
|
4277
4278
|
const E = ot(e, !0, !1);
|
|
@@ -4357,6 +4358,7 @@ const Sc = (e, t, n, o) => {
|
|
|
4357
4358
|
};
|
|
4358
4359
|
}, wo = O.select`
|
|
4359
4360
|
color: inherit;
|
|
4361
|
+
cursor: inherit;
|
|
4360
4362
|
`, So = "<reset>", Zt = "<nothing>", en = "yes", Eo = "no", qi = Oe((e, t) => {
|
|
4361
4363
|
var x, R, C;
|
|
4362
4364
|
if (ne()) {
|
|
@@ -4430,6 +4432,7 @@ const Sc = (e, t, n, o) => {
|
|
|
4430
4432
|
te(qi, Ec);
|
|
4431
4433
|
const Ao = O.select`
|
|
4432
4434
|
color: inherit;
|
|
4435
|
+
cursor: inherit;
|
|
4433
4436
|
`, Ro = "<reset>", tn = "<nothing>", nn = "included", on = "excluded", Yi = Oe((e, t) => {
|
|
4434
4437
|
var R, C, S;
|
|
4435
4438
|
if (ne()) {
|
|
@@ -4643,7 +4646,7 @@ const Gi = Oe((e, t) => {
|
|
|
4643
4646
|
v(e.toggleFrom);
|
|
4644
4647
|
const m = v(e.toggleTo), x = async () => {
|
|
4645
4648
|
const R = m ? e.toggleFrom : e.toggleTo, C = f(R), S = u ? se.isComponentStatePossible(s, C) : !1, I = p ? se.isBooleanValuePossible(s, C) : !1;
|
|
4646
|
-
if ((b ? h.possibleDecisionStates.
|
|
4649
|
+
if ((b ? h.possibleDecisionStates.includes(C) : !1) || I || S || C == null)
|
|
4647
4650
|
try {
|
|
4648
4651
|
await i({
|
|
4649
4652
|
type: s.type,
|
|
@@ -4708,7 +4711,7 @@ const Ji = Oe((e, t) => {
|
|
|
4708
4711
|
Ie();
|
|
4709
4712
|
}
|
|
4710
4713
|
else {
|
|
4711
|
-
const x = f(), R = h ? se.isComponentStatePossible(s, x) : !1, C = u ? se.isBooleanValuePossible(s, x) : !1, I = (d ? v.possibleDecisionStates.
|
|
4714
|
+
const x = f(), R = h ? se.isComponentStatePossible(s, x) : !1, C = u ? se.isBooleanValuePossible(s, x) : !1, I = (d ? v.possibleDecisionStates.includes(x) : !1) || C || R;
|
|
4712
4715
|
if (p || I || x == null)
|
|
4713
4716
|
try {
|
|
4714
4717
|
await i({
|