@uniformdev/context-ui
Advanced tools
Comparing version 16.2.1-alpha.142 to 16.2.1-alpha.320
@@ -12,3 +12,3 @@ import{jsx as e}from"@emotion/react";import*as p from"react";import{Icon as ye}from"@uniformdev/design-system";import{CgChevronRight as De}from"react-icons/cg";import{css as he}from"@emotion/react";var Y=he` | ||
} | ||
`;var X=({linkTo:t,name:n,linkText:o=`Edit ${n} Component`})=>e("a",{css:Y,title:`Edit ${n} component definition`,rel:"noopener noreferrer",target:"_blank",href:t},o,e(ye,{icon:De,iconColor:"currentColor",size:"1.5rem"}));import j,{useMemo as Q,useState as U}from"react";import{useEffect as xe,useState as Ie}from"react";import{DimensionClient as we,computeDimensionDisplayName as Be,ApiClientError as Ee}from"@uniformdev/context/api";function J(t,n,o){return t.reduce((m,a)=>{let r=n(a);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return m[n(a)]=o?o(a):a,m},{})}function I({apiHost:t,apiKey:n,projectId:o}){let[m,a]=Ie({loading:!1,notConfigured:!1,error:null,result:null});return xe(()=>{if(!o||!n||!t){a({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{a({notConfigured:!1,loading:!0,error:null,result:null});try{let i=(await new we({projectId:o,apiKey:n,apiHost:t}).get()).dimensions.map(c=>({...c,displayName:Be(c)})),l={dimensions:i,dimIndex:J(i,c=>c.dim,c=>c)};a({notConfigured:!1,loading:!1,error:null,result:l})}catch(s){let i;s instanceof Ee?i=s.message:i=s.toString(),a({notConfigured:!1,loading:!1,error:i,result:null});return}})()},[t,n,o]),{result:m.result,error:m.error,loading:m.loading,notConfigured:m.notConfigured}}import{getEnrichmentVectorKey as G}from"@uniformdev/context";import{Input as ee,Button as Me,InputSelect as Se,Callout as H,Icon as W,LoadingIndicator as Pe,AddListButton as Re}from"@uniformdev/design-system";import{CgMathPlus as Oe,CgMathMinus as ke,CgCloseO as Te}from"react-icons/cg";import Z from"immer";import{css as q}from"@emotion/react";var Ne=q` | ||
`;var X=({linkTo:t,name:n,linkText:o=`Edit ${n} Component`})=>e("a",{css:Y,title:`Edit ${n} component definition`,rel:"noopener noreferrer",target:"_blank",href:t},o,e(ye,{icon:De,iconColor:"currentColor",size:"1.5rem"}));import j,{useMemo as Q,useState as U}from"react";import{useEffect as xe,useState as Ie}from"react";import{computeDimensionDisplayName as we,ApiClientError as Be,CachedDimensionClient as Ee}from"@uniformdev/context/api";function J(t,n,o){return t.reduce((m,a)=>{let r=n(a);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return m[n(a)]=o?o(a):a,m},{})}function I({apiHost:t,apiKey:n,projectId:o}){let[m,a]=Ie({loading:!1,notConfigured:!1,error:null,result:null});return xe(()=>{if(!o||!n||!t){a({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{a({notConfigured:!1,loading:!0,error:null,result:null});try{let i=(await new Ee({projectId:o,apiKey:n,apiHost:t}).get()).dimensions.map(c=>({...c,displayName:we(c)})),l={dimensions:i,dimIndex:J(i,c=>c.dim,c=>c)};a({notConfigured:!1,loading:!1,error:null,result:l})}catch(s){let i;s instanceof Be?i=s.message:i=s.toString(),a({notConfigured:!1,loading:!1,error:i,result:null});return}})()},[t,n,o]),{result:m.result,error:m.error,loading:m.loading,notConfigured:m.notConfigured}}import{getEnrichmentVectorKey as G}from"@uniformdev/context";import{Input as ee,Button as Me,InputSelect as Se,Callout as H,Icon as W,LoadingIndicator as Pe,AddListButton as Re}from"@uniformdev/design-system";import{CgMathPlus as Oe,CgMathMinus as Ne,CgCloseO as ke}from"react-icons/cg";import Z from"immer";import{css as q}from"@emotion/react";var Te=q` | ||
flex: 2; | ||
@@ -24,3 +24,3 @@ display: flex; | ||
} | ||
`,kt=({value:t,setValue:n,contextConfig:o,displayTitle:m=!0})=>{let{loading:a,result:r,error:s}=I(o),i=Q(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),l=Q(()=>{if(!t)return i;if(i)return i.filter(g=>!t.some(y=>G(y.cat,y.key)===g.dim))},[i,t]),[c,h]=U(""),[u,C]=U(50),[f,D]=U(!1),d=i==null?void 0:i.find(g=>g.dim===c),v=()=>{let[g,y]=c.split("_");x([...t!=null?t:[],{cat:g,key:y,str:u}]),h(""),C(50),D(!1)},x=g=>{let y=[];r?y=g.filter(w=>{let M=r.dimIndex[G(w.cat,w.key)];return Boolean(M)}):y=g;let E=y.length===0?null:y;n(E)};return s?e(H,{type:"danger"},s):a||r===null?e(Pe,null):e("fieldset",{className:"enrichment-tag"},m?e("div",{css:{display:"flex",justifyContent:"space-between",marginBottom:"var(--spacing-base)"}},e("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Enrichment Tags")):null,i!=null&&i.length?!f&&!t?e(H,{title:"No enrichment tags assigned.",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"Click"," ",e("a",{onClick:()=>D(!0),target:"_blank",rel:"noopener noreferrer",css:{textDecorationLine:"underline"}},"here")," ","to assign your first enrichment tag.")):e(j.Fragment,null,r&&e($e,{list:t!=null?t:[],setList:x,dimIndex:r.dimIndex}),f&&l&&l.length>0?e("div",{className:"add-enrichment-tag",css:{display:"flex",flexWrap:"wrap",gap:"var(--spacing-lg)",marginTop:"var(--spacing-md)",alignItems:"center"}},e("div",{css:{flexGrow:1}},e(Se,{name:"enrichment-type",label:"Enrichment Tag",showLabel:!0,value:c,options:[{label:"Select",value:""},...l.map(g=>({label:g.displayName,value:g.dim}))],onChange:g=>h(g.currentTarget.value)})),e(Le,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),e(Me,{buttonType:"tertiary",size:"xl",css:{marginBottom:"var(--spacing-xs)",height:"3.5rem",margin:0,alignSelf:"flex-end"},onClick:v,disabled:!c},"Add")):null,e("div",{className:"enrichment-cta",style:{paddingTop:"10px",display:"flex",justifyContent:"space-between"}},!f&&l&&l.length>0&&t?e(Re,{className:"add-more",buttonText:"Add More",onButtonClick:()=>D(!0)}):e("a",{css:Ne,title:"none",href:"#"}),e(X,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):e(Ve,{contextConfig:o}))},Ve=({contextConfig:t})=>e(H,{title:"No enrichments found.",type:"caution",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"Looks like you do not have any enrichment created in your connected Uniform project. Start by creating your first enrichment"," ",e("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),te=(t,n=100,o=0)=>Math.max(Math.min(t,n),o),ne=q` | ||
`,Nt=({value:t,setValue:n,contextConfig:o,displayTitle:m=!0})=>{let{loading:a,result:r,error:s}=I(o),i=Q(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),l=Q(()=>{if(!t)return i;if(i)return i.filter(g=>!t.some(y=>G(y.cat,y.key)===g.dim))},[i,t]),[c,h]=U(""),[u,C]=U(50),[f,D]=U(!1),d=i==null?void 0:i.find(g=>g.dim===c),v=()=>{let[g,y]=c.split("_");x([...t!=null?t:[],{cat:g,key:y,str:u}]),h(""),C(50),D(!1)},x=g=>{let y=[];r?y=g.filter(w=>{let M=r.dimIndex[G(w.cat,w.key)];return Boolean(M)}):y=g;let E=y.length===0?null:y;n(E)};return s?e(H,{type:"danger"},s):a||r===null?e(Pe,null):e("fieldset",{className:"enrichment-tag"},m?e("div",{css:{display:"flex",justifyContent:"space-between",marginBottom:"var(--spacing-base)"}},e("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Enrichment Tags")):null,i!=null&&i.length?!f&&!t?e(H,{title:"No enrichment tags assigned.",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"Click"," ",e("a",{onClick:()=>D(!0),target:"_blank",rel:"noopener noreferrer",css:{textDecorationLine:"underline"}},"here")," ","to assign your first enrichment tag.")):e(j.Fragment,null,r&&e($e,{list:t!=null?t:[],setList:x,dimIndex:r.dimIndex}),f&&l&&l.length>0?e("div",{className:"add-enrichment-tag",css:{display:"flex",flexWrap:"wrap",gap:"var(--spacing-lg)",marginTop:"var(--spacing-md)",alignItems:"center"}},e("div",{css:{flexGrow:1}},e(Se,{name:"enrichment-type",label:"Enrichment Tag",showLabel:!0,value:c,options:[{label:"Select",value:""},...l.map(g=>({label:g.displayName,value:g.dim}))],onChange:g=>h(g.currentTarget.value)})),e(Le,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),e(Me,{buttonType:"tertiary",size:"xl",css:{marginBottom:"var(--spacing-xs)",height:"3.5rem",margin:0,alignSelf:"flex-end"},onClick:v,disabled:!c},"Add")):null,e("div",{className:"enrichment-cta",style:{paddingTop:"10px",display:"flex",justifyContent:"space-between"}},!f&&l&&l.length>0&&t?e(Re,{className:"add-more",buttonText:"Add More",onButtonClick:()=>D(!0)}):e("a",{css:Te,title:"none",href:"#"}),e(X,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):e(Ve,{contextConfig:o}))},Ve=({contextConfig:t})=>e(H,{title:"No enrichments found.",type:"caution",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"Looks like you do not have any enrichment created in your connected Uniform project. Start by creating your first enrichment"," ",e("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),te=(t,n=100,o=0)=>Math.max(Math.min(t,n),o),ne=q` | ||
position: absolute; | ||
@@ -41,3 +41,3 @@ bottom: 0.875rem; | ||
right: var(--spacing-sm); | ||
`,Le=({score:t,setValue:n,cap:o=100,...m})=>{let a=r=>{let s=r==="increment"?t+10:t-10;s<0&&(s=0),s>o&&(s=o),n(s)};return e("div",{css:{position:"relative"},...m},e(ee,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:t,onChange:r=>n(te(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),e("button",{type:"button",title:"Reduce enrichment count",onClick:()=>a("decrement"),disabled:t===0,className:"scoreCounterButton",css:ne},e(W,{icon:ke,iconColor:"gray",size:"1.5rem"})),e("button",{type:"button",title:"Increase enrichment count",onClick:()=>a("increment"),className:"scoreCounterButton",css:ze},e(W,{icon:Oe,iconColor:"gray",size:"1.5rem"})))},$e=({list:t,setList:n,dimIndex:o})=>{let m=r=>{n(Z(t,s=>{s.splice(r,1)}))},a=(r,s)=>{var l;let i=(l=o[`${t[r].cat}_${t[r].key}`])==null?void 0:l.cap;n(Z(t,c=>{c[r].str=te(Number(s)||0,i)}))};return e(j.Fragment,null,t.map((r,s)=>{let i=o[G(r.cat,r.key)];if(!!i)return e("div",{css:{display:"flex",alignItems:"center",gap:"var(--spacing-base)",backgroundColor:"var(--brand-secondary-2)",boxShadow:"var(--shadow-base)",borderRadius:"var(--rounded-base)",paddingInline:"var(--spacing-base)",marginBlock:"var(--spacing-base)"},className:"selected-enrichments",key:`${r.cat}-${r.key}`},e("span",{css:{fontWeight:"var(--fw-bold)",color:i?void 0:"var(--brand-secondary-5)"}},i?i.displayName:`Enrichment '${r.cat}_${r.key}' is unknown`),e("div",{css:{marginLeft:"auto",display:"flex",alignItems:"center",border:"0 solid var(--gray-400)",borderLeftWidth:"1px",borderRightWidth:"1px",padding:"var(--spacing-sm) var(--spacing-base)",flexBasis:"9rem"}},e(ee,{type:"text",min:0,max:i.cap||100,title:"score",value:r.str,css:{textAlign:"center",width:"100px"},onChange:l=>a(s,l.currentTarget.value)})),e("button",{type:"button",title:"Delete enrichment",onClick:()=>m(s),css:{border:0}},e(W,{icon:Te,iconColor:"red",size:"1.5rem"})))}))};import{LoadingIndicator as je,Callout as ge}from"@uniformdev/design-system";import{css as Ke}from"@emotion/react";import{Callout as ce,InputInlineSelect as Ye,Icon as Xe,AddListButton as Je,Paragraph as Qe}from"@uniformdev/design-system";import de from"immer";import{CgCloseO as Ze}from"react-icons/cg";import{css as B}from"@emotion/react";var _="6rem",oe=B` | ||
`,Le=({score:t,setValue:n,cap:o=100,...m})=>{let a=r=>{let s=r==="increment"?t+10:t-10;s<0&&(s=0),s>o&&(s=o),n(s)};return e("div",{css:{position:"relative"},...m},e(ee,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:t,onChange:r=>n(te(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),e("button",{type:"button",title:"Reduce enrichment count",onClick:()=>a("decrement"),disabled:t===0,className:"scoreCounterButton",css:ne},e(W,{icon:Ne,iconColor:"gray",size:"1.5rem"})),e("button",{type:"button",title:"Increase enrichment count",onClick:()=>a("increment"),className:"scoreCounterButton",css:ze},e(W,{icon:Oe,iconColor:"gray",size:"1.5rem"})))},$e=({list:t,setList:n,dimIndex:o})=>{let m=r=>{n(Z(t,s=>{s.splice(r,1)}))},a=(r,s)=>{var l;let i=(l=o[`${t[r].cat}_${t[r].key}`])==null?void 0:l.cap;n(Z(t,c=>{c[r].str=te(Number(s)||0,i)}))};return e(j.Fragment,null,t.map((r,s)=>{let i=o[G(r.cat,r.key)];if(!!i)return e("div",{css:{display:"flex",alignItems:"center",gap:"var(--spacing-base)",backgroundColor:"var(--brand-secondary-2)",boxShadow:"var(--shadow-base)",borderRadius:"var(--rounded-base)",paddingInline:"var(--spacing-base)",marginBlock:"var(--spacing-base)"},className:"selected-enrichments",key:`${r.cat}-${r.key}`},e("span",{css:{fontWeight:"var(--fw-bold)",color:i?void 0:"var(--brand-secondary-5)"}},i?i.displayName:`Enrichment '${r.cat}_${r.key}' is unknown`),e("div",{css:{marginLeft:"auto",display:"flex",alignItems:"center",border:"0 solid var(--gray-400)",borderLeftWidth:"1px",borderRightWidth:"1px",padding:"var(--spacing-sm) var(--spacing-base)",flexBasis:"9rem"}},e(ee,{type:"text",min:0,max:i.cap||100,title:"score",value:r.str,css:{textAlign:"center",width:"100px"},onChange:l=>a(s,l.currentTarget.value)})),e("button",{type:"button",title:"Delete enrichment",onClick:()=>m(s),css:{border:0}},e(W,{icon:ke,iconColor:"red",size:"1.5rem"})))}))};import{LoadingIndicator as je,Callout as ge}from"@uniformdev/design-system";import{css as Ke}from"@emotion/react";import{Callout as ce,InputInlineSelect as Ye,Icon as Xe,AddListButton as Je,Paragraph as Qe}from"@uniformdev/design-system";import de from"immer";import{CgCloseO as Ze}from"react-icons/cg";import{css as B}from"@emotion/react";var _="6rem",oe=B` | ||
position: relative; | ||
@@ -76,3 +76,2 @@ padding: var(--spacing-base); | ||
align-items: stretch; | ||
z-index: var(--z-10); | ||
`,P=B` | ||
@@ -93,5 +92,5 @@ height: 100%; | ||
font-size: var(--fs-base); | ||
`},t)}var ie=t=>{var l,c;let{data:n,getStyles:o,isDisabled:m,innerRef:a,innerProps:r}=t,[s,i]=(c=(l=n.label)==null?void 0:l.split(":"))!=null?c:[];return e("div",{css:{...o("option",t),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:a,"aria-disabled":m,...r},i?e(R,{op:s}):e("div",{css:{width:"20px",height:"20px"}}),e("div",null,i!=null?i:s))};var ae=t=>{let{data:n,getStyles:o}=t;return e("div",{css:{...o("singleValue",t),width:"max-content"}},n.label.length===1?e(R,{op:n.label}):n.label)};var se=[{name:"=",description:"equals",value:"="},{name:"\u2260",description:"not equal",value:"!="},{name:">",description:"is greater than",value:">"},{name:"\u2265",description:"is greater than or equal to",value:">="},{name:"<",description:"is less than",value:"<"},{name:"\u2264",description:"is less than or equal to",value:"<="},{name:"has the strongest score",value:"+"},{name:"has the weakest score",value:"-"}];function le({onChange:t,value:n,...o}){var m,a;return e(Ge,{...o,value:{label:(a=(m=se.find(r=>r.value===n))==null?void 0:m.name)!=null?a:n,value:n},options:se.map(r=>({label:r.description?`${r.name}:${r.description}`:r.name,value:r.value})),styles:{...o.styles,valueContainer:(r,s)=>{var i,l;return{...r,padding:"var(--spacing-sm)",...(l=(i=o.styles)==null?void 0:i.valueContainer)==null?void 0:l.call(i,r,s)}},menu:(r,s)=>{var i,l;return{...r,width:"max-content",...(l=(i=o.styles)==null?void 0:i.menu)==null?void 0:l.call(i,r,s)}},control:(r,s)=>{var i,l;return{...r,border:0,...(l=(i=o.styles)==null?void 0:i.control)==null?void 0:l.call(i,r,s)}},indicatorSeparator:(r,s)=>{var i,l;return{...r,display:"none",...(l=(i=o.styles)==null?void 0:i.indicatorSeparator)==null?void 0:l.call(i,r,s)}}},onChange:r=>{r&&t(r.value)},components:{SingleValue:ae,Option:ie,...o.components}})}import{InputComboBox as qe}from"@uniformdev/design-system";import{Icon as He}from"@uniformdev/design-system";function F(t){return{label:t.displayName,value:t.dim,isDisabled:!1}}function O(t){if(!t)return"unavailable";let[n]=t.split(":");switch(n.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function k(t){let n=[],o="";for(let m of t){let[a]=m.displayName.split(":");o!==a&&(n.push({label:a,options:[]}),o=a),n[n.length-1].options.push(F(m))}return n}var T=t=>{var a;let{data:n,getStyles:o,className:m}=t;return e("div",{css:{...o("groupHeading",t),textTransform:"none",fontSize:"var(--font-size-sm)"},className:m},e("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},e(He,{icon:O((a=n.label)!=null?a:""),iconColor:"currentColor",size:16}),e("span",null,n.label)))};function N({message:t}){return t?e("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},t):null}var V=t=>{var u,C;let{data:n,getStyles:o,cx:m,isDisabled:a,isFocused:r,isSelected:s,className:i,innerRef:l,innerProps:c}=t,[,h]=(C=(u=n.label)==null?void 0:u.split(":"))!=null?C:[];return e("div",{css:o("option",t),className:m({option:!0,"option--is-disabled":a,"option--is-focused":r,"option--is-selected":s},i),ref:l,"aria-disabled":a,...c},e("div",{css:{color:"var(--gray-700)"}},h!=null?h:n.label))};import{Icon as We}from"@uniformdev/design-system";function me({displayName:t}){let[n,o]=t.split(":");return e("div",{css:{whiteSpace:"normal",overflow:"hidden"}},o?e("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},n?e(We,{icon:O(n),iconColor:"currentColor",size:16}):null,e("span",{"data-test-id":"dimension-name"},n)):null,e("div",{css:{color:"var(--gray-700)"},"data-test-id":"dimension-value"},o!=null?o:n))}var z=t=>{let{data:n,getStyles:o}=t;return e("div",{css:o("singleValue",t)},e(me,{displayName:n.label}))};function ue({onChange:t,value:n,dimensions:o,errorMessage:m,...a}){return e(p.Fragment,null,e(qe,{...a,value:n?F(n):void 0,options:k(o),styles:{...a.styles,valueContainer:(r,s)=>{var i,l;return{...r,padding:"var(--spacing-sm)",...(l=(i=a.styles)==null?void 0:i.valueContainer)==null?void 0:l.call(i,r,s)}}},onChange:r=>{r&&t(o.find(s=>s.dim===r.value))},components:{Option:V,SingleValue:z,GroupHeading:T,...a.components}}),e(N,{message:m}))}import{InputComboBox as _e}from"@uniformdev/design-system";import{useState as Fe}from"react";function pe({onChange:t,criteriaMatch:n,dimensions:o,errorMessage:m,...a}){var c,h;let[r,s]=Fe(typeof n.r!="undefined"&&L(n.r)!==null?n.r.toString(10):""),i=n.rDim,l=n.rDim?o.dimIndex[n.rDim]:void 0;return e(p.Fragment,null,e(_e,{...a,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=l==null?void 0:l.displayName)!=null?c:i&&!l?`${n.rDim} (unknown)`:"",value:(h=n.rDim)!=null?h:n.r?n.r.toString(10):"",isDisabled:!1},options:[{label:"Enter a numeric score to match, or choose another dimension to match its score",value:"",isDisabled:!0},...k(o.dimensions)],styles:{...a.styles,valueContainer:(u,C)=>{var f,D;return{...u,padding:"var(--spacing-sm)",...(D=(f=a.styles)==null?void 0:f.valueContainer)==null?void 0:D.call(f,u,C)}},option:(u,C)=>{var f,D;return{fontSize:C.isDisabled?"0.8rem":void 0,...(D=(f=a.styles)==null?void 0:f.option)==null?void 0:D.call(f,u,C)}}},onChange:u=>{var C;u&&(t({...n,rDim:(C=u.value)==null?void 0:C.toString(),r:void 0}),s(""))},onInputChange:(u,C)=>{let f=L(u);C.action==="input-change"||C.action==="set-value"?(s(u),(f||u==="")&&t({...n,r:u||void 0,rDim:void 0})):!f&&!L(C.prevInputValue)&&(!u&&n.r?s(n.r.toString()):s(u))},components:{...a.components,Option:V,SingleValue:z,GroupHeading:T},noOptionsMessage:({inputValue:u})=>L(u)?e(p.Fragment,null,e("div",null,"Score: ",u),e("small",null,"If you want to match on another dimension\u2019s score instead, clear the score value to search for a dimension.")):e(p.Fragment,null,e("div",null,"No dimensions match your search \u201C",u,"\u201D"),e("small",null,"If you want to match a literal score, enter a numeric value."))}),e(N,{message:m}))}function L(t){return/^\d+$/.test(t.toString(10))}var fe=({value:t,setValue:n,dimensions:o,onMenuOpen:m,onMenuClose:a,onAddCriteria:r,onRemoveCriteria:s,displayTitle:i=!0,components:l,errors:c={}})=>{let h=t||{crit:[]},u=d=>{n({...h,op:d==="&"?void 0:d})},C=()=>{let d={...h,crit:[...h.crit,{l:"",op:">",r:0}]};n(d),r==null||r(d)},f=(d,v)=>{n(de(h,x=>{x.crit[v]=d}))},D=d=>{let v=de(h,g=>{g.crit.splice(d,1)}),x=v.crit.length===0?null:v;n(x),s==null||s(x)};return e("fieldset",{className:"personalization-criteria"},i?l!=null&&l.Title?e(l.Title,null):e("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,l!=null&&l.CustomVariantName?e(l.CustomVariantName,null):null,h.crit.length?e("div",null,h.crit.map((d,v)=>{var y,E,w,M;let x=((y=d.l)==null?void 0:y.length)>0,g=d.op!=="+"&&d.op!=="-";return e("div",{css:oe,key:v},e("div",{css:Ke` | ||
`},t)}var ie=t=>{var l,c;let{data:n,getStyles:o,isDisabled:m,innerRef:a,innerProps:r}=t,[s,i]=(c=(l=n.label)==null?void 0:l.split(":"))!=null?c:[];return e("div",{css:{...o("option",t),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:a,"aria-disabled":m,...r},i?e(R,{op:s}):e("div",{css:{width:"20px",height:"20px"}}),e("div",null,i!=null?i:s))};var ae=t=>{let{data:n,getStyles:o}=t;return e("div",{css:{...o("singleValue",t),width:"max-content"}},n.label.length===1?e(R,{op:n.label}):n.label)};var se=[{name:"=",description:"equals",value:"="},{name:"\u2260",description:"not equal",value:"!="},{name:">",description:"is greater than",value:">"},{name:"\u2265",description:"is greater than or equal to",value:">="},{name:"<",description:"is less than",value:"<"},{name:"\u2264",description:"is less than or equal to",value:"<="},{name:"has the strongest score",value:"+"},{name:"has the weakest score",value:"-"}];function le({onChange:t,value:n,...o}){var m,a;return e(Ge,{...o,value:{label:(a=(m=se.find(r=>r.value===n))==null?void 0:m.name)!=null?a:n,value:n},options:se.map(r=>({label:r.description?`${r.name}:${r.description}`:r.name,value:r.value})),styles:{...o.styles,valueContainer:(r,s)=>{var i,l;return{...r,padding:"var(--spacing-sm)",...(l=(i=o.styles)==null?void 0:i.valueContainer)==null?void 0:l.call(i,r,s)}},menu:(r,s)=>{var i,l;return{...r,width:"max-content",...(l=(i=o.styles)==null?void 0:i.menu)==null?void 0:l.call(i,r,s)}},control:(r,s)=>{var i,l;return{...r,border:0,...(l=(i=o.styles)==null?void 0:i.control)==null?void 0:l.call(i,r,s)}},indicatorSeparator:(r,s)=>{var i,l;return{...r,display:"none",...(l=(i=o.styles)==null?void 0:i.indicatorSeparator)==null?void 0:l.call(i,r,s)}}},onChange:r=>{r&&t(r.value)},components:{SingleValue:ae,Option:ie,...o.components}})}import{InputComboBox as qe}from"@uniformdev/design-system";import{Icon as He}from"@uniformdev/design-system";function F(t){return{label:t.displayName,value:t.dim,isDisabled:!1}}function O(t){if(!t)return"unavailable";let[n]=t.split(":");switch(n.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function N(t){let n=[],o="";for(let m of t){let[a]=m.displayName.split(":");o!==a&&(n.push({label:a,options:[]}),o=a),n[n.length-1].options.push(F(m))}return n}var k=t=>{var a;let{data:n,getStyles:o,className:m}=t;return e("div",{css:{...o("groupHeading",t),textTransform:"none",fontSize:"var(--font-size-sm)"},className:m},e("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},e(He,{icon:O((a=n.label)!=null?a:""),iconColor:"currentColor",size:16}),e("span",null,n.label)))};function T({message:t}){return t?e("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},t):null}var V=t=>{var u,C;let{data:n,getStyles:o,cx:m,isDisabled:a,isFocused:r,isSelected:s,className:i,innerRef:l,innerProps:c}=t,[,h]=(C=(u=n.label)==null?void 0:u.split(":"))!=null?C:[];return e("div",{css:o("option",t),className:m({option:!0,"option--is-disabled":a,"option--is-focused":r,"option--is-selected":s},i),ref:l,"aria-disabled":a,...c},e("div",{css:{color:"var(--gray-700)"}},h!=null?h:n.label))};import{Icon as We}from"@uniformdev/design-system";function me({displayName:t}){let[n,o]=t.split(":");return e("div",{css:{whiteSpace:"normal",overflow:"hidden"}},o?e("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},n?e(We,{icon:O(n),iconColor:"currentColor",size:16}):null,e("span",{"data-test-id":"dimension-name"},n)):null,e("div",{css:{color:"var(--gray-700)"},"data-test-id":"dimension-value"},o!=null?o:n))}var z=t=>{let{data:n,getStyles:o}=t;return e("div",{css:o("singleValue",t)},e(me,{displayName:n.label}))};function ue({onChange:t,value:n,dimensions:o,errorMessage:m,...a}){return e(p.Fragment,null,e(qe,{...a,value:n?F(n):void 0,options:N(o),styles:{...a.styles,valueContainer:(r,s)=>{var i,l;return{...r,padding:"var(--spacing-sm)",...(l=(i=a.styles)==null?void 0:i.valueContainer)==null?void 0:l.call(i,r,s)}}},onChange:r=>{r&&t(o.find(s=>s.dim===r.value))},components:{Option:V,SingleValue:z,GroupHeading:k,...a.components}}),e(T,{message:m}))}import{InputComboBox as _e}from"@uniformdev/design-system";import{useState as Fe}from"react";function pe({onChange:t,criteriaMatch:n,dimensions:o,errorMessage:m,...a}){var c,h;let[r,s]=Fe(typeof n.r!="undefined"&&L(n.r)!==null?n.r.toString(10):""),i=n.rDim,l=n.rDim?o.dimIndex[n.rDim]:void 0;return e(p.Fragment,null,e(_e,{...a,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=l==null?void 0:l.displayName)!=null?c:i&&!l?`${n.rDim} (unknown)`:"",value:(h=n.rDim)!=null?h:n.r?n.r.toString(10):"",isDisabled:!1},options:[{label:"Enter a numeric score to match, or choose another dimension to match its score",value:"",isDisabled:!0},...N(o.dimensions)],styles:{...a.styles,valueContainer:(u,C)=>{var f,D;return{...u,padding:"var(--spacing-sm)",...(D=(f=a.styles)==null?void 0:f.valueContainer)==null?void 0:D.call(f,u,C)}},option:(u,C)=>{var f,D;return{fontSize:C.isDisabled?"0.8rem":void 0,...(D=(f=a.styles)==null?void 0:f.option)==null?void 0:D.call(f,u,C)}}},onChange:u=>{var C;u&&(t({...n,rDim:(C=u.value)==null?void 0:C.toString(),r:void 0}),s(""))},onInputChange:(u,C)=>{let f=L(u);C.action==="input-change"||C.action==="set-value"?(s(u),(f||u==="")&&t({...n,r:u||void 0,rDim:void 0})):!f&&!L(C.prevInputValue)&&(!u&&n.r?s(n.r.toString()):s(u))},components:{...a.components,Option:V,SingleValue:z,GroupHeading:k},noOptionsMessage:({inputValue:u})=>L(u)?e(p.Fragment,null,e("div",null,"Score: ",u),e("small",null,"If you want to match on another dimension\u2019s score instead, clear the score value to search for a dimension.")):e(p.Fragment,null,e("div",null,"No dimensions match your search \u201C",u,"\u201D"),e("small",null,"If you want to match a literal score, enter a numeric value."))}),e(T,{message:m}))}function L(t){return/^\d+$/.test(t.toString(10))}var fe=({value:t,setValue:n,dimensions:o,onMenuOpen:m,onMenuClose:a,onAddCriteria:r,onRemoveCriteria:s,displayTitle:i=!0,components:l,errors:c={}})=>{let h=t||{crit:[]},u=d=>{n({...h,op:d==="&"?void 0:d})},C=()=>{let d={...h,crit:[...h.crit,{l:"",op:">",r:0}]};n(d),r==null||r(d)},f=(d,v)=>{n(de(h,x=>{x.crit[v]=d}))},D=d=>{let v=de(h,g=>{g.crit.splice(d,1)}),x=v.crit.length===0?null:v;n(x),s==null||s(x)};return e("fieldset",{className:"personalization-criteria"},i?l!=null&&l.Title?e(l.Title,null):e("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,l!=null&&l.CustomVariantName?e(l.CustomVariantName,null):null,h.crit.length?e("div",null,h.crit.map((d,v)=>{var y,E,w,M;let x=((y=d.l)==null?void 0:y.length)>0,g=d.op!=="+"&&d.op!=="-";return e("div",{css:oe,key:v,"data-test-id":"criteria-container"},e("div",{css:Ke` | ||
${re} | ||
grid-template-columns: minmax(0, 1fr) ${g?"minmax(0, 79px) minmax(0, 1fr)":"minmax(0, 1fr)"} | ||
`,className:"criteriaItemInner"},e("div",{css:S},e(ue,{errorMessage:(E=c.lhs)==null?void 0:E[v],css:P,styles:{control:b=>({...b,height:"100%"})},dimensions:o.dimensions,onChange:b=>{f({...d,l:b.dim},v)},value:o.dimIndex[d.l],onMenuOpen:m,onMenuClose:a})),e("div",{css:S},e(le,{name:`op-${v}`,css:P,styles:{control:b=>({...b,height:"100%"})},value:d.op,onChange:b=>{f(b==="+"||b==="-"?{...d,op:b,r:void 0,rDim:void 0}:{...d,op:b},v)},onMenuOpen:m,onMenuClose:a})),g?e("div",{css:S},e(pe,{errorMessage:(w=c.rhs)==null?void 0:w[v],css:P,styles:{control:b=>({...b,height:"100%"})},criteriaMatch:d,onChange:b=>{f(b,v)},isDisabled:!x,dimensions:o,onMenuOpen:m,onMenuClose:a})):null),e("button",{type:"button",onClick:()=>D(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0}},e(Xe,{icon:Ze,iconColor:"red",size:"1.5rem"})),v>0?e("div",{className:"criteria-group-operation",css:{position:"absolute",top:"-4rem",transform:"translateX(calc(1.5rem - 50%))"}},e(Ye,{disabled:v>1,value:(M=h.op)!=null?M:"&",options:[{label:"AND",value:"&"},{label:"OR",value:"|"}],onChange:b=>{u(b.value)}})):null)})):e(ce,{title:"Default variant",type:"info",css:{marginBlock:"var(--spacing-base)"}},e(Qe,null,'This personalized variant has no match criteria and will be shown to any visitor that does not match any preceding variants. Ensure that default variants come last in the variant list. Personalize this variant by clicking "Add Criteria" to get started.')),o.dimensions.length===0?l!=null&&l.NoDimensionsDefined?e(l.NoDimensionsDefined,null):e(ce,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"You do not have any dimensions configured.")):e(Je,{className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var $n=({contextConfig:t,...n})=>{let{loading:o,result:m,error:a}=I(t);return a?e(ge,{type:"danger"},a):o||m===null?e(je,null):e(fe,{...n,dimensions:m,components:{NoDimensionsDefined:()=>e(ge,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"You do not have any dimensions configured. Create your first"," ",e("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};import rt from"react";import{useEffect as et,useState as tt}from"react";import{ManifestClient as nt,ApiClientError as ot}from"@uniformdev/context/api";function $({apiHost:t,apiKey:n,projectId:o}){let[m,a]=tt({loading:!1,notConfigured:!1,error:null,result:null});return et(()=>{if(!o||!n||!t){a({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{a({notConfigured:!1,loading:!0,error:null,result:null});try{let i=await new nt({projectId:o,apiKey:n,apiHost:t}).get({preview:!0});a({notConfigured:!1,loading:!1,error:null,result:i})}catch(s){let i;s instanceof ot?(s.statusCode===403&&(i=`The API key ${n} did not have permissions to fetch the manifest. Ensure Context > Read Drafts permissions are granted.`),i=s.message):i=s.toString(),a({notConfigured:!1,loading:!1,error:i,result:null});return}})()},[t,n,o]),{result:m.result,error:m.error,loading:m.loading,notConfigured:m.notConfigured}}import{LoadingIndicator as it}from"@uniformdev/design-system";function Yn({children:t,versionMap:n,contextConfig:o}){let{loading:m,result:a}=$(o);if(m)return e(it,null);if(a){let r=n[a.project.ui_version];if(r)return e(r,null)}return e(rt.Fragment,null,t)}import Ce,{createContext as at,useContext as K}from"react";import{LoadingIndicator as st}from"@uniformdev/design-system";var A=at(null),oo=({loadingComponent:t,errorComponent:n,contextConfig:o,children:m})=>{let a=$(o),r=I(o);return a.error||a.notConfigured?n?e(n,{contextConfig:o,result:a}):e(Ce.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?n?e(n,{contextConfig:o,result:r}):e(Ce.Fragment,null,"ErrorComponent is not configured"):a.loading||r.loading?t?e(t,null):e(st,null):e(A.Provider,{value:{manifest:a.result,dimensions:r.result,contextConfig:o}},m)};function ro(){let t=K(A);if(!(t!=null&&t.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return t.contextConfig}function io(){let t=K(A);if(!(t!=null&&t.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return t.manifest}function ao(){let t=K(A);if(!(t!=null&&t.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return t.dimensions}import{validate as lt}from"uuid";import{ManifestClient as mt}from"@uniformdev/context/api";var ve=async t=>{if(!t)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!t.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!t.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!lt(t.apiKey)&&!t.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let n=new mt({projectId:t.projectId,apiKey:t.apiKey,apiHost:t.apiHost});try{let o=await n.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};import{useEffect as ut,useState as pt}from"react";var go=t=>{let[n,o]=pt({validating:!1,error:void 0}),{apiKey:m,apiHost:a,projectId:r}=t||{};return ut(()=>{if(!m||!a)return;(async()=>{o({validating:!0,error:void 0});let{error:i,result:l}=await ve({apiHost:a,apiKey:m,projectId:r});o(i?{error:i,validating:!1}:{error:void 0,validating:!1,result:l})})()},[a,m,r]),{validating:n.validating,error:n.error,result:n.result}};function vo(t){return Array.isArray(t)&&t.length>0&&t[0].cat!==void 0}function ho(t){return t.crit!==void 0}export*from"@uniformdev/design-system";export{oo as ContextData,pe as CriteriaMatchMenu,le as CriteriaOperatorMenu,ue as DimensionMenu,me as DimensionValue,X as EditLink,kt as EnrichmentTag,$n as PersonalizationCriteria,fe as PersonalizationCriteriaStatic,Yn as ProjectUIVersion,Ne as addEnrichmentLink,se as contextCriteriaMenuOperators,vo as isEnrichmentTagData,ho as isPersonalizationCriteriaData,ro as useContextConfig,$ as useContextData,I as useDimensions,ao as useDimensionsDataContext,io as useManifest,go as useValidateContextConfig,ve as validateContextConfig}; | ||
`,className:"criteriaItemInner"},e("div",{css:S,className:"criteria-wrapper","data-test-id":"select-criteria"},e(ue,{errorMessage:(E=c.lhs)==null?void 0:E[v],css:P,styles:{control:b=>({...b,height:"100%"})},dimensions:o.dimensions,onChange:b=>{f({...d,l:b.dim},v)},value:o.dimIndex[d.l],onMenuOpen:m,onMenuClose:a})),e("div",{css:S,className:"criteria-wrapper","data-test-id":"select-operator"},e(le,{name:`op-${v}`,css:P,styles:{control:b=>({...b,height:"100%"})},value:d.op,onChange:b=>{f(b==="+"||b==="-"?{...d,op:b,r:void 0,rDim:void 0}:{...d,op:b},v)},onMenuOpen:m,onMenuClose:a})),g?e("div",{css:S,className:"criteria-wrapper","data-test-id":"select-match-criteria"},e(pe,{errorMessage:(w=c.rhs)==null?void 0:w[v],css:P,styles:{control:b=>({...b,height:"100%"})},criteriaMatch:d,onChange:b=>{f(b,v)},isDisabled:!x,dimensions:o,onMenuOpen:m,onMenuClose:a})):null),e("button",{type:"button",onClick:()=>D(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0},"data-test-id":"button-delete"},e(Xe,{icon:Ze,iconColor:"red",size:"1.5rem"})),v>0?e("div",{className:"criteria-group-operation",css:{position:"absolute",top:"-4rem",transform:"translateX(calc(1.5rem - 50%))"}},e(Ye,{"data-test-id":"dropdown-button-combine",disabled:v>1,value:(M=h.op)!=null?M:"&",options:[{label:"AND",value:"&"},{label:"OR",value:"|"}],onChange:b=>{u(b.value)}})):null)})):e(ce,{title:"Default variant",type:"info",css:{marginBlock:"var(--spacing-base)"}},e(Qe,null,'This personalized variant has no match criteria and will be shown to any visitor that does not match any preceding variants. Ensure that default variants come last in the variant list. Personalize this variant by clicking "Add Criteria" to get started.')),o.dimensions.length===0?l!=null&&l.NoDimensionsDefined?e(l.NoDimensionsDefined,null):e(ce,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"You do not have any dimensions configured.")):e(Je,{"data-test-id":"button-add-criteria",className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var $n=({contextConfig:t,...n})=>{let{loading:o,result:m,error:a}=I(t);return a?e(ge,{type:"danger"},a):o||m===null?e(je,null):e(fe,{...n,dimensions:m,components:{NoDimensionsDefined:()=>e(ge,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"You do not have any dimensions configured. Create your first"," ",e("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};import rt from"react";import{useEffect as et,useState as tt}from"react";import{ApiClientError as nt,CachedManifestClient as ot}from"@uniformdev/context/api";function $({apiHost:t,apiKey:n,projectId:o}){let[m,a]=tt({loading:!1,notConfigured:!1,error:null,result:null});return et(()=>{if(!o||!n||!t){a({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{a({notConfigured:!1,loading:!0,error:null,result:null});try{let i=await new ot({projectId:o,apiKey:n,apiHost:t}).get({preview:!0});a({notConfigured:!1,loading:!1,error:null,result:i})}catch(s){let i;s instanceof nt?(s.statusCode===403&&(i=`The API key ${n} did not have permissions to fetch the manifest. Ensure Context > Read Drafts permissions are granted.`),i=s.message):i=s.toString(),a({notConfigured:!1,loading:!1,error:i,result:null});return}})()},[t,n,o]),{result:m.result,error:m.error,loading:m.loading,notConfigured:m.notConfigured}}import{LoadingIndicator as it}from"@uniformdev/design-system";function Yn({children:t,versionMap:n,contextConfig:o}){let{loading:m,result:a}=$(o);if(m)return e(it,null);if(a){let r=n[a.project.ui_version];if(r)return e(r,null)}return e(rt.Fragment,null,t)}import Ce,{createContext as at,useContext as K}from"react";import{LoadingIndicator as st}from"@uniformdev/design-system";var A=at(null),oo=({loadingComponent:t,errorComponent:n,contextConfig:o,children:m})=>{let a=$(o),r=I(o);return a.error||a.notConfigured?n?e(n,{contextConfig:o,result:a}):e(Ce.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?n?e(n,{contextConfig:o,result:r}):e(Ce.Fragment,null,"ErrorComponent is not configured"):a.loading||r.loading?t?e(t,null):e(st,null):e(A.Provider,{value:{manifest:a.result,dimensions:r.result,contextConfig:o}},m)};function ro(){let t=K(A);if(!(t!=null&&t.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return t.contextConfig}function io(){let t=K(A);if(!(t!=null&&t.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return t.manifest}function ao(){let t=K(A);if(!(t!=null&&t.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return t.dimensions}import{validate as lt}from"uuid";import{UncachedManifestClient as mt}from"@uniformdev/context/api";var ve=async t=>{if(!t)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!t.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!t.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!lt(t.apiKey)&&!t.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let n=new mt({projectId:t.projectId,apiKey:t.apiKey,apiHost:t.apiHost});try{let o=await n.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};import{useEffect as ut,useState as pt}from"react";var go=t=>{let[n,o]=pt({validating:!1,error:void 0}),{apiKey:m,apiHost:a,projectId:r}=t||{};return ut(()=>{if(!m||!a)return;(async()=>{o({validating:!0,error:void 0});let{error:i,result:l}=await ve({apiHost:a,apiKey:m,projectId:r});o(i?{error:i,validating:!1}:{error:void 0,validating:!1,result:l})})()},[a,m,r]),{validating:n.validating,error:n.error,result:n.result}};function vo(t){return Array.isArray(t)&&t.length>0&&t[0].cat!==void 0}function ho(t){return t.crit!==void 0}export*from"@uniformdev/design-system";export{oo as ContextData,pe as CriteriaMatchMenu,le as CriteriaOperatorMenu,ue as DimensionMenu,me as DimensionValue,X as EditLink,Nt as EnrichmentTag,$n as PersonalizationCriteria,fe as PersonalizationCriteriaStatic,Yn as ProjectUIVersion,Te as addEnrichmentLink,se as contextCriteriaMenuOperators,vo as isEnrichmentTagData,ho as isPersonalizationCriteriaData,ro as useContextConfig,$ as useContextData,I as useDimensions,ao as useDimensionsDataContext,io as useManifest,go as useValidateContextConfig,ve as validateContextConfig}; |
@@ -12,3 +12,3 @@ "use strict";var He=Object.create;var U=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var Ke=(t,n)=>{for(var o in n)U(t,o,{get:n[o],enumerable:!0})},A=(t,n,o,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of qe(n))!Fe.call(t,i)&&i!==o&&U(t,i,{get:()=>n[i],enumerable:!(l=We(n,i))||l.enumerable});return t},w=(t,n,o)=>(A(t,n,"default"),o&&A(o,n,"default")),R=(t,n,o)=>(o=t!=null?He(_e(t)):{},A(n||!t||!t.__esModule?U(o,"default",{value:t,enumerable:!0}):o,t)),Ye=t=>A(U({},"__esModule",{value:!0}),t);var x={};Ke(x,{ContextData:()=>rt,CriteriaMatchMenu:()=>ce,CriteriaOperatorMenu:()=>le,DimensionMenu:()=>pe,DimensionValue:()=>ue,EditLink:()=>re,EnrichmentTag:()=>Je,PersonalizationCriteria:()=>nt,PersonalizationCriteriaStatic:()=>fe,ProjectUIVersion:()=>ot,addEnrichmentLink:()=>De,contextCriteriaMenuOperators:()=>se,isEnrichmentTagData:()=>mt,isPersonalizationCriteriaData:()=>ut,useContextConfig:()=>it,useContextData:()=>z,useDimensions:()=>P,useDimensionsDataContext:()=>st,useManifest:()=>at,useValidateContextConfig:()=>lt,validateContextConfig:()=>ge});module.exports=Ye(x);var e=require("@emotion/react"),p=R(require("react"));var he=require("@uniformdev/design-system"),be=require("react-icons/cg");var Ce=require("@emotion/react"),ve=Ce.css` | ||
} | ||
`;var re=({linkTo:t,name:n,linkText:o=`Edit ${n} Component`})=>(0,e.jsx)("a",{css:ve,title:`Edit ${n} component definition`,rel:"noopener noreferrer",target:"_blank",href:t},o,(0,e.jsx)(he.Icon,{icon:be.CgChevronRight,iconColor:"currentColor",size:"1.5rem"}));var E=R(require("react"));var G=require("react"),O=require("@uniformdev/context/api");function ye(t,n,o){return t.reduce((l,i)=>{let r=n(i);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return l[n(i)]=o?o(i):i,l},{})}function P({apiHost:t,apiKey:n,projectId:o}){let[l,i]=(0,G.useState)({loading:!1,notConfigured:!1,error:null,result:null});return(0,G.useEffect)(()=>{if(!o||!n||!t){i({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{i({notConfigured:!1,loading:!0,error:null,result:null});try{let a=(await new O.DimensionClient({projectId:o,apiKey:n,apiHost:t}).get()).dimensions.map(c=>({...c,displayName:(0,O.computeDimensionDisplayName)(c)})),m={dimensions:a,dimIndex:ye(a,c=>c.dim,c=>c)};i({notConfigured:!1,loading:!1,error:null,result:m})}catch(s){let a;s instanceof O.ApiClientError?a=s.message:a=s.toString(),i({notConfigured:!1,loading:!1,error:a,result:null});return}})()},[t,n,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}var H=require("@uniformdev/context"),h=require("@uniformdev/design-system"),k=require("react-icons/cg"),ie=R(require("immer")),W=require("@emotion/react"),De=W.css` | ||
`;var re=({linkTo:t,name:n,linkText:o=`Edit ${n} Component`})=>(0,e.jsx)("a",{css:ve,title:`Edit ${n} component definition`,rel:"noopener noreferrer",target:"_blank",href:t},o,(0,e.jsx)(he.Icon,{icon:be.CgChevronRight,iconColor:"currentColor",size:"1.5rem"}));var E=R(require("react"));var G=require("react"),O=require("@uniformdev/context/api");function ye(t,n,o){return t.reduce((l,i)=>{let r=n(i);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return l[n(i)]=o?o(i):i,l},{})}function P({apiHost:t,apiKey:n,projectId:o}){let[l,i]=(0,G.useState)({loading:!1,notConfigured:!1,error:null,result:null});return(0,G.useEffect)(()=>{if(!o||!n||!t){i({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{i({notConfigured:!1,loading:!0,error:null,result:null});try{let a=(await new O.CachedDimensionClient({projectId:o,apiKey:n,apiHost:t}).get()).dimensions.map(c=>({...c,displayName:(0,O.computeDimensionDisplayName)(c)})),m={dimensions:a,dimIndex:ye(a,c=>c.dim,c=>c)};i({notConfigured:!1,loading:!1,error:null,result:m})}catch(s){let a;s instanceof O.ApiClientError?a=s.message:a=s.toString(),i({notConfigured:!1,loading:!1,error:a,result:null});return}})()},[t,n,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}var H=require("@uniformdev/context"),h=require("@uniformdev/design-system"),N=require("react-icons/cg"),ie=R(require("immer")),W=require("@emotion/react"),De=W.css` | ||
flex: 2; | ||
@@ -24,3 +24,3 @@ display: flex; | ||
} | ||
`,Je=({value:t,setValue:n,contextConfig:o,displayTitle:l=!0})=>{let{loading:i,result:r,error:s}=P(o),a=(0,E.useMemo)(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),m=(0,E.useMemo)(()=>{if(!t)return a;if(a)return a.filter(g=>!t.some(D=>(0,H.getEnrichmentVectorKey)(D.cat,D.key)===g.dim))},[a,t]),[c,b]=(0,E.useState)(""),[u,C]=(0,E.useState)(50),[f,I]=(0,E.useState)(!1),d=a==null?void 0:a.find(g=>g.dim===c),v=()=>{let[g,D]=c.split("_");M([...t!=null?t:[],{cat:g,key:D,str:u}]),b(""),C(50),I(!1)},M=g=>{let D=[];r?D=g.filter(N=>{let $=r.dimIndex[(0,H.getEnrichmentVectorKey)(N.cat,N.key)];return Boolean($)}):D=g;let L=D.length===0?null:D;n(L)};return s?(0,e.jsx)(h.Callout,{type:"danger"},s):i||r===null?(0,e.jsx)(h.LoadingIndicator,null):(0,e.jsx)("fieldset",{className:"enrichment-tag"},l?(0,e.jsx)("div",{css:{display:"flex",justifyContent:"space-between",marginBottom:"var(--spacing-base)"}},(0,e.jsx)("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Enrichment Tags")):null,a!=null&&a.length?!f&&!t?(0,e.jsx)(h.Callout,{title:"No enrichment tags assigned.",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"Click"," ",(0,e.jsx)("a",{onClick:()=>I(!0),target:"_blank",rel:"noopener noreferrer",css:{textDecorationLine:"underline"}},"here")," ","to assign your first enrichment tag.")):(0,e.jsx)(E.default.Fragment,null,r&&(0,e.jsx)(et,{list:t!=null?t:[],setList:M,dimIndex:r.dimIndex}),f&&m&&m.length>0?(0,e.jsx)("div",{className:"add-enrichment-tag",css:{display:"flex",flexWrap:"wrap",gap:"var(--spacing-lg)",marginTop:"var(--spacing-md)",alignItems:"center"}},(0,e.jsx)("div",{css:{flexGrow:1}},(0,e.jsx)(h.InputSelect,{name:"enrichment-type",label:"Enrichment Tag",showLabel:!0,value:c,options:[{label:"Select",value:""},...m.map(g=>({label:g.displayName,value:g.dim}))],onChange:g=>b(g.currentTarget.value)})),(0,e.jsx)(je,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),(0,e.jsx)(h.Button,{buttonType:"tertiary",size:"xl",css:{marginBottom:"var(--spacing-xs)",height:"3.5rem",margin:0,alignSelf:"flex-end"},onClick:v,disabled:!c},"Add")):null,(0,e.jsx)("div",{className:"enrichment-cta",style:{paddingTop:"10px",display:"flex",justifyContent:"space-between"}},!f&&m&&m.length>0&&t?(0,e.jsx)(h.AddListButton,{className:"add-more",buttonText:"Add More",onButtonClick:()=>I(!0)}):(0,e.jsx)("a",{css:De,title:"none",href:"#"}),(0,e.jsx)(re,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):(0,e.jsx)(Qe,{contextConfig:o}))},Qe=({contextConfig:t})=>(0,e.jsx)(h.Callout,{title:"No enrichments found.",type:"caution",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"Looks like you do not have any enrichment created in your connected Uniform project. Start by creating your first enrichment"," ",(0,e.jsx)("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),xe=(t,n=100,o=0)=>Math.max(Math.min(t,n),o),Ie=W.css` | ||
`,Je=({value:t,setValue:n,contextConfig:o,displayTitle:l=!0})=>{let{loading:i,result:r,error:s}=P(o),a=(0,E.useMemo)(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),m=(0,E.useMemo)(()=>{if(!t)return a;if(a)return a.filter(g=>!t.some(D=>(0,H.getEnrichmentVectorKey)(D.cat,D.key)===g.dim))},[a,t]),[c,b]=(0,E.useState)(""),[u,C]=(0,E.useState)(50),[f,I]=(0,E.useState)(!1),d=a==null?void 0:a.find(g=>g.dim===c),v=()=>{let[g,D]=c.split("_");M([...t!=null?t:[],{cat:g,key:D,str:u}]),b(""),C(50),I(!1)},M=g=>{let D=[];r?D=g.filter(T=>{let $=r.dimIndex[(0,H.getEnrichmentVectorKey)(T.cat,T.key)];return Boolean($)}):D=g;let L=D.length===0?null:D;n(L)};return s?(0,e.jsx)(h.Callout,{type:"danger"},s):i||r===null?(0,e.jsx)(h.LoadingIndicator,null):(0,e.jsx)("fieldset",{className:"enrichment-tag"},l?(0,e.jsx)("div",{css:{display:"flex",justifyContent:"space-between",marginBottom:"var(--spacing-base)"}},(0,e.jsx)("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Enrichment Tags")):null,a!=null&&a.length?!f&&!t?(0,e.jsx)(h.Callout,{title:"No enrichment tags assigned.",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"Click"," ",(0,e.jsx)("a",{onClick:()=>I(!0),target:"_blank",rel:"noopener noreferrer",css:{textDecorationLine:"underline"}},"here")," ","to assign your first enrichment tag.")):(0,e.jsx)(E.default.Fragment,null,r&&(0,e.jsx)(et,{list:t!=null?t:[],setList:M,dimIndex:r.dimIndex}),f&&m&&m.length>0?(0,e.jsx)("div",{className:"add-enrichment-tag",css:{display:"flex",flexWrap:"wrap",gap:"var(--spacing-lg)",marginTop:"var(--spacing-md)",alignItems:"center"}},(0,e.jsx)("div",{css:{flexGrow:1}},(0,e.jsx)(h.InputSelect,{name:"enrichment-type",label:"Enrichment Tag",showLabel:!0,value:c,options:[{label:"Select",value:""},...m.map(g=>({label:g.displayName,value:g.dim}))],onChange:g=>b(g.currentTarget.value)})),(0,e.jsx)(je,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),(0,e.jsx)(h.Button,{buttonType:"tertiary",size:"xl",css:{marginBottom:"var(--spacing-xs)",height:"3.5rem",margin:0,alignSelf:"flex-end"},onClick:v,disabled:!c},"Add")):null,(0,e.jsx)("div",{className:"enrichment-cta",style:{paddingTop:"10px",display:"flex",justifyContent:"space-between"}},!f&&m&&m.length>0&&t?(0,e.jsx)(h.AddListButton,{className:"add-more",buttonText:"Add More",onButtonClick:()=>I(!0)}):(0,e.jsx)("a",{css:De,title:"none",href:"#"}),(0,e.jsx)(re,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):(0,e.jsx)(Qe,{contextConfig:o}))},Qe=({contextConfig:t})=>(0,e.jsx)(h.Callout,{title:"No enrichments found.",type:"caution",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"Looks like you do not have any enrichment created in your connected Uniform project. Start by creating your first enrichment"," ",(0,e.jsx)("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),xe=(t,n=100,o=0)=>Math.max(Math.min(t,n),o),Ie=W.css` | ||
position: absolute; | ||
@@ -41,3 +41,3 @@ bottom: 0.875rem; | ||
right: var(--spacing-sm); | ||
`,je=({score:t,setValue:n,cap:o=100,...l})=>{let i=r=>{let s=r==="increment"?t+10:t-10;s<0&&(s=0),s>o&&(s=o),n(s)};return(0,e.jsx)("div",{css:{position:"relative"},...l},(0,e.jsx)(h.Input,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:t,onChange:r=>n(xe(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),(0,e.jsx)("button",{type:"button",title:"Reduce enrichment count",onClick:()=>i("decrement"),disabled:t===0,className:"scoreCounterButton",css:Ie},(0,e.jsx)(h.Icon,{icon:k.CgMathMinus,iconColor:"gray",size:"1.5rem"})),(0,e.jsx)("button",{type:"button",title:"Increase enrichment count",onClick:()=>i("increment"),className:"scoreCounterButton",css:Ze},(0,e.jsx)(h.Icon,{icon:k.CgMathPlus,iconColor:"gray",size:"1.5rem"})))},et=({list:t,setList:n,dimIndex:o})=>{let l=r=>{n((0,ie.default)(t,s=>{s.splice(r,1)}))},i=(r,s)=>{var m;let a=(m=o[`${t[r].cat}_${t[r].key}`])==null?void 0:m.cap;n((0,ie.default)(t,c=>{c[r].str=xe(Number(s)||0,a)}))};return(0,e.jsx)(E.default.Fragment,null,t.map((r,s)=>{let a=o[(0,H.getEnrichmentVectorKey)(r.cat,r.key)];if(!!a)return(0,e.jsx)("div",{css:{display:"flex",alignItems:"center",gap:"var(--spacing-base)",backgroundColor:"var(--brand-secondary-2)",boxShadow:"var(--shadow-base)",borderRadius:"var(--rounded-base)",paddingInline:"var(--spacing-base)",marginBlock:"var(--spacing-base)"},className:"selected-enrichments",key:`${r.cat}-${r.key}`},(0,e.jsx)("span",{css:{fontWeight:"var(--fw-bold)",color:a?void 0:"var(--brand-secondary-5)"}},a?a.displayName:`Enrichment '${r.cat}_${r.key}' is unknown`),(0,e.jsx)("div",{css:{marginLeft:"auto",display:"flex",alignItems:"center",border:"0 solid var(--gray-400)",borderLeftWidth:"1px",borderRightWidth:"1px",padding:"var(--spacing-sm) var(--spacing-base)",flexBasis:"9rem"}},(0,e.jsx)(h.Input,{type:"text",min:0,max:a.cap||100,title:"score",value:r.str,css:{textAlign:"center",width:"100px"},onChange:m=>i(s,m.currentTarget.value)})),(0,e.jsx)("button",{type:"button",title:"Delete enrichment",onClick:()=>l(s),css:{border:0}},(0,e.jsx)(h.Icon,{icon:k.CgCloseO,iconColor:"red",size:"1.5rem"})))}))};var V=require("@uniformdev/design-system");var Ve=require("@emotion/react"),B=require("@uniformdev/design-system"),de=R(require("immer")),ze=require("react-icons/cg");var T=require("@emotion/react"),ae="6rem",we=T.css` | ||
`,je=({score:t,setValue:n,cap:o=100,...l})=>{let i=r=>{let s=r==="increment"?t+10:t-10;s<0&&(s=0),s>o&&(s=o),n(s)};return(0,e.jsx)("div",{css:{position:"relative"},...l},(0,e.jsx)(h.Input,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:t,onChange:r=>n(xe(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),(0,e.jsx)("button",{type:"button",title:"Reduce enrichment count",onClick:()=>i("decrement"),disabled:t===0,className:"scoreCounterButton",css:Ie},(0,e.jsx)(h.Icon,{icon:N.CgMathMinus,iconColor:"gray",size:"1.5rem"})),(0,e.jsx)("button",{type:"button",title:"Increase enrichment count",onClick:()=>i("increment"),className:"scoreCounterButton",css:Ze},(0,e.jsx)(h.Icon,{icon:N.CgMathPlus,iconColor:"gray",size:"1.5rem"})))},et=({list:t,setList:n,dimIndex:o})=>{let l=r=>{n((0,ie.default)(t,s=>{s.splice(r,1)}))},i=(r,s)=>{var m;let a=(m=o[`${t[r].cat}_${t[r].key}`])==null?void 0:m.cap;n((0,ie.default)(t,c=>{c[r].str=xe(Number(s)||0,a)}))};return(0,e.jsx)(E.default.Fragment,null,t.map((r,s)=>{let a=o[(0,H.getEnrichmentVectorKey)(r.cat,r.key)];if(!!a)return(0,e.jsx)("div",{css:{display:"flex",alignItems:"center",gap:"var(--spacing-base)",backgroundColor:"var(--brand-secondary-2)",boxShadow:"var(--shadow-base)",borderRadius:"var(--rounded-base)",paddingInline:"var(--spacing-base)",marginBlock:"var(--spacing-base)"},className:"selected-enrichments",key:`${r.cat}-${r.key}`},(0,e.jsx)("span",{css:{fontWeight:"var(--fw-bold)",color:a?void 0:"var(--brand-secondary-5)"}},a?a.displayName:`Enrichment '${r.cat}_${r.key}' is unknown`),(0,e.jsx)("div",{css:{marginLeft:"auto",display:"flex",alignItems:"center",border:"0 solid var(--gray-400)",borderLeftWidth:"1px",borderRightWidth:"1px",padding:"var(--spacing-sm) var(--spacing-base)",flexBasis:"9rem"}},(0,e.jsx)(h.Input,{type:"text",min:0,max:a.cap||100,title:"score",value:r.str,css:{textAlign:"center",width:"100px"},onChange:m=>i(s,m.currentTarget.value)})),(0,e.jsx)("button",{type:"button",title:"Delete enrichment",onClick:()=>l(s),css:{border:0}},(0,e.jsx)(h.Icon,{icon:N.CgCloseO,iconColor:"red",size:"1.5rem"})))}))};var V=require("@uniformdev/design-system");var Ve=require("@emotion/react"),B=require("@uniformdev/design-system"),de=R(require("immer")),ze=require("react-icons/cg");var k=require("@emotion/react"),ae="6rem",we=k.css` | ||
position: relative; | ||
@@ -67,3 +67,3 @@ padding: var(--spacing-base); | ||
} | ||
`,Be=T.css` | ||
`,Be=k.css` | ||
display: grid; | ||
@@ -73,11 +73,10 @@ gap: var(--spacing-xs); | ||
margin-right: var(--spacing-base); | ||
`,q=T.css` | ||
`,q=k.css` | ||
width: 100%; | ||
display: flex; | ||
align-items: stretch; | ||
z-index: var(--z-10); | ||
`,_=T.css` | ||
`,_=k.css` | ||
height: 100%; | ||
width: 100%; | ||
`,Dt=T.css` | ||
`,Dt=k.css` | ||
height: 100%; | ||
@@ -94,5 +93,5 @@ `;var Pe=require("@uniformdev/design-system");var Ee=require("@emotion/react");function F({op:t}){return(0,e.jsx)("div",{className:"operation-bubble",css:Ee.css` | ||
font-size: var(--fs-base); | ||
`},t)}var Me=t=>{var m,c;let{data:n,getStyles:o,isDisabled:l,innerRef:i,innerProps:r}=t,[s,a]=(c=(m=n.label)==null?void 0:m.split(":"))!=null?c:[];return(0,e.jsx)("div",{css:{...o("option",t),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:i,"aria-disabled":l,...r},a?(0,e.jsx)(F,{op:s}):(0,e.jsx)("div",{css:{width:"20px",height:"20px"}}),(0,e.jsx)("div",null,a!=null?a:s))};var Se=t=>{let{data:n,getStyles:o}=t;return(0,e.jsx)("div",{css:{...o("singleValue",t),width:"max-content"}},n.label.length===1?(0,e.jsx)(F,{op:n.label}):n.label)};var se=[{name:"=",description:"equals",value:"="},{name:"\u2260",description:"not equal",value:"!="},{name:">",description:"is greater than",value:">"},{name:"\u2265",description:"is greater than or equal to",value:">="},{name:"<",description:"is less than",value:"<"},{name:"\u2264",description:"is less than or equal to",value:"<="},{name:"has the strongest score",value:"+"},{name:"has the weakest score",value:"-"}];function le({onChange:t,value:n,...o}){var l,i;return(0,e.jsx)(Pe.InputComboBox,{...o,value:{label:(i=(l=se.find(r=>r.value===n))==null?void 0:l.name)!=null?i:n,value:n},options:se.map(r=>({label:r.description?`${r.name}:${r.description}`:r.name,value:r.value})),styles:{...o.styles,valueContainer:(r,s)=>{var a,m;return{...r,padding:"var(--spacing-sm)",...(m=(a=o.styles)==null?void 0:a.valueContainer)==null?void 0:m.call(a,r,s)}},menu:(r,s)=>{var a,m;return{...r,width:"max-content",...(m=(a=o.styles)==null?void 0:a.menu)==null?void 0:m.call(a,r,s)}},control:(r,s)=>{var a,m;return{...r,border:0,...(m=(a=o.styles)==null?void 0:a.control)==null?void 0:m.call(a,r,s)}},indicatorSeparator:(r,s)=>{var a,m;return{...r,display:"none",...(m=(a=o.styles)==null?void 0:a.indicatorSeparator)==null?void 0:m.call(a,r,s)}}},onChange:r=>{r&&t(r.value)},components:{SingleValue:Se,Option:Me,...o.components}})}var ke=require("@uniformdev/design-system");var Re=require("@uniformdev/design-system");function me(t){return{label:t.displayName,value:t.dim,isDisabled:!1}}function K(t){if(!t)return"unavailable";let[n]=t.split(":");switch(n.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function Y(t){let n=[],o="";for(let l of t){let[i]=l.displayName.split(":");o!==i&&(n.push({label:i,options:[]}),o=i),n[n.length-1].options.push(me(l))}return n}var X=t=>{var i;let{data:n,getStyles:o,className:l}=t;return(0,e.jsx)("div",{css:{...o("groupHeading",t),textTransform:"none",fontSize:"var(--font-size-sm)"},className:l},(0,e.jsx)("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},(0,e.jsx)(Re.Icon,{icon:K((i=n.label)!=null?i:""),iconColor:"currentColor",size:16}),(0,e.jsx)("span",null,n.label)))};function J({message:t}){return t?(0,e.jsx)("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},t):null}var Q=t=>{var u,C;let{data:n,getStyles:o,cx:l,isDisabled:i,isFocused:r,isSelected:s,className:a,innerRef:m,innerProps:c}=t,[,b]=(C=(u=n.label)==null?void 0:u.split(":"))!=null?C:[];return(0,e.jsx)("div",{css:o("option",t),className:l({option:!0,"option--is-disabled":i,"option--is-focused":r,"option--is-selected":s},a),ref:m,"aria-disabled":i,...c},(0,e.jsx)("div",{css:{color:"var(--gray-700)"}},b!=null?b:n.label))};var Oe=require("@uniformdev/design-system");function ue({displayName:t}){let[n,o]=t.split(":");return(0,e.jsx)("div",{css:{whiteSpace:"normal",overflow:"hidden"}},o?(0,e.jsx)("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},n?(0,e.jsx)(Oe.Icon,{icon:K(n),iconColor:"currentColor",size:16}):null,(0,e.jsx)("span",{"data-test-id":"dimension-name"},n)):null,(0,e.jsx)("div",{css:{color:"var(--gray-700)"},"data-test-id":"dimension-value"},o!=null?o:n))}var Z=t=>{let{data:n,getStyles:o}=t;return(0,e.jsx)("div",{css:o("singleValue",t)},(0,e.jsx)(ue,{displayName:n.label}))};function pe({onChange:t,value:n,dimensions:o,errorMessage:l,...i}){return(0,e.jsx)(p.Fragment,null,(0,e.jsx)(ke.InputComboBox,{...i,value:n?me(n):void 0,options:Y(o),styles:{...i.styles,valueContainer:(r,s)=>{var a,m;return{...r,padding:"var(--spacing-sm)",...(m=(a=i.styles)==null?void 0:a.valueContainer)==null?void 0:m.call(a,r,s)}}},onChange:r=>{r&&t(o.find(s=>s.dim===r.value))},components:{Option:Q,SingleValue:Z,GroupHeading:X,...i.components}}),(0,e.jsx)(J,{message:l}))}var Te=require("@uniformdev/design-system"),Ne=require("react");function ce({onChange:t,criteriaMatch:n,dimensions:o,errorMessage:l,...i}){var c,b;let[r,s]=(0,Ne.useState)(typeof n.r!="undefined"&&j(n.r)!==null?n.r.toString(10):""),a=n.rDim,m=n.rDim?o.dimIndex[n.rDim]:void 0;return(0,e.jsx)(p.Fragment,null,(0,e.jsx)(Te.InputComboBox,{...i,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=m==null?void 0:m.displayName)!=null?c:a&&!m?`${n.rDim} (unknown)`:"",value:(b=n.rDim)!=null?b:n.r?n.r.toString(10):"",isDisabled:!1},options:[{label:"Enter a numeric score to match, or choose another dimension to match its score",value:"",isDisabled:!0},...Y(o.dimensions)],styles:{...i.styles,valueContainer:(u,C)=>{var f,I;return{...u,padding:"var(--spacing-sm)",...(I=(f=i.styles)==null?void 0:f.valueContainer)==null?void 0:I.call(f,u,C)}},option:(u,C)=>{var f,I;return{fontSize:C.isDisabled?"0.8rem":void 0,...(I=(f=i.styles)==null?void 0:f.option)==null?void 0:I.call(f,u,C)}}},onChange:u=>{var C;u&&(t({...n,rDim:(C=u.value)==null?void 0:C.toString(),r:void 0}),s(""))},onInputChange:(u,C)=>{let f=j(u);C.action==="input-change"||C.action==="set-value"?(s(u),(f||u==="")&&t({...n,r:u||void 0,rDim:void 0})):!f&&!j(C.prevInputValue)&&(!u&&n.r?s(n.r.toString()):s(u))},components:{...i.components,Option:Q,SingleValue:Z,GroupHeading:X},noOptionsMessage:({inputValue:u})=>j(u)?(0,e.jsx)(p.Fragment,null,(0,e.jsx)("div",null,"Score: ",u),(0,e.jsx)("small",null,"If you want to match on another dimension\u2019s score instead, clear the score value to search for a dimension.")):(0,e.jsx)(p.Fragment,null,(0,e.jsx)("div",null,"No dimensions match your search \u201C",u,"\u201D"),(0,e.jsx)("small",null,"If you want to match a literal score, enter a numeric value."))}),(0,e.jsx)(J,{message:l}))}function j(t){return/^\d+$/.test(t.toString(10))}var fe=({value:t,setValue:n,dimensions:o,onMenuOpen:l,onMenuClose:i,onAddCriteria:r,onRemoveCriteria:s,displayTitle:a=!0,components:m,errors:c={}})=>{let b=t||{crit:[]},u=d=>{n({...b,op:d==="&"?void 0:d})},C=()=>{let d={...b,crit:[...b.crit,{l:"",op:">",r:0}]};n(d),r==null||r(d)},f=(d,v)=>{n((0,de.default)(b,M=>{M.crit[v]=d}))},I=d=>{let v=(0,de.default)(b,g=>{g.crit.splice(d,1)}),M=v.crit.length===0?null:v;n(M),s==null||s(M)};return(0,e.jsx)("fieldset",{className:"personalization-criteria"},a?m!=null&&m.Title?(0,e.jsx)(m.Title,null):(0,e.jsx)("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,m!=null&&m.CustomVariantName?(0,e.jsx)(m.CustomVariantName,null):null,b.crit.length?(0,e.jsx)("div",null,b.crit.map((d,v)=>{var D,L,N,$;let M=((D=d.l)==null?void 0:D.length)>0,g=d.op!=="+"&&d.op!=="-";return(0,e.jsx)("div",{css:we,key:v},(0,e.jsx)("div",{css:Ve.css` | ||
`},t)}var Me=t=>{var m,c;let{data:n,getStyles:o,isDisabled:l,innerRef:i,innerProps:r}=t,[s,a]=(c=(m=n.label)==null?void 0:m.split(":"))!=null?c:[];return(0,e.jsx)("div",{css:{...o("option",t),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:i,"aria-disabled":l,...r},a?(0,e.jsx)(F,{op:s}):(0,e.jsx)("div",{css:{width:"20px",height:"20px"}}),(0,e.jsx)("div",null,a!=null?a:s))};var Se=t=>{let{data:n,getStyles:o}=t;return(0,e.jsx)("div",{css:{...o("singleValue",t),width:"max-content"}},n.label.length===1?(0,e.jsx)(F,{op:n.label}):n.label)};var se=[{name:"=",description:"equals",value:"="},{name:"\u2260",description:"not equal",value:"!="},{name:">",description:"is greater than",value:">"},{name:"\u2265",description:"is greater than or equal to",value:">="},{name:"<",description:"is less than",value:"<"},{name:"\u2264",description:"is less than or equal to",value:"<="},{name:"has the strongest score",value:"+"},{name:"has the weakest score",value:"-"}];function le({onChange:t,value:n,...o}){var l,i;return(0,e.jsx)(Pe.InputComboBox,{...o,value:{label:(i=(l=se.find(r=>r.value===n))==null?void 0:l.name)!=null?i:n,value:n},options:se.map(r=>({label:r.description?`${r.name}:${r.description}`:r.name,value:r.value})),styles:{...o.styles,valueContainer:(r,s)=>{var a,m;return{...r,padding:"var(--spacing-sm)",...(m=(a=o.styles)==null?void 0:a.valueContainer)==null?void 0:m.call(a,r,s)}},menu:(r,s)=>{var a,m;return{...r,width:"max-content",...(m=(a=o.styles)==null?void 0:a.menu)==null?void 0:m.call(a,r,s)}},control:(r,s)=>{var a,m;return{...r,border:0,...(m=(a=o.styles)==null?void 0:a.control)==null?void 0:m.call(a,r,s)}},indicatorSeparator:(r,s)=>{var a,m;return{...r,display:"none",...(m=(a=o.styles)==null?void 0:a.indicatorSeparator)==null?void 0:m.call(a,r,s)}}},onChange:r=>{r&&t(r.value)},components:{SingleValue:Se,Option:Me,...o.components}})}var Ne=require("@uniformdev/design-system");var Re=require("@uniformdev/design-system");function me(t){return{label:t.displayName,value:t.dim,isDisabled:!1}}function K(t){if(!t)return"unavailable";let[n]=t.split(":");switch(n.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function Y(t){let n=[],o="";for(let l of t){let[i]=l.displayName.split(":");o!==i&&(n.push({label:i,options:[]}),o=i),n[n.length-1].options.push(me(l))}return n}var X=t=>{var i;let{data:n,getStyles:o,className:l}=t;return(0,e.jsx)("div",{css:{...o("groupHeading",t),textTransform:"none",fontSize:"var(--font-size-sm)"},className:l},(0,e.jsx)("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},(0,e.jsx)(Re.Icon,{icon:K((i=n.label)!=null?i:""),iconColor:"currentColor",size:16}),(0,e.jsx)("span",null,n.label)))};function J({message:t}){return t?(0,e.jsx)("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},t):null}var Q=t=>{var u,C;let{data:n,getStyles:o,cx:l,isDisabled:i,isFocused:r,isSelected:s,className:a,innerRef:m,innerProps:c}=t,[,b]=(C=(u=n.label)==null?void 0:u.split(":"))!=null?C:[];return(0,e.jsx)("div",{css:o("option",t),className:l({option:!0,"option--is-disabled":i,"option--is-focused":r,"option--is-selected":s},a),ref:m,"aria-disabled":i,...c},(0,e.jsx)("div",{css:{color:"var(--gray-700)"}},b!=null?b:n.label))};var Oe=require("@uniformdev/design-system");function ue({displayName:t}){let[n,o]=t.split(":");return(0,e.jsx)("div",{css:{whiteSpace:"normal",overflow:"hidden"}},o?(0,e.jsx)("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},n?(0,e.jsx)(Oe.Icon,{icon:K(n),iconColor:"currentColor",size:16}):null,(0,e.jsx)("span",{"data-test-id":"dimension-name"},n)):null,(0,e.jsx)("div",{css:{color:"var(--gray-700)"},"data-test-id":"dimension-value"},o!=null?o:n))}var Z=t=>{let{data:n,getStyles:o}=t;return(0,e.jsx)("div",{css:o("singleValue",t)},(0,e.jsx)(ue,{displayName:n.label}))};function pe({onChange:t,value:n,dimensions:o,errorMessage:l,...i}){return(0,e.jsx)(p.Fragment,null,(0,e.jsx)(Ne.InputComboBox,{...i,value:n?me(n):void 0,options:Y(o),styles:{...i.styles,valueContainer:(r,s)=>{var a,m;return{...r,padding:"var(--spacing-sm)",...(m=(a=i.styles)==null?void 0:a.valueContainer)==null?void 0:m.call(a,r,s)}}},onChange:r=>{r&&t(o.find(s=>s.dim===r.value))},components:{Option:Q,SingleValue:Z,GroupHeading:X,...i.components}}),(0,e.jsx)(J,{message:l}))}var ke=require("@uniformdev/design-system"),Te=require("react");function ce({onChange:t,criteriaMatch:n,dimensions:o,errorMessage:l,...i}){var c,b;let[r,s]=(0,Te.useState)(typeof n.r!="undefined"&&j(n.r)!==null?n.r.toString(10):""),a=n.rDim,m=n.rDim?o.dimIndex[n.rDim]:void 0;return(0,e.jsx)(p.Fragment,null,(0,e.jsx)(ke.InputComboBox,{...i,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=m==null?void 0:m.displayName)!=null?c:a&&!m?`${n.rDim} (unknown)`:"",value:(b=n.rDim)!=null?b:n.r?n.r.toString(10):"",isDisabled:!1},options:[{label:"Enter a numeric score to match, or choose another dimension to match its score",value:"",isDisabled:!0},...Y(o.dimensions)],styles:{...i.styles,valueContainer:(u,C)=>{var f,I;return{...u,padding:"var(--spacing-sm)",...(I=(f=i.styles)==null?void 0:f.valueContainer)==null?void 0:I.call(f,u,C)}},option:(u,C)=>{var f,I;return{fontSize:C.isDisabled?"0.8rem":void 0,...(I=(f=i.styles)==null?void 0:f.option)==null?void 0:I.call(f,u,C)}}},onChange:u=>{var C;u&&(t({...n,rDim:(C=u.value)==null?void 0:C.toString(),r:void 0}),s(""))},onInputChange:(u,C)=>{let f=j(u);C.action==="input-change"||C.action==="set-value"?(s(u),(f||u==="")&&t({...n,r:u||void 0,rDim:void 0})):!f&&!j(C.prevInputValue)&&(!u&&n.r?s(n.r.toString()):s(u))},components:{...i.components,Option:Q,SingleValue:Z,GroupHeading:X},noOptionsMessage:({inputValue:u})=>j(u)?(0,e.jsx)(p.Fragment,null,(0,e.jsx)("div",null,"Score: ",u),(0,e.jsx)("small",null,"If you want to match on another dimension\u2019s score instead, clear the score value to search for a dimension.")):(0,e.jsx)(p.Fragment,null,(0,e.jsx)("div",null,"No dimensions match your search \u201C",u,"\u201D"),(0,e.jsx)("small",null,"If you want to match a literal score, enter a numeric value."))}),(0,e.jsx)(J,{message:l}))}function j(t){return/^\d+$/.test(t.toString(10))}var fe=({value:t,setValue:n,dimensions:o,onMenuOpen:l,onMenuClose:i,onAddCriteria:r,onRemoveCriteria:s,displayTitle:a=!0,components:m,errors:c={}})=>{let b=t||{crit:[]},u=d=>{n({...b,op:d==="&"?void 0:d})},C=()=>{let d={...b,crit:[...b.crit,{l:"",op:">",r:0}]};n(d),r==null||r(d)},f=(d,v)=>{n((0,de.default)(b,M=>{M.crit[v]=d}))},I=d=>{let v=(0,de.default)(b,g=>{g.crit.splice(d,1)}),M=v.crit.length===0?null:v;n(M),s==null||s(M)};return(0,e.jsx)("fieldset",{className:"personalization-criteria"},a?m!=null&&m.Title?(0,e.jsx)(m.Title,null):(0,e.jsx)("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,m!=null&&m.CustomVariantName?(0,e.jsx)(m.CustomVariantName,null):null,b.crit.length?(0,e.jsx)("div",null,b.crit.map((d,v)=>{var D,L,T,$;let M=((D=d.l)==null?void 0:D.length)>0,g=d.op!=="+"&&d.op!=="-";return(0,e.jsx)("div",{css:we,key:v,"data-test-id":"criteria-container"},(0,e.jsx)("div",{css:Ve.css` | ||
${Be} | ||
grid-template-columns: minmax(0, 1fr) ${g?"minmax(0, 79px) minmax(0, 1fr)":"minmax(0, 1fr)"} | ||
`,className:"criteriaItemInner"},(0,e.jsx)("div",{css:q},(0,e.jsx)(pe,{errorMessage:(L=c.lhs)==null?void 0:L[v],css:_,styles:{control:y=>({...y,height:"100%"})},dimensions:o.dimensions,onChange:y=>{f({...d,l:y.dim},v)},value:o.dimIndex[d.l],onMenuOpen:l,onMenuClose:i})),(0,e.jsx)("div",{css:q},(0,e.jsx)(le,{name:`op-${v}`,css:_,styles:{control:y=>({...y,height:"100%"})},value:d.op,onChange:y=>{f(y==="+"||y==="-"?{...d,op:y,r:void 0,rDim:void 0}:{...d,op:y},v)},onMenuOpen:l,onMenuClose:i})),g?(0,e.jsx)("div",{css:q},(0,e.jsx)(ce,{errorMessage:(N=c.rhs)==null?void 0:N[v],css:_,styles:{control:y=>({...y,height:"100%"})},criteriaMatch:d,onChange:y=>{f(y,v)},isDisabled:!M,dimensions:o,onMenuOpen:l,onMenuClose:i})):null),(0,e.jsx)("button",{type:"button",onClick:()=>I(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0}},(0,e.jsx)(B.Icon,{icon:ze.CgCloseO,iconColor:"red",size:"1.5rem"})),v>0?(0,e.jsx)("div",{className:"criteria-group-operation",css:{position:"absolute",top:"-4rem",transform:"translateX(calc(1.5rem - 50%))"}},(0,e.jsx)(B.InputInlineSelect,{disabled:v>1,value:($=b.op)!=null?$:"&",options:[{label:"AND",value:"&"},{label:"OR",value:"|"}],onChange:y=>{u(y.value)}})):null)})):(0,e.jsx)(B.Callout,{title:"Default variant",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)(B.Paragraph,null,'This personalized variant has no match criteria and will be shown to any visitor that does not match any preceding variants. Ensure that default variants come last in the variant list. Personalize this variant by clicking "Add Criteria" to get started.')),o.dimensions.length===0?m!=null&&m.NoDimensionsDefined?(0,e.jsx)(m.NoDimensionsDefined,null):(0,e.jsx)(B.Callout,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"You do not have any dimensions configured.")):(0,e.jsx)(B.AddListButton,{className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var nt=({contextConfig:t,...n})=>{let{loading:o,result:l,error:i}=P(t);return i?(0,e.jsx)(V.Callout,{type:"danger"},i):o||l===null?(0,e.jsx)(V.LoadingIndicator,null):(0,e.jsx)(fe,{...n,dimensions:l,components:{NoDimensionsDefined:()=>(0,e.jsx)(V.Callout,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"You do not have any dimensions configured. Create your first"," ",(0,e.jsx)("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};var Le=R(require("react"));var ee=require("react"),te=require("@uniformdev/context/api");function z({apiHost:t,apiKey:n,projectId:o}){let[l,i]=(0,ee.useState)({loading:!1,notConfigured:!1,error:null,result:null});return(0,ee.useEffect)(()=>{if(!o||!n||!t){i({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{i({notConfigured:!1,loading:!0,error:null,result:null});try{let a=await new te.ManifestClient({projectId:o,apiKey:n,apiHost:t}).get({preview:!0});i({notConfigured:!1,loading:!1,error:null,result:a})}catch(s){let a;s instanceof te.ApiClientError?(s.statusCode===403&&(a=`The API key ${n} did not have permissions to fetch the manifest. Ensure Context > Read Drafts permissions are granted.`),a=s.message):a=s.toString(),i({notConfigured:!1,loading:!1,error:a,result:null});return}})()},[t,n,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}var $e=require("@uniformdev/design-system");function ot({children:t,versionMap:n,contextConfig:o}){let{loading:l,result:i}=z(o);if(l)return(0,e.jsx)($e.LoadingIndicator,null);if(i){let r=n[i.project.ui_version];if(r)return(0,e.jsx)(r,null)}return(0,e.jsx)(Le.default.Fragment,null,t)}var S=R(require("react"));var Ae=require("@uniformdev/design-system"),ne=(0,S.createContext)(null),rt=({loadingComponent:t,errorComponent:n,contextConfig:o,children:l})=>{let i=z(o),r=P(o);return i.error||i.notConfigured?n?(0,e.jsx)(n,{contextConfig:o,result:i}):(0,e.jsx)(S.default.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?n?(0,e.jsx)(n,{contextConfig:o,result:r}):(0,e.jsx)(S.default.Fragment,null,"ErrorComponent is not configured"):i.loading||r.loading?t?(0,e.jsx)(t,null):(0,e.jsx)(Ae.LoadingIndicator,null):(0,e.jsx)(ne.Provider,{value:{manifest:i.result,dimensions:r.result,contextConfig:o}},l)};function it(){let t=(0,S.useContext)(ne);if(!(t!=null&&t.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return t.contextConfig}function at(){let t=(0,S.useContext)(ne);if(!(t!=null&&t.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return t.manifest}function st(){let t=(0,S.useContext)(ne);if(!(t!=null&&t.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return t.dimensions}var Ue=require("uuid"),Ge=require("@uniformdev/context/api"),ge=async t=>{if(!t)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!t.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!t.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!(0,Ue.validate)(t.apiKey)&&!t.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let n=new Ge.ManifestClient({projectId:t.projectId,apiKey:t.apiKey,apiHost:t.apiHost});try{let o=await n.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};var oe=require("react");var lt=t=>{let[n,o]=(0,oe.useState)({validating:!1,error:void 0}),{apiKey:l,apiHost:i,projectId:r}=t||{};return(0,oe.useEffect)(()=>{if(!l||!i)return;(async()=>{o({validating:!0,error:void 0});let{error:a,result:m}=await ge({apiHost:i,apiKey:l,projectId:r});o(a?{error:a,validating:!1}:{error:void 0,validating:!1,result:m})})()},[i,l,r]),{validating:n.validating,error:n.error,result:n.result}};function mt(t){return Array.isArray(t)&&t.length>0&&t[0].cat!==void 0}function ut(t){return t.crit!==void 0}w(x,require("@uniformdev/design-system"),module.exports);0&&(module.exports={ContextData,CriteriaMatchMenu,CriteriaOperatorMenu,DimensionMenu,DimensionValue,EditLink,EnrichmentTag,PersonalizationCriteria,PersonalizationCriteriaStatic,ProjectUIVersion,addEnrichmentLink,contextCriteriaMenuOperators,isEnrichmentTagData,isPersonalizationCriteriaData,useContextConfig,useContextData,useDimensions,useDimensionsDataContext,useManifest,useValidateContextConfig,validateContextConfig}); | ||
`,className:"criteriaItemInner"},(0,e.jsx)("div",{css:q,className:"criteria-wrapper","data-test-id":"select-criteria"},(0,e.jsx)(pe,{errorMessage:(L=c.lhs)==null?void 0:L[v],css:_,styles:{control:y=>({...y,height:"100%"})},dimensions:o.dimensions,onChange:y=>{f({...d,l:y.dim},v)},value:o.dimIndex[d.l],onMenuOpen:l,onMenuClose:i})),(0,e.jsx)("div",{css:q,className:"criteria-wrapper","data-test-id":"select-operator"},(0,e.jsx)(le,{name:`op-${v}`,css:_,styles:{control:y=>({...y,height:"100%"})},value:d.op,onChange:y=>{f(y==="+"||y==="-"?{...d,op:y,r:void 0,rDim:void 0}:{...d,op:y},v)},onMenuOpen:l,onMenuClose:i})),g?(0,e.jsx)("div",{css:q,className:"criteria-wrapper","data-test-id":"select-match-criteria"},(0,e.jsx)(ce,{errorMessage:(T=c.rhs)==null?void 0:T[v],css:_,styles:{control:y=>({...y,height:"100%"})},criteriaMatch:d,onChange:y=>{f(y,v)},isDisabled:!M,dimensions:o,onMenuOpen:l,onMenuClose:i})):null),(0,e.jsx)("button",{type:"button",onClick:()=>I(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0},"data-test-id":"button-delete"},(0,e.jsx)(B.Icon,{icon:ze.CgCloseO,iconColor:"red",size:"1.5rem"})),v>0?(0,e.jsx)("div",{className:"criteria-group-operation",css:{position:"absolute",top:"-4rem",transform:"translateX(calc(1.5rem - 50%))"}},(0,e.jsx)(B.InputInlineSelect,{"data-test-id":"dropdown-button-combine",disabled:v>1,value:($=b.op)!=null?$:"&",options:[{label:"AND",value:"&"},{label:"OR",value:"|"}],onChange:y=>{u(y.value)}})):null)})):(0,e.jsx)(B.Callout,{title:"Default variant",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)(B.Paragraph,null,'This personalized variant has no match criteria and will be shown to any visitor that does not match any preceding variants. Ensure that default variants come last in the variant list. Personalize this variant by clicking "Add Criteria" to get started.')),o.dimensions.length===0?m!=null&&m.NoDimensionsDefined?(0,e.jsx)(m.NoDimensionsDefined,null):(0,e.jsx)(B.Callout,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"You do not have any dimensions configured.")):(0,e.jsx)(B.AddListButton,{"data-test-id":"button-add-criteria",className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var nt=({contextConfig:t,...n})=>{let{loading:o,result:l,error:i}=P(t);return i?(0,e.jsx)(V.Callout,{type:"danger"},i):o||l===null?(0,e.jsx)(V.LoadingIndicator,null):(0,e.jsx)(fe,{...n,dimensions:l,components:{NoDimensionsDefined:()=>(0,e.jsx)(V.Callout,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,e.jsx)("p",null,"You do not have any dimensions configured. Create your first"," ",(0,e.jsx)("a",{href:`${t.apiHost}/projects/${encodeURIComponent(t.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};var Le=R(require("react"));var ee=require("react"),te=require("@uniformdev/context/api");function z({apiHost:t,apiKey:n,projectId:o}){let[l,i]=(0,ee.useState)({loading:!1,notConfigured:!1,error:null,result:null});return(0,ee.useEffect)(()=>{if(!o||!n||!t){i({notConfigured:!0,loading:!1,error:null,result:null});return}(async()=>{i({notConfigured:!1,loading:!0,error:null,result:null});try{let a=await new te.CachedManifestClient({projectId:o,apiKey:n,apiHost:t}).get({preview:!0});i({notConfigured:!1,loading:!1,error:null,result:a})}catch(s){let a;s instanceof te.ApiClientError?(s.statusCode===403&&(a=`The API key ${n} did not have permissions to fetch the manifest. Ensure Context > Read Drafts permissions are granted.`),a=s.message):a=s.toString(),i({notConfigured:!1,loading:!1,error:a,result:null});return}})()},[t,n,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}var $e=require("@uniformdev/design-system");function ot({children:t,versionMap:n,contextConfig:o}){let{loading:l,result:i}=z(o);if(l)return(0,e.jsx)($e.LoadingIndicator,null);if(i){let r=n[i.project.ui_version];if(r)return(0,e.jsx)(r,null)}return(0,e.jsx)(Le.default.Fragment,null,t)}var S=R(require("react"));var Ae=require("@uniformdev/design-system"),ne=(0,S.createContext)(null),rt=({loadingComponent:t,errorComponent:n,contextConfig:o,children:l})=>{let i=z(o),r=P(o);return i.error||i.notConfigured?n?(0,e.jsx)(n,{contextConfig:o,result:i}):(0,e.jsx)(S.default.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?n?(0,e.jsx)(n,{contextConfig:o,result:r}):(0,e.jsx)(S.default.Fragment,null,"ErrorComponent is not configured"):i.loading||r.loading?t?(0,e.jsx)(t,null):(0,e.jsx)(Ae.LoadingIndicator,null):(0,e.jsx)(ne.Provider,{value:{manifest:i.result,dimensions:r.result,contextConfig:o}},l)};function it(){let t=(0,S.useContext)(ne);if(!(t!=null&&t.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return t.contextConfig}function at(){let t=(0,S.useContext)(ne);if(!(t!=null&&t.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return t.manifest}function st(){let t=(0,S.useContext)(ne);if(!(t!=null&&t.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return t.dimensions}var Ue=require("uuid"),Ge=require("@uniformdev/context/api"),ge=async t=>{if(!t)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!t.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!t.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!(0,Ue.validate)(t.apiKey)&&!t.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let n=new Ge.UncachedManifestClient({projectId:t.projectId,apiKey:t.apiKey,apiHost:t.apiHost});try{let o=await n.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};var oe=require("react");var lt=t=>{let[n,o]=(0,oe.useState)({validating:!1,error:void 0}),{apiKey:l,apiHost:i,projectId:r}=t||{};return(0,oe.useEffect)(()=>{if(!l||!i)return;(async()=>{o({validating:!0,error:void 0});let{error:a,result:m}=await ge({apiHost:i,apiKey:l,projectId:r});o(a?{error:a,validating:!1}:{error:void 0,validating:!1,result:m})})()},[i,l,r]),{validating:n.validating,error:n.error,result:n.result}};function mt(t){return Array.isArray(t)&&t.length>0&&t[0].cat!==void 0}function ut(t){return t.crit!==void 0}w(x,require("@uniformdev/design-system"),module.exports);0&&(module.exports={ContextData,CriteriaMatchMenu,CriteriaOperatorMenu,DimensionMenu,DimensionValue,EditLink,EnrichmentTag,PersonalizationCriteria,PersonalizationCriteriaStatic,ProjectUIVersion,addEnrichmentLink,contextCriteriaMenuOperators,isEnrichmentTagData,isPersonalizationCriteriaData,useContextConfig,useContextData,useDimensions,useDimensionsDataContext,useManifest,useValidateContextConfig,validateContextConfig}); |
{ | ||
"name": "@uniformdev/context-ui", | ||
"version": "16.2.1-alpha.142+0cfd8c64a", | ||
"version": "16.2.1-alpha.320+8dcf5fc30", | ||
"description": "React-based functionality and components for Uniform Context", | ||
@@ -34,4 +34,4 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"@emotion/react": "11.9.3", | ||
"@uniformdev/context": "^16.2.1-alpha.142+0cfd8c64a", | ||
"@uniformdev/design-system": "^16.2.1-alpha.142+0cfd8c64a", | ||
"@uniformdev/context": "^16.2.1-alpha.320+8dcf5fc30", | ||
"@uniformdev/design-system": "^16.2.1-alpha.320+8dcf5fc30", | ||
"immer": "9.0.15", | ||
@@ -51,4 +51,4 @@ "react-beautiful-dnd": "13.1.0", | ||
"devDependencies": { | ||
"@babel/core": "7.18.6", | ||
"@babel/preset-env": "7.18.6", | ||
"@babel/core": "7.18.9", | ||
"@babel/preset-env": "7.18.9", | ||
"@babel/preset-react": "7.18.6", | ||
@@ -78,3 +78,3 @@ "@emotion/babel-preset-css-prop": "11.2.0", | ||
}, | ||
"gitHead": "0cfd8c64a32188799639bf906d0a1cc706dfa957" | ||
"gitHead": "8dcf5fc30e73cb76d24e091562e4b55f5d388688" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
81339
640