@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.js
CHANGED
|
@@ -1 +1,522 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Sr=Object.create;var ve=Object.defineProperty;var Cr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Rr=Object.getPrototypeOf,kr=Object.prototype.hasOwnProperty;var Ot=t=>ve(t,"__esModule",{value:!0});var Ht=(t,n)=>{for(var r in n)ve(t,r,{get:n[r],enumerable:!0})},k=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Pr(n))!kr.call(t,a)&&(r||a!=="default")&&ve(t,a,{get:()=>n[a],enumerable:!(o=Cr(n,a))||o.enumerable});return t},$=(t,n)=>k(Ot(ve(t!=null?Sr(Rr(t)):{},"default",!n&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),xr=(t=>(n,r)=>t&&t.get(n)||(r=k(Ot({}),n,1),t&&t.set(n,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var I={};Ht(I,{Button:()=>y.Button,Callout:()=>y.Callout,DefaultSearchRow:()=>at,DefaultSelectedItem:()=>je,EntrySearch:()=>ht,Heading:()=>y.Heading,Icons:()=>Pe,Input:()=>y.Input,InputSelect:()=>y.InputSelect,InputToggle:()=>y.InputToggle,KeywordSearchInput:()=>y.InputKeywordSearch,LoadingIndicator:()=>y.LoadingIndicator,LoadingOverlay:()=>y.LoadingOverlay,Menu:()=>y.Menu,MenuItem:()=>y.MenuItem,ProductPreviewList:()=>$e,ProductQuery:()=>Dr,ProductQueryContext:()=>He,ProductSearch:()=>qr,ProductSearchContext:()=>It,ProductSearchRow:()=>xt,ProductSelectedItem:()=>Et,ResolvableLoadingValue:()=>Be,SelectionField:()=>Oe,Theme:()=>y.Theme,UniformMeshLocationContext:()=>Te,UniformMeshLocationContextProvider:()=>De,UniformMeshSdkContext:()=>ze,UniformMeshSdkContextProvider:()=>Vr,badgeIcon:()=>Me,draggableContainer:()=>gt,draggableIcon:()=>Le,draggableIconOffset:()=>vt,draggableIconWrapper:()=>ft,entrySearchBtn:()=>st,entrySearchConfig:()=>dt,entrySearchConfigHidden:()=>lt,entrySearchLoadMoreBtn:()=>ct,entrySearchResultList:()=>pt,entrySearchSelectIcon:()=>mt,entrySearchSelectImg:()=>ut,entrySearchSelectInput:()=>Nr,entrySearchSelectOption:()=>_r,entrySearchWrapper:()=>it,productSearchRowActiveIcon:()=>Rt,productSearchRowCategory:()=>Ct,productSearchRowContainer:()=>bt,productSearchRowContent:()=>yt,productSearchRowContentActive:()=>wt,productSearchRowDetails:()=>Pt,productSearchRowTitle:()=>St,productSelectedItemContainer:()=>Lt,productSelectedItemContent:()=>Vt,productSelectedItemDetails:()=>Mt,productSelectedItemImage:()=>Ve,searchRowBtn:()=>ot,searchRowContainer:()=>et,searchRowContainerActive:()=>tt,searchRowPopover:()=>rt,searchRowText:()=>xe,searchRowTextSmall:()=>ke,selectItemLinkBtn:()=>Re,selectItemLinkContainer:()=>Ye,selectItemPopover:()=>Xe,selectItemPopoverLabel:()=>ce,selectItemSmallText:()=>N,selectedItemCloseIcon:()=>Je,selectedItemContainer:()=>Qe,selectedItemCopy:()=>Ze,selectedItemDetails:()=>_e,selectedItemIcon:()=>We,selectedItemInner:()=>Ne,selectedItemTitle:()=>qe,useInitializeUniformMeshSdk:()=>Mr,useProductQueryContext:()=>Fe,useProductSearchContext:()=>de,useUniformMeshLocation:()=>Lr,useUniformMeshLocationContext:()=>Ge,useUniformMeshSdk:()=>Er,useUniformMeshSdkContext:()=>Ue});var e=require("@emotion/react"),M=$(require("react"));var j=require("react"),Te=(0,j.createContext)(void 0),De=({children:t})=>{let[n,r]=(0,j.useState)(),o;if(typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"){let a=n||window.UniformMeshSDK.getCurrentLocation();o={location:{getValue:a.getValue,getMetadata:a.getMetadata,setValue:async d=>{await a.setValue(d),r(window.UniformMeshSDK.getCurrentLocation())}}}}return(0,e.jsx)(Te.Provider,{value:o},t)},Ge=()=>{let t=(0,j.useContext)(Te);if(!t)throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");return t};function Lr(){let{location:t}=Ge();return{value:t==null?void 0:t.getValue(),setValue:t==null?void 0:t.setValue,metadata:t==null?void 0:t.getMetadata()}}var Ft=require("@uniformdev/mesh-sdk"),ie=require("react"),Mr=({autoResizingDisabled:t}={})=>{let[n,r]=(0,ie.useState)(),[o,a]=(0,ie.useState)();return(0,ie.useEffect)(()=>{typeof window=="undefined"||o||(typeof window.UniformMeshSDK=="undefined"?(0,Ft.initializeUniformMeshSDK)({autoResizingDisabled:t}).then(d=>{a(d)}).catch(d=>{r(d)}):a(window.UniformMeshSDK))},[t]),{initializing:!o&&!n,error:n,sdk:o}};var he=require("react");var $t=require("@uniformdev/design-system"),ze=(0,he.createContext)(void 0),Vr=({children:t})=>{let n;return typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"&&(n={sdk:window.UniformMeshSDK}),(0,e.jsx)(ze.Provider,{value:n},(0,e.jsx)($t.Theme,null),(0,e.jsx)(De,null,t))},Ue=()=>{let t=(0,he.useContext)(ze);if(!t)throw new Error("useUniformMeshSdkContext must be used within a UniformMeshSdkContextProvider");return t};function Er(){let{sdk:t}=Ue();return t}var Ke=$(require("react"));var K=$(require("react"));var ee=require("@emotion/react"),Kt=require("@uniformdev/design-system");var Ae=$(require("react")),Be=({value:t,text:n,loading:r})=>(0,e.jsx)(Ae.default.Fragment,null,!!n&&n,!n&&(0,e.jsx)(Ae.default.Fragment,null,r&&`${t} (Loading...)`,!r&&`${t} (Unresolvable)`));var Oe=({name:t,loading:n,selectedValues:r,values:o,onAdd:a,onRemove:d})=>{var v;let f=(v=o==null?void 0:o.filter(m=>!(r!=null&&r.includes(m.id.toString()))))!=null?v:[],h=(m,c)=>{m.preventDefault(),d(c)};return(0,e.jsx)("div",null,(0,e.jsx)(Kt.InputSelect,{id:"product-query",name:"product-query",label:t,onChange:m=>a(m.target.value),disabled:n,options:[{value:"",label:"Add..."},...f.map(m=>({value:m.id,label:m.name||m.id}))],css:Array.isArray(r)&&r.length>0?ee.css`
|
|
2
|
+
margin-bottom: var(--spacing-base);
|
|
3
|
+
`:""}),r==null?void 0:r.map(m=>{var c;return(0,e.jsx)("div",{css:ee.css`
|
|
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:m},(0,e.jsx)("span",{css:ee.css`
|
|
13
|
+
padding: var(--spacing-3);
|
|
14
|
+
color: var(--gray-800);
|
|
15
|
+
`},(0,e.jsx)(Be,{value:m,loading:n,text:(c=o.find(u=>u.id===m))==null?void 0:c.name})),(0,e.jsx)("button",{css:ee.css`
|
|
16
|
+
padding: var(--spacing-3);
|
|
17
|
+
border-left: 1px solid var(--gray-300);
|
|
18
|
+
`,title:"remove",onClick:u=>h(u,m)},(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",css:ee.css`
|
|
19
|
+
height: 1.25rem;
|
|
20
|
+
width: 1.25rem;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
display: block;
|
|
23
|
+
`,viewBox:"0 0 20 20",fill:"currentColor"},(0,e.jsx)("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 Ir=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 46 46",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},(0,e.jsx)("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"})),be=Ir;var Tr=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},(0,e.jsx)("path",{d:"M4 12a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1Z",fill:"currentColor"})),ye=Tr;var we=require("react-use"),V=require("@uniformdev/design-system"),C=require("@emotion/react"),Qt={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},Dr=({value:t,setValue:n,brands:r,categories:o,loading:a,categoriesLoading:d,brandsLoading:f,logoIcon:h,onGetProducts:v,sortOptions:m,sortOrderOptions:c})=>{var U;let u=async s=>{n({...Qt,...t||{},...s})},g=(0,K.useMemo)(()=>({...Qt,...t||{}}),[t]),[q,T]=(0,we.useAsyncFn)(async s=>await v(s),[v]);(0,we.useDebounce)(async()=>{await T({brand:g.brand,categories:g.categories,keyword:g.keyword,sort:g.sort,sortOrder:g.sortOrder,count:g.count})},250,[g]);let X=(0,K.useMemo)(()=>{let s=[];return o==null||o.forEach(p=>{let A=_t(p,void 0);s.push(...A)}),s},[o]),H=(0,K.useMemo)(()=>(r==null?void 0:r.map(s=>({id:s.id.toString(),name:s.name})))||[],[r]),F=s=>{let p=(t==null?void 0:t.categories)||[];u({categories:[...p,s]})},W=s=>{var p;u({categories:(p=t==null?void 0:t.categories)==null?void 0:p.filter(A=>A!==s)})},me=s=>{u({brand:s.target.value})},z=s=>{u({count:s||1})};return a||q.loading?(0,e.jsx)("div",null,"Loading..."):(0,e.jsx)(He.Provider,{value:{categories:o,logoIcon:h}},(0,e.jsx)("div",{css:C.css`
|
|
24
|
+
> :not(:last-child) {
|
|
25
|
+
margin-bottom: var(--spacing-md);
|
|
26
|
+
}
|
|
27
|
+
`},(0,e.jsx)(Oe,{loading:d||!1,name:"Product Category",onAdd:F,onRemove:W,selectedValues:g.categories,values:X}),(0,e.jsx)("div",{css:C.css`
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
column-gap: var(--spacing-lg);
|
|
31
|
+
row-gap: var(--spacing-md);
|
|
32
|
+
${(0,V.mq)("md")} {
|
|
33
|
+
flex-wrap: nowrap;
|
|
34
|
+
}
|
|
35
|
+
`},(0,e.jsx)("div",{css:C.css`
|
|
36
|
+
width: 50%;
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
`},(0,e.jsx)(V.InputSelect,{id:"brand",name:"brand",label:"Brand",disabled:f,value:g.brand,onChange:me,options:[{value:"",label:"Select a brand"},...H.map(s=>({value:s.id,label:s.name}))]})),(0,e.jsx)("div",{css:C.css`
|
|
39
|
+
flex-grow: 1;
|
|
40
|
+
position: relative;
|
|
41
|
+
`},(0,e.jsx)(V.Input,{id:"count",name:"count",type:"number",min:1,step:1,value:g.count,onChange:s=>z(s.target.valueAsNumber),label:"Count"}),(0,e.jsx)("div",{css:C.css`
|
|
42
|
+
position: absolute;
|
|
43
|
+
bottom: var(--spacing-sm);
|
|
44
|
+
right: var(--spacing-sm);
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: var(--spacing-sm);
|
|
47
|
+
`},(0,e.jsx)(Nt,{onCountChange:()=>z(g.count-1),countIcon:"decrement",disabled:g.count===1}),(0,e.jsx)(Nt,{onCountChange:()=>z(g.count+1),countIcon:"increment"})))),(0,e.jsx)("div",{css:C.css`
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-wrap: wrap;
|
|
50
|
+
column-gap: var(--spacing-lg);
|
|
51
|
+
row-gap: var(--spacing-md);
|
|
52
|
+
${(0,V.mq)("md")} {
|
|
53
|
+
flex-wrap: nowrap;
|
|
54
|
+
}
|
|
55
|
+
`},(0,e.jsx)("div",{css:C.css`
|
|
56
|
+
width: 100%;
|
|
57
|
+
${(0,V.mq)("md")} {
|
|
58
|
+
width: 33.333333%;
|
|
59
|
+
}
|
|
60
|
+
`},(0,e.jsx)(V.Input,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:g.keyword,placeholder:"Enter keyword",onChange:s=>u({keyword:s.target.value})})),Array.isArray(m)&&m.length>0?(0,e.jsx)("div",{css:C.css`
|
|
61
|
+
flex-grow: 1;
|
|
62
|
+
${(0,V.mq)("md")} {
|
|
63
|
+
width: 33.333333%;
|
|
64
|
+
}
|
|
65
|
+
`},(0,e.jsx)(V.InputSelect,{id:"sort",name:"sort",label:"Sort",value:g.sort,onChange:s=>u({sort:s.target.value}),options:[{value:"",label:"Select a sort"},...m.map(s=>({value:s.sortKey,label:s.name}))]})):null,Array.isArray(c)&&c.length>0?(0,e.jsx)("div",{css:C.css`
|
|
66
|
+
flex-grow: 1;
|
|
67
|
+
`},(0,e.jsx)(V.InputSelect,{id:"sort-order",name:"sort-order",label:"Sort Order",value:g.sortOrder,onChange:s=>u({sortOrder:s.target.value}),options:c.map(s=>({value:s.sortOrderKey,label:s.name}))})):null),(0,e.jsx)("div",null,(0,e.jsx)("h3",{css:C.css`
|
|
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"),(0,e.jsx)($e,{products:(U=q.value)==null?void 0:U.products}))))};function _t(t,n){var d;let r=[],o=n?`${n.name} > `:"",a={id:t.id.toString(),name:`${o}${t.name}`};return r.push(a),(d=t.children)==null||d.forEach(f=>{let h=_t(f,a);r.push(...h)}),r}function Nt({onCountChange:t,countIcon:n,disabled:r}){return(0,e.jsx)("button",{css:C.css`
|
|
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
|
+
${r?C.css`
|
|
85
|
+
cursor: not-allowed;
|
|
86
|
+
opacity: 0.3;
|
|
87
|
+
`:""}
|
|
88
|
+
`,onClick:t,disabled:r},n==="increment"?(0,e.jsx)(be,{css:C.css`
|
|
89
|
+
width: 1rem;
|
|
90
|
+
height: 1rem;
|
|
91
|
+
`}):(0,e.jsx)(ye,{css:C.css`
|
|
92
|
+
width: 1rem;
|
|
93
|
+
height: 1rem;
|
|
94
|
+
`}))}var He=K.default.createContext(void 0),Fe=()=>{let t=(0,K.useContext)(He);if(!t)throw new Error("useProductQueryContext must be used within a <ProductQueryContext> provider");return t};function Q({src:t,alt:n,className:r}){let o=t&&typeof t!="string"?t:null;return o?(0,e.jsx)(o,{className:r}):(0,e.jsx)("img",{src:t,alt:n,className:r})}var P=require("@emotion/react"),Zt=require("@uniformdev/design-system"),$e=({products:t})=>{let{categories:n,logoIcon:r}=Fe();return(0,e.jsx)(Ke.default.Fragment,null,(0,e.jsx)("p",{css:P.css`
|
|
95
|
+
margin-bottom: var(--spacing-base);
|
|
96
|
+
`},"Matching ",(t==null?void 0:t.length)||0," products"),(0,e.jsx)("ul",{css:[P.css`
|
|
97
|
+
max-height: 24rem;
|
|
98
|
+
overflow-x: auto;
|
|
99
|
+
`,Zt.scrollbarStyles]},t==null?void 0:t.map((o,a)=>{var h;let[d]=(o==null?void 0:o.categories)||[],f=typeof d=="undefined"||!n||(h=n.find(v=>v.id===d.id))==null?void 0:h.name;return(0,e.jsx)("li",{key:`product-${o.id}`,css:P.css`
|
|
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
|
+
`},(0,e.jsx)("div",{css:P.css`
|
|
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
|
+
`},o.thumbnailUrl?(0,e.jsx)("img",{src:o.thumbnailUrl,alt:o.name||`Product ${a}`,css:P.css`
|
|
112
|
+
background-color: var(--gray-200);
|
|
113
|
+
width: 3.5rem;
|
|
114
|
+
height: 3.5rem;
|
|
115
|
+
object-fit: cover;
|
|
116
|
+
`}):(0,e.jsx)("div",{css:P.css`
|
|
117
|
+
height: 3.5rem;
|
|
118
|
+
width: 3.5rem;
|
|
119
|
+
background-color: var(--gray-100);
|
|
120
|
+
`}),(0,e.jsx)("h4",{css:P.css`
|
|
121
|
+
font-weight: var(--fw-bold);
|
|
122
|
+
width: 33.333333%;
|
|
123
|
+
font-size: var(--fs-sm);
|
|
124
|
+
`},o.name,f&&(0,e.jsx)("span",{css:P.css`
|
|
125
|
+
display: block;
|
|
126
|
+
font-weight: var(--fw-regular);
|
|
127
|
+
`},f)),o&&(0,e.jsx)(Ke.default.Fragment,null,(0,e.jsx)("p",{css:P.css`
|
|
128
|
+
margin-right: var(--spacing-lg);
|
|
129
|
+
font-size: var(--fs-sm);
|
|
130
|
+
`},"SKU: ",o.sku," ",o.id,(0,e.jsx)("br",null)),o.price&&(0,e.jsx)("p",{css:P.css`
|
|
131
|
+
margin-right: var(--spacing-lg);
|
|
132
|
+
font-size: var(--fs-sm);
|
|
133
|
+
`},o.price&&(0,e.jsx)("span",{css:P.css`
|
|
134
|
+
display: block;
|
|
135
|
+
`},"Price: ",o.price)),(0,e.jsx)("a",{css:P.css`
|
|
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:o.url,title:`Goto ${o.name}`,target:"__blank",rel:"noopener"},(0,e.jsx)("span",{css:P.css`
|
|
148
|
+
font-size: var(--fs-sm);
|
|
149
|
+
margin-right: var(--spacing-sm);
|
|
150
|
+
`},"Edit"),r?(0,e.jsx)(Q,{src:r,alt:"Logo",css:P.css`
|
|
151
|
+
width: 2.25rem;
|
|
152
|
+
height: 2.25rem;
|
|
153
|
+
`}):null))))})))};var Z=$(require("react"));var G=$(require("react"));var Pe={};Ht(Pe,{Caution:()=>qt,Checkmark:()=>Se,ChevronDown:()=>Ce,Close:()=>te,Danger:()=>Wt,ExclamationPoint:()=>Jt,Info:()=>re,Lightbulb:()=>Xt,MagnifyingGlass:()=>Yt,MaximizeAlt:()=>jt,Minus:()=>ye,MoreVerticalAlt:()=>se,Plus:()=>be});var Gr=t=>(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 16 16",fill:"currentColor",...t},(0,e.jsx)("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"})),qt=Gr;var zr=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 40 40",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},(0,e.jsx)("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"})),Se=zr;var Ur=t=>(0,e.jsx)("svg",{viewBox:"0 0 24 24",width:"1em",height:"1em",...t},(0,e.jsx)("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"})),Ce=Ur;var Ar=t=>(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 19 19",fill:"currentColor",...t},(0,e.jsx)("g",{fillRule:"evenodd"},(0,e.jsx)("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"}),(0,e.jsx)("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"}))),te=Ar;var Br=t=>(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 12 16",fill:"currentColor",...t},(0,e.jsx)("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"})),Wt=Br;var Or=t=>(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 14 16",fill:"currentColor",...t},(0,e.jsx)("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"})),Jt=Or;var Hr=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",fill:"currentColor",...t},(0,e.jsx)("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"}),(0,e.jsx)("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"})),re=Hr;var Fr=t=>(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 12 16",fill:"currentColor",...t},(0,e.jsx)("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"})),Xt=Fr;var $r=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 26 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},(0,e.jsx)("g",{clipPath:"url(#magnifying-glass_svg__a)"},(0,e.jsx)("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"}),(0,e.jsx)("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"})),(0,e.jsx)("defs",null,(0,e.jsx)("clipPath",{id:"magnifying-glass_svg__a"},(0,e.jsx)("path",{fill:"#fff",transform:"translate(.558)",d:"M0 0h24.935v24H0z"})))),Yt=$r;var Kr=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",fill:"currentColor",...t},(0,e.jsx)("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"})),jt=Kr;var Qr=t=>(0,e.jsx)("svg",{width:"1em",height:"1em",fill:"currentColor",...t},(0,e.jsx)("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"})),se=Qr;var or=require("react-use"),nr=require("uuid");var B=$(require("react"));function er(t,n){let r=window.open(t,"_blank"),o=setInterval(()=>{r!=null&&r.closed&&(clearInterval(o),n())},500)}var rr=require("timeago.js");var x=require("@emotion/react"),tr=require("@uniformdev/design-system"),Qe=x.css`
|
|
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
|
+
`,Ne=x.css`
|
|
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
|
+
`,_e=x.css`
|
|
168
|
+
flex-grow: 1;
|
|
169
|
+
`,Ze=x.css`
|
|
170
|
+
align-items: start;
|
|
171
|
+
display: inline-flex;
|
|
172
|
+
position: relative;
|
|
173
|
+
`,qe=x.css`
|
|
174
|
+
color: var(--brand-secondary-1);
|
|
175
|
+
font-size: var(--fs-base);
|
|
176
|
+
font-weight: var(--fw-bold);
|
|
177
|
+
line-height: 1;
|
|
178
|
+
`,We=x.css`
|
|
179
|
+
width: 1.5rem;
|
|
180
|
+
height: 1.5rem;
|
|
181
|
+
`,Je=x.css`
|
|
182
|
+
width: 1rem;
|
|
183
|
+
height: 1rem;
|
|
184
|
+
`,Xe=x.css`
|
|
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
|
+
`,N=x.css`
|
|
193
|
+
font-size: var(--fs-sm);
|
|
194
|
+
`,ce=x.css`
|
|
195
|
+
font-weight: var(--fw-bold);
|
|
196
|
+
margin-right: var(--spacing-sm);
|
|
197
|
+
`,Ye=x.css`
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: var(--spacing-sm);
|
|
201
|
+
|
|
202
|
+
${(0,tr.mq)("md")} {
|
|
203
|
+
flex-direction: row;
|
|
204
|
+
}
|
|
205
|
+
`,Re=x.css`
|
|
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
|
+
`;var D=require("@emotion/react");var je=({selectedItem:t,logoIcon:n,onDeselect:r,onEditClosed:o})=>{var m;let a=(0,B.useRef)(null),d=(0,B.useRef)(null),[f,h]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let c=g=>{a.current&&!a.current.contains(g.target)&&d.current&&!d.current.contains(g.target)&&h(!1)},u=()=>{h(!1)};return window.addEventListener("resize",u,!0),document.addEventListener("scroll",c,!0),document.addEventListener("mousedown",c),()=>{window.removeEventListener("resize",u,!0),document.removeEventListener("scroll",c,!0),document.removeEventListener("mousedown",c)}},[d]);let v=()=>{var c;if(h(!f),d.current&&a.current){let u=(c=a==null?void 0:a.current)==null?void 0:c.getBoundingClientRect();d.current.style.top=`${u.top+30}px`}};return(0,e.jsx)("div",{css:Qe,key:t.id},(0,e.jsx)("div",{css:Ne},(0,e.jsx)("div",{css:_e},(0,e.jsx)("div",{css:Ze},(0,e.jsx)("h4",{css:[qe,t.popoverData?D.css`
|
|
219
|
+
margin-bottom: var(--spacing-sm);
|
|
220
|
+
`:""],title:`ID: ${t.id}`,"data-test-id":"entry-id"},t.title||t.id||""),t.popoverData?(0,e.jsx)(B.default.Fragment,null,(0,e.jsx)("button",{type:"button",ref:a,css:D.css`
|
|
221
|
+
margin: calc(var(--spacing-xs) * -1) 0 calc(var(--spacing-xs) * -1) var(--spacing-sm);
|
|
222
|
+
`,"aria-controls":"path-details","aria-expanded":f,onClick:v},(0,e.jsx)(re,{width:24,height:24,css:D.css`
|
|
223
|
+
color: var(--gray-400);
|
|
224
|
+
`})),(0,e.jsx)("div",{id:"path-details","aria-hidden":!f,ref:d,css:[Xe,f?D.css`
|
|
225
|
+
visibility: visible;
|
|
226
|
+
`:D.css`
|
|
227
|
+
visibility: hidden;
|
|
228
|
+
`]},Object.entries(t.popoverData).map(([c,u],g)=>(0,e.jsx)("div",{css:N,key:g},(0,e.jsx)("span",{css:ce},c,":"),u)))):null),t.createdDate&&(0,e.jsx)("div",{css:N},(0,e.jsx)("span",{css:ce},"Created:"),(0,rr.format)((m=t.createdDate)!=null?m:0)),(0,e.jsx)("div",{css:D.css`
|
|
229
|
+
display: flex;
|
|
230
|
+
gap: var(--spacing-base);
|
|
231
|
+
`},t.metadata?Object.entries(t.metadata).filter(([c])=>["type","status"].includes(c.toLocaleLowerCase())).map(([c,u])=>(0,e.jsx)("span",{css:N,key:c},u)):null),t.metadata?Object.entries(t.metadata).filter(([c])=>!["type","status"].includes(c.toLocaleLowerCase())).map(([c,u])=>(0,e.jsx)("div",{css:[N,D.css`
|
|
232
|
+
order: 1;
|
|
233
|
+
`],key:c},(0,e.jsx)("span",{css:[ce,D.css`
|
|
234
|
+
order: 1;
|
|
235
|
+
`]},c,":"),u)):null),(0,e.jsx)("div",{css:Ye},t.editLink?(0,e.jsx)("a",{href:t.editLink,title:"edit",rel:"noopener",target:"__blank",onClick:c=>{o&&(er(c.currentTarget.href,()=>o(t)),c.preventDefault())},css:Re},(0,e.jsx)("span",{css:N},"Edit"),(0,e.jsx)(Q,{src:n,css:We,alt:"Logo"})):null,(0,e.jsx)("button",{type:"button",onClick:c=>{c.preventDefault(),r(t)},css:Re},(0,e.jsx)("span",{css:N},"Unlink"),(0,e.jsx)(te,{css:[Je,D.css`
|
|
236
|
+
color: var(--brand-secondary-5);
|
|
237
|
+
`]})))))};var O=$(require("react"));var J=require("@emotion/react"),et=J.css`
|
|
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
|
+
`,tt=J.css`
|
|
244
|
+
background: var(--brand-secondary-3);
|
|
245
|
+
color: var(--white);
|
|
246
|
+
`,ke=J.css`
|
|
247
|
+
font-size: var(--fs-xs);
|
|
248
|
+
`,xe=J.css`
|
|
249
|
+
font-weight: var(--fw-bold);
|
|
250
|
+
margin-right: var(--spacing-sm);
|
|
251
|
+
`,rt=J.css`
|
|
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
|
+
`,ot=J.css`
|
|
264
|
+
position: absolute;
|
|
265
|
+
inset: 0 var(--spacing-sm) 0 auto;
|
|
266
|
+
`;var nt=require("@emotion/react"),at=({result:t,isSelected:n,triggerSelection:r})=>{let o=(0,O.useRef)(null),a=(0,O.useRef)(null),[d,f]=(0,O.useState)(!1);(0,O.useEffect)(()=>{function v(m){o.current&&!o.current.contains(m.target)&&a.current&&!a.current.contains(m.target)&&f(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[a]);let h=v=>{v.stopPropagation(),f(!d)};return(0,e.jsx)("div",{key:t.id,css:[et,n?tt:void 0],"data-value":t.id,role:"option",tabIndex:-1,onClick:()=>r()},t.title,t.popoverData&&n?(0,e.jsx)(O.default.Fragment,null,(0,e.jsx)("button",{type:"button",ref:o,css:ot,"aria-controls":"path-details",onClick:v=>h(v),"aria-expanded":d},(0,e.jsx)(re,{width:24,height:24})),(0,e.jsx)("div",{id:"path-details","aria-hidden":!d,ref:a,css:[rt,d?nt.css`
|
|
267
|
+
visibility: visible;
|
|
268
|
+
`:nt.css`
|
|
269
|
+
visibility: hidden;
|
|
270
|
+
`]},t.metadata&&Object.entries(t.metadata).map(([v,m],c)=>(0,e.jsx)("div",{css:ke,key:c},(0,e.jsx)("span",{css:xe},v,":"),m)),Object.entries(t.popoverData).map(([v,m],c)=>(0,e.jsx)("div",{css:ke,key:c},(0,e.jsx)("span",{css:xe},v,":"),m)))):null)};var oe=require("react-beautiful-dnd");var S=require("@emotion/react"),it=S.css`
|
|
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
|
+
`,st=S.css`
|
|
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
|
+
`,ct=S.css`
|
|
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
|
+
`,dt=S.css`
|
|
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
|
+
`,lt=S.css`
|
|
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
|
+
`,pt=S.css`
|
|
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
|
+
`,Nr=S.css`
|
|
322
|
+
background-color: var(--gray-50);
|
|
323
|
+
max-width: 33.33%;
|
|
324
|
+
`,mt=S.css`
|
|
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
|
+
`,ut=S.css`
|
|
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
|
+
`,_r=S.css`
|
|
338
|
+
background: var(--white);
|
|
339
|
+
color: var(--brand-secondary-1);
|
|
340
|
+
`,gt=S.css`
|
|
341
|
+
position: relative;
|
|
342
|
+
margin-block: var(--spacing-sm) 0;
|
|
343
|
+
|
|
344
|
+
&:hover > span {
|
|
345
|
+
opacity: 0.3;
|
|
346
|
+
}
|
|
347
|
+
`,ft=S.css`
|
|
348
|
+
align-items: center;
|
|
349
|
+
display: flex;
|
|
350
|
+
position: absolute;
|
|
351
|
+
inset: 0 auto 0 0;
|
|
352
|
+
margin-block: auto;
|
|
353
|
+
opacity: 0;
|
|
354
|
+
`,Le=S.css`
|
|
355
|
+
color: var(--brand-secondary-1);
|
|
356
|
+
`,vt=S.css`
|
|
357
|
+
position: absolute;
|
|
358
|
+
left: 0.375rem;
|
|
359
|
+
`,Me=S.css`
|
|
360
|
+
width: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
361
|
+
height: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
362
|
+
`;var E=require("@emotion/react"),w=require("@uniformdev/design-system"),Zr=({searchText:t,selectedContentType:n})=>{let r="No content found";return n&&(r=`No ${n} content was found`),t&&(r=`${r} for keyword '${t}'.`),(0,e.jsx)(w.Callout,{type:"info"},r)},ht=({search:t,results:n,contentTypes:r,selectedItems:o,logoIcon:a,select:d,multiSelect:f,multiSelectId:h,rowComponent:v,selectedItemComponent:m,totalResults:c,resultsLoading:u,requireContentType:g,onAddNew:q,onEditClosed:T,onCancel:X,noResultsComponent:H,helpComponent:F,onSort:W})=>{var Ut,At,Bt;let z=()=>g?Array.isArray(r)&&r.length>0?r[0].id:"":"any",[U,s]=G.useState(""),[p,A]=G.useState(z),[ne,Ee]=G.useState(!1),[ue,ge]=G.useState([]),[cr,Tt]=G.useState(!1),fe=(0,or.useThrottle)(U,750);G.useEffect(()=>{t(fe,{count:5,offset:0,contentType:p==="any"?void 0:p})},[fe,p]);let dr=i=>{ue.includes(i.id)?ge(b=>b.filter(Y=>Y!==i.id)):ge(f?b=>[...b,i==null?void 0:i.id]:[i.id])},lr=()=>{A(z()),s(""),ge(o!=null&&o.length?o.map(i=>i.id):[])},pr=()=>{Ee(i=>!i),ne||lr()},Dt=i=>{d((o==null?void 0:o.filter(b=>b.id!==i.id).map(b=>b.id))||[],"")},mr=i=>{i.preventDefault(),d(ue,p),Ee(!1)},ur=i=>{i.preventDefault(),Ee(!1),X&&X()},gr=i=>{i.preventDefault(),t(fe,{count:5,offset:(n==null?void 0:n.length)||0,contentType:p==="any"?void 0:p}),Tt(!0);let b=setTimeout(()=>{Tt(!1)},750);return()=>clearTimeout(b)},Ie=G.useRef((0,nr.v4)()),fr=!(o==null?void 0:o.length)||f,vr=v||at,Gt=m||je,hr=H||Zr,zt=a&&typeof a!="string"?a:null,br=zt?(0,e.jsx)(zt,{css:Me}):(0,e.jsx)("img",{src:a,alt:"CMS logo",css:Me}),yr=i=>{var b,Y;if(i.destination&&i.source.droppableId===((b=i.destination)==null?void 0:b.droppableId)){let L=[...o||[]],[ae]=(Y=L==null?void 0:L.splice(i.source.index,1))!=null?Y:[];return L==null||L.splice(i.destination.index,0,ae),W==null||W(L.map(wr=>wr.id)),L}};return(0,e.jsx)("div",{css:E.css`
|
|
363
|
+
width: 100%;
|
|
364
|
+
`},(0,e.jsx)("div",{css:E.css`
|
|
365
|
+
position: relative;
|
|
366
|
+
margin-block: var(--spacing-base);
|
|
367
|
+
`},fr&&(0,e.jsx)("div",null,(0,e.jsx)("div",{css:it,"data-test-id":"component-search"},(0,e.jsx)("button",{css:st,onClick:pr,type:"button","aria-haspopup":!0,"aria-expanded":ne,"aria-controls":`entry-search-config-${Ie.current}`},br,(0,e.jsx)("span",{css:E.css`
|
|
368
|
+
margin-left: var(--spacing-base);
|
|
369
|
+
`},"Select"),(0,e.jsx)("span",{css:mt},(0,e.jsx)(Ce,{css:[ut,ne?E.css`
|
|
370
|
+
transform: rotate(180deg);
|
|
371
|
+
`:void 0]})))),(0,e.jsx)("div",{id:`entry-search-config-${Ie.current}`,"aria-hidden":!ne,css:[dt,ne?void 0:lt]},F||null,(0,e.jsx)("div",{css:E.css`
|
|
372
|
+
display: flex;
|
|
373
|
+
gap: calc(var(--spacing-base) - 0.25rem);
|
|
374
|
+
margin-bottom: var(--spacing-base);
|
|
375
|
+
`},(0,e.jsx)(w.InputSelect,{onChange:i=>A(i.target.value),value:p,label:"Content Type Select",showLabel:!1,options:[...g?[]:[{value:"any",label:"All content types"}],...r?r.map(i=>({value:i.id,label:i.name})):[]]}),(0,e.jsx)("div",{css:E.css`
|
|
376
|
+
flex-grow: 1;
|
|
377
|
+
`},(0,e.jsx)(w.InputKeywordSearch,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:s,disabledFieldSubmission:!0,value:U}))),(0,e.jsx)("div",{css:[pt,w.scrollbarStyles],id:Ie.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},!u&&Array.isArray(n)?n.map(i=>(0,e.jsx)(vr,{key:i.id,isSelected:ue.includes(i.id),result:i,triggerSelection:()=>dr(i)})):u?null:(0,e.jsx)(hr,{searchText:fe||U,selectedContentType:(At=(Ut=r==null?void 0:r.find(i=>i.id===p))==null?void 0:Ut.name)!=null?At:p}),!u&&typeof c!="undefined"&&n&&(n==null?void 0:n.length)<c&&(0,e.jsx)("button",{css:ct,onClick:gr},cr?(0,e.jsx)(w.LoadingIndicator,null):"Load More"),u&&!(n!=null&&n.length)?(0,e.jsx)("div",{css:E.css`
|
|
378
|
+
padding: var(--spacing-base);
|
|
379
|
+
text-align: center;
|
|
380
|
+
width: 100%;
|
|
381
|
+
`},(0,e.jsx)(w.LoadingIndicator,null)):null),(0,e.jsx)("div",{css:E.css`
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: space-between;
|
|
384
|
+
`},(0,e.jsx)("div",null,q&&((Bt=r==null?void 0:r.length)!=null?Bt:0)>0?(0,e.jsx)(w.Menu,{menuLabel:"Add new menu",menuTrigger:(0,e.jsx)(w.Button,{buttonType:"secondary"},"Add New")},r==null?void 0:r.map(i=>(0,e.jsx)(w.MenuItem,{key:i.id,css:E.css`
|
|
385
|
+
background: var(--white);
|
|
386
|
+
color: var(--brand-secondary-1);
|
|
387
|
+
`,onClick:()=>q(i)},i.name))):null),(0,e.jsx)("div",{css:E.css`
|
|
388
|
+
display: flex;
|
|
389
|
+
gap: var(--spacing-base);
|
|
390
|
+
`},(0,e.jsx)(w.Button,{buttonType:"unimportant",onClick:ur},"Cancel"),(0,e.jsx)(w.Button,{disabled:!ue.length,onClick:mr,"data-test-id":"entry-accept-button"},"Accept"))))),f?(0,e.jsx)(oe.DragDropContext,{onDragEnd:i=>yr(i)},(0,e.jsx)(oe.Droppable,{droppableId:h||"canvas-multi-select"},i=>(0,e.jsx)("div",{...i.droppableProps,ref:i.innerRef,css:E.css`
|
|
391
|
+
margin-block: var(--spacing-sm) 0;
|
|
392
|
+
`},o==null?void 0:o.map((b,Y)=>{if(b!=null&&b.id)return(0,e.jsx)(oe.Draggable,{key:b.id,draggableId:b.id,index:Y},L=>(0,e.jsx)("div",{css:gt,ref:L.innerRef,...L.draggableProps,...L.dragHandleProps},(0,e.jsx)("span",{css:ft},(0,e.jsx)(se,{css:[Le,vt],width:24,height:24}),(0,e.jsx)(se,{css:Le,width:24,height:24})),(0,e.jsx)(Gt,{key:`selected-item-${b.id}`,logoIcon:a,selectedItem:b,onDeselect:ae=>Dt(ae),onEditClosed:T?ae=>T(ae):void 0})))}),i.placeholder))):o==null?void 0:o.map(i=>(0,e.jsx)(Gt,{key:`selected-item-${i.id}`,logoIcon:a,selectedItem:i,onDeselect:b=>Dt(b),onEditClosed:T?b=>T(b):void 0}))))};var _=require("@emotion/react"),bt=_.css`
|
|
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
|
+
`,yt=_.css`
|
|
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
|
+
`,wt=_.css`
|
|
407
|
+
background-color: var(--green-50);
|
|
408
|
+
`,St=_.css`
|
|
409
|
+
font-size: var(--fs-sm);
|
|
410
|
+
font-weight: var(--fw-bold);
|
|
411
|
+
width: 50%;
|
|
412
|
+
`,Ct=_.css`
|
|
413
|
+
font-weight: var(--fw-normal);
|
|
414
|
+
display: block;
|
|
415
|
+
`,Pt=_.css`
|
|
416
|
+
font-size: var(--fs-sm);
|
|
417
|
+
> * {
|
|
418
|
+
display: block;
|
|
419
|
+
}
|
|
420
|
+
`,Rt=_.css`
|
|
421
|
+
display: block;
|
|
422
|
+
height: 1.5rem;
|
|
423
|
+
width: 1.5rem;
|
|
424
|
+
color: var(--brand-secondary-3);
|
|
425
|
+
margin-left: auto;
|
|
426
|
+
`;var kt=require("@emotion/react");function xt({result:t,isSelected:n,triggerSelection:r}){var h;let{categories:o,logoIcon:a}=de(),[d]=t.categories||[{id:"",name:""}],f=typeof d=="undefined"||!o||(h=o.find(v=>v.id===d.id))==null?void 0:h.name;return(0,e.jsx)("div",{key:t.id,"data-value":t.id,role:"option",tabIndex:-1,onClick:()=>r(),css:[bt]},(0,e.jsx)("div",{css:[yt,n?wt:void 0]},t.thumbnailUrl?(0,e.jsx)("img",{src:t.thumbnailUrl,alt:`Thumbnail for ${t.title}`,css:kt.css`
|
|
427
|
+
background-color: var(--gray-200);
|
|
428
|
+
width: 3rem;
|
|
429
|
+
height: 3rem;
|
|
430
|
+
object-fit: cover;
|
|
431
|
+
`}):(0,e.jsx)(Q,{src:a,alt:"Logo",css:kt.css`
|
|
432
|
+
height: 2.25rem;
|
|
433
|
+
width: 2.25rem;
|
|
434
|
+
`}),(0,e.jsx)("h4",{css:[St]},t.title,f?(0,e.jsx)("span",{css:[Ct]},f):null),(0,e.jsx)("p",{css:[Pt]},"SKU: ",t.id,t.price&&(0,e.jsx)("span",null,t.price)),n?(0,e.jsx)(Se,{css:[Rt]}):null))}var le=require("@emotion/react"),ar=require("@uniformdev/design-system"),Lt=le.css`
|
|
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
|
+
`,Mt=le.css`
|
|
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
|
+
`,Vt=le.css`
|
|
449
|
+
display: flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
gap: var(--spacing-sm);
|
|
452
|
+
margin-bottom: var(--spacing-sm);
|
|
453
|
+
${(0,ar.mq)("lg")} {
|
|
454
|
+
width: 50%;
|
|
455
|
+
margin-bottom: 0;
|
|
456
|
+
}
|
|
457
|
+
`,Ve=le.css`
|
|
458
|
+
background-color: var(--gray-200);
|
|
459
|
+
width: 3.5rem;
|
|
460
|
+
height: 3.5rem;
|
|
461
|
+
object-fit: cover;
|
|
462
|
+
`;var R=require("@emotion/react"),ir=require("@uniformdev/design-system");function Et({selectedItem:t,onDeselect:n}){var f;let{categories:r,logoIcon:o}=de(),[a]=t.categories||[{id:"",name:""}],d=typeof a=="undefined"||!r||(f=r.find(h=>h.id===a.id))==null?void 0:f.name;return(0,e.jsx)("div",{css:[Lt],key:t.id},(0,e.jsx)("article",{css:[Mt]},(0,e.jsx)("div",{css:[Vt]},t.thumbnailUrl?(0,e.jsx)("img",{src:t.thumbnailUrl,alt:d,css:[Ve],loading:"lazy"}):(0,e.jsx)("div",{css:[Ve]}),(0,e.jsx)("div",{css:R.css`
|
|
463
|
+
> :not(:last-child) {
|
|
464
|
+
margin-bottom: var(--spacing-xs);
|
|
465
|
+
}
|
|
466
|
+
`},(0,e.jsx)("h4",{css:R.css`
|
|
467
|
+
font-weight: var(--fw-bold);
|
|
468
|
+
`},t.title||t.id||"",d&&(0,e.jsx)("span",{css:R.css`
|
|
469
|
+
display: block;
|
|
470
|
+
font-weight: var(--fw-regular);
|
|
471
|
+
`},d)),(0,e.jsx)("ul",{css:R.css`
|
|
472
|
+
font-size: var(--fs-sm);
|
|
473
|
+
display: flex;
|
|
474
|
+
gap: var(--spacing-base);
|
|
475
|
+
`},(0,e.jsx)("li",null,(0,e.jsx)("span",{css:R.css`
|
|
476
|
+
margin-right: var(--spacing-xs);
|
|
477
|
+
`},"SKU:"),t.id),t.price&&(0,e.jsx)("li",null,(0,e.jsx)("span",{css:R.css`
|
|
478
|
+
margin-right: var(--spacing-xs);
|
|
479
|
+
`},"Price:"),(0,e.jsx)("span",null,t.price))))),(0,e.jsx)("div",{css:R.css`
|
|
480
|
+
display: flex;
|
|
481
|
+
flex-wrap: wrap;
|
|
482
|
+
gap: var(--spacing-sm);
|
|
483
|
+
justify-content: flex-end;
|
|
484
|
+
margin-left: auto;
|
|
485
|
+
${(0,ir.mq)("md")} {
|
|
486
|
+
align-items: center;
|
|
487
|
+
}
|
|
488
|
+
`},t.editLink?(0,e.jsx)("a",{href:t.editLink,title:"edit",rel:"noopener",target:"__blank",css:R.css`
|
|
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
|
+
`},(0,e.jsx)("span",{css:R.css`
|
|
500
|
+
margin-right: var(--spacing-sm);
|
|
501
|
+
font-size: var(--fs-sm);
|
|
502
|
+
`},"Edit"),(0,e.jsx)(Q,{src:o,alt:"Logo",css:R.css`
|
|
503
|
+
width: 1.75rem;
|
|
504
|
+
height: 1.75rem;
|
|
505
|
+
display: block;
|
|
506
|
+
`})):null,(0,e.jsx)("button",{type:"button",onClick:h=>{h.preventDefault(),n==null||n(t)},css:R.css`
|
|
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
|
+
`},(0,e.jsx)("span",{css:R.css`
|
|
519
|
+
font-size: var(--fs-sm);
|
|
520
|
+
`},"Unlink"),(0,e.jsx)(te,{css:R.css`
|
|
521
|
+
color: var(--brand-secondary-5);
|
|
522
|
+
`})))))}var sr=require("@uniformdev/design-system"),pe=require("react-use");function qr({value:t,setValue:n,onGetSelectedProducts:r,onGetCategories:o,onSearchProducts:a,logoIcon:d,multiSelect:f,multiSelectId:h,selectedItemComponent:v,rowComponent:m}){var z,U;let{value:c,loading:u,error:g}=(0,pe.useAsync)(async()=>await o(),[o]),{value:q,error:T}=(0,pe.useAsync)(async()=>{if(!t)return;let s=await r({ids:t});return Array.isArray(s)?s:void 0},[r,t]),X=(0,Z.useMemo)(()=>c?c.map(p=>({id:p.id,name:p.name})):void 0,[c]),H=(0,Z.useRef)(),[F,W]=(0,pe.useAsyncFn)(async(s,p)=>{let A=await a({text:s,options:{limit:p==null?void 0:p.count,offset:p==null?void 0:p.offset,categoryId:p==null?void 0:p.contentType}});return(p==null?void 0:p.offset)===0&&(H.current=[]),(H.current=H.current||[]).push(...A.products),A},[a]),me=async s=>{s&&await n(s)};return u?(0,e.jsx)(sr.LoadingIndicator,null):g||T||F.error?(0,e.jsx)("div",null,"There was an error:"," ",(g==null?void 0:g.message)||(T==null?void 0:T.message)||((z=F.error)==null?void 0:z.message)):(0,e.jsx)(It.Provider,{value:{categories:c,logoIcon:d}},(0,e.jsx)(ht,{search:W,results:H.current,logoIcon:d,selectedItems:q,select:me,multiSelectId:h||"product-search-multi-select",multiSelect:f,contentTypes:X,selectedItemComponent:v||Et,rowComponent:m||xt,totalResults:(U=F.value)==null?void 0:U.total,resultsLoading:F.loading}))}var It=Z.default.createContext(void 0),de=()=>{let t=(0,Z.useContext)(It);if(!t)throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");return t};k(I,require("@uniformdev/mesh-sdk"));var y=require("@uniformdev/design-system");module.exports=xr(I);0&&(module.exports={Button,Callout,DefaultSearchRow,DefaultSelectedItem,EntrySearch,Heading,Icons,Input,InputSelect,InputToggle,KeywordSearchInput,LoadingIndicator,LoadingOverlay,Menu,MenuItem,ProductPreviewList,ProductQuery,ProductQueryContext,ProductSearch,ProductSearchContext,ProductSearchRow,ProductSelectedItem,ResolvableLoadingValue,SelectionField,Theme,UniformMeshLocationContext,UniformMeshLocationContextProvider,UniformMeshSdkContext,UniformMeshSdkContextProvider,badgeIcon,draggableContainer,draggableIcon,draggableIconOffset,draggableIconWrapper,entrySearchBtn,entrySearchConfig,entrySearchConfigHidden,entrySearchLoadMoreBtn,entrySearchResultList,entrySearchSelectIcon,entrySearchSelectImg,entrySearchSelectInput,entrySearchSelectOption,entrySearchWrapper,productSearchRowActiveIcon,productSearchRowCategory,productSearchRowContainer,productSearchRowContent,productSearchRowContentActive,productSearchRowDetails,productSearchRowTitle,productSelectedItemContainer,productSelectedItemContent,productSelectedItemDetails,productSelectedItemImage,searchRowBtn,searchRowContainer,searchRowContainerActive,searchRowPopover,searchRowText,searchRowTextSmall,selectItemLinkBtn,selectItemLinkContainer,selectItemPopover,selectItemPopoverLabel,selectItemSmallText,selectedItemCloseIcon,selectedItemContainer,selectedItemCopy,selectedItemDetails,selectedItemIcon,selectedItemInner,selectedItemTitle,useInitializeUniformMeshSdk,useProductQueryContext,useProductSearchContext,useUniformMeshLocation,useUniformMeshLocationContext,useUniformMeshSdk,useUniformMeshSdkContext});
|