@uniformdev/mesh-sdk-react 13.0.0-beta.0 → 13.0.1-alpha.96
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 +311 -14
- package/dist/index.esm.js +522 -1
- package/dist/index.js +522 -1
- package/dist/index.mjs +522 -1
- package/package.json +57 -22
package/dist/index.esm.js
CHANGED
|
@@ -1 +1,522 @@
|
|
|
1
|
-
|
|
1
|
+
var rr=Object.defineProperty;var or=(t,n)=>{for(var o in n)rr(t,o,{get:n[o],enumerable:!0})};import{jsx as e}from"@emotion/react";import*as k from"react";import{createContext as nr,useContext as ar,useState as ir}from"react";var Le=nr(void 0),Me=({children:t})=>{let[n,o]=ir(),r;if(typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"){let c=n||window.UniformMeshSDK.getCurrentLocation();r={location:{getValue:c.getValue,getMetadata:c.getMetadata,setValue:async d=>{await c.setValue(d),o(window.UniformMeshSDK.getCurrentLocation())}}}}return e(Le.Provider,{value:r},t)},Ve=()=>{let t=ar(Le);if(!t)throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");return t};function go(){let{location:t}=Ve();return{value:t==null?void 0:t.getValue(),setValue:t==null?void 0:t.setValue,metadata:t==null?void 0:t.getMetadata()}}import{initializeUniformMeshSDK as sr}from"@uniformdev/mesh-sdk";import{useEffect as cr,useState as Ee}from"react";var yo=({autoResizingDisabled:t}={})=>{let[n,o]=Ee(),[r,c]=Ee();return cr(()=>{typeof window=="undefined"||r||(typeof window.UniformMeshSDK=="undefined"?sr({autoResizingDisabled:t}).then(d=>{c(d)}).catch(d=>{o(d)}):c(window.UniformMeshSDK))},[t]),{initializing:!r&&!n,error:n,sdk:r}};import{createContext as dr,useContext as lr}from"react";import{Theme as pr}from"@uniformdev/design-system";var Ie=dr(void 0),ko=({children:t})=>{let n;return typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"&&(n={sdk:window.UniformMeshSDK}),e(Ie.Provider,{value:n},e(pr,null),e(Me,null,t))},Te=()=>{let t=lr(Ie);if(!t)throw new Error("useUniformMeshSdkContext must be used within a UniformMeshSdkContextProvider");return t};function Mo(){let{sdk:t}=Te();return t}import Ke from"react";import fr,{useMemo as le,useContext as vr}from"react";import{css as q}from"@emotion/react";import{InputSelect as mr}from"@uniformdev/design-system";import De from"react";var Ge=({value:t,text:n,loading:o})=>e(De.Fragment,null,!!n&&n,!n&&e(De.Fragment,null,o&&`${t} (Loading...)`,!o&&`${t} (Unresolvable)`));var ze=({name:t,loading:n,selectedValues:o,values:r,onAdd:c,onRemove:d})=>{var h;let v=(h=r==null?void 0:r.filter(u=>!(o!=null&&o.includes(u.id.toString()))))!=null?h:[],b=(u,s)=>{u.preventDefault(),d(s)};return e("div",null,e(mr,{id:"product-query",name:"product-query",label:t,onChange:u=>c(u.target.value),disabled:n,options:[{value:"",label:"Add..."},...v.map(u=>({value:u.id,label:u.name||u.id}))],css:Array.isArray(o)&&o.length>0?q`
|
|
2
|
+
margin-bottom: var(--spacing-base);
|
|
3
|
+
`:""}),o==null?void 0:o.map(u=>{var s;return e("div",{css:q`
|
|
4
|
+
font-size: var(--fs-sm);
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
background-color: var(--gray-100);
|
|
9
|
+
border: 1px solid var(--gray-300);
|
|
10
|
+
margin-bottom: var(--spacing-sm);
|
|
11
|
+
margin-right: var(--spacing-sm);
|
|
12
|
+
`,key:u},e("span",{css:q`
|
|
13
|
+
padding: var(--spacing-3);
|
|
14
|
+
color: var(--gray-800);
|
|
15
|
+
`},e(Ge,{value:u,loading:n,text:(s=r.find(g=>g.id===u))==null?void 0:s.name})),e("button",{css:q`
|
|
16
|
+
padding: var(--spacing-3);
|
|
17
|
+
border-left: 1px solid var(--gray-300);
|
|
18
|
+
`,title:"remove",onClick:g=>b(g,u)},e("svg",{xmlns:"http://www.w3.org/2000/svg",css:q`
|
|
19
|
+
height: 1.25rem;
|
|
20
|
+
width: 1.25rem;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
display: block;
|
|
23
|
+
`,viewBox:"0 0 20 20",fill:"currentColor"},e("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"}))))}))};var ur=t=>e("svg",{width:"1em",height:"1em",viewBox:"0 0 46 46",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},e("path",{d:"M44.203 21.203H24.797V1.797a1.797 1.797 0 1 0-3.594 0v19.406H1.797a1.797 1.797 0 1 0 0 3.594h19.406v19.406a1.797 1.797 0 0 0 3.594 0V24.797h19.406a1.797 1.797 0 0 0 0-3.594Z"})),ee=ur;var gr=t=>e("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e("path",{d:"M4 12a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1Z",fill:"currentColor"})),te=gr;import{useAsyncFn as hr,useDebounce as br}from"react-use";import{Input as Ue,InputSelect as pe,mq as re}from"@uniformdev/design-system";import{css as S}from"@emotion/react";var Ae={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},Zo=({value:t,setValue:n,brands:o,categories:r,loading:c,categoriesLoading:d,brandsLoading:v,logoIcon:b,onGetProducts:h,sortOptions:u,sortOrderOptions:s})=>{var I;let g=async i=>{n({...Ae,...t||{},...i})},f=le(()=>({...Ae,...t||{}}),[t]),[A,L]=hr(async i=>await h(i),[h]);br(async()=>{await L({brand:f.brand,categories:f.categories,keyword:f.keyword,sort:f.sort,sortOrder:f.sortOrder,count:f.count})},250,[f]);let F=le(()=>{let i=[];return r==null||r.forEach(m=>{let T=Oe(m,void 0);i.push(...T)}),i},[r]),G=le(()=>(o==null?void 0:o.map(i=>({id:i.id.toString(),name:i.name})))||[],[o]),z=i=>{let m=(t==null?void 0:t.categories)||[];g({categories:[...m,i]})},B=i=>{var m;g({categories:(m=t==null?void 0:t.categories)==null?void 0:m.filter(T=>T!==i)})},J=i=>{g({brand:i.target.value})},E=i=>{g({count:i||1})};return c||A.loading?e("div",null,"Loading..."):e(He.Provider,{value:{categories:r,logoIcon:b}},e("div",{css:S`
|
|
24
|
+
> :not(:last-child) {
|
|
25
|
+
margin-bottom: var(--spacing-md);
|
|
26
|
+
}
|
|
27
|
+
`},e(ze,{loading:d||!1,name:"Product Category",onAdd:z,onRemove:B,selectedValues:f.categories,values:F}),e("div",{css:S`
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
column-gap: var(--spacing-lg);
|
|
31
|
+
row-gap: var(--spacing-md);
|
|
32
|
+
${re("md")} {
|
|
33
|
+
flex-wrap: nowrap;
|
|
34
|
+
}
|
|
35
|
+
`},e("div",{css:S`
|
|
36
|
+
width: 50%;
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
`},e(pe,{id:"brand",name:"brand",label:"Brand",disabled:v,value:f.brand,onChange:J,options:[{value:"",label:"Select a brand"},...G.map(i=>({value:i.id,label:i.name}))]})),e("div",{css:S`
|
|
39
|
+
flex-grow: 1;
|
|
40
|
+
position: relative;
|
|
41
|
+
`},e(Ue,{id:"count",name:"count",type:"number",min:1,step:1,value:f.count,onChange:i=>E(i.target.valueAsNumber),label:"Count"}),e("div",{css:S`
|
|
42
|
+
position: absolute;
|
|
43
|
+
bottom: var(--spacing-sm);
|
|
44
|
+
right: var(--spacing-sm);
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: var(--spacing-sm);
|
|
47
|
+
`},e(Be,{onCountChange:()=>E(f.count-1),countIcon:"decrement",disabled:f.count===1}),e(Be,{onCountChange:()=>E(f.count+1),countIcon:"increment"})))),e("div",{css:S`
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-wrap: wrap;
|
|
50
|
+
column-gap: var(--spacing-lg);
|
|
51
|
+
row-gap: var(--spacing-md);
|
|
52
|
+
${re("md")} {
|
|
53
|
+
flex-wrap: nowrap;
|
|
54
|
+
}
|
|
55
|
+
`},e("div",{css:S`
|
|
56
|
+
width: 100%;
|
|
57
|
+
${re("md")} {
|
|
58
|
+
width: 33.333333%;
|
|
59
|
+
}
|
|
60
|
+
`},e(Ue,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:f.keyword,placeholder:"Enter keyword",onChange:i=>g({keyword:i.target.value})})),Array.isArray(u)&&u.length>0?e("div",{css:S`
|
|
61
|
+
flex-grow: 1;
|
|
62
|
+
${re("md")} {
|
|
63
|
+
width: 33.333333%;
|
|
64
|
+
}
|
|
65
|
+
`},e(pe,{id:"sort",name:"sort",label:"Sort",value:f.sort,onChange:i=>g({sort:i.target.value}),options:[{value:"",label:"Select a sort"},...u.map(i=>({value:i.sortKey,label:i.name}))]})):null,Array.isArray(s)&&s.length>0?e("div",{css:S`
|
|
66
|
+
flex-grow: 1;
|
|
67
|
+
`},e(pe,{id:"sort-order",name:"sort-order",label:"Sort Order",value:f.sortOrder,onChange:i=>g({sortOrder:i.target.value}),options:s.map(i=>({value:i.sortOrderKey,label:i.name}))})):null),e("div",null,e("h3",{css:S`
|
|
68
|
+
font-size: var(--fs-md);
|
|
69
|
+
line-height: var(--spacing-md);
|
|
70
|
+
font-weight: var(--fw-bold);
|
|
71
|
+
margin-bottom: var(--spacing-xs);
|
|
72
|
+
`},"Result Preview"),e($e,{products:(I=A.value)==null?void 0:I.products}))))};function Oe(t,n){var d;let o=[],r=n?`${n.name} > `:"",c={id:t.id.toString(),name:`${r}${t.name}`};return o.push(c),(d=t.children)==null||d.forEach(v=>{let b=Oe(v,c);o.push(...b)}),o}function Be({onCountChange:t,countIcon:n,disabled:o}){return e("button",{css:S`
|
|
73
|
+
width: 2.25rem;
|
|
74
|
+
height: 2.25rem;
|
|
75
|
+
border: 1px solid var(--gray-300);
|
|
76
|
+
border-radius: var(--rounded-base);
|
|
77
|
+
background-color: var(--gray-100);
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
&:hover {
|
|
82
|
+
background-color: var(--gray-200);
|
|
83
|
+
}
|
|
84
|
+
${o?S`
|
|
85
|
+
cursor: not-allowed;
|
|
86
|
+
opacity: 0.3;
|
|
87
|
+
`:""}
|
|
88
|
+
`,onClick:t,disabled:o},n==="increment"?e(ee,{css:S`
|
|
89
|
+
width: 1rem;
|
|
90
|
+
height: 1rem;
|
|
91
|
+
`}):e(te,{css:S`
|
|
92
|
+
width: 1rem;
|
|
93
|
+
height: 1rem;
|
|
94
|
+
`}))}var He=fr.createContext(void 0),Fe=()=>{let t=vr(He);if(!t)throw new Error("useProductQueryContext must be used within a <ProductQueryContext> provider");return t};function U({src:t,alt:n,className:o}){let r=t&&typeof t!="string"?t:null;return r?e(r,{className:o}):e("img",{src:t,alt:n,className:o})}import{css as C}from"@emotion/react";import{scrollbarStyles as yr}from"@uniformdev/design-system";var $e=({products:t})=>{let{categories:n,logoIcon:o}=Fe();return e(Ke.Fragment,null,e("p",{css:C`
|
|
95
|
+
margin-bottom: var(--spacing-base);
|
|
96
|
+
`},"Matching ",(t==null?void 0:t.length)||0," products"),e("ul",{css:[C`
|
|
97
|
+
max-height: 24rem;
|
|
98
|
+
overflow-x: auto;
|
|
99
|
+
`,yr]},t==null?void 0:t.map((r,c)=>{var b;let[d]=(r==null?void 0:r.categories)||[],v=typeof d=="undefined"||!n||(b=n.find(h=>h.id===d.id))==null?void 0:b.name;return e("li",{key:`product-${r.id}`,css:C`
|
|
100
|
+
border: 1px solid var(--gray-300);
|
|
101
|
+
border-radius: var(--rounded-md);
|
|
102
|
+
background-color: var(--gray-100);
|
|
103
|
+
margin: var(--spacing-base) 0;
|
|
104
|
+
`},e("div",{css:C`
|
|
105
|
+
padding: var(--spacing-sm);
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-grow: 1;
|
|
108
|
+
margin-right: var(--spacing-sm);
|
|
109
|
+
gap: var(--spacing-base);
|
|
110
|
+
align-items: center;
|
|
111
|
+
`},r.thumbnailUrl?e("img",{src:r.thumbnailUrl,alt:r.name||`Product ${c}`,css:C`
|
|
112
|
+
background-color: var(--gray-200);
|
|
113
|
+
width: 3.5rem;
|
|
114
|
+
height: 3.5rem;
|
|
115
|
+
object-fit: cover;
|
|
116
|
+
`}):e("div",{css:C`
|
|
117
|
+
height: 3.5rem;
|
|
118
|
+
width: 3.5rem;
|
|
119
|
+
background-color: var(--gray-100);
|
|
120
|
+
`}),e("h4",{css:C`
|
|
121
|
+
font-weight: var(--fw-bold);
|
|
122
|
+
width: 33.333333%;
|
|
123
|
+
font-size: var(--fs-sm);
|
|
124
|
+
`},r.name,v&&e("span",{css:C`
|
|
125
|
+
display: block;
|
|
126
|
+
font-weight: var(--fw-regular);
|
|
127
|
+
`},v)),r&&e(Ke.Fragment,null,e("p",{css:C`
|
|
128
|
+
margin-right: var(--spacing-lg);
|
|
129
|
+
font-size: var(--fs-sm);
|
|
130
|
+
`},"SKU: ",r.sku," ",r.id,e("br",null)),r.price&&e("p",{css:C`
|
|
131
|
+
margin-right: var(--spacing-lg);
|
|
132
|
+
font-size: var(--fs-sm);
|
|
133
|
+
`},r.price&&e("span",{css:C`
|
|
134
|
+
display: block;
|
|
135
|
+
`},"Price: ",r.price)),e("a",{css:C`
|
|
136
|
+
display: inline-flex;
|
|
137
|
+
justify-content: space-between;
|
|
138
|
+
align-items: center;
|
|
139
|
+
padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-base);
|
|
140
|
+
background-color: var(--white);
|
|
141
|
+
border-radius: var(--rounded-base);
|
|
142
|
+
border: 2px solid var(--gray-400);
|
|
143
|
+
margin-left: auto;
|
|
144
|
+
&:hover {
|
|
145
|
+
background-color: var(--gray-100);
|
|
146
|
+
}
|
|
147
|
+
`,href:r.url,title:`Goto ${r.name}`,target:"__blank",rel:"noopener"},e("span",{css:C`
|
|
148
|
+
font-size: var(--fs-sm);
|
|
149
|
+
margin-right: var(--spacing-sm);
|
|
150
|
+
`},"Edit"),o?e(U,{src:o,alt:"Logo",css:C`
|
|
151
|
+
width: 2.25rem;
|
|
152
|
+
height: 2.25rem;
|
|
153
|
+
`}):null))))})))};import jr,{useContext as eo,useMemo as to,useRef as ro}from"react";import*as V from"react";var me={};or(me,{Caution:()=>Qe,Checkmark:()=>oe,ChevronDown:()=>ne,Close:()=>K,Danger:()=>Ne,ExclamationPoint:()=>_e,Info:()=>Q,Lightbulb:()=>Ze,MagnifyingGlass:()=>qe,MaximizeAlt:()=>We,Minus:()=>te,MoreVerticalAlt:()=>W,Plus:()=>ee});var wr=t=>e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 16 16",fill:"currentColor",...t},e("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})),Qe=wr;var Sr=t=>e("svg",{width:"1em",height:"1em",viewBox:"0 0 40 40",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 39.2A19.2 19.2 0 1 0 20 .8a19.2 19.2 0 0 0 0 38.4Zm8.897-22.303a2.4 2.4 0 0 0-3.394-3.394L17.6 21.407l-3.103-3.104a2.4 2.4 0 0 0-3.394 3.394l4.8 4.8a2.4 2.4 0 0 0 3.394 0l9.6-9.6Z"})),oe=Sr;var Cr=t=>e("svg",{viewBox:"0 0 24 24",width:"1em",height:"1em",...t},e("path",{d:"M5.293 8.293a1 1 0 0 1 1.414 0L12 13.586l5.293-5.293a1 1 0 1 1 1.414 1.414l-6 6a1 1 0 0 1-1.414 0l-6-6a1 1 0 0 1 0-1.414Z"})),ne=Cr;var Pr=t=>e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 19 19",fill:"currentColor",...t},e("g",{fillRule:"evenodd"},e("path",{d:"M16.578 1.636a1.174 1.174 0 0 1 0 1.66L3.296 16.578a1.174 1.174 0 1 1-1.66-1.66L14.918 1.636a1.174 1.174 0 0 1 1.66 0Z"}),e("path",{d:"M1.636 1.636a1.174 1.174 0 0 1 1.66 0l13.282 13.282a1.174 1.174 0 1 1-1.66 1.66L1.636 3.296a1.174 1.174 0 0 1 0-1.66Z"}))),K=Pr;var Rr=t=>e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 12 16",fill:"currentColor",...t},e("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})),Ne=Rr;var kr=t=>e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 14 16",fill:"currentColor",...t},e("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})),_e=kr;var xr=t=>e("svg",{width:"1em",height:"1em",fill:"currentColor",...t},e("path",{xmlns:"http://www.w3.org/2000/svg",d:"M11 10.98a1 1 0 1 1 2 0v6a1 1 0 1 1-2 0v-6zm1-4.929a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"}),e("path",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zM4 12a8 8 0 1 0 16 0 8 8 0 0 0-16 0z"})),Q=xr;var Lr=t=>e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 12 16",fill:"currentColor",...t},e("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})),Ze=Lr;var Mr=t=>e("svg",{width:"1em",height:"1em",viewBox:"0 0 26 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},e("g",{clipPath:"url(#magnifying-glass_svg__a)"},e("path",{d:"M11.539 0C5.484 0 .559 4.741.559 10.57c0 5.827 4.925 10.568 10.98 10.568 6.055 0 10.98-4.74 10.98-10.569C22.52 4.741 17.595 0 11.54 0Zm0 19.187c-4.937 0-8.954-3.866-8.954-8.618 0-4.752 4.017-8.618 8.954-8.618s8.954 3.866 8.954 8.618c0 4.752-4.017 8.618-8.954 8.618Z"}),e("path",{d:"m25.196 22.334-5.811-5.593a1.041 1.041 0 0 0-1.434 0 .95.95 0 0 0 0 1.38l5.812 5.593c.198.19.457.286.716.286.26 0 .519-.096.717-.286a.95.95 0 0 0 0-1.38Z"})),e("defs",null,e("clipPath",{id:"magnifying-glass_svg__a"},e("path",{fill:"#fff",transform:"translate(.558)",d:"M0 0h24.935v24H0z"})))),qe=Mr;var Vr=t=>e("svg",{width:"1em",height:"1em",fill:"currentColor",...t},e("path",{xmlns:"http://www.w3.org/2000/svg",d:"M3 3h6v2H6.462l4.843 4.843-1.415 1.414L5 6.367V9H3V3zm0 18h6v-2H6.376l4.929-4.928-1.415-1.414L5 17.548V15H3v6zm12 0h6v-6h-2v2.524l-4.867-4.866-1.414 1.414L17.647 19H15v2zm6-18h-6v2h2.562l-4.843 4.843 1.414 1.414L19 6.39V9h2V3z"})),We=Vr;var Er=t=>e("svg",{width:"1em",height:"1em",fill:"currentColor",...t},e("path",{xmlns:"http://www.w3.org/2000/svg",d:"M14 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm0 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm0 6a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"})),W=Er;import{useThrottle as Or}from"react-use";import{v4 as Hr}from"uuid";import Tr,{useState as Dr,useRef as it,useEffect as Gr}from"react";function Je(t,n){let o=window.open(t,"_blank"),r=setInterval(()=>{o!=null&&o.closed&&(clearInterval(r),n())},500)}import{format as zr}from"timeago.js";import{css as x}from"@emotion/react";import{mq as Ir}from"@uniformdev/design-system";var Xe=x`
|
|
154
|
+
border: 1px solid var(--gray-200);
|
|
155
|
+
background: var(--gray-50);
|
|
156
|
+
border-radius: var(--rounded-base);
|
|
157
|
+
display: flex;
|
|
158
|
+
width: 100%;
|
|
159
|
+
`,Ye=x`
|
|
160
|
+
align-items: center;
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-grow: 1;
|
|
163
|
+
gap: var(--spacing-sm);
|
|
164
|
+
margin-inline: 0 var(--spacing-sm);
|
|
165
|
+
padding: var(--spacing-base) var(--spacing-base) var(--spacing-base) var(--spacing-lg);
|
|
166
|
+
position: relative;
|
|
167
|
+
`,je=x`
|
|
168
|
+
flex-grow: 1;
|
|
169
|
+
`,et=x`
|
|
170
|
+
align-items: start;
|
|
171
|
+
display: inline-flex;
|
|
172
|
+
position: relative;
|
|
173
|
+
`,tt=x`
|
|
174
|
+
color: var(--brand-secondary-1);
|
|
175
|
+
font-size: var(--fs-base);
|
|
176
|
+
font-weight: var(--fw-bold);
|
|
177
|
+
line-height: 1;
|
|
178
|
+
`,rt=x`
|
|
179
|
+
width: 1.5rem;
|
|
180
|
+
height: 1.5rem;
|
|
181
|
+
`,ot=x`
|
|
182
|
+
width: 1rem;
|
|
183
|
+
height: 1rem;
|
|
184
|
+
`,nt=x`
|
|
185
|
+
background: var(--white);
|
|
186
|
+
border-radius: var(--rounded-base);
|
|
187
|
+
border-left: 4px solid var(--brand-secondary-3);
|
|
188
|
+
position: fixed;
|
|
189
|
+
padding: var(--spacing-base);
|
|
190
|
+
z-index: var(--z-10);
|
|
191
|
+
width: max-content;
|
|
192
|
+
`,O=x`
|
|
193
|
+
font-size: var(--fs-sm);
|
|
194
|
+
`,ae=x`
|
|
195
|
+
font-weight: var(--fw-bold);
|
|
196
|
+
margin-right: var(--spacing-sm);
|
|
197
|
+
`,at=x`
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: var(--spacing-sm);
|
|
201
|
+
|
|
202
|
+
${Ir("md")} {
|
|
203
|
+
flex-direction: row;
|
|
204
|
+
}
|
|
205
|
+
`,ue=x`
|
|
206
|
+
align-items: center;
|
|
207
|
+
background: var(--white);
|
|
208
|
+
border-radius: var(--rounded-base);
|
|
209
|
+
border: 2px solid var(--gray-300);
|
|
210
|
+
display: flex;
|
|
211
|
+
gap: var(--spacing-sm);
|
|
212
|
+
padding: var(--spacing-sm) var(--spacing-base);
|
|
213
|
+
justify-content: space-between;
|
|
214
|
+
|
|
215
|
+
&:hover {
|
|
216
|
+
background: var(--gray-50);
|
|
217
|
+
}
|
|
218
|
+
`;import{css as D}from"@emotion/react";var st=({selectedItem:t,logoIcon:n,onDeselect:o,onEditClosed:r})=>{var u;let c=it(null),d=it(null),[v,b]=Dr(!1);Gr(()=>{let s=f=>{c.current&&!c.current.contains(f.target)&&d.current&&!d.current.contains(f.target)&&b(!1)},g=()=>{b(!1)};return window.addEventListener("resize",g,!0),document.addEventListener("scroll",s,!0),document.addEventListener("mousedown",s),()=>{window.removeEventListener("resize",g,!0),document.removeEventListener("scroll",s,!0),document.removeEventListener("mousedown",s)}},[d]);let h=()=>{var s;if(b(!v),d.current&&c.current){let g=(s=c==null?void 0:c.current)==null?void 0:s.getBoundingClientRect();d.current.style.top=`${g.top+30}px`}};return e("div",{css:Xe,key:t.id},e("div",{css:Ye},e("div",{css:je},e("div",{css:et},e("h4",{css:[tt,t.popoverData?D`
|
|
219
|
+
margin-bottom: var(--spacing-sm);
|
|
220
|
+
`:""],title:`ID: ${t.id}`,"data-test-id":"entry-id"},t.title||t.id||""),t.popoverData?e(Tr.Fragment,null,e("button",{type:"button",ref:c,css:D`
|
|
221
|
+
margin: calc(var(--spacing-xs) * -1) 0 calc(var(--spacing-xs) * -1) var(--spacing-sm);
|
|
222
|
+
`,"aria-controls":"path-details","aria-expanded":v,onClick:h},e(Q,{width:24,height:24,css:D`
|
|
223
|
+
color: var(--gray-400);
|
|
224
|
+
`})),e("div",{id:"path-details","aria-hidden":!v,ref:d,css:[nt,v?D`
|
|
225
|
+
visibility: visible;
|
|
226
|
+
`:D`
|
|
227
|
+
visibility: hidden;
|
|
228
|
+
`]},Object.entries(t.popoverData).map(([s,g],f)=>e("div",{css:O,key:f},e("span",{css:ae},s,":"),g)))):null),t.createdDate&&e("div",{css:O},e("span",{css:ae},"Created:"),zr((u=t.createdDate)!=null?u:0)),e("div",{css:D`
|
|
229
|
+
display: flex;
|
|
230
|
+
gap: var(--spacing-base);
|
|
231
|
+
`},t.metadata?Object.entries(t.metadata).filter(([s])=>["type","status"].includes(s.toLocaleLowerCase())).map(([s,g])=>e("span",{css:O,key:s},g)):null),t.metadata?Object.entries(t.metadata).filter(([s])=>!["type","status"].includes(s.toLocaleLowerCase())).map(([s,g])=>e("div",{css:[O,D`
|
|
232
|
+
order: 1;
|
|
233
|
+
`],key:s},e("span",{css:[ae,D`
|
|
234
|
+
order: 1;
|
|
235
|
+
`]},s,":"),g)):null),e("div",{css:at},t.editLink?e("a",{href:t.editLink,title:"edit",rel:"noopener",target:"__blank",onClick:s=>{r&&(Je(s.currentTarget.href,()=>r(t)),s.preventDefault())},css:ue},e("span",{css:O},"Edit"),e(U,{src:n,css:rt,alt:"Logo"})):null,e("button",{type:"button",onClick:s=>{s.preventDefault(),o(t)},css:ue},e("span",{css:O},"Unlink"),e(K,{css:[ot,D`
|
|
236
|
+
color: var(--brand-secondary-5);
|
|
237
|
+
`]})))))};import Ur,{useState as Ar,useRef as mt,useEffect as Br}from"react";import{css as N}from"@emotion/react";var ct=N`
|
|
238
|
+
cursor: pointer;
|
|
239
|
+
padding: var(--spacing-sm);
|
|
240
|
+
position: relative;
|
|
241
|
+
transition: background-color var(--duration-fast) var(--timing-ease-out),
|
|
242
|
+
color var(--duration-fast) var(--timing-ease-out);
|
|
243
|
+
`,dt=N`
|
|
244
|
+
background: var(--brand-secondary-3);
|
|
245
|
+
color: var(--white);
|
|
246
|
+
`,ge=N`
|
|
247
|
+
font-size: var(--fs-xs);
|
|
248
|
+
`,fe=N`
|
|
249
|
+
font-weight: var(--fw-bold);
|
|
250
|
+
margin-right: var(--spacing-sm);
|
|
251
|
+
`,lt=N`
|
|
252
|
+
background: var(--white);
|
|
253
|
+
border-left: 4px solid var(--brand-secondary-3);
|
|
254
|
+
border-radius: var(--rounded-base);
|
|
255
|
+
box-shadow: var(--shadow-base);
|
|
256
|
+
color: var(--brand-secondary-1);
|
|
257
|
+
padding: var(--spacing-base);
|
|
258
|
+
position: absolute;
|
|
259
|
+
top: var(--spacing-base);
|
|
260
|
+
right: var(--spacing-xl);
|
|
261
|
+
z-index: var(--z-10);
|
|
262
|
+
width: max-content;
|
|
263
|
+
`,pt=N`
|
|
264
|
+
position: absolute;
|
|
265
|
+
inset: 0 var(--spacing-sm) 0 auto;
|
|
266
|
+
`;import{css as ut}from"@emotion/react";var gt=({result:t,isSelected:n,triggerSelection:o})=>{let r=mt(null),c=mt(null),[d,v]=Ar(!1);Br(()=>{function h(u){r.current&&!r.current.contains(u.target)&&c.current&&!c.current.contains(u.target)&&v(!1)}return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[c]);let b=h=>{h.stopPropagation(),v(!d)};return e("div",{key:t.id,css:[ct,n?dt:void 0],"data-value":t.id,role:"option",tabIndex:-1,onClick:()=>o()},t.title,t.popoverData&&n?e(Ur.Fragment,null,e("button",{type:"button",ref:r,css:pt,"aria-controls":"path-details",onClick:h=>b(h),"aria-expanded":d},e(Q,{width:24,height:24})),e("div",{id:"path-details","aria-hidden":!d,ref:c,css:[lt,d?ut`
|
|
267
|
+
visibility: visible;
|
|
268
|
+
`:ut`
|
|
269
|
+
visibility: hidden;
|
|
270
|
+
`]},t.metadata&&Object.entries(t.metadata).map(([h,u],s)=>e("div",{css:ge,key:s},e("span",{css:fe},h,":"),u)),Object.entries(t.popoverData).map(([h,u],s)=>e("div",{css:ge,key:s},e("span",{css:fe},h,":"),u)))):null)};import{Droppable as Fr,DragDropContext as $r,Draggable as Kr}from"react-beautiful-dnd";import{css as w}from"@emotion/react";var ft=w`
|
|
271
|
+
background: var(--white);
|
|
272
|
+
border: 1px solid var(--gray-300);
|
|
273
|
+
border-radius: var(--rounded-base);
|
|
274
|
+
padding: calc(var(--spacing-base) - 0.25rem) var(--spacing-sm);
|
|
275
|
+
margin-block: 0 var(--spacing-base);
|
|
276
|
+
`,vt=w`
|
|
277
|
+
align-items: center;
|
|
278
|
+
display: flex;
|
|
279
|
+
position: relative;
|
|
280
|
+
font-size: var(--fs-base);
|
|
281
|
+
width: 100%;
|
|
282
|
+
background-color: transparent;
|
|
283
|
+
border: 0;
|
|
284
|
+
`,ht=w`
|
|
285
|
+
color: var(--brand-secondary-1);
|
|
286
|
+
display: block;
|
|
287
|
+
font-weight: var(--fw-bold);
|
|
288
|
+
font-size: var(--fs-sm);
|
|
289
|
+
padding: var(--spacing-base);
|
|
290
|
+
width: 100%;
|
|
291
|
+
text-align: center;
|
|
292
|
+
border: none;
|
|
293
|
+
background: none;
|
|
294
|
+
|
|
295
|
+
&:focus,
|
|
296
|
+
&:hover {
|
|
297
|
+
background: var(--gray-100);
|
|
298
|
+
outline: none;
|
|
299
|
+
}
|
|
300
|
+
`,bt=w`
|
|
301
|
+
background: var(--white);
|
|
302
|
+
border: 1px solid var(--gray-300);
|
|
303
|
+
border-radius: var(--rounded-base);
|
|
304
|
+
padding: calc(var(--spacing-base) - 0.25rem) var(--spacing-base);
|
|
305
|
+
`,yt=w`
|
|
306
|
+
border: none;
|
|
307
|
+
position: absolute;
|
|
308
|
+
padding: 0;
|
|
309
|
+
clip: rect(0, 0, 0, 0);
|
|
310
|
+
height: 1px;
|
|
311
|
+
width: 1px;
|
|
312
|
+
overflow: hidden;
|
|
313
|
+
`,wt=w`
|
|
314
|
+
overflow-y: auto;
|
|
315
|
+
max-height: 16rem;
|
|
316
|
+
margin-bottom: var(--spacing-base);
|
|
317
|
+
|
|
318
|
+
& > :not(:last-child) {
|
|
319
|
+
border-bottom: 1px solid var(--gray-200);
|
|
320
|
+
}
|
|
321
|
+
`,Zn=w`
|
|
322
|
+
background-color: var(--gray-50);
|
|
323
|
+
max-width: 33.33%;
|
|
324
|
+
`,St=w`
|
|
325
|
+
align-items: center;
|
|
326
|
+
display: flex;
|
|
327
|
+
position: absolute;
|
|
328
|
+
inset: 0 0 0 auto;
|
|
329
|
+
pointer-events: none;
|
|
330
|
+
padding-right: var(--spacing-sm);
|
|
331
|
+
`,Ct=w`
|
|
332
|
+
color: var(--brand-secondary-1);
|
|
333
|
+
width: 1.25rem;
|
|
334
|
+
height: 1.25rem;
|
|
335
|
+
transition: transform var(--duration-fast) var(--timing-ease-out);
|
|
336
|
+
transform: rotate(0);
|
|
337
|
+
`,qn=w`
|
|
338
|
+
background: var(--white);
|
|
339
|
+
color: var(--brand-secondary-1);
|
|
340
|
+
`,Pt=w`
|
|
341
|
+
position: relative;
|
|
342
|
+
margin-block: var(--spacing-sm) 0;
|
|
343
|
+
|
|
344
|
+
&:hover > span {
|
|
345
|
+
opacity: 0.3;
|
|
346
|
+
}
|
|
347
|
+
`,Rt=w`
|
|
348
|
+
align-items: center;
|
|
349
|
+
display: flex;
|
|
350
|
+
position: absolute;
|
|
351
|
+
inset: 0 auto 0 0;
|
|
352
|
+
margin-block: auto;
|
|
353
|
+
opacity: 0;
|
|
354
|
+
`,ve=w`
|
|
355
|
+
color: var(--brand-secondary-1);
|
|
356
|
+
`,kt=w`
|
|
357
|
+
position: absolute;
|
|
358
|
+
left: 0.375rem;
|
|
359
|
+
`,he=w`
|
|
360
|
+
width: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
361
|
+
height: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
362
|
+
`;import{css as M}from"@emotion/react";import{InputSelect as Qr,scrollbarStyles as Nr,Button as be,Callout as _r,InputKeywordSearch as Zr,LoadingIndicator as xt,Menu as qr,MenuItem as Wr}from"@uniformdev/design-system";var Jr=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),e(_r,{type:"info"},o)},Lt=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:c,select:d,multiSelect:v,multiSelectId:b,rowComponent:h,selectedItemComponent:u,totalResults:s,resultsLoading:g,requireContentType:f,onAddNew:A,onEditClosed:L,onCancel:F,noResultsComponent:G,helpComponent:z,onSort:B})=>{var Re,ke,xe;let E=()=>f?Array.isArray(o)&&o.length>0?o[0].id:"":"any",[I,i]=V.useState(""),[m,T]=V.useState(E),[_,ce]=V.useState(!1),[X,Y]=V.useState([]),[Kt,we]=V.useState(!1),j=Or(I,750);V.useEffect(()=>{t(j,{count:5,offset:0,contentType:m==="any"?void 0:m})},[j,m]);let Qt=a=>{X.includes(a.id)?Y(y=>y.filter($=>$!==a.id)):Y(v?y=>[...y,a==null?void 0:a.id]:[a.id])},Nt=()=>{T(E()),i(""),Y(r!=null&&r.length?r.map(a=>a.id):[])},_t=()=>{ce(a=>!a),_||Nt()},Se=a=>{d((r==null?void 0:r.filter(y=>y.id!==a.id).map(y=>y.id))||[],"")},Zt=a=>{a.preventDefault(),d(X,m),ce(!1)},qt=a=>{a.preventDefault(),ce(!1),F&&F()},Wt=a=>{a.preventDefault(),t(j,{count:5,offset:(n==null?void 0:n.length)||0,contentType:m==="any"?void 0:m}),we(!0);let y=setTimeout(()=>{we(!1)},750);return()=>clearTimeout(y)},de=V.useRef(Hr()),Jt=!(r==null?void 0:r.length)||v,Xt=h||gt,Ce=u||st,Yt=G||Jr,Pe=c&&typeof c!="string"?c:null,jt=Pe?e(Pe,{css:he}):e("img",{src:c,alt:"CMS logo",css:he}),er=a=>{var y,$;if(a.destination&&a.source.droppableId===((y=a.destination)==null?void 0:y.droppableId)){let R=[...r||[]],[Z]=($=R==null?void 0:R.splice(a.source.index,1))!=null?$:[];return R==null||R.splice(a.destination.index,0,Z),B==null||B(R.map(tr=>tr.id)),R}};return e("div",{css:M`
|
|
363
|
+
width: 100%;
|
|
364
|
+
`},e("div",{css:M`
|
|
365
|
+
position: relative;
|
|
366
|
+
margin-block: var(--spacing-base);
|
|
367
|
+
`},Jt&&e("div",null,e("div",{css:ft,"data-test-id":"component-search"},e("button",{css:vt,onClick:_t,type:"button","aria-haspopup":!0,"aria-expanded":_,"aria-controls":`entry-search-config-${de.current}`},jt,e("span",{css:M`
|
|
368
|
+
margin-left: var(--spacing-base);
|
|
369
|
+
`},"Select"),e("span",{css:St},e(ne,{css:[Ct,_?M`
|
|
370
|
+
transform: rotate(180deg);
|
|
371
|
+
`:void 0]})))),e("div",{id:`entry-search-config-${de.current}`,"aria-hidden":!_,css:[bt,_?void 0:yt]},z||null,e("div",{css:M`
|
|
372
|
+
display: flex;
|
|
373
|
+
gap: calc(var(--spacing-base) - 0.25rem);
|
|
374
|
+
margin-bottom: var(--spacing-base);
|
|
375
|
+
`},e(Qr,{onChange:a=>T(a.target.value),value:m,label:"Content Type Select",showLabel:!1,options:[...f?[]:[{value:"any",label:"All content types"}],...o?o.map(a=>({value:a.id,label:a.name})):[]]}),e("div",{css:M`
|
|
376
|
+
flex-grow: 1;
|
|
377
|
+
`},e(Zr,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:i,disabledFieldSubmission:!0,value:I}))),e("div",{css:[wt,Nr],id:de.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},!g&&Array.isArray(n)?n.map(a=>e(Xt,{key:a.id,isSelected:X.includes(a.id),result:a,triggerSelection:()=>Qt(a)})):g?null:e(Yt,{searchText:j||I,selectedContentType:(ke=(Re=o==null?void 0:o.find(a=>a.id===m))==null?void 0:Re.name)!=null?ke:m}),!g&&typeof s!="undefined"&&n&&(n==null?void 0:n.length)<s&&e("button",{css:ht,onClick:Wt},Kt?e(xt,null):"Load More"),g&&!(n!=null&&n.length)?e("div",{css:M`
|
|
378
|
+
padding: var(--spacing-base);
|
|
379
|
+
text-align: center;
|
|
380
|
+
width: 100%;
|
|
381
|
+
`},e(xt,null)):null),e("div",{css:M`
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: space-between;
|
|
384
|
+
`},e("div",null,A&&((xe=o==null?void 0:o.length)!=null?xe:0)>0?e(qr,{menuLabel:"Add new menu",menuTrigger:e(be,{buttonType:"secondary"},"Add New")},o==null?void 0:o.map(a=>e(Wr,{key:a.id,css:M`
|
|
385
|
+
background: var(--white);
|
|
386
|
+
color: var(--brand-secondary-1);
|
|
387
|
+
`,onClick:()=>A(a)},a.name))):null),e("div",{css:M`
|
|
388
|
+
display: flex;
|
|
389
|
+
gap: var(--spacing-base);
|
|
390
|
+
`},e(be,{buttonType:"unimportant",onClick:qt},"Cancel"),e(be,{disabled:!X.length,onClick:Zt,"data-test-id":"entry-accept-button"},"Accept"))))),v?e($r,{onDragEnd:a=>er(a)},e(Fr,{droppableId:b||"canvas-multi-select"},a=>e("div",{...a.droppableProps,ref:a.innerRef,css:M`
|
|
391
|
+
margin-block: var(--spacing-sm) 0;
|
|
392
|
+
`},r==null?void 0:r.map((y,$)=>{if(y!=null&&y.id)return e(Kr,{key:y.id,draggableId:y.id,index:$},R=>e("div",{css:Pt,ref:R.innerRef,...R.draggableProps,...R.dragHandleProps},e("span",{css:Rt},e(W,{css:[ve,kt],width:24,height:24}),e(W,{css:ve,width:24,height:24})),e(Ce,{key:`selected-item-${y.id}`,logoIcon:c,selectedItem:y,onDeselect:Z=>Se(Z),onEditClosed:L?Z=>L(Z):void 0})))}),a.placeholder))):r==null?void 0:r.map(a=>e(Ce,{key:`selected-item-${a.id}`,logoIcon:c,selectedItem:a,onDeselect:y=>Se(y),onEditClosed:L?y=>L(y):void 0}))))};import{css as H}from"@emotion/react";var Mt=H`
|
|
393
|
+
cursor: pointer;
|
|
394
|
+
padding: var(--spacing-sm) 0;
|
|
395
|
+
margin-right: var(--spacing-sm);
|
|
396
|
+
position: relative;
|
|
397
|
+
transition: background-color var(--duration-fast) var(--timing-ease-out),
|
|
398
|
+
color var(--duration-fast) var(--timing-ease-out);
|
|
399
|
+
`,Vt=H`
|
|
400
|
+
border: 2px solid transparent;
|
|
401
|
+
border-radius: var(--rounded-base);
|
|
402
|
+
display: flex;
|
|
403
|
+
align-items: center;
|
|
404
|
+
gap: var(--spacing-base);
|
|
405
|
+
padding: var(--spacing-sm) var(--spacing-xs);
|
|
406
|
+
`,Et=H`
|
|
407
|
+
background-color: var(--green-50);
|
|
408
|
+
`,It=H`
|
|
409
|
+
font-size: var(--fs-sm);
|
|
410
|
+
font-weight: var(--fw-bold);
|
|
411
|
+
width: 50%;
|
|
412
|
+
`,Tt=H`
|
|
413
|
+
font-weight: var(--fw-normal);
|
|
414
|
+
display: block;
|
|
415
|
+
`,Dt=H`
|
|
416
|
+
font-size: var(--fs-sm);
|
|
417
|
+
> * {
|
|
418
|
+
display: block;
|
|
419
|
+
}
|
|
420
|
+
`,Gt=H`
|
|
421
|
+
display: block;
|
|
422
|
+
height: 1.5rem;
|
|
423
|
+
width: 1.5rem;
|
|
424
|
+
color: var(--brand-secondary-3);
|
|
425
|
+
margin-left: auto;
|
|
426
|
+
`;import{css as zt}from"@emotion/react";function Ut({result:t,isSelected:n,triggerSelection:o}){var b;let{categories:r,logoIcon:c}=ie(),[d]=t.categories||[{id:"",name:""}],v=typeof d=="undefined"||!r||(b=r.find(h=>h.id===d.id))==null?void 0:b.name;return e("div",{key:t.id,"data-value":t.id,role:"option",tabIndex:-1,onClick:()=>o(),css:[Mt]},e("div",{css:[Vt,n?Et:void 0]},t.thumbnailUrl?e("img",{src:t.thumbnailUrl,alt:`Thumbnail for ${t.title}`,css:zt`
|
|
427
|
+
background-color: var(--gray-200);
|
|
428
|
+
width: 3rem;
|
|
429
|
+
height: 3rem;
|
|
430
|
+
object-fit: cover;
|
|
431
|
+
`}):e(U,{src:c,alt:"Logo",css:zt`
|
|
432
|
+
height: 2.25rem;
|
|
433
|
+
width: 2.25rem;
|
|
434
|
+
`}),e("h4",{css:[It]},t.title,v?e("span",{css:[Tt]},v):null),e("p",{css:[Dt]},"SKU: ",t.id,t.price&&e("span",null,t.price)),n?e(oe,{css:[Gt]}):null))}import{css as se}from"@emotion/react";import{mq as Xr}from"@uniformdev/design-system";var At=se`
|
|
435
|
+
display: flex;
|
|
436
|
+
width: 100%;
|
|
437
|
+
border: 1px solid var(--gray-300);
|
|
438
|
+
border-radius: var(--rounded-base);
|
|
439
|
+
background-color: var(--gray-100);
|
|
440
|
+
margin: var(--spacing-base) 0;
|
|
441
|
+
`,Bt=se`
|
|
442
|
+
padding: var(--spacing-base) 0 var(--spacing-base) var(--spacing-lg);
|
|
443
|
+
display: flex;
|
|
444
|
+
flex-grow: 1;
|
|
445
|
+
align-items: center;
|
|
446
|
+
margin-right: var(--spacing-sm);
|
|
447
|
+
gap: var(--spacing-base);
|
|
448
|
+
`,Ot=se`
|
|
449
|
+
display: flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
gap: var(--spacing-sm);
|
|
452
|
+
margin-bottom: var(--spacing-sm);
|
|
453
|
+
${Xr("lg")} {
|
|
454
|
+
width: 50%;
|
|
455
|
+
margin-bottom: 0;
|
|
456
|
+
}
|
|
457
|
+
`,ye=se`
|
|
458
|
+
background-color: var(--gray-200);
|
|
459
|
+
width: 3.5rem;
|
|
460
|
+
height: 3.5rem;
|
|
461
|
+
object-fit: cover;
|
|
462
|
+
`;import{css as P}from"@emotion/react";import{mq as Yr}from"@uniformdev/design-system";function Ht({selectedItem:t,onDeselect:n}){var v;let{categories:o,logoIcon:r}=ie(),[c]=t.categories||[{id:"",name:""}],d=typeof c=="undefined"||!o||(v=o.find(b=>b.id===c.id))==null?void 0:v.name;return e("div",{css:[At],key:t.id},e("article",{css:[Bt]},e("div",{css:[Ot]},t.thumbnailUrl?e("img",{src:t.thumbnailUrl,alt:d,css:[ye],loading:"lazy"}):e("div",{css:[ye]}),e("div",{css:P`
|
|
463
|
+
> :not(:last-child) {
|
|
464
|
+
margin-bottom: var(--spacing-xs);
|
|
465
|
+
}
|
|
466
|
+
`},e("h4",{css:P`
|
|
467
|
+
font-weight: var(--fw-bold);
|
|
468
|
+
`},t.title||t.id||"",d&&e("span",{css:P`
|
|
469
|
+
display: block;
|
|
470
|
+
font-weight: var(--fw-regular);
|
|
471
|
+
`},d)),e("ul",{css:P`
|
|
472
|
+
font-size: var(--fs-sm);
|
|
473
|
+
display: flex;
|
|
474
|
+
gap: var(--spacing-base);
|
|
475
|
+
`},e("li",null,e("span",{css:P`
|
|
476
|
+
margin-right: var(--spacing-xs);
|
|
477
|
+
`},"SKU:"),t.id),t.price&&e("li",null,e("span",{css:P`
|
|
478
|
+
margin-right: var(--spacing-xs);
|
|
479
|
+
`},"Price:"),e("span",null,t.price))))),e("div",{css:P`
|
|
480
|
+
display: flex;
|
|
481
|
+
flex-wrap: wrap;
|
|
482
|
+
gap: var(--spacing-sm);
|
|
483
|
+
justify-content: flex-end;
|
|
484
|
+
margin-left: auto;
|
|
485
|
+
${Yr("md")} {
|
|
486
|
+
align-items: center;
|
|
487
|
+
}
|
|
488
|
+
`},t.editLink?e("a",{href:t.editLink,title:"edit",rel:"noopener",target:"__blank",css:P`
|
|
489
|
+
display: inline-flex;
|
|
490
|
+
justify-content: space-between;
|
|
491
|
+
align-items: center;
|
|
492
|
+
padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-base);
|
|
493
|
+
background-color: var(--white);
|
|
494
|
+
border-radius: var(--rounded-base);
|
|
495
|
+
border: 2px solid var(--gray-400);
|
|
496
|
+
&:hover {
|
|
497
|
+
background-color: var(--gray-100);
|
|
498
|
+
}
|
|
499
|
+
`},e("span",{css:P`
|
|
500
|
+
margin-right: var(--spacing-sm);
|
|
501
|
+
font-size: var(--fs-sm);
|
|
502
|
+
`},"Edit"),e(U,{src:r,alt:"Logo",css:P`
|
|
503
|
+
width: 1.75rem;
|
|
504
|
+
height: 1.75rem;
|
|
505
|
+
display: block;
|
|
506
|
+
`})):null,e("button",{type:"button",onClick:b=>{b.preventDefault(),n==null||n(t)},css:P`
|
|
507
|
+
display: flex;
|
|
508
|
+
justify-content: space-between;
|
|
509
|
+
align-items: center;
|
|
510
|
+
background-color: var(--white);
|
|
511
|
+
border-radius: var(--rounded-base);
|
|
512
|
+
border: 2px solid var(--gray-400);
|
|
513
|
+
height: 2.5rem;
|
|
514
|
+
padding: 0 var(--spacing-base);
|
|
515
|
+
&:hover {
|
|
516
|
+
background-color: var(--gray-100);
|
|
517
|
+
}
|
|
518
|
+
`},e("span",{css:P`
|
|
519
|
+
font-size: var(--fs-sm);
|
|
520
|
+
`},"Unlink"),e(K,{css:P`
|
|
521
|
+
color: var(--brand-secondary-5);
|
|
522
|
+
`})))))}import{LoadingIndicator as oo}from"@uniformdev/design-system";import{useAsync as Ft,useAsyncFn as no}from"react-use";function Ua({value:t,setValue:n,onGetSelectedProducts:o,onGetCategories:r,onSearchProducts:c,logoIcon:d,multiSelect:v,multiSelectId:b,selectedItemComponent:h,rowComponent:u}){var E,I;let{value:s,loading:g,error:f}=Ft(async()=>await r(),[r]),{value:A,error:L}=Ft(async()=>{if(!t)return;let i=await o({ids:t});return Array.isArray(i)?i:void 0},[o,t]),F=to(()=>s?s.map(m=>({id:m.id,name:m.name})):void 0,[s]),G=ro(),[z,B]=no(async(i,m)=>{let T=await c({text:i,options:{limit:m==null?void 0:m.count,offset:m==null?void 0:m.offset,categoryId:m==null?void 0:m.contentType}});return(m==null?void 0:m.offset)===0&&(G.current=[]),(G.current=G.current||[]).push(...T.products),T},[c]),J=async i=>{i&&await n(i)};return g?e(oo,null):f||L||z.error?e("div",null,"There was an error:"," ",(f==null?void 0:f.message)||(L==null?void 0:L.message)||((E=z.error)==null?void 0:E.message)):e($t.Provider,{value:{categories:s,logoIcon:d}},e(Lt,{search:B,results:G.current,logoIcon:d,selectedItems:A,select:J,multiSelectId:b||"product-search-multi-select",multiSelect:v,contentTypes:F,selectedItemComponent:h||Ht,rowComponent:u||Ut,totalResults:(I=z.value)==null?void 0:I.total,resultsLoading:z.loading}))}var $t=jr.createContext(void 0),ie=()=>{let t=eo($t);if(!t)throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");return t};export*from"@uniformdev/mesh-sdk";import{Button as Na,Callout as _a,LoadingIndicator as Za,LoadingOverlay as qa,Menu as Wa,MenuItem as Ja,Input as Xa,InputSelect as Ya,InputToggle as ja,Theme as ei,InputKeywordSearch as ti,Heading as ri}from"@uniformdev/design-system";export{Na as Button,_a as Callout,gt as DefaultSearchRow,st as DefaultSelectedItem,Lt as EntrySearch,ri as Heading,me as Icons,Xa as Input,Ya as InputSelect,ja as InputToggle,ti as KeywordSearchInput,Za as LoadingIndicator,qa as LoadingOverlay,Wa as Menu,Ja as MenuItem,$e as ProductPreviewList,Zo as ProductQuery,He as ProductQueryContext,Ua as ProductSearch,$t as ProductSearchContext,Ut as ProductSearchRow,Ht as ProductSelectedItem,Ge as ResolvableLoadingValue,ze as SelectionField,ei as Theme,Le as UniformMeshLocationContext,Me as UniformMeshLocationContextProvider,Ie as UniformMeshSdkContext,ko as UniformMeshSdkContextProvider,he as badgeIcon,Pt as draggableContainer,ve as draggableIcon,kt as draggableIconOffset,Rt as draggableIconWrapper,vt as entrySearchBtn,bt as entrySearchConfig,yt as entrySearchConfigHidden,ht as entrySearchLoadMoreBtn,wt as entrySearchResultList,St as entrySearchSelectIcon,Ct as entrySearchSelectImg,Zn as entrySearchSelectInput,qn as entrySearchSelectOption,ft as entrySearchWrapper,Gt as productSearchRowActiveIcon,Tt as productSearchRowCategory,Mt as productSearchRowContainer,Vt as productSearchRowContent,Et as productSearchRowContentActive,Dt as productSearchRowDetails,It as productSearchRowTitle,At as productSelectedItemContainer,Ot as productSelectedItemContent,Bt as productSelectedItemDetails,ye as productSelectedItemImage,pt as searchRowBtn,ct as searchRowContainer,dt as searchRowContainerActive,lt as searchRowPopover,fe as searchRowText,ge as searchRowTextSmall,ue as selectItemLinkBtn,at as selectItemLinkContainer,nt as selectItemPopover,ae as selectItemPopoverLabel,O as selectItemSmallText,ot as selectedItemCloseIcon,Xe as selectedItemContainer,et as selectedItemCopy,je as selectedItemDetails,rt as selectedItemIcon,Ye as selectedItemInner,tt as selectedItemTitle,yo as useInitializeUniformMeshSdk,Fe as useProductQueryContext,ie as useProductSearchContext,go as useUniformMeshLocation,Ve as useUniformMeshLocationContext,Mo as useUniformMeshSdk,Te as useUniformMeshSdkContext};
|