@uniformdev/context-ui 16.1.1-alpha.169 → 16.1.1-alpha.294
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.d.ts +52 -8
- package/dist/index.esm.js +21 -12
- package/dist/index.js +21 -12
- package/dist/index.mjs +21 -12
- package/package.json +11 -15
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as _emotion_react_types_jsx_namespace from '@emotion/react/types/jsx-na
|
|
|
2
2
|
import * as _emotion_react from '@emotion/react';
|
|
3
3
|
import React, { ReactElement, ComponentType } from 'react';
|
|
4
4
|
import { DimensionDefinition, ManifestGetResponse } from '@uniformdev/context/api';
|
|
5
|
-
import { EnrichmentData,
|
|
5
|
+
import { EnrichmentData, VariantMatchCriteria, DimensionMatch } from '@uniformdev/context';
|
|
6
|
+
import { InputComboBoxProps, InputComboBoxOption } from '@uniformdev/design-system';
|
|
6
7
|
export * from '@uniformdev/design-system';
|
|
7
8
|
|
|
8
9
|
declare type EditLinkProps = {
|
|
@@ -34,18 +35,29 @@ interface EnrichmentTagProps {
|
|
|
34
35
|
}
|
|
35
36
|
declare const EnrichmentTag: React.FC<EnrichmentTagProps>;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
name: string;
|
|
39
|
-
value: DimensionMatch['op'];
|
|
40
|
-
}>;
|
|
41
|
-
interface PersonalizationCriteriaProps {
|
|
38
|
+
interface PersonalizationCriteriaStaticProps {
|
|
42
39
|
value: VariantMatchCriteria | null | undefined;
|
|
43
40
|
setValue: (value: VariantMatchCriteria | null) => void;
|
|
44
|
-
|
|
41
|
+
dimensions: DimensionsData;
|
|
45
42
|
displayTitle?: boolean;
|
|
46
43
|
onMenuOpen?: () => void;
|
|
47
44
|
onMenuClose?: () => void;
|
|
45
|
+
onAddCriteria?: (value: VariantMatchCriteria) => void;
|
|
46
|
+
onRemoveCriteria?: (value: VariantMatchCriteria | null) => void;
|
|
47
|
+
components?: {
|
|
48
|
+
NoDimensionsDefined?: React.ComponentType;
|
|
49
|
+
Title?: React.ComponentType;
|
|
50
|
+
};
|
|
51
|
+
errors?: {
|
|
52
|
+
lhs?: Array<string | undefined>;
|
|
53
|
+
rhs?: Array<string | undefined>;
|
|
54
|
+
};
|
|
48
55
|
}
|
|
56
|
+
declare const PersonalizationCriteriaStatic: React.FC<PersonalizationCriteriaStaticProps>;
|
|
57
|
+
|
|
58
|
+
declare type PersonalizationCriteriaProps = {
|
|
59
|
+
contextConfig: ContextConfig;
|
|
60
|
+
} & Omit<PersonalizationCriteriaStaticProps, 'dimensions'>;
|
|
49
61
|
declare const PersonalizationCriteria: React.FC<PersonalizationCriteriaProps>;
|
|
50
62
|
|
|
51
63
|
declare type UIVersionProps = {
|
|
@@ -86,6 +98,38 @@ declare function useContextConfig(): ContextConfig;
|
|
|
86
98
|
declare function useManifest(): ManifestGetResponse;
|
|
87
99
|
declare function useDimensionsDataContext(): DimensionsData;
|
|
88
100
|
|
|
101
|
+
declare type CriteriaOperatorMenuProps = {
|
|
102
|
+
value: DimensionMatch['op'];
|
|
103
|
+
onChange: (newValue: DimensionMatch['op']) => void;
|
|
104
|
+
} & Omit<InputComboBoxProps<InputComboBoxOption, false>, 'value' | 'options' | 'onChange'>;
|
|
105
|
+
declare const contextCriteriaMenuOperators: Array<{
|
|
106
|
+
name: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
value: DimensionMatch['op'];
|
|
109
|
+
}>;
|
|
110
|
+
declare function CriteriaOperatorMenu({ onChange, value, ...props }: CriteriaOperatorMenuProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
111
|
+
|
|
112
|
+
declare type DimensionMenuProps = {
|
|
113
|
+
value?: ResolvedDimensionDefinition;
|
|
114
|
+
dimensions: ResolvedDimensionDefinition[];
|
|
115
|
+
errorMessage?: string;
|
|
116
|
+
onChange: (newValue: ResolvedDimensionDefinition) => void;
|
|
117
|
+
} & Omit<InputComboBoxProps<InputComboBoxOption, false>, 'value' | 'options' | 'onChange'>;
|
|
118
|
+
declare function DimensionMenu({ onChange, value, dimensions, errorMessage, ...props }: DimensionMenuProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
119
|
+
|
|
120
|
+
declare type CriteriaMatchMenuProps = {
|
|
121
|
+
criteriaMatch: DimensionMatch;
|
|
122
|
+
dimensions: DimensionsData;
|
|
123
|
+
errorMessage?: string;
|
|
124
|
+
onChange: (newCriteria: DimensionMatch) => void;
|
|
125
|
+
} & Omit<InputComboBoxProps<InputComboBoxOption, false>, 'value' | 'options' | 'onChange' | 'inputValue' | 'value' | 'onInputChange'>;
|
|
126
|
+
declare function CriteriaMatchMenu({ onChange, criteriaMatch, dimensions, errorMessage, ...props }: CriteriaMatchMenuProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
127
|
+
|
|
128
|
+
declare type DimensionValueProps = {
|
|
129
|
+
displayName: string;
|
|
130
|
+
};
|
|
131
|
+
declare function DimensionValue({ displayName }: DimensionValueProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
132
|
+
|
|
89
133
|
declare const validateContextConfig: (contextConfig?: ContextConfig) => Promise<{
|
|
90
134
|
valid: boolean;
|
|
91
135
|
error?: Error;
|
|
@@ -102,4 +146,4 @@ declare const useValidateContextConfig: (contextConfig?: ContextConfig) => UseVa
|
|
|
102
146
|
declare function isEnrichmentTagData(obj: any): obj is EnrichmentData[];
|
|
103
147
|
declare function isPersonalizationCriteriaData(obj: any): obj is VariantMatchCriteria;
|
|
104
148
|
|
|
105
|
-
export { ContextConfig, ContextData, ContextDataProps, DataContextErrorProps, DimensionsData, EditLink, EditLinkProps, EnrichmentTag, EnrichmentTagProps, PersonalizationCriteria, PersonalizationCriteriaProps, ProjectUIVersion, ResolvedDimensionDefinition, UseContextDataResult, UseDimensionsResult, UseValidateContextConfigResult, addEnrichmentLink,
|
|
149
|
+
export { ContextConfig, ContextData, ContextDataProps, CriteriaMatchMenu, CriteriaMatchMenuProps, CriteriaOperatorMenu, CriteriaOperatorMenuProps, DataContextErrorProps, DimensionMenu, DimensionMenuProps, DimensionValue, DimensionValueProps, DimensionsData, EditLink, EditLinkProps, EnrichmentTag, EnrichmentTagProps, PersonalizationCriteria, PersonalizationCriteriaProps, PersonalizationCriteriaStatic, PersonalizationCriteriaStaticProps, ProjectUIVersion, ResolvedDimensionDefinition, UseContextDataResult, UseDimensionsResult, UseValidateContextConfigResult, addEnrichmentLink, contextCriteriaMenuOperators, isEnrichmentTagData, isPersonalizationCriteriaData, useContextConfig, useContextData, useDimensions, useDimensionsDataContext, useManifest, useValidateContextConfig, validateContextConfig };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e}from"@emotion/react";import*as
|
|
1
|
+
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`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
font-weight: var(--fw-bold);
|
|
@@ -9,7 +9,7 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
9
9
|
&:focus {
|
|
10
10
|
text-decoration-line: underline;
|
|
11
11
|
}
|
|
12
|
-
`;var
|
|
12
|
+
`;var X=({linkTo:n,name:t,linkText:o=`Edit ${t} Component`})=>e("a",{css:Y,title:`Edit ${t} component definition`,rel:"noopener noreferrer",target:"_blank",href:n},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 Se}from"@uniformdev/context/api";function J(n,t,o){return n.reduce((l,a)=>{let r=t(a);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return l[t(a)]=o?o(a):a,l},{})}function I({apiHost:n,apiKey:t,projectId:o}){let[l,a]=Ie({loading:!1,notConfigured:!1,error:null,result:null});return xe(()=>{if(!o||!t||!n){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:t,apiHost:n}).get()).dimensions.map(c=>({...c,displayName:Be(c)})),m={dimensions:i,dimIndex:J(i,c=>c.dim,c=>c)};a({notConfigured:!1,loading:!1,error:null,result:m})}catch(s){let i;s instanceof Se?i=s.message:i=s.toString(),a({notConfigured:!1,loading:!1,error:i,result:null});return}})()},[n,t,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}import{getEnrichmentVectorKey as G}from"@uniformdev/context";import{Input as ee,Button as Ee,InputSelect as Me,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 Ve=q`
|
|
13
13
|
flex: 2;
|
|
14
14
|
display: flex;
|
|
15
15
|
width: 50%;
|
|
@@ -20,7 +20,7 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
20
20
|
&:focus {
|
|
21
21
|
text-decoration-line: underline;
|
|
22
22
|
}
|
|
23
|
-
`,
|
|
23
|
+
`,Rn=({value:n,setValue:t,contextConfig:o,displayTitle:l=!0})=>{let{loading:a,result:r,error:s}=I(o),i=Q(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),m=Q(()=>{if(!n)return i;if(i)return i.filter(g=>!n.some(y=>G(y.cat,y.key)===g.dim))},[i,n]),[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([...n!=null?n:[],{cat:g,key:y,str:u}]),h(""),C(50),D(!1)},x=g=>{let y=[];r?y=g.filter(w=>{let E=r.dimIndex[G(w.cat,w.key)];return Boolean(E)}):y=g;let S=y.length===0?null:y;t(S)};return s?e(H,{type:"danger"},s):a||r===null?e(Pe,null):e("fieldset",{className:"enrichment-tag"},l?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&&!n?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:n!=null?n:[],setList:x,dimIndex:r.dimIndex}),f&&m&&m.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(Me,{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=>h(g.currentTarget.value)})),e(Le,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),e(Ee,{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&&m&&m.length>0&&n?e(Re,{className:"add-more",buttonText:"Add More",onButtonClick:()=>D(!0)}):e("a",{css:Ve,title:"none",href:"#"}),e(X,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):e(Ne,{contextConfig:o}))},Ne=({contextConfig:n})=>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:`${n.apiHost}/projects/${encodeURIComponent(n.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),ne=(n,t=100,o=0)=>Math.max(Math.min(n,t),o),te=q`
|
|
24
24
|
position: absolute;
|
|
25
25
|
bottom: 0.875rem;
|
|
26
26
|
left: var(--spacing-sm);
|
|
@@ -32,27 +32,27 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
32
32
|
background-color: var(--gray-100);
|
|
33
33
|
border: 1px solid var(--gray-300);
|
|
34
34
|
border-radius: var(--rounded-full);
|
|
35
|
-
`,
|
|
36
|
-
${
|
|
35
|
+
`,ze=q`
|
|
36
|
+
${te}
|
|
37
37
|
left: auto;
|
|
38
38
|
right: var(--spacing-sm);
|
|
39
|
-
`,
|
|
39
|
+
`,Le=({score:n,setValue:t,cap:o=100,...l})=>{let a=r=>{let s=r==="increment"?n+10:n-10;s<0&&(s=0),s>o&&(s=o),t(s)};return e("div",{css:{position:"relative"},...l},e(ee,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:n,onChange:r=>t(ne(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),e("button",{type:"button",title:"Reduce enrichment count",onClick:()=>a("decrement"),disabled:n===0,className:"scoreCounterButton",css:te},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:n,setList:t,dimIndex:o})=>{let l=r=>{t(Z(n,s=>{s.splice(r,1)}))},a=(r,s)=>{var m;let i=(m=o[`${n[r].cat}_${n[r].key}`])==null?void 0:m.cap;t(Z(n,c=>{c[r].str=ne(Number(s)||0,i)}))};return e(j.Fragment,null,n.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:m=>a(s,m.currentTarget.value)})),e("button",{type:"button",title:"Delete enrichment",onClick:()=>l(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{Callout as ce,InputInlineSelect as Fe,Icon as Ke,AddListButton as Ye}from"@uniformdev/design-system";import de from"immer";import{CgCloseO as Xe}from"react-icons/cg";import{css as B}from"@emotion/react";var _="6rem",oe=B`
|
|
40
40
|
position: relative;
|
|
41
41
|
padding: var(--spacing-base);
|
|
42
42
|
border: 1px solid var(--gray-300);
|
|
43
43
|
box-shadow: var(--shadow-base);
|
|
44
44
|
background-color: white;
|
|
45
45
|
border-radius: var(--rounded-base);
|
|
46
|
-
margin-top: ${
|
|
46
|
+
margin-top: ${_};
|
|
47
47
|
display: flex;
|
|
48
48
|
&:before {
|
|
49
49
|
content: '';
|
|
50
50
|
display: block;
|
|
51
51
|
width: 1px;
|
|
52
|
-
height: ${
|
|
52
|
+
height: ${_};
|
|
53
53
|
background-color: var(--gray-300);
|
|
54
54
|
position: absolute;
|
|
55
|
-
top: -${
|
|
55
|
+
top: -${_};
|
|
56
56
|
left: var(--spacing-lg);
|
|
57
57
|
}
|
|
58
58
|
&:first-of-type {
|
|
@@ -61,9 +61,18 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
61
61
|
display: none;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,
|
|
64
|
+
`,re=B`
|
|
65
65
|
display: grid;
|
|
66
|
-
gap: var(--spacing-
|
|
66
|
+
gap: var(--spacing-xs);
|
|
67
67
|
flex-grow: 1;
|
|
68
68
|
margin-right: var(--spacing-base);
|
|
69
|
-
|
|
69
|
+
`,M=B`
|
|
70
|
+
width: 100%;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: stretch;
|
|
73
|
+
`,P=B`
|
|
74
|
+
height: 100%;
|
|
75
|
+
width: 100%;
|
|
76
|
+
`,Tn=B`
|
|
77
|
+
height: 100%;
|
|
78
|
+
`;import{InputComboBox as Ue}from"@uniformdev/design-system";function R({op:n}){return e("div",{css:{background:"var(--gray-700)",color:"white",borderRadius:"100%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px"}},n)}var ie=n=>{var m,c;let{data:t,getStyles:o,isDisabled:l,innerRef:a,innerProps:r}=n,[s,i]=(c=(m=t.label)==null?void 0:m.split(":"))!=null?c:[];return e("div",{css:{...o("option",n),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:a,"aria-disabled":l,...r},i?e(R,{op:s}):e("div",{css:{width:"20px",height:"20px"}}),e("div",null,i!=null?i:s))};var ae=n=>{let{data:t,getStyles:o}=n;return e("div",{css:{...o("singleValue",n),width:"max-content"}},t.label.length===1?e(R,{op:t.label}):t.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:n,value:t,...o}){var l,a;return e(Ue,{...o,value:{label:(a=(l=se.find(r=>r.value===t))==null?void 0:l.name)!=null?a:t,value:t},options:se.map(r=>({label:r.description?`${r.name}:${r.description}`:r.name,value:r.value})),styles:{...o.styles,valueContainer:(r,s)=>{var i,m;return{...r,padding:"var(--spacing-sm)",...(m=(i=o.styles)==null?void 0:i.valueContainer)==null?void 0:m.call(i,r,s)}},menu:(r,s)=>{var i,m;return{...r,width:"max-content",...(m=(i=o.styles)==null?void 0:i.menu)==null?void 0:m.call(i,r,s)}},control:(r,s)=>{var i,m;return{...r,border:0,...(m=(i=o.styles)==null?void 0:i.control)==null?void 0:m.call(i,r,s)}},indicatorSeparator:(r,s)=>{var i,m;return{...r,display:"none",...(m=(i=o.styles)==null?void 0:i.indicatorSeparator)==null?void 0:m.call(i,r,s)}}},onChange:r=>{r&&n(r.value)},components:{SingleValue:ae,Option:ie,...o.components}})}import{InputComboBox as We}from"@uniformdev/design-system";import{Icon as Ge}from"@uniformdev/design-system";function F(n){return{label:n.displayName,value:n.dim,isDisabled:!1}}function O(n){if(!n)return"unavailable";let[t]=n.split(":");switch(t.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function k(n){let t=[],o="";for(let l of n){let[a]=l.displayName.split(":");o!==a&&(t.push({label:a,options:[]}),o=a),t[t.length-1].options.push(F(l))}return t}var T=n=>{var a;let{data:t,getStyles:o,className:l}=n;return e("div",{css:{...o("groupHeading",n),textTransform:"none",fontSize:"var(--font-size-sm)"},className:l},e("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},e(Ge,{icon:O((a=t.label)!=null?a:""),iconColor:"currentColor",size:16}),e("span",null,t.label)))};function V({message:n}){return n?e("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},n):null}var N=n=>{var u,C;let{data:t,getStyles:o,cx:l,isDisabled:a,isFocused:r,isSelected:s,className:i,innerRef:m,innerProps:c}=n,[,h]=(C=(u=t.label)==null?void 0:u.split(":"))!=null?C:[];return e("div",{css:o("option",n),className:l({option:!0,"option--is-disabled":a,"option--is-focused":r,"option--is-selected":s},i),ref:m,"aria-disabled":a,...c},e("div",{css:{color:"var(--gray-700)"}},h!=null?h:t.label))};import{Icon as He}from"@uniformdev/design-system";function me({displayName:n}){let[t,o]=n.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)"}},t?e(He,{icon:O(t),iconColor:"currentColor",size:16}):null,e("span",null,t)):null,e("div",{css:{color:"var(--gray-700)"}},o!=null?o:t))}var z=n=>{let{data:t,getStyles:o}=n;return e("div",{css:o("singleValue",n)},e(me,{displayName:t.label}))};function ue({onChange:n,value:t,dimensions:o,errorMessage:l,...a}){return e(p.Fragment,null,e(We,{...a,value:t?F(t):void 0,options:k(o),styles:{...a.styles,valueContainer:(r,s)=>{var i,m;return{...r,padding:"var(--spacing-sm)",...(m=(i=a.styles)==null?void 0:i.valueContainer)==null?void 0:m.call(i,r,s)}}},onChange:r=>{r&&n(o.find(s=>s.dim===r.value))},components:{Option:N,SingleValue:z,GroupHeading:T,...a.components}}),e(V,{message:l}))}import{InputComboBox as qe}from"@uniformdev/design-system";import{useState as _e}from"react";function pe({onChange:n,criteriaMatch:t,dimensions:o,errorMessage:l,...a}){var c,h;let[r,s]=_e(typeof t.r!="undefined"&&L(t.r)!==null?t.r.toString(10):""),i=t.rDim,m=t.rDim?o.dimIndex[t.rDim]:void 0;return e(p.Fragment,null,e(qe,{...a,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=m==null?void 0:m.displayName)!=null?c:i&&!m?`${t.rDim} (unknown)`:"",value:(h=t.rDim)!=null?h:t.r?t.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&&(n({...t,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==="")&&n({...t,r:u||void 0,rDim:void 0})):!f&&!L(C.prevInputValue)&&(!u&&t.r?s(t.r.toString()):s(u))},components:{...a.components,Option:N,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(V,{message:l}))}function L(n){return/^\d+$/.test(n.toString(10))}var fe=({value:n,setValue:t,dimensions:o,onMenuOpen:l,onMenuClose:a,onAddCriteria:r,onRemoveCriteria:s,displayTitle:i=!0,components:m,errors:c={}})=>{let h=n||{crit:[]},u=d=>{t({...h,op:d==="&"?void 0:d})},C=()=>{let d={...h,crit:[...h.crit,{l:"",op:">",r:0}]};t(d),r==null||r(d)},f=(d,v)=>{t(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;t(x),s==null||s(x)};return e("fieldset",{className:"personalization-criteria"},i?m!=null&&m.Title?e(m.Title,null):e("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,h.crit.length?h.crit.map((d,v)=>{var y,S,w,E;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:re,style:{gridTemplateColumns:`minmax(0, 1fr) ${g?"minmax(0, 79px) minmax(0, 1fr)":"minmax(0, 1fr)"}`},className:"criteriaItemInner"},e("div",{css:M},e(ue,{errorMessage:(S=c.lhs)==null?void 0:S[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]})),e("div",{css:M},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:l,onMenuClose:a})),g?e("div",{css:M},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:l,onMenuClose:a})):null),e("button",{type:"button",onClick:()=>D(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0}},e(Ke,{icon:Xe,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(Fe,{disabled:v>1,value:(E=h.op)!=null?E:"&",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("p",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?e(m.NoDimensionsDefined,null):e(ce,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"You do not have any dimensions configured.")):e(Ye,{className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var Tt=({contextConfig:n,...t})=>{let{loading:o,result:l,error:a}=I(n);return a?e(ge,{type:"danger"},a):o||l===null?e(Je,null):e(fe,{...t,dimensions:l,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:`${n.apiHost}/projects/${encodeURIComponent(n.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};import nn from"react";import{useEffect as Qe,useState as Ze}from"react";import{ManifestClient as je,ApiClientError as en}from"@uniformdev/context/api";function $({apiHost:n,apiKey:t,projectId:o}){let[l,a]=Ze({loading:!1,notConfigured:!1,error:null,result:null});return Qe(()=>{if(!o||!t||!n){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 je({projectId:o,apiKey:t,apiHost:n}).get({preview:!0});a({notConfigured:!1,loading:!1,error:null,result:i})}catch(s){let i;s instanceof en?(s.statusCode===403&&(i=`The API key ${t} 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}})()},[n,t,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}import{LoadingIndicator as tn}from"@uniformdev/design-system";function Wt({children:n,versionMap:t,contextConfig:o}){let{loading:l,result:a}=$(o);if(l)return e(tn,null);if(a){let r=t[a.project.ui_version];if(r)return e(r,null)}return e(nn.Fragment,null,n)}import Ce,{createContext as on,useContext as K}from"react";import{LoadingIndicator as rn}from"@uniformdev/design-system";var A=on(null),Zt=({loadingComponent:n,errorComponent:t,contextConfig:o,children:l})=>{let a=$(o),r=I(o);return a.error||a.notConfigured?t?e(t,{contextConfig:o,result:a}):e(Ce.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?t?e(t,{contextConfig:o,result:r}):e(Ce.Fragment,null,"ErrorComponent is not configured"):a.loading||r.loading?n?e(n,null):e(rn,null):e(A.Provider,{value:{manifest:a.result,dimensions:r.result,contextConfig:o}},l)};function jt(){let n=K(A);if(!(n!=null&&n.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return n.contextConfig}function eo(){let n=K(A);if(!(n!=null&&n.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return n.manifest}function no(){let n=K(A);if(!(n!=null&&n.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return n.dimensions}import{validate as an}from"uuid";import{ManifestClient as sn}from"@uniformdev/context/api";var ve=async n=>{if(!n)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!n.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!n.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!an(n.apiKey)&&!n.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let t=new sn({projectId:n.projectId,apiKey:n.apiKey,apiHost:n.apiHost});try{let o=await t.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};import{useEffect as ln,useState as mn}from"react";var mo=n=>{let[t,o]=mn({validating:!1,error:void 0}),{apiKey:l,apiHost:a,projectId:r}=n||{};return ln(()=>{if(!l||!a)return;(async()=>{o({validating:!0,error:void 0});let{error:i,result:m}=await ve({apiHost:a,apiKey:l,projectId:r});o(i?{error:i,validating:!1}:{error:void 0,validating:!1,result:m})})()},[a,l,r]),{validating:t.validating,error:t.error,result:t.result}};function po(n){return Array.isArray(n)&&n.length>0&&n[0].cat!==void 0}function co(n){return n.crit!==void 0}export*from"@uniformdev/design-system";export{Zt as ContextData,pe as CriteriaMatchMenu,le as CriteriaOperatorMenu,ue as DimensionMenu,me as DimensionValue,X as EditLink,Rn as EnrichmentTag,Tt as PersonalizationCriteria,fe as PersonalizationCriteriaStatic,Wt as ProjectUIVersion,Ve as addEnrichmentLink,se as contextCriteriaMenuOperators,po as isEnrichmentTagData,co as isPersonalizationCriteriaData,jt as useContextConfig,$ as useContextData,I as useDimensions,no as useDimensionsDataContext,eo as useManifest,mo as useValidateContextConfig,ve as validateContextConfig};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ue=Object.create;var U=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var o in t)U(e,o,{get:t[o],enumerable:!0})},A=(e,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of He(t))!qe.call(e,i)&&i!==o&&U(e,i,{get:()=>t[i],enumerable:!(l=Ge(t,i))||l.enumerable});return e},w=(e,t,o)=>(A(e,t,"default"),o&&A(o,t,"default")),R=(e,t,o)=>(o=e!=null?Ue(We(e)):{},A(t||!e||!e.__esModule?U(o,"default",{value:e,enumerable:!0}):o,e)),Fe=e=>A(U({},"__esModule",{value:!0}),e);var x={};_e(x,{ContextData:()=>tn,CriteriaMatchMenu:()=>ce,CriteriaOperatorMenu:()=>le,DimensionMenu:()=>pe,DimensionValue:()=>ue,EditLink:()=>re,EnrichmentTag:()=>Ye,PersonalizationCriteria:()=>en,PersonalizationCriteriaStatic:()=>fe,ProjectUIVersion:()=>nn,addEnrichmentLink:()=>De,contextCriteriaMenuOperators:()=>se,isEnrichmentTagData:()=>ln,isPersonalizationCriteriaData:()=>mn,useContextConfig:()=>on,useContextData:()=>z,useDimensions:()=>P,useDimensionsDataContext:()=>an,useManifest:()=>rn,useValidateContextConfig:()=>sn,validateContextConfig:()=>ge});module.exports=Fe(x);var n=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`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
font-weight: var(--fw-bold);
|
|
@@ -9,7 +9,7 @@ var Ce=Object.create;var z=Object.defineProperty;var ve=Object.getOwnPropertyDes
|
|
|
9
9
|
&:focus {
|
|
10
10
|
text-decoration-line: underline;
|
|
11
11
|
}
|
|
12
|
-
`;var
|
|
12
|
+
`;var re=({linkTo:e,name:t,linkText:o=`Edit ${t} Component`})=>(0,n.jsx)("a",{css:ve,title:`Edit ${t} component definition`,rel:"noopener noreferrer",target:"_blank",href:e},o,(0,n.jsx)(he.Icon,{icon:be.CgChevronRight,iconColor:"currentColor",size:"1.5rem"}));var B=R(require("react"));var G=require("react"),O=require("@uniformdev/context/api");function ye(e,t,o){return e.reduce((l,i)=>{let r=t(i);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return l[t(i)]=o?o(i):i,l},{})}function P({apiHost:e,apiKey:t,projectId:o}){let[l,i]=(0,G.useState)({loading:!1,notConfigured:!1,error:null,result:null});return(0,G.useEffect)(()=>{if(!o||!t||!e){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:t,apiHost:e}).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}})()},[e,t,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`
|
|
13
13
|
flex: 2;
|
|
14
14
|
display: flex;
|
|
15
15
|
width: 50%;
|
|
@@ -20,7 +20,7 @@ var Ce=Object.create;var z=Object.defineProperty;var ve=Object.getOwnPropertyDes
|
|
|
20
20
|
&:focus {
|
|
21
21
|
text-decoration-line: underline;
|
|
22
22
|
}
|
|
23
|
-
`,
|
|
23
|
+
`,Ye=({value:e,setValue:t,contextConfig:o,displayTitle:l=!0})=>{let{loading:i,result:r,error:s}=P(o),a=(0,B.useMemo)(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),m=(0,B.useMemo)(()=>{if(!e)return a;if(a)return a.filter(g=>!e.some(D=>(0,H.getEnrichmentVectorKey)(D.cat,D.key)===g.dim))},[a,e]),[c,b]=(0,B.useState)(""),[u,C]=(0,B.useState)(50),[f,I]=(0,B.useState)(!1),d=a==null?void 0:a.find(g=>g.dim===c),v=()=>{let[g,D]=c.split("_");S([...e!=null?e:[],{cat:g,key:D,str:u}]),b(""),C(50),I(!1)},S=g=>{let D=[];r?D=g.filter(V=>{let $=r.dimIndex[(0,H.getEnrichmentVectorKey)(V.cat,V.key)];return Boolean($)}):D=g;let L=D.length===0?null:D;t(L)};return s?(0,n.jsx)(h.Callout,{type:"danger"},s):i||r===null?(0,n.jsx)(h.LoadingIndicator,null):(0,n.jsx)("fieldset",{className:"enrichment-tag"},l?(0,n.jsx)("div",{css:{display:"flex",justifyContent:"space-between",marginBottom:"var(--spacing-base)"}},(0,n.jsx)("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Enrichment Tags")):null,a!=null&&a.length?!f&&!e?(0,n.jsx)(h.Callout,{title:"No enrichment tags assigned.",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,n.jsx)("p",null,"Click"," ",(0,n.jsx)("a",{onClick:()=>I(!0),target:"_blank",rel:"noopener noreferrer",css:{textDecorationLine:"underline"}},"here")," ","to assign your first enrichment tag.")):(0,n.jsx)(B.default.Fragment,null,r&&(0,n.jsx)(Ze,{list:e!=null?e:[],setList:S,dimIndex:r.dimIndex}),f&&m&&m.length>0?(0,n.jsx)("div",{className:"add-enrichment-tag",css:{display:"flex",flexWrap:"wrap",gap:"var(--spacing-lg)",marginTop:"var(--spacing-md)",alignItems:"center"}},(0,n.jsx)("div",{css:{flexGrow:1}},(0,n.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,n.jsx)(Qe,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),(0,n.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,n.jsx)("div",{className:"enrichment-cta",style:{paddingTop:"10px",display:"flex",justifyContent:"space-between"}},!f&&m&&m.length>0&&e?(0,n.jsx)(h.AddListButton,{className:"add-more",buttonText:"Add More",onButtonClick:()=>I(!0)}):(0,n.jsx)("a",{css:De,title:"none",href:"#"}),(0,n.jsx)(re,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):(0,n.jsx)(Xe,{contextConfig:o}))},Xe=({contextConfig:e})=>(0,n.jsx)(h.Callout,{title:"No enrichments found.",type:"caution",css:{marginBlock:"var(--spacing-base)"}},(0,n.jsx)("p",null,"Looks like you do not have any enrichment created in your connected Uniform project. Start by creating your first enrichment"," ",(0,n.jsx)("a",{href:`${e.apiHost}/projects/${encodeURIComponent(e.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),xe=(e,t=100,o=0)=>Math.max(Math.min(e,t),o),Ie=W.css`
|
|
24
24
|
position: absolute;
|
|
25
25
|
bottom: 0.875rem;
|
|
26
26
|
left: var(--spacing-sm);
|
|
@@ -32,27 +32,27 @@ var Ce=Object.create;var z=Object.defineProperty;var ve=Object.getOwnPropertyDes
|
|
|
32
32
|
background-color: var(--gray-100);
|
|
33
33
|
border: 1px solid var(--gray-300);
|
|
34
34
|
border-radius: var(--rounded-full);
|
|
35
|
-
`,
|
|
36
|
-
${
|
|
35
|
+
`,Je=W.css`
|
|
36
|
+
${Ie}
|
|
37
37
|
left: auto;
|
|
38
38
|
right: var(--spacing-sm);
|
|
39
|
-
`,
|
|
39
|
+
`,Qe=({score:e,setValue:t,cap:o=100,...l})=>{let i=r=>{let s=r==="increment"?e+10:e-10;s<0&&(s=0),s>o&&(s=o),t(s)};return(0,n.jsx)("div",{css:{position:"relative"},...l},(0,n.jsx)(h.Input,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:e,onChange:r=>t(xe(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),(0,n.jsx)("button",{type:"button",title:"Reduce enrichment count",onClick:()=>i("decrement"),disabled:e===0,className:"scoreCounterButton",css:Ie},(0,n.jsx)(h.Icon,{icon:k.CgMathMinus,iconColor:"gray",size:"1.5rem"})),(0,n.jsx)("button",{type:"button",title:"Increase enrichment count",onClick:()=>i("increment"),className:"scoreCounterButton",css:Je},(0,n.jsx)(h.Icon,{icon:k.CgMathPlus,iconColor:"gray",size:"1.5rem"})))},Ze=({list:e,setList:t,dimIndex:o})=>{let l=r=>{t((0,ie.default)(e,s=>{s.splice(r,1)}))},i=(r,s)=>{var m;let a=(m=o[`${e[r].cat}_${e[r].key}`])==null?void 0:m.cap;t((0,ie.default)(e,c=>{c[r].str=xe(Number(s)||0,a)}))};return(0,n.jsx)(B.default.Fragment,null,e.map((r,s)=>{let a=o[(0,H.getEnrichmentVectorKey)(r.cat,r.key)];if(!!a)return(0,n.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,n.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,n.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,n.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,n.jsx)("button",{type:"button",title:"Delete enrichment",onClick:()=>l(s),css:{border:0}},(0,n.jsx)(h.Icon,{icon:k.CgCloseO,iconColor:"red",size:"1.5rem"})))}))};var N=require("@uniformdev/design-system");var E=require("@uniformdev/design-system"),de=R(require("immer")),Ve=require("react-icons/cg");var T=require("@emotion/react"),ae="6rem",we=T.css`
|
|
40
40
|
position: relative;
|
|
41
41
|
padding: var(--spacing-base);
|
|
42
42
|
border: 1px solid var(--gray-300);
|
|
43
43
|
box-shadow: var(--shadow-base);
|
|
44
44
|
background-color: white;
|
|
45
45
|
border-radius: var(--rounded-base);
|
|
46
|
-
margin-top: ${
|
|
46
|
+
margin-top: ${ae};
|
|
47
47
|
display: flex;
|
|
48
48
|
&:before {
|
|
49
49
|
content: '';
|
|
50
50
|
display: block;
|
|
51
51
|
width: 1px;
|
|
52
|
-
height: ${
|
|
52
|
+
height: ${ae};
|
|
53
53
|
background-color: var(--gray-300);
|
|
54
54
|
position: absolute;
|
|
55
|
-
top: -${
|
|
55
|
+
top: -${ae};
|
|
56
56
|
left: var(--spacing-lg);
|
|
57
57
|
}
|
|
58
58
|
&:first-of-type {
|
|
@@ -61,9 +61,18 @@ var Ce=Object.create;var z=Object.defineProperty;var ve=Object.getOwnPropertyDes
|
|
|
61
61
|
display: none;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,
|
|
64
|
+
`,Be=T.css`
|
|
65
65
|
display: grid;
|
|
66
|
-
gap: var(--spacing-
|
|
66
|
+
gap: var(--spacing-xs);
|
|
67
67
|
flex-grow: 1;
|
|
68
68
|
margin-right: var(--spacing-base);
|
|
69
|
-
|
|
69
|
+
`,q=T.css`
|
|
70
|
+
width: 100%;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: stretch;
|
|
73
|
+
`,_=T.css`
|
|
74
|
+
height: 100%;
|
|
75
|
+
width: 100%;
|
|
76
|
+
`,yn=T.css`
|
|
77
|
+
height: 100%;
|
|
78
|
+
`;var Me=require("@uniformdev/design-system");function F({op:e}){return(0,n.jsx)("div",{css:{background:"var(--gray-700)",color:"white",borderRadius:"100%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px"}},e)}var Se=e=>{var m,c;let{data:t,getStyles:o,isDisabled:l,innerRef:i,innerProps:r}=e,[s,a]=(c=(m=t.label)==null?void 0:m.split(":"))!=null?c:[];return(0,n.jsx)("div",{css:{...o("option",e),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:i,"aria-disabled":l,...r},a?(0,n.jsx)(F,{op:s}):(0,n.jsx)("div",{css:{width:"20px",height:"20px"}}),(0,n.jsx)("div",null,a!=null?a:s))};var Ee=e=>{let{data:t,getStyles:o}=e;return(0,n.jsx)("div",{css:{...o("singleValue",e),width:"max-content"}},t.label.length===1?(0,n.jsx)(F,{op:t.label}):t.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:e,value:t,...o}){var l,i;return(0,n.jsx)(Me.InputComboBox,{...o,value:{label:(i=(l=se.find(r=>r.value===t))==null?void 0:l.name)!=null?i:t,value:t},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&&e(r.value)},components:{SingleValue:Ee,Option:Se,...o.components}})}var Oe=require("@uniformdev/design-system");var Pe=require("@uniformdev/design-system");function me(e){return{label:e.displayName,value:e.dim,isDisabled:!1}}function K(e){if(!e)return"unavailable";let[t]=e.split(":");switch(t.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function Y(e){let t=[],o="";for(let l of e){let[i]=l.displayName.split(":");o!==i&&(t.push({label:i,options:[]}),o=i),t[t.length-1].options.push(me(l))}return t}var X=e=>{var i;let{data:t,getStyles:o,className:l}=e;return(0,n.jsx)("div",{css:{...o("groupHeading",e),textTransform:"none",fontSize:"var(--font-size-sm)"},className:l},(0,n.jsx)("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},(0,n.jsx)(Pe.Icon,{icon:K((i=t.label)!=null?i:""),iconColor:"currentColor",size:16}),(0,n.jsx)("span",null,t.label)))};function J({message:e}){return e?(0,n.jsx)("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},e):null}var Q=e=>{var u,C;let{data:t,getStyles:o,cx:l,isDisabled:i,isFocused:r,isSelected:s,className:a,innerRef:m,innerProps:c}=e,[,b]=(C=(u=t.label)==null?void 0:u.split(":"))!=null?C:[];return(0,n.jsx)("div",{css:o("option",e),className:l({option:!0,"option--is-disabled":i,"option--is-focused":r,"option--is-selected":s},a),ref:m,"aria-disabled":i,...c},(0,n.jsx)("div",{css:{color:"var(--gray-700)"}},b!=null?b:t.label))};var Re=require("@uniformdev/design-system");function ue({displayName:e}){let[t,o]=e.split(":");return(0,n.jsx)("div",{css:{whiteSpace:"normal",overflow:"hidden"}},o?(0,n.jsx)("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},t?(0,n.jsx)(Re.Icon,{icon:K(t),iconColor:"currentColor",size:16}):null,(0,n.jsx)("span",null,t)):null,(0,n.jsx)("div",{css:{color:"var(--gray-700)"}},o!=null?o:t))}var Z=e=>{let{data:t,getStyles:o}=e;return(0,n.jsx)("div",{css:o("singleValue",e)},(0,n.jsx)(ue,{displayName:t.label}))};function pe({onChange:e,value:t,dimensions:o,errorMessage:l,...i}){return(0,n.jsx)(p.Fragment,null,(0,n.jsx)(Oe.InputComboBox,{...i,value:t?me(t):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&&e(o.find(s=>s.dim===r.value))},components:{Option:Q,SingleValue:Z,GroupHeading:X,...i.components}}),(0,n.jsx)(J,{message:l}))}var ke=require("@uniformdev/design-system"),Te=require("react");function ce({onChange:e,criteriaMatch:t,dimensions:o,errorMessage:l,...i}){var c,b;let[r,s]=(0,Te.useState)(typeof t.r!="undefined"&&j(t.r)!==null?t.r.toString(10):""),a=t.rDim,m=t.rDim?o.dimIndex[t.rDim]:void 0;return(0,n.jsx)(p.Fragment,null,(0,n.jsx)(ke.InputComboBox,{...i,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=m==null?void 0:m.displayName)!=null?c:a&&!m?`${t.rDim} (unknown)`:"",value:(b=t.rDim)!=null?b:t.r?t.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&&(e({...t,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==="")&&e({...t,r:u||void 0,rDim:void 0})):!f&&!j(C.prevInputValue)&&(!u&&t.r?s(t.r.toString()):s(u))},components:{...i.components,Option:Q,SingleValue:Z,GroupHeading:X},noOptionsMessage:({inputValue:u})=>j(u)?(0,n.jsx)(p.Fragment,null,(0,n.jsx)("div",null,"Score: ",u),(0,n.jsx)("small",null,"If you want to match on another dimension\u2019s score instead, clear the score value to search for a dimension.")):(0,n.jsx)(p.Fragment,null,(0,n.jsx)("div",null,"No dimensions match your search \u201C",u,"\u201D"),(0,n.jsx)("small",null,"If you want to match a literal score, enter a numeric value."))}),(0,n.jsx)(J,{message:l}))}function j(e){return/^\d+$/.test(e.toString(10))}var fe=({value:e,setValue:t,dimensions:o,onMenuOpen:l,onMenuClose:i,onAddCriteria:r,onRemoveCriteria:s,displayTitle:a=!0,components:m,errors:c={}})=>{let b=e||{crit:[]},u=d=>{t({...b,op:d==="&"?void 0:d})},C=()=>{let d={...b,crit:[...b.crit,{l:"",op:">",r:0}]};t(d),r==null||r(d)},f=(d,v)=>{t((0,de.default)(b,S=>{S.crit[v]=d}))},I=d=>{let v=(0,de.default)(b,g=>{g.crit.splice(d,1)}),S=v.crit.length===0?null:v;t(S),s==null||s(S)};return(0,n.jsx)("fieldset",{className:"personalization-criteria"},a?m!=null&&m.Title?(0,n.jsx)(m.Title,null):(0,n.jsx)("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,b.crit.length?b.crit.map((d,v)=>{var D,L,V,$;let S=((D=d.l)==null?void 0:D.length)>0,g=d.op!=="+"&&d.op!=="-";return(0,n.jsx)("div",{css:we,key:v},(0,n.jsx)("div",{css:Be,style:{gridTemplateColumns:`minmax(0, 1fr) ${g?"minmax(0, 79px) minmax(0, 1fr)":"minmax(0, 1fr)"}`},className:"criteriaItemInner"},(0,n.jsx)("div",{css:q},(0,n.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]})),(0,n.jsx)("div",{css:q},(0,n.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,n.jsx)("div",{css:q},(0,n.jsx)(ce,{errorMessage:(V=c.rhs)==null?void 0:V[v],css:_,styles:{control:y=>({...y,height:"100%"})},criteriaMatch:d,onChange:y=>{f(y,v)},isDisabled:!S,dimensions:o,onMenuOpen:l,onMenuClose:i})):null),(0,n.jsx)("button",{type:"button",onClick:()=>I(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0}},(0,n.jsx)(E.Icon,{icon:Ve.CgCloseO,iconColor:"red",size:"1.5rem"})),v>0?(0,n.jsx)("div",{className:"criteria-group-operation",css:{position:"absolute",top:"-4rem",transform:"translateX(calc(1.5rem - 50%))"}},(0,n.jsx)(E.InputInlineSelect,{disabled:v>1,value:($=b.op)!=null?$:"&",options:[{label:"AND",value:"&"},{label:"OR",value:"|"}],onChange:y=>{u(y.value)}})):null)}):(0,n.jsx)(E.Callout,{title:"Default variant",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,n.jsx)("p",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,n.jsx)(m.NoDimensionsDefined,null):(0,n.jsx)(E.Callout,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,n.jsx)("p",null,"You do not have any dimensions configured.")):(0,n.jsx)(E.AddListButton,{className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var en=({contextConfig:e,...t})=>{let{loading:o,result:l,error:i}=P(e);return i?(0,n.jsx)(N.Callout,{type:"danger"},i):o||l===null?(0,n.jsx)(N.LoadingIndicator,null):(0,n.jsx)(fe,{...t,dimensions:l,components:{NoDimensionsDefined:()=>(0,n.jsx)(N.Callout,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},(0,n.jsx)("p",null,"You do not have any dimensions configured. Create your first"," ",(0,n.jsx)("a",{href:`${e.apiHost}/projects/${encodeURIComponent(e.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};var Ne=R(require("react"));var ee=require("react"),ne=require("@uniformdev/context/api");function z({apiHost:e,apiKey:t,projectId:o}){let[l,i]=(0,ee.useState)({loading:!1,notConfigured:!1,error:null,result:null});return(0,ee.useEffect)(()=>{if(!o||!t||!e){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 ne.ManifestClient({projectId:o,apiKey:t,apiHost:e}).get({preview:!0});i({notConfigured:!1,loading:!1,error:null,result:a})}catch(s){let a;s instanceof ne.ApiClientError?(s.statusCode===403&&(a=`The API key ${t} 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}})()},[e,t,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}var ze=require("@uniformdev/design-system");function nn({children:e,versionMap:t,contextConfig:o}){let{loading:l,result:i}=z(o);if(l)return(0,n.jsx)(ze.LoadingIndicator,null);if(i){let r=t[i.project.ui_version];if(r)return(0,n.jsx)(r,null)}return(0,n.jsx)(Ne.default.Fragment,null,e)}var M=R(require("react"));var Le=require("@uniformdev/design-system"),te=(0,M.createContext)(null),tn=({loadingComponent:e,errorComponent:t,contextConfig:o,children:l})=>{let i=z(o),r=P(o);return i.error||i.notConfigured?t?(0,n.jsx)(t,{contextConfig:o,result:i}):(0,n.jsx)(M.default.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?t?(0,n.jsx)(t,{contextConfig:o,result:r}):(0,n.jsx)(M.default.Fragment,null,"ErrorComponent is not configured"):i.loading||r.loading?e?(0,n.jsx)(e,null):(0,n.jsx)(Le.LoadingIndicator,null):(0,n.jsx)(te.Provider,{value:{manifest:i.result,dimensions:r.result,contextConfig:o}},l)};function on(){let e=(0,M.useContext)(te);if(!(e!=null&&e.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return e.contextConfig}function rn(){let e=(0,M.useContext)(te);if(!(e!=null&&e.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return e.manifest}function an(){let e=(0,M.useContext)(te);if(!(e!=null&&e.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return e.dimensions}var $e=require("uuid"),Ae=require("@uniformdev/context/api"),ge=async e=>{if(!e)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!e.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!e.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!(0,$e.validate)(e.apiKey)&&!e.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let t=new Ae.ManifestClient({projectId:e.projectId,apiKey:e.apiKey,apiHost:e.apiHost});try{let o=await t.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};var oe=require("react");var sn=e=>{let[t,o]=(0,oe.useState)({validating:!1,error:void 0}),{apiKey:l,apiHost:i,projectId:r}=e||{};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:t.validating,error:t.error,result:t.result}};function ln(e){return Array.isArray(e)&&e.length>0&&e[0].cat!==void 0}function mn(e){return e.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});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e}from"@emotion/react";import*as
|
|
1
|
+
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`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
font-weight: var(--fw-bold);
|
|
@@ -9,7 +9,7 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
9
9
|
&:focus {
|
|
10
10
|
text-decoration-line: underline;
|
|
11
11
|
}
|
|
12
|
-
`;var
|
|
12
|
+
`;var X=({linkTo:n,name:t,linkText:o=`Edit ${t} Component`})=>e("a",{css:Y,title:`Edit ${t} component definition`,rel:"noopener noreferrer",target:"_blank",href:n},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 Se}from"@uniformdev/context/api";function J(n,t,o){return n.reduce((l,a)=>{let r=t(a);if(typeof r=="undefined"||r===null)throw new Error("Objectify key selector returned undefined or null.");return l[t(a)]=o?o(a):a,l},{})}function I({apiHost:n,apiKey:t,projectId:o}){let[l,a]=Ie({loading:!1,notConfigured:!1,error:null,result:null});return xe(()=>{if(!o||!t||!n){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:t,apiHost:n}).get()).dimensions.map(c=>({...c,displayName:Be(c)})),m={dimensions:i,dimIndex:J(i,c=>c.dim,c=>c)};a({notConfigured:!1,loading:!1,error:null,result:m})}catch(s){let i;s instanceof Se?i=s.message:i=s.toString(),a({notConfigured:!1,loading:!1,error:i,result:null});return}})()},[n,t,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}import{getEnrichmentVectorKey as G}from"@uniformdev/context";import{Input as ee,Button as Ee,InputSelect as Me,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 Ve=q`
|
|
13
13
|
flex: 2;
|
|
14
14
|
display: flex;
|
|
15
15
|
width: 50%;
|
|
@@ -20,7 +20,7 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
20
20
|
&:focus {
|
|
21
21
|
text-decoration-line: underline;
|
|
22
22
|
}
|
|
23
|
-
`,
|
|
23
|
+
`,Rn=({value:n,setValue:t,contextConfig:o,displayTitle:l=!0})=>{let{loading:a,result:r,error:s}=I(o),i=Q(()=>{if(r)return r.dimensions.filter(g=>g.category==="ENR")},[r]),m=Q(()=>{if(!n)return i;if(i)return i.filter(g=>!n.some(y=>G(y.cat,y.key)===g.dim))},[i,n]),[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([...n!=null?n:[],{cat:g,key:y,str:u}]),h(""),C(50),D(!1)},x=g=>{let y=[];r?y=g.filter(w=>{let E=r.dimIndex[G(w.cat,w.key)];return Boolean(E)}):y=g;let S=y.length===0?null:y;t(S)};return s?e(H,{type:"danger"},s):a||r===null?e(Pe,null):e("fieldset",{className:"enrichment-tag"},l?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&&!n?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:n!=null?n:[],setList:x,dimIndex:r.dimIndex}),f&&m&&m.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(Me,{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=>h(g.currentTarget.value)})),e(Le,{score:u,setValue:C,cap:d?d.cap:100,css:{flexBasis:"9rem"}}),e(Ee,{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&&m&&m.length>0&&n?e(Re,{className:"add-more",buttonText:"Add More",onButtonClick:()=>D(!0)}):e("a",{css:Ve,title:"none",href:"#"}),e(X,{name:"Enrichments",linkText:"Manage Enrichments",linkTo:`${o.apiHost}/projects/${encodeURIComponent(o.projectId)}/personalization/enrichments`}))):e(Ne,{contextConfig:o}))},Ne=({contextConfig:n})=>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:`${n.apiHost}/projects/${encodeURIComponent(n.projectId)}/personalization/enrichments`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"here"),".")),ne=(n,t=100,o=0)=>Math.max(Math.min(n,t),o),te=q`
|
|
24
24
|
position: absolute;
|
|
25
25
|
bottom: 0.875rem;
|
|
26
26
|
left: var(--spacing-sm);
|
|
@@ -32,27 +32,27 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
32
32
|
background-color: var(--gray-100);
|
|
33
33
|
border: 1px solid var(--gray-300);
|
|
34
34
|
border-radius: var(--rounded-full);
|
|
35
|
-
`,
|
|
36
|
-
${
|
|
35
|
+
`,ze=q`
|
|
36
|
+
${te}
|
|
37
37
|
left: auto;
|
|
38
38
|
right: var(--spacing-sm);
|
|
39
|
-
`,
|
|
39
|
+
`,Le=({score:n,setValue:t,cap:o=100,...l})=>{let a=r=>{let s=r==="increment"?n+10:n-10;s<0&&(s=0),s>o&&(s=o),t(s)};return e("div",{css:{position:"relative"},...l},e(ee,{label:"Strength",id:"enrichment-score",type:"number",min:0,max:o,value:n,onChange:r=>t(ne(Number(r.currentTarget.value)||0,o)),css:{textAlign:"center",boxSizing:"border-box"}}),e("button",{type:"button",title:"Reduce enrichment count",onClick:()=>a("decrement"),disabled:n===0,className:"scoreCounterButton",css:te},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:n,setList:t,dimIndex:o})=>{let l=r=>{t(Z(n,s=>{s.splice(r,1)}))},a=(r,s)=>{var m;let i=(m=o[`${n[r].cat}_${n[r].key}`])==null?void 0:m.cap;t(Z(n,c=>{c[r].str=ne(Number(s)||0,i)}))};return e(j.Fragment,null,n.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:m=>a(s,m.currentTarget.value)})),e("button",{type:"button",title:"Delete enrichment",onClick:()=>l(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{Callout as ce,InputInlineSelect as Fe,Icon as Ke,AddListButton as Ye}from"@uniformdev/design-system";import de from"immer";import{CgCloseO as Xe}from"react-icons/cg";import{css as B}from"@emotion/react";var _="6rem",oe=B`
|
|
40
40
|
position: relative;
|
|
41
41
|
padding: var(--spacing-base);
|
|
42
42
|
border: 1px solid var(--gray-300);
|
|
43
43
|
box-shadow: var(--shadow-base);
|
|
44
44
|
background-color: white;
|
|
45
45
|
border-radius: var(--rounded-base);
|
|
46
|
-
margin-top: ${
|
|
46
|
+
margin-top: ${_};
|
|
47
47
|
display: flex;
|
|
48
48
|
&:before {
|
|
49
49
|
content: '';
|
|
50
50
|
display: block;
|
|
51
51
|
width: 1px;
|
|
52
|
-
height: ${
|
|
52
|
+
height: ${_};
|
|
53
53
|
background-color: var(--gray-300);
|
|
54
54
|
position: absolute;
|
|
55
|
-
top: -${
|
|
55
|
+
top: -${_};
|
|
56
56
|
left: var(--spacing-lg);
|
|
57
57
|
}
|
|
58
58
|
&:first-of-type {
|
|
@@ -61,9 +61,18 @@ import{jsx as e}from"@emotion/react";import*as h from"react";import{Icon as re}f
|
|
|
61
61
|
display: none;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,
|
|
64
|
+
`,re=B`
|
|
65
65
|
display: grid;
|
|
66
|
-
gap: var(--spacing-
|
|
66
|
+
gap: var(--spacing-xs);
|
|
67
67
|
flex-grow: 1;
|
|
68
68
|
margin-right: var(--spacing-base);
|
|
69
|
-
|
|
69
|
+
`,M=B`
|
|
70
|
+
width: 100%;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: stretch;
|
|
73
|
+
`,P=B`
|
|
74
|
+
height: 100%;
|
|
75
|
+
width: 100%;
|
|
76
|
+
`,Tn=B`
|
|
77
|
+
height: 100%;
|
|
78
|
+
`;import{InputComboBox as Ue}from"@uniformdev/design-system";function R({op:n}){return e("div",{css:{background:"var(--gray-700)",color:"white",borderRadius:"100%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px"}},n)}var ie=n=>{var m,c;let{data:t,getStyles:o,isDisabled:l,innerRef:a,innerProps:r}=n,[s,i]=(c=(m=t.label)==null?void 0:m.split(":"))!=null?c:[];return e("div",{css:{...o("option",n),display:"flex",alignItems:"center",gap:"var(--spacing-sm)"},ref:a,"aria-disabled":l,...r},i?e(R,{op:s}):e("div",{css:{width:"20px",height:"20px"}}),e("div",null,i!=null?i:s))};var ae=n=>{let{data:t,getStyles:o}=n;return e("div",{css:{...o("singleValue",n),width:"max-content"}},t.label.length===1?e(R,{op:t.label}):t.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:n,value:t,...o}){var l,a;return e(Ue,{...o,value:{label:(a=(l=se.find(r=>r.value===t))==null?void 0:l.name)!=null?a:t,value:t},options:se.map(r=>({label:r.description?`${r.name}:${r.description}`:r.name,value:r.value})),styles:{...o.styles,valueContainer:(r,s)=>{var i,m;return{...r,padding:"var(--spacing-sm)",...(m=(i=o.styles)==null?void 0:i.valueContainer)==null?void 0:m.call(i,r,s)}},menu:(r,s)=>{var i,m;return{...r,width:"max-content",...(m=(i=o.styles)==null?void 0:i.menu)==null?void 0:m.call(i,r,s)}},control:(r,s)=>{var i,m;return{...r,border:0,...(m=(i=o.styles)==null?void 0:i.control)==null?void 0:m.call(i,r,s)}},indicatorSeparator:(r,s)=>{var i,m;return{...r,display:"none",...(m=(i=o.styles)==null?void 0:i.indicatorSeparator)==null?void 0:m.call(i,r,s)}}},onChange:r=>{r&&n(r.value)},components:{SingleValue:ae,Option:ie,...o.components}})}import{InputComboBox as We}from"@uniformdev/design-system";import{Icon as Ge}from"@uniformdev/design-system";function F(n){return{label:n.displayName,value:n.dim,isDisabled:!1}}function O(n){if(!n)return"unavailable";let[t]=n.split(":");switch(t.toLowerCase()){case"signal":return"data";case"intent":return"assign";case"audience":return"boy";default:return"user-list"}}function k(n){let t=[],o="";for(let l of n){let[a]=l.displayName.split(":");o!==a&&(t.push({label:a,options:[]}),o=a),t[t.length-1].options.push(F(l))}return t}var T=n=>{var a;let{data:t,getStyles:o,className:l}=n;return e("div",{css:{...o("groupHeading",n),textTransform:"none",fontSize:"var(--font-size-sm)"},className:l},e("small",{css:{color:"var(--gray-500)",display:"flex",alignItems:"center",gap:"var(--spacing-xs)"}},e(Ge,{icon:O((a=t.label)!=null?a:""),iconColor:"currentColor",size:16}),e("span",null,t.label)))};function V({message:n}){return n?e("div",{css:{position:"absolute",background:"white",borderRadius:"3px",fontSize:"0.8rem",color:"var(--brand-primary-2)",bottom:"calc(var(--spacing-xs) * -1)"}},n):null}var N=n=>{var u,C;let{data:t,getStyles:o,cx:l,isDisabled:a,isFocused:r,isSelected:s,className:i,innerRef:m,innerProps:c}=n,[,h]=(C=(u=t.label)==null?void 0:u.split(":"))!=null?C:[];return e("div",{css:o("option",n),className:l({option:!0,"option--is-disabled":a,"option--is-focused":r,"option--is-selected":s},i),ref:m,"aria-disabled":a,...c},e("div",{css:{color:"var(--gray-700)"}},h!=null?h:t.label))};import{Icon as He}from"@uniformdev/design-system";function me({displayName:n}){let[t,o]=n.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)"}},t?e(He,{icon:O(t),iconColor:"currentColor",size:16}):null,e("span",null,t)):null,e("div",{css:{color:"var(--gray-700)"}},o!=null?o:t))}var z=n=>{let{data:t,getStyles:o}=n;return e("div",{css:o("singleValue",n)},e(me,{displayName:t.label}))};function ue({onChange:n,value:t,dimensions:o,errorMessage:l,...a}){return e(p.Fragment,null,e(We,{...a,value:t?F(t):void 0,options:k(o),styles:{...a.styles,valueContainer:(r,s)=>{var i,m;return{...r,padding:"var(--spacing-sm)",...(m=(i=a.styles)==null?void 0:i.valueContainer)==null?void 0:m.call(i,r,s)}}},onChange:r=>{r&&n(o.find(s=>s.dim===r.value))},components:{Option:N,SingleValue:z,GroupHeading:T,...a.components}}),e(V,{message:l}))}import{InputComboBox as qe}from"@uniformdev/design-system";import{useState as _e}from"react";function pe({onChange:n,criteriaMatch:t,dimensions:o,errorMessage:l,...a}){var c,h;let[r,s]=_e(typeof t.r!="undefined"&&L(t.r)!==null?t.r.toString(10):""),i=t.rDim,m=t.rDim?o.dimIndex[t.rDim]:void 0;return e(p.Fragment,null,e(qe,{...a,inputValue:r,menuShouldScrollIntoView:!0,value:{label:(c=m==null?void 0:m.displayName)!=null?c:i&&!m?`${t.rDim} (unknown)`:"",value:(h=t.rDim)!=null?h:t.r?t.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&&(n({...t,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==="")&&n({...t,r:u||void 0,rDim:void 0})):!f&&!L(C.prevInputValue)&&(!u&&t.r?s(t.r.toString()):s(u))},components:{...a.components,Option:N,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(V,{message:l}))}function L(n){return/^\d+$/.test(n.toString(10))}var fe=({value:n,setValue:t,dimensions:o,onMenuOpen:l,onMenuClose:a,onAddCriteria:r,onRemoveCriteria:s,displayTitle:i=!0,components:m,errors:c={}})=>{let h=n||{crit:[]},u=d=>{t({...h,op:d==="&"?void 0:d})},C=()=>{let d={...h,crit:[...h.crit,{l:"",op:">",r:0}]};t(d),r==null||r(d)},f=(d,v)=>{t(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;t(x),s==null||s(x)};return e("fieldset",{className:"personalization-criteria"},i?m!=null&&m.Title?e(m.Title,null):e("legend",{css:{fontSize:"var(--fs-md)",fontWeight:"var(--fw-bold)"}},"Personalize This"):null,h.crit.length?h.crit.map((d,v)=>{var y,S,w,E;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:re,style:{gridTemplateColumns:`minmax(0, 1fr) ${g?"minmax(0, 79px) minmax(0, 1fr)":"minmax(0, 1fr)"}`},className:"criteriaItemInner"},e("div",{css:M},e(ue,{errorMessage:(S=c.lhs)==null?void 0:S[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]})),e("div",{css:M},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:l,onMenuClose:a})),g?e("div",{css:M},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:l,onMenuClose:a})):null),e("button",{type:"button",onClick:()=>D(v),title:"Delete Personalization",css:{backgroundColor:"transparent",backgroundImage:"none",borderWidth:0}},e(Ke,{icon:Xe,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(Fe,{disabled:v>1,value:(E=h.op)!=null?E:"&",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("p",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?e(m.NoDimensionsDefined,null):e(ce,{title:"Dimensions",type:"info",css:{marginBlock:"var(--spacing-base)"}},e("p",null,"You do not have any dimensions configured.")):e(Ye,{className:"add-more",buttonText:"Add Criteria",onButtonClick:C}))};var Tt=({contextConfig:n,...t})=>{let{loading:o,result:l,error:a}=I(n);return a?e(ge,{type:"danger"},a):o||l===null?e(Je,null):e(fe,{...t,dimensions:l,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:`${n.apiHost}/projects/${encodeURIComponent(n.projectId)}/personalization/signals`,target:"_blank",rel:"noopener noreferrer",css:{":hover":{textDecorationLine:"underline"}}},"Dimension")))}})};import nn from"react";import{useEffect as Qe,useState as Ze}from"react";import{ManifestClient as je,ApiClientError as en}from"@uniformdev/context/api";function $({apiHost:n,apiKey:t,projectId:o}){let[l,a]=Ze({loading:!1,notConfigured:!1,error:null,result:null});return Qe(()=>{if(!o||!t||!n){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 je({projectId:o,apiKey:t,apiHost:n}).get({preview:!0});a({notConfigured:!1,loading:!1,error:null,result:i})}catch(s){let i;s instanceof en?(s.statusCode===403&&(i=`The API key ${t} 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}})()},[n,t,o]),{result:l.result,error:l.error,loading:l.loading,notConfigured:l.notConfigured}}import{LoadingIndicator as tn}from"@uniformdev/design-system";function Wt({children:n,versionMap:t,contextConfig:o}){let{loading:l,result:a}=$(o);if(l)return e(tn,null);if(a){let r=t[a.project.ui_version];if(r)return e(r,null)}return e(nn.Fragment,null,n)}import Ce,{createContext as on,useContext as K}from"react";import{LoadingIndicator as rn}from"@uniformdev/design-system";var A=on(null),Zt=({loadingComponent:n,errorComponent:t,contextConfig:o,children:l})=>{let a=$(o),r=I(o);return a.error||a.notConfigured?t?e(t,{contextConfig:o,result:a}):e(Ce.Fragment,null,"ErrorComponent is not configured"):r.error||r.notConfigured?t?e(t,{contextConfig:o,result:r}):e(Ce.Fragment,null,"ErrorComponent is not configured"):a.loading||r.loading?n?e(n,null):e(rn,null):e(A.Provider,{value:{manifest:a.result,dimensions:r.result,contextConfig:o}},l)};function jt(){let n=K(A);if(!(n!=null&&n.contextConfig))throw new Error("Not within DataContext! Configuration data is not exist.");return n.contextConfig}function eo(){let n=K(A);if(!(n!=null&&n.manifest))throw new Error("Not within DataContext! Manifest data is not exist.");return n.manifest}function no(){let n=K(A);if(!(n!=null&&n.dimensions))throw new Error("Not within DataContext! Dimensions data is not exist.");return n.dimensions}import{validate as an}from"uuid";import{ManifestClient as sn}from"@uniformdev/context/api";var ve=async n=>{if(!n)return{valid:!1,error:new Error("contextConfig was not defined.")};if(!n.apiHost)return{valid:!1,error:new Error("apiHost was not defined.")};if(!n.apiKey)return{valid:!1,error:new Error("apiKey was not defined.")};if(!an(n.apiKey)&&!n.projectId)return{valid:!1,error:new Error("projectId is required when using a modern API key.")};let t=new sn({projectId:n.projectId,apiKey:n.apiKey,apiHost:n.apiHost});try{let o=await t.get({preview:!0});return{valid:!0,result:o}}catch(o){return{valid:!1,error:o}}};import{useEffect as ln,useState as mn}from"react";var mo=n=>{let[t,o]=mn({validating:!1,error:void 0}),{apiKey:l,apiHost:a,projectId:r}=n||{};return ln(()=>{if(!l||!a)return;(async()=>{o({validating:!0,error:void 0});let{error:i,result:m}=await ve({apiHost:a,apiKey:l,projectId:r});o(i?{error:i,validating:!1}:{error:void 0,validating:!1,result:m})})()},[a,l,r]),{validating:t.validating,error:t.error,result:t.result}};function po(n){return Array.isArray(n)&&n.length>0&&n[0].cat!==void 0}function co(n){return n.crit!==void 0}export*from"@uniformdev/design-system";export{Zt as ContextData,pe as CriteriaMatchMenu,le as CriteriaOperatorMenu,ue as DimensionMenu,me as DimensionValue,X as EditLink,Rn as EnrichmentTag,Tt as PersonalizationCriteria,fe as PersonalizationCriteriaStatic,Wt as ProjectUIVersion,Ve as addEnrichmentLink,se as contextCriteriaMenuOperators,po as isEnrichmentTagData,co as isPersonalizationCriteriaData,jt as useContextConfig,$ as useContextData,I as useDimensions,no as useDimensionsDataContext,eo as useManifest,mo as useValidateContextConfig,ve as validateContextConfig};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/context-ui",
|
|
3
|
-
"version": "16.1.1-alpha.
|
|
3
|
+
"version": "16.1.1-alpha.294+787422ba9",
|
|
4
4
|
"description": "React-based functionality and components for Uniform Context",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,13 +14,7 @@
|
|
|
14
14
|
"require": "./dist/index.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"*": {
|
|
19
|
-
"*": [
|
|
20
|
-
"./dist/index.d.ts"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
},
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
24
18
|
"sideEffects": false,
|
|
25
19
|
"scripts": {
|
|
26
20
|
"build": "pnpm build:esm",
|
|
@@ -31,12 +25,14 @@
|
|
|
31
25
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
32
26
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
33
27
|
"storybook": "pnpm build && start-storybook -p 9011 -c ./.storybook",
|
|
34
|
-
"
|
|
28
|
+
"deploy": "run-s deploy:storybook deploy:netlify",
|
|
29
|
+
"deploy:storybook": "pnpm build && pnpm build-storybook -o ./out",
|
|
30
|
+
"deploy:netlify": "tsx ../../scripts/deploy-to-netlify.ts"
|
|
35
31
|
},
|
|
36
32
|
"dependencies": {
|
|
37
33
|
"@emotion/react": "11.9.3",
|
|
38
|
-
"@uniformdev/context": "^16.1.1-alpha.
|
|
39
|
-
"@uniformdev/design-system": "^16.1.1-alpha.
|
|
34
|
+
"@uniformdev/context": "^16.1.1-alpha.294+787422ba9",
|
|
35
|
+
"@uniformdev/design-system": "^16.1.1-alpha.294+787422ba9",
|
|
40
36
|
"immer": "9.0.15",
|
|
41
37
|
"react-beautiful-dnd": "13.1.0",
|
|
42
38
|
"react-icons": "^4.3.1",
|
|
@@ -67,9 +63,9 @@
|
|
|
67
63
|
"autoprefixer": "10.4.7",
|
|
68
64
|
"postcss": "8.4.14",
|
|
69
65
|
"postcss-import": "14.1.0",
|
|
70
|
-
"react": "18.
|
|
71
|
-
"react-dom": "18.
|
|
72
|
-
"webpack": "5.
|
|
66
|
+
"react": "18.2.0",
|
|
67
|
+
"react-dom": "18.2.0",
|
|
68
|
+
"webpack": "5.73.0"
|
|
73
69
|
},
|
|
74
70
|
"files": [
|
|
75
71
|
"/dist"
|
|
@@ -77,5 +73,5 @@
|
|
|
77
73
|
"publishConfig": {
|
|
78
74
|
"access": "public"
|
|
79
75
|
},
|
|
80
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "787422ba907e4819d9d4243724c3c3286f3c9aed"
|
|
81
77
|
}
|