@uniformdev/mesh-sdk-react 16.1.1-alpha.238 → 16.1.1-alpha.319
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.esm.js +18 -16
- package/dist/index.js +18 -16
- package/dist/index.mjs +18 -16
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -20,11 +20,11 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
20
20
|
width: 1.25rem;
|
|
21
21
|
pointer-events: none;
|
|
22
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 Xr=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"})),ae=Xr;var qr=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"})),ie=qr;import{useAsyncFn as jr,useDebounce as eo}from"react-use";import{Input as We,InputSelect as ce,mq as de}from"@uniformdev/design-system";import{css as L}from"@emotion/react";var _e={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},_n=({value:t,setValue:n,brands:o,categories:r,loading:a,categoriesLoading:i,brandsLoading:l,logoIcon:g,onGetProducts:u,sortOptions:f,sortOrderOptions:s,categoryLabel:p="Product Category",brandLabel:h="Brand",disableBrands:E,restrictToSingleCategory:G=!1})=>{var m,I,U;let w=async d=>{n({..._e,...t||{},...d})},
|
|
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 Xr=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"})),ae=Xr;var qr=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"})),ie=qr;import{useAsyncFn as jr,useDebounce as eo}from"react-use";import{Input as We,InputSelect as ce,mq as de}from"@uniformdev/design-system";import{css as L}from"@emotion/react";var _e={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},_n=({value:t,setValue:n,brands:o,categories:r,loading:a,categoriesLoading:i,brandsLoading:l,logoIcon:g,onGetProducts:u,sortOptions:f,sortOrderOptions:s,categoryLabel:p="Product Category",brandLabel:h="Brand",disableBrands:E,restrictToSingleCategory:G=!1})=>{var m,I,U;let w=async d=>{n({..._e,...t||{},...d})},y=se(()=>({..._e,...t||{}}),[t]),[Z,A]=jr(async d=>await u(d),[u]);eo(async()=>{await A({brand:y.brand,categories:y.categories,keyword:y.keyword,sort:y.sort,sortOrder:y.sortOrder,count:y.count})},250,[y]);let N=se(()=>{let d=[];return r==null||r.forEach(b=>{let T=Xe(b,void 0);d.push(...T)}),d},[r]),B=se(()=>[{value:"",label:"All categories"},...N.map(d=>({label:d.name,value:d.id}))],[N]),O=se(()=>(o==null?void 0:o.map(d=>({id:d.id.toString(),name:d.name})))||[],[o]),oe=d=>{if(!d)return;let b=(t==null?void 0:t.categories)||[];w({categories:[...b,d]})},X=d=>{var b;w({categories:(b=t==null?void 0:t.categories)==null?void 0:b.filter(T=>T!==d)})},H=d=>{w({brand:d.target.value})},P=d=>{w({count:d||1})};return a?e("div",null,"Loading..."):e(qe.Provider,{value:{categories:r,logoIcon:g}},e("div",{css:L`
|
|
24
24
|
> :not(:last-child) {
|
|
25
25
|
margin-bottom: var(--spacing-md);
|
|
26
26
|
}
|
|
27
|
-
`},G?e(ce,{id:"selection-field-product-category",label:p,disabled:a,value:(I=(m=
|
|
27
|
+
`},G?e(ce,{id:"selection-field-product-category",label:p,disabled:a,value:(I=(m=y.categories)==null?void 0:m[0])!=null?I:"",options:B,onChange:d=>{w({categories:d.target.value===""?[]:[d.target.value]})}}):e(Qe,{loading:i||!1,id:"selection-field-product-category",label:p,onAdd:oe,onRemove:X,selectedValues:y.categories,values:N}),e("div",{css:L`
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-wrap: wrap;
|
|
30
30
|
column-gap: var(--spacing-lg);
|
|
@@ -34,10 +34,10 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
34
34
|
}
|
|
35
35
|
`},E?null:e("div",{css:L`
|
|
36
36
|
width: 50%;
|
|
37
|
-
`},e(ce,{id:"brand",name:"brand",label:h,disabled:l,value:
|
|
37
|
+
`},e(ce,{id:"brand",name:"brand",label:h,disabled:l,value:y.brand,onChange:H,options:[{value:"",label:"Choose..."},...O.map(d=>({value:d.id,label:d.name}))]})),e("div",{css:L`
|
|
38
38
|
flex-grow: 1;
|
|
39
39
|
position: relative;
|
|
40
|
-
`},e(We,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:
|
|
40
|
+
`},e(We,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:y.keyword,placeholder:"Enter keyword",onChange:d=>w({keyword:d.target.value})}))),e("div",{css:L`
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-wrap: wrap;
|
|
43
43
|
column-gap: var(--spacing-lg);
|
|
@@ -51,20 +51,20 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
51
51
|
width: 33.333333%;
|
|
52
52
|
}
|
|
53
53
|
position: relative;
|
|
54
|
-
`},e(We,{id:"count",name:"count",type:"number",min:1,step:1,value:
|
|
54
|
+
`},e(We,{id:"count",name:"count",type:"number",min:1,step:1,value:y.count,onChange:d=>P(d.target.valueAsNumber),label:"Count"}),e("div",{css:L`
|
|
55
55
|
position: absolute;
|
|
56
56
|
bottom: var(--spacing-sm);
|
|
57
57
|
right: var(--spacing-sm);
|
|
58
58
|
display: flex;
|
|
59
59
|
gap: var(--spacing-sm);
|
|
60
|
-
`},e(Ze,{onCountChange:()=>P(
|
|
60
|
+
`},e(Ze,{onCountChange:()=>P(y.count-1),countIcon:"decrement",disabled:y.count===1}),e(Ze,{onCountChange:()=>P(y.count+1),countIcon:"increment"}))),Array.isArray(f)&&f.length>0?e("div",{css:L`
|
|
61
61
|
flex-grow: 1;
|
|
62
62
|
${de("md")} {
|
|
63
63
|
width: 33.333333%;
|
|
64
64
|
}
|
|
65
|
-
`},e(ce,{id:"sort",name:"sort",label:"Sort",value:
|
|
65
|
+
`},e(ce,{id:"sort",name:"sort",label:"Sort",value:y.sort,onChange:d=>w({sort:d.target.value}),options:[{value:"",label:"Select a sort"},...f.map(d=>({value:d.sortKey,label:d.name}))]})):null,Array.isArray(s)&&s.length>0?e("div",{css:L`
|
|
66
66
|
flex-grow: 1;
|
|
67
|
-
`},e(ce,{id:"sort-order",name:"sort-order",label:"Sort Order",value:
|
|
67
|
+
`},e(ce,{id:"sort-order",name:"sort-order",label:"Sort Order",value:y.sortOrder,onChange:d=>w({sortOrder:d.target.value}),options:s.map(d=>({value:d.sortOrderKey,label:d.name}))})):null),e("div",null,e("h3",{css:L`
|
|
68
68
|
font-size: var(--fs-md);
|
|
69
69
|
line-height: var(--spacing-md);
|
|
70
70
|
font-weight: var(--fw-bold);
|
|
@@ -99,17 +99,18 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
99
99
|
color: currentColor;
|
|
100
100
|
display: inline-flex;
|
|
101
101
|
justify-content: space-between;
|
|
102
|
-
padding: var(--spacing-
|
|
102
|
+
padding: var(--spacing-sm) var(--spacing-base);
|
|
103
103
|
margin-left: auto;
|
|
104
104
|
text-decoration: none;
|
|
105
|
+
gap: var(--spacing-base);
|
|
105
106
|
&:hover {
|
|
106
107
|
background: var(--gray-50);
|
|
107
108
|
}
|
|
108
109
|
`,et=D`
|
|
109
110
|
font-size: var(--fs-sm);
|
|
110
111
|
`,tt=D`
|
|
111
|
-
width:
|
|
112
|
-
height:
|
|
112
|
+
width: 1rem;
|
|
113
|
+
height: 1rem;
|
|
113
114
|
`,he=D`
|
|
114
115
|
margin-right: var(--spacing-lg);
|
|
115
116
|
font-size: var(--fs-sm);
|
|
@@ -354,7 +355,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
354
355
|
`,Pe=C`
|
|
355
356
|
width: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
356
357
|
height: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
357
|
-
`;import{css as z}from"@emotion/react";import{InputSelect as Mo,scrollbarStyles as Vo,Button as Le,Callout as Do,InputKeywordSearch as zo,LoadingIndicator as Uo,Menu as Go,MenuItem as Ao,LoadingOverlay as Bo}from"@uniformdev/design-system";import{useState as Lo,useEffect as Wt,useRef as Ro}from"react";function _t(t,{delay:n=500,minDuration:o=200}={delay:500,minDuration:200}){let[r,a]=Lo("IDLE"),i=Ro(void 0);return Wt(()=>{t&&r==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!t)return a("IDLE");i.current=setTimeout(()=>{a("EXPIRE")},o),a("DISPLAY")},n),a("DELAY")),!t&&r!=="DISPLAY"&&(clearTimeout(i.current),a("IDLE"))},[t,r,n,o]),Wt(()=>()=>clearTimeout(i.current),[]),r==="DISPLAY"||r==="EXPIRE"}var Oo=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&n!=="any"&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),e(Do,{type:"info"},o)},Zt=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:a,select:i,multiSelect:l,multiSelectId:g,rowComponent:u,selectedItemComponent:f,totalResults:s,resultsLoading:p,requireContentType:h,onAddNew:E,onEditClosed:G,onCancel:w,noResultsComponent:
|
|
358
|
+
`;import{css as z}from"@emotion/react";import{InputSelect as Mo,scrollbarStyles as Vo,Button as Le,Callout as Do,InputKeywordSearch as zo,LoadingIndicator as Uo,Menu as Go,MenuItem as Ao,LoadingOverlay as Bo}from"@uniformdev/design-system";import{useState as Lo,useEffect as Wt,useRef as Ro}from"react";function _t(t,{delay:n=500,minDuration:o=200}={delay:500,minDuration:200}){let[r,a]=Lo("IDLE"),i=Ro(void 0);return Wt(()=>{t&&r==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!t)return a("IDLE");i.current=setTimeout(()=>{a("EXPIRE")},o),a("DISPLAY")},n),a("DELAY")),!t&&r!=="DISPLAY"&&(clearTimeout(i.current),a("IDLE"))},[t,r,n,o]),Wt(()=>()=>clearTimeout(i.current),[]),r==="DISPLAY"||r==="EXPIRE"}var Oo=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&n!=="any"&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),e(Do,{type:"info"},o)},Zt=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:a,select:i,multiSelect:l,multiSelectId:g,rowComponent:u,selectedItemComponent:f,totalResults:s,resultsLoading:p,requireContentType:h,onAddNew:E,onEditClosed:G,onCancel:w,noResultsComponent:y,helpComponent:Z,onSort:A,typeSelectorLabel:N="Content Type Select",typeSelectorAllTypesOptionText:B="All content types",loadingIndicatorDelay:O=1e3})=>{var ze,Ue,Ge;let X=()=>h?Array.isArray(o)&&o.length>0?o[0].id:"":"any",[H,P]=k.useState(""),[m,I]=k.useState(X),[U,d]=k.useState(!1),[b,T]=k.useState([]),[Lr,Te]=k.useState(!1),ve=k.useRef(`x${ko()}`),ne=xo(H,750);k.useEffect(()=>{t(ne,{count:5,offset:0,contentType:m==="any"?void 0:m})},[ne,m]);let Rr=_t(p,{delay:O}),xr=c=>{b.some(v=>v.id===c.id)?T(v=>v.filter($=>$.id!==c.id)):T(l?v=>[...v,c]:[c])},kr=r==null?void 0:r.map(c=>c.id+c.title).join(",");k.useEffect(()=>{Array.isArray(r)&&T(r)},[kr]);let Ir=()=>{I(X()),P(""),T(r!=null&&r.length?r:[])},Er=()=>{d(c=>!c),U||Ir()},Me=c=>{let v=(b==null?void 0:b.filter($=>$.id!==c.id))||[];T(v),i(v,"")},Tr=c=>{c.preventDefault(),i(b,m),d(!1)},Mr=c=>{c.preventDefault(),d(!1),w&&w()},Vr=()=>{t(ne,{count:5,offset:(n==null?void 0:n.length)||0,contentType:m==="any"?void 0:m}),Te(!0);let c=setTimeout(()=>{Te(!1)},750);return()=>clearTimeout(c)},Dr=!(r==null?void 0:r.length)||l,zr=u||zt,Ve=f||xt,Ur=y||Oo,De=a&&typeof a!="string"?a:null,Gr=De?e(De,{css:Pe}):e("img",{src:a,alt:"Logo",css:Pe}),Ar=c=>{var v,$;if(c.destination&&c.source.droppableId===((v=c.destination)==null?void 0:v.droppableId)){let x=[...r||[]],[j]=($=x==null?void 0:x.splice(c.source.index,1))!=null?$:[];return x==null||x.splice(c.destination.index,0,j),A&&(T(x),A==null||A(x)),x}};return e("div",{css:z`
|
|
358
359
|
width: 100%;
|
|
359
360
|
`},e("div",{css:z`
|
|
360
361
|
position: relative;
|
|
@@ -369,7 +370,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
369
370
|
margin-bottom: var(--spacing-base);
|
|
370
371
|
`},e(Mo,{onChange:c=>I(c.target.value),value:m,label:N,showLabel:!1,options:[...h?[]:[{value:"any",label:B}],...o?o.map(c=>({value:c.id,label:c.name})):[]]}),e("div",{css:z`
|
|
371
372
|
flex-grow: 1;
|
|
372
|
-
`},e(zo,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:P,disabledFieldSubmission:!0,value:H}))),e("div",{css:[Ht,Vo],id:ve.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},e(Bo,{isActive:Rr}),Array.isArray(n)&&n.length>0?n.map(c=>e(zr,{key:c.id,isSelected:
|
|
373
|
+
`},e(zo,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:P,disabledFieldSubmission:!0,value:H}))),e("div",{css:[Ht,Vo],id:ve.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},e(Bo,{isActive:Rr}),Array.isArray(n)&&n.length>0?n.map(c=>e(zr,{key:c.id,isSelected:b.some(v=>v.id===c.id),result:c,triggerSelection:()=>xr(c)})):e(Ur,{searchText:ne||H,selectedContentType:(Ue=(ze=o==null?void 0:o.find(c=>c.id===m))==null?void 0:ze.name)!=null?Ue:m}),!p&&typeof s!="undefined"&&n&&(n==null?void 0:n.length)<s&&e("button",{type:"button",css:At,onClick:Vr},Lr?e(Uo,null):"Load More")),e("div",{css:z`
|
|
373
374
|
display: flex;
|
|
374
375
|
justify-content: space-between;
|
|
375
376
|
`},e("div",null,E&&((Ge=o==null?void 0:o.length)!=null?Ge:0)>0?e(Go,{menuLabel:"Add new menu",menuTrigger:e(Le,{buttonType:"secondary"},"Add New")},o==null?void 0:o.map(c=>e(Ao,{key:c.id,css:z`
|
|
@@ -378,9 +379,9 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
378
379
|
`,onClick:()=>E(c)},c.name))):null),e("div",{css:z`
|
|
379
380
|
display: flex;
|
|
380
381
|
gap: var(--spacing-base);
|
|
381
|
-
`},e(Le,{buttonType:"unimportant",onClick:Mr},"Cancel"),e(Le,{disabled:!
|
|
382
|
+
`},e(Le,{buttonType:"unimportant",onClick:Mr},"Cancel"),e(Le,{disabled:!b.length,onClick:Tr,"data-test-id":"entry-accept-button"},"Accept"))))):null,U?null:l&&b.length>1?e(Eo,{onDragEnd:c=>Ar(c)},e(Io,{droppableId:g||"canvas-multi-select"},c=>e("div",{...c.droppableProps,ref:c.innerRef,css:z`
|
|
382
383
|
margin-block: var(--spacing-sm) 0;
|
|
383
|
-
`},
|
|
384
|
+
`},b==null?void 0:b.map((v,$)=>{if(v!=null&&v.id)return e(To,{key:v.id,draggableId:v.id,index:$},x=>e("div",{css:Kt,ref:x.innerRef,...x.draggableProps,...x.dragHandleProps},e("span",{css:Nt},e(te,{css:[Ce,Qt],width:24,height:24}),e(te,{css:Ce,width:24,height:24})),e(Ve,{key:`selected-item-${v.id}`,logoIcon:a,selectedItem:v,onDeselect:j=>Me(j),onEditClosed:G?j=>G(j):void 0})))}),c.placeholder))):b==null?void 0:b.map(c=>e(Ve,{key:`selected-item-${c.id}`,logoIcon:a,selectedItem:c,onDeselect:v=>Me(v),onEditClosed:G?v=>G(v):void 0}))))};import{css as _}from"@emotion/react";var Xt=_`
|
|
384
385
|
cursor: pointer;
|
|
385
386
|
padding: var(--spacing-sm) 0;
|
|
386
387
|
margin-right: var(--spacing-sm);
|
|
@@ -504,7 +505,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
504
505
|
margin-right: var(--spacing-xs);
|
|
505
506
|
`},"SKU:"),t.sku||t.id),t.price!==void 0?e("li",null,e("span",{css:q`
|
|
506
507
|
margin-right: var(--spacing-xs);
|
|
507
|
-
`},"Price:"),e("span",null,t.price)):null))),e("div",{css:dr},t.editLink?e("a",{href:t.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:xe},e("span",{css:ke},"Edit"),e(V,{src:r,alt:"Logo",css:cr})):null,e("button",{type:"button",onClick:()=>{n==null||n(t)},css:xe},e("span",{css:ke},"Unlink"),e(Ho,{icon:Fo,iconColor:"red",size:16})))))}import{Callout as _o}from"@uniformdev/design-system";import{useAsync as Zo,useAsyncFn as Xo}from"react-use";function $i({selectedProducts:t,setSelectedProducts:n,onGetCategories:o,onSearchProducts:r,logoIcon:a,multiSelect:i,multiSelectId:l,selectedItemComponent:g,rowComponent:u,errorComponent:f,helpComponent:s,noResultsComponent:p,onSort:h,typeSelectorAllTypesOptionText:E="All categories",typeSelectorLabel:G="Select Category"}){var H;let{value:w,loading:
|
|
508
|
+
`},"Price:"),e("span",null,t.price)):null))),e("div",{css:dr},t.editLink?e("a",{href:t.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:xe},e("span",{css:ke},"Edit"),e(V,{src:r,alt:"Logo",css:cr})):null,e("button",{type:"button",onClick:()=>{n==null||n(t)},css:xe},e("span",{css:ke},"Unlink"),e(Ho,{icon:Fo,iconColor:"red",size:16})))))}import{Callout as _o}from"@uniformdev/design-system";import{useAsync as Zo,useAsyncFn as Xo}from"react-use";function $i({selectedProducts:t,setSelectedProducts:n,onGetCategories:o,onSearchProducts:r,logoIcon:a,multiSelect:i,multiSelectId:l,selectedItemComponent:g,rowComponent:u,errorComponent:f,helpComponent:s,noResultsComponent:p,onSort:h,typeSelectorAllTypesOptionText:E="All categories",typeSelectorLabel:G="Select Category"}){var H;let{value:w,loading:y,error:Z}=Zo(async()=>await o(),[o]),A=w==null?void 0:w.map(P=>P.id).join(","),N=Qo(()=>w?w.map(m=>({id:m.id,name:m.name})):void 0,[A]),B=Wo(),[O,oe]=Xo(async(P,m)=>{let I=await r({text:P,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&&(B.current=[]),(B.current=B.current||[]).push(...I.products),I},[r]),X=async P=>{await n(P)};return Z||O.error?e(f||(({categoriesError:m,searchError:I})=>e(_o,{type:"error"},"There was an error: ",(m==null?void 0:m.message)||(I==null?void 0:I.message))),{categoriesError:Z,searchError:O.error}):e(pr.Provider,{value:{categories:w,logoIcon:a}},e(Zt,{search:oe,results:B.current,logoIcon:a,selectedItems:t,select:X,multiSelectId:l||"product-search-multi-select",multiSelect:i,contentTypes:N,selectedItemComponent:g||lr,rowComponent:u||or,totalResults:(H=O.value)==null?void 0:H.total,resultsLoading:O.loading||y,helpComponent:s,noResultsComponent:p,onSort:h,typeSelectorAllTypesOptionText:E,typeSelectorLabel:G}))}var pr=Ko.createContext(void 0),ge=()=>{let t=No(pr);if(!t)throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");return t};import{css as R}from"@emotion/react";import{mq as qo}from"@uniformdev/design-system";var mr=R`
|
|
508
509
|
border: 1px solid var(--gray-200);
|
|
509
510
|
background: var(--gray-50);
|
|
510
511
|
border-radius: var(--rounded-base);
|
|
@@ -530,6 +531,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
530
531
|
font-weight: var(--fw-bold);
|
|
531
532
|
line-height: 1;
|
|
532
533
|
margin: 0;
|
|
534
|
+
word-break: break-word;
|
|
533
535
|
`,hr=R`
|
|
534
536
|
width: 1.5rem;
|
|
535
537
|
height: 1.5rem;
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,11 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
20
20
|
width: 1.25rem;
|
|
21
21
|
pointer-events: none;
|
|
22
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 wo=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"})),Re=wo;var Co=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"})),xe=Co;var ke=require("react-use"),E=require("@uniformdev/design-system"),R=require("@emotion/react"),wr={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},Po=({value:t,setValue:n,brands:o,categories:r,loading:a,categoriesLoading:i,brandsLoading:l,logoIcon:f,onGetProducts:g,sortOptions:v,sortOrderOptions:s,categoryLabel:p="Product Category",brandLabel:b="Brand",disableBrands:D,restrictToSingleCategory:_=!1})=>{var u,M,H;let P=async d=>{n({...wr,...t||{},...d})},
|
|
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 wo=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"})),Re=wo;var Co=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"})),xe=Co;var ke=require("react-use"),E=require("@uniformdev/design-system"),R=require("@emotion/react"),wr={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},Po=({value:t,setValue:n,brands:o,categories:r,loading:a,categoriesLoading:i,brandsLoading:l,logoIcon:f,onGetProducts:g,sortOptions:v,sortOrderOptions:s,categoryLabel:p="Product Category",brandLabel:b="Brand",disableBrands:D,restrictToSingleCategory:_=!1})=>{var u,M,H;let P=async d=>{n({...wr,...t||{},...d})},S=(0,$.useMemo)(()=>({...wr,...t||{}}),[t]),[de,Z]=(0,ke.useAsyncFn)(async d=>await g(d),[g]);(0,ke.useDebounce)(async()=>{await Z({brand:S.brand,categories:S.categories,keyword:S.keyword,sort:S.sort,sortOrder:S.sortOrder,count:S.count})},250,[S]);let ne=(0,$.useMemo)(()=>{let d=[];return r==null||r.forEach(y=>{let z=Pr(y,void 0);d.push(...z)}),d},[r]),X=(0,$.useMemo)(()=>[{value:"",label:"All categories"},...ne.map(d=>({label:d.name,value:d.id}))],[ne]),q=(0,$.useMemo)(()=>(o==null?void 0:o.map(d=>({id:d.id.toString(),name:d.name})))||[],[o]),Se=d=>{if(!d)return;let y=(t==null?void 0:t.categories)||[];P({categories:[...y,d]})},le=d=>{var y;P({categories:(y=t==null?void 0:t.categories)==null?void 0:y.filter(z=>z!==d)})},Y=d=>{P({brand:d.target.value})},k=d=>{P({count:d||1})};return a?(0,e.jsx)("div",null,"Loading..."):(0,e.jsx)(rt.Provider,{value:{categories:r,logoIcon:f}},(0,e.jsx)("div",{css:R.css`
|
|
24
24
|
> :not(:last-child) {
|
|
25
25
|
margin-bottom: var(--spacing-md);
|
|
26
26
|
}
|
|
27
|
-
`},_?(0,e.jsx)(E.InputSelect,{id:"selection-field-product-category",label:p,disabled:a,value:(M=(u=
|
|
27
|
+
`},_?(0,e.jsx)(E.InputSelect,{id:"selection-field-product-category",label:p,disabled:a,value:(M=(u=S.categories)==null?void 0:u[0])!=null?M:"",options:X,onChange:d=>{P({categories:d.target.value===""?[]:[d.target.value]})}}):(0,e.jsx)(tt,{loading:i||!1,id:"selection-field-product-category",label:p,onAdd:Se,onRemove:le,selectedValues:S.categories,values:ne}),(0,e.jsx)("div",{css:R.css`
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-wrap: wrap;
|
|
30
30
|
column-gap: var(--spacing-lg);
|
|
@@ -34,10 +34,10 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
34
34
|
}
|
|
35
35
|
`},D?null:(0,e.jsx)("div",{css:R.css`
|
|
36
36
|
width: 50%;
|
|
37
|
-
`},(0,e.jsx)(E.InputSelect,{id:"brand",name:"brand",label:b,disabled:l,value:
|
|
37
|
+
`},(0,e.jsx)(E.InputSelect,{id:"brand",name:"brand",label:b,disabled:l,value:S.brand,onChange:Y,options:[{value:"",label:"Choose..."},...q.map(d=>({value:d.id,label:d.name}))]})),(0,e.jsx)("div",{css:R.css`
|
|
38
38
|
flex-grow: 1;
|
|
39
39
|
position: relative;
|
|
40
|
-
`},(0,e.jsx)(E.Input,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:
|
|
40
|
+
`},(0,e.jsx)(E.Input,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:S.keyword,placeholder:"Enter keyword",onChange:d=>P({keyword:d.target.value})}))),(0,e.jsx)("div",{css:R.css`
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-wrap: wrap;
|
|
43
43
|
column-gap: var(--spacing-lg);
|
|
@@ -51,20 +51,20 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
51
51
|
width: 33.333333%;
|
|
52
52
|
}
|
|
53
53
|
position: relative;
|
|
54
|
-
`},(0,e.jsx)(E.Input,{id:"count",name:"count",type:"number",min:1,step:1,value:
|
|
54
|
+
`},(0,e.jsx)(E.Input,{id:"count",name:"count",type:"number",min:1,step:1,value:S.count,onChange:d=>k(d.target.valueAsNumber),label:"Count"}),(0,e.jsx)("div",{css:R.css`
|
|
55
55
|
position: absolute;
|
|
56
56
|
bottom: var(--spacing-sm);
|
|
57
57
|
right: var(--spacing-sm);
|
|
58
58
|
display: flex;
|
|
59
59
|
gap: var(--spacing-sm);
|
|
60
|
-
`},(0,e.jsx)(Cr,{onCountChange:()=>k(
|
|
60
|
+
`},(0,e.jsx)(Cr,{onCountChange:()=>k(S.count-1),countIcon:"decrement",disabled:S.count===1}),(0,e.jsx)(Cr,{onCountChange:()=>k(S.count+1),countIcon:"increment"}))),Array.isArray(v)&&v.length>0?(0,e.jsx)("div",{css:R.css`
|
|
61
61
|
flex-grow: 1;
|
|
62
62
|
${(0,E.mq)("md")} {
|
|
63
63
|
width: 33.333333%;
|
|
64
64
|
}
|
|
65
|
-
`},(0,e.jsx)(E.InputSelect,{id:"sort",name:"sort",label:"Sort",value:
|
|
65
|
+
`},(0,e.jsx)(E.InputSelect,{id:"sort",name:"sort",label:"Sort",value:S.sort,onChange:d=>P({sort:d.target.value}),options:[{value:"",label:"Select a sort"},...v.map(d=>({value:d.sortKey,label:d.name}))]})):null,Array.isArray(s)&&s.length>0?(0,e.jsx)("div",{css:R.css`
|
|
66
66
|
flex-grow: 1;
|
|
67
|
-
`},(0,e.jsx)(E.InputSelect,{id:"sort-order",name:"sort-order",label:"Sort Order",value:
|
|
67
|
+
`},(0,e.jsx)(E.InputSelect,{id:"sort-order",name:"sort-order",label:"Sort Order",value:S.sortOrder,onChange:d=>P({sortOrder:d.target.value}),options:s.map(d=>({value:d.sortOrderKey,label:d.name}))})):null),(0,e.jsx)("div",null,(0,e.jsx)("h3",{css:R.css`
|
|
68
68
|
font-size: var(--fs-md);
|
|
69
69
|
line-height: var(--spacing-md);
|
|
70
70
|
font-weight: var(--fw-bold);
|
|
@@ -99,17 +99,18 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
99
99
|
color: currentColor;
|
|
100
100
|
display: inline-flex;
|
|
101
101
|
justify-content: space-between;
|
|
102
|
-
padding: var(--spacing-
|
|
102
|
+
padding: var(--spacing-sm) var(--spacing-base);
|
|
103
103
|
margin-left: auto;
|
|
104
104
|
text-decoration: none;
|
|
105
|
+
gap: var(--spacing-base);
|
|
105
106
|
&:hover {
|
|
106
107
|
background: var(--gray-50);
|
|
107
108
|
}
|
|
108
109
|
`,Rr=U.css`
|
|
109
110
|
font-size: var(--fs-sm);
|
|
110
111
|
`,xr=U.css`
|
|
111
|
-
width:
|
|
112
|
-
height:
|
|
112
|
+
width: 1rem;
|
|
113
|
+
height: 1rem;
|
|
113
114
|
`,at=U.css`
|
|
114
115
|
margin-right: var(--spacing-lg);
|
|
115
116
|
font-size: var(--fs-sm);
|
|
@@ -354,7 +355,7 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
354
355
|
`,Be=L.css`
|
|
355
356
|
width: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
356
357
|
height: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
357
|
-
`;var G=require("@emotion/react"),C=require("@uniformdev/design-system");var ae=require("react");function Kr(t,{delay:n=500,minDuration:o=200}={delay:500,minDuration:200}){let[r,a]=(0,ae.useState)("IDLE"),i=(0,ae.useRef)(void 0);return(0,ae.useEffect)(()=>{t&&r==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!t)return a("IDLE");i.current=setTimeout(()=>{a("EXPIRE")},o),a("DISPLAY")},n),a("DELAY")),!t&&r!=="DISPLAY"&&(clearTimeout(i.current),a("IDLE"))},[t,r,n,o]),(0,ae.useEffect)(()=>()=>clearTimeout(i.current),[]),r==="DISPLAY"||r==="EXPIRE"}var Ao=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&n!=="any"&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),(0,e.jsx)(C.Callout,{type:"info"},o)},Ut=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:a,select:i,multiSelect:l,multiSelectId:f,rowComponent:g,selectedItemComponent:v,totalResults:s,resultsLoading:p,requireContentType:b,onAddNew:D,onEditClosed:_,onCancel:P,noResultsComponent:
|
|
358
|
+
`;var G=require("@emotion/react"),C=require("@uniformdev/design-system");var ae=require("react");function Kr(t,{delay:n=500,minDuration:o=200}={delay:500,minDuration:200}){let[r,a]=(0,ae.useState)("IDLE"),i=(0,ae.useRef)(void 0);return(0,ae.useEffect)(()=>{t&&r==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!t)return a("IDLE");i.current=setTimeout(()=>{a("EXPIRE")},o),a("DISPLAY")},n),a("DELAY")),!t&&r!=="DISPLAY"&&(clearTimeout(i.current),a("IDLE"))},[t,r,n,o]),(0,ae.useEffect)(()=>()=>clearTimeout(i.current),[]),r==="DISPLAY"||r==="EXPIRE"}var Ao=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&n!=="any"&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),(0,e.jsx)(C.Callout,{type:"info"},o)},Ut=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:a,select:i,multiSelect:l,multiSelectId:f,rowComponent:g,selectedItemComponent:v,totalResults:s,resultsLoading:p,requireContentType:b,onAddNew:D,onEditClosed:_,onCancel:P,noResultsComponent:S,helpComponent:de,onSort:Z,typeSelectorLabel:ne="Content Type Select",typeSelectorAllTypesOptionText:X="All content types",loadingIndicatorDelay:q=1e3})=>{var gr,fr,vr;let le=()=>b?Array.isArray(o)&&o.length>0?o[0].id:"":"any",[Y,k]=T.useState(""),[u,M]=T.useState(le),[H,d]=T.useState(!1),[y,z]=T.useState([]),[qr,lr]=T.useState(!1),_e=T.useRef(`x${(0,Qr.v4)()}`),we=(0,Nr.useThrottle)(Y,750);T.useEffect(()=>{t(we,{count:5,offset:0,contentType:u==="any"?void 0:u})},[we,u]);let Yr=Kr(p,{delay:q}),Jr=c=>{y.some(h=>h.id===c.id)?z(h=>h.filter(J=>J.id!==c.id)):z(l?h=>[...h,c]:[c])},jr=r==null?void 0:r.map(c=>c.id+c.title).join(",");T.useEffect(()=>{Array.isArray(r)&&z(r)},[jr]);let eo=()=>{M(le()),k(""),z(r!=null&&r.length?r:[])},to=()=>{d(c=>!c),H||eo()},pr=c=>{let h=(y==null?void 0:y.filter(J=>J.id!==c.id))||[];z(h),i(h,"")},ro=c=>{c.preventDefault(),i(y,u),d(!1)},oo=c=>{c.preventDefault(),d(!1),P&&P()},no=()=>{t(we,{count:5,offset:(n==null?void 0:n.length)||0,contentType:u==="any"?void 0:u}),lr(!0);let c=setTimeout(()=>{lr(!1)},750);return()=>clearTimeout(c)},ao=!(r==null?void 0:r.length)||l,io=g||Pt,mr=v||vt,so=S||Ao,ur=a&&typeof a!="string"?a:null,co=ur?(0,e.jsx)(ur,{css:Be}):(0,e.jsx)("img",{src:a,alt:"Logo",css:Be}),lo=c=>{var h,J;if(c.destination&&c.source.droppableId===((h=c.destination)==null?void 0:h.droppableId)){let I=[...r||[]],[fe]=(J=I==null?void 0:I.splice(c.source.index,1))!=null?J:[];return I==null||I.splice(c.destination.index,0,fe),Z&&(z(I),Z==null||Z(I)),I}};return(0,e.jsx)("div",{css:G.css`
|
|
358
359
|
width: 100%;
|
|
359
360
|
`},(0,e.jsx)("div",{css:G.css`
|
|
360
361
|
position: relative;
|
|
@@ -369,7 +370,7 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
369
370
|
margin-bottom: var(--spacing-base);
|
|
370
371
|
`},(0,e.jsx)(C.InputSelect,{onChange:c=>M(c.target.value),value:u,label:ne,showLabel:!1,options:[...b?[]:[{value:"any",label:X}],...o?o.map(c=>({value:c.id,label:c.name})):[]]}),(0,e.jsx)("div",{css:G.css`
|
|
371
372
|
flex-grow: 1;
|
|
372
|
-
`},(0,e.jsx)(C.InputKeywordSearch,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:k,disabledFieldSubmission:!0,value:Y}))),(0,e.jsx)("div",{css:[Et,C.scrollbarStyles],id:_e.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},(0,e.jsx)(C.LoadingOverlay,{isActive:Yr}),Array.isArray(n)&&n.length>0?n.map(c=>(0,e.jsx)(io,{key:c.id,isSelected:
|
|
373
|
+
`},(0,e.jsx)(C.InputKeywordSearch,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:k,disabledFieldSubmission:!0,value:Y}))),(0,e.jsx)("div",{css:[Et,C.scrollbarStyles],id:_e.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},(0,e.jsx)(C.LoadingOverlay,{isActive:Yr}),Array.isArray(n)&&n.length>0?n.map(c=>(0,e.jsx)(io,{key:c.id,isSelected:y.some(h=>h.id===c.id),result:c,triggerSelection:()=>Jr(c)})):(0,e.jsx)(so,{searchText:we||Y,selectedContentType:(fr=(gr=o==null?void 0:o.find(c=>c.id===u))==null?void 0:gr.name)!=null?fr:u}),!p&&typeof s!="undefined"&&n&&(n==null?void 0:n.length)<s&&(0,e.jsx)("button",{type:"button",css:xt,onClick:no},qr?(0,e.jsx)(C.LoadingIndicator,null):"Load More")),(0,e.jsx)("div",{css:G.css`
|
|
373
374
|
display: flex;
|
|
374
375
|
justify-content: space-between;
|
|
375
376
|
`},(0,e.jsx)("div",null,D&&((vr=o==null?void 0:o.length)!=null?vr:0)>0?(0,e.jsx)(C.Menu,{menuLabel:"Add new menu",menuTrigger:(0,e.jsx)(C.Button,{buttonType:"secondary"},"Add New")},o==null?void 0:o.map(c=>(0,e.jsx)(C.MenuItem,{key:c.id,css:G.css`
|
|
@@ -378,9 +379,9 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
378
379
|
`,onClick:()=>D(c)},c.name))):null),(0,e.jsx)("div",{css:G.css`
|
|
379
380
|
display: flex;
|
|
380
381
|
gap: var(--spacing-base);
|
|
381
|
-
`},(0,e.jsx)(C.Button,{buttonType:"unimportant",onClick:oo},"Cancel"),(0,e.jsx)(C.Button,{disabled:!
|
|
382
|
+
`},(0,e.jsx)(C.Button,{buttonType:"unimportant",onClick:oo},"Cancel"),(0,e.jsx)(C.Button,{disabled:!y.length,onClick:ro,"data-test-id":"entry-accept-button"},"Accept"))))):null,H?null:l&&y.length>1?(0,e.jsx)(ge.DragDropContext,{onDragEnd:c=>lo(c)},(0,e.jsx)(ge.Droppable,{droppableId:f||"canvas-multi-select"},c=>(0,e.jsx)("div",{...c.droppableProps,ref:c.innerRef,css:G.css`
|
|
382
383
|
margin-block: var(--spacing-sm) 0;
|
|
383
|
-
`},
|
|
384
|
+
`},y==null?void 0:y.map((h,J)=>{if(h!=null&&h.id)return(0,e.jsx)(ge.Draggable,{key:h.id,draggableId:h.id,index:J},I=>(0,e.jsx)("div",{css:Vt,ref:I.innerRef,...I.draggableProps,...I.dragHandleProps},(0,e.jsx)("span",{css:Dt},(0,e.jsx)(he,{css:[Ae,zt],width:24,height:24}),(0,e.jsx)(he,{css:Ae,width:24,height:24})),(0,e.jsx)(mr,{key:`selected-item-${h.id}`,logoIcon:a,selectedItem:h,onDeselect:fe=>pr(fe),onEditClosed:_?fe=>_(fe):void 0})))}),c.placeholder))):y==null?void 0:y.map(c=>(0,e.jsx)(mr,{key:`selected-item-${c.id}`,logoIcon:a,selectedItem:c,onDeselect:h=>pr(h),onEditClosed:_?h=>_(h):void 0}))))};var re=require("@emotion/react"),Gt=re.css`
|
|
384
385
|
cursor: pointer;
|
|
385
386
|
padding: var(--spacing-sm) 0;
|
|
386
387
|
margin-right: var(--spacing-sm);
|
|
@@ -504,7 +505,7 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
504
505
|
margin-right: var(--spacing-xs);
|
|
505
506
|
`},"SKU:"),t.sku||t.id),t.price!==void 0?(0,e.jsx)("li",null,(0,e.jsx)("span",{css:ie.css`
|
|
506
507
|
margin-right: var(--spacing-xs);
|
|
507
|
-
`},"Price:"),(0,e.jsx)("span",null,t.price)):null))),(0,e.jsx)("div",{css:qt},t.editLink?(0,e.jsx)("a",{href:t.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:He},(0,e.jsx)("span",{css:$e},"Edit"),(0,e.jsx)(O,{src:r,alt:"Logo",css:Xt})):null,(0,e.jsx)("button",{type:"button",onClick:()=>{n==null||n(t)},css:He},(0,e.jsx)("span",{css:$e},"Unlink"),(0,e.jsx)(Fe.Icon,{icon:Wr.CgClose,iconColor:"red",size:16})))))}var _r=require("@uniformdev/design-system"),Ke=require("react-use");function Bo({selectedProducts:t,setSelectedProducts:n,onGetCategories:o,onSearchProducts:r,logoIcon:a,multiSelect:i,multiSelectId:l,selectedItemComponent:f,rowComponent:g,errorComponent:v,helpComponent:s,noResultsComponent:p,onSort:b,typeSelectorAllTypesOptionText:D="All categories",typeSelectorLabel:_="Select Category"}){var Y;let{value:P,loading:
|
|
508
|
+
`},"Price:"),(0,e.jsx)("span",null,t.price)):null))),(0,e.jsx)("div",{css:qt},t.editLink?(0,e.jsx)("a",{href:t.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:He},(0,e.jsx)("span",{css:$e},"Edit"),(0,e.jsx)(O,{src:r,alt:"Logo",css:Xt})):null,(0,e.jsx)("button",{type:"button",onClick:()=>{n==null||n(t)},css:He},(0,e.jsx)("span",{css:$e},"Unlink"),(0,e.jsx)(Fe.Icon,{icon:Wr.CgClose,iconColor:"red",size:16})))))}var _r=require("@uniformdev/design-system"),Ke=require("react-use");function Bo({selectedProducts:t,setSelectedProducts:n,onGetCategories:o,onSearchProducts:r,logoIcon:a,multiSelect:i,multiSelectId:l,selectedItemComponent:f,rowComponent:g,errorComponent:v,helpComponent:s,noResultsComponent:p,onSort:b,typeSelectorAllTypesOptionText:D="All categories",typeSelectorLabel:_="Select Category"}){var Y;let{value:P,loading:S,error:de}=(0,Ke.useAsync)(async()=>await o(),[o]),Z=P==null?void 0:P.map(k=>k.id).join(","),ne=(0,oe.useMemo)(()=>P?P.map(u=>({id:u.id,name:u.name})):void 0,[Z]),X=(0,oe.useRef)(),[q,Se]=(0,Ke.useAsyncFn)(async(k,u)=>{let M=await r({text:k,options:{limit:u==null?void 0:u.count,offset:u==null?void 0:u.offset,categoryId:u==null?void 0:u.contentType}});return(u==null?void 0:u.offset)===0&&(X.current=[]),(X.current=X.current||[]).push(...M.products),M},[r]),le=async k=>{await n(k)};return de||q.error?(0,e.jsx)(v||(({categoriesError:u,searchError:M})=>(0,e.jsx)(_r.Callout,{type:"error"},"There was an error: ",(u==null?void 0:u.message)||(M==null?void 0:M.message))),{categoriesError:de,searchError:q.error}):(0,e.jsx)(Jt.Provider,{value:{categories:P,logoIcon:a}},(0,e.jsx)(Ut,{search:Se,results:X.current,logoIcon:a,selectedItems:t,select:le,multiSelectId:l||"product-search-multi-select",multiSelect:i,contentTypes:ne,selectedItemComponent:f||Yt,rowComponent:g||Nt,totalResults:(Y=q.value)==null?void 0:Y.total,resultsLoading:q.loading||S,helpComponent:s,noResultsComponent:p,onSort:b,typeSelectorAllTypesOptionText:D,typeSelectorLabel:_}))}var Jt=oe.default.createContext(void 0),be=()=>{let t=(0,oe.useContext)(Jt);if(!t)throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");return t};var x=require("@emotion/react"),Zr=require("@uniformdev/design-system"),jt=x.css`
|
|
508
509
|
border: 1px solid var(--gray-200);
|
|
509
510
|
background: var(--gray-50);
|
|
510
511
|
border-radius: var(--rounded-base);
|
|
@@ -530,6 +531,7 @@ var po=Object.create;var Pe=Object.defineProperty;var mo=Object.getOwnPropertyDe
|
|
|
530
531
|
font-weight: var(--fw-bold);
|
|
531
532
|
line-height: 1;
|
|
532
533
|
margin: 0;
|
|
534
|
+
word-break: break-word;
|
|
533
535
|
`,nr=x.css`
|
|
534
536
|
width: 1.5rem;
|
|
535
537
|
height: 1.5rem;
|
package/dist/index.mjs
CHANGED
|
@@ -20,11 +20,11 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
20
20
|
width: 1.25rem;
|
|
21
21
|
pointer-events: none;
|
|
22
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 Xr=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"})),ae=Xr;var qr=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"})),ie=qr;import{useAsyncFn as jr,useDebounce as eo}from"react-use";import{Input as We,InputSelect as ce,mq as de}from"@uniformdev/design-system";import{css as L}from"@emotion/react";var _e={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},_n=({value:t,setValue:n,brands:o,categories:r,loading:a,categoriesLoading:i,brandsLoading:l,logoIcon:g,onGetProducts:u,sortOptions:f,sortOrderOptions:s,categoryLabel:p="Product Category",brandLabel:h="Brand",disableBrands:E,restrictToSingleCategory:G=!1})=>{var m,I,U;let w=async d=>{n({..._e,...t||{},...d})},
|
|
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 Xr=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"})),ae=Xr;var qr=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"})),ie=qr;import{useAsyncFn as jr,useDebounce as eo}from"react-use";import{Input as We,InputSelect as ce,mq as de}from"@uniformdev/design-system";import{css as L}from"@emotion/react";var _e={count:1,categories:[],brand:"",keyword:"",sort:"date_modified",sortOrder:"desc"},_n=({value:t,setValue:n,brands:o,categories:r,loading:a,categoriesLoading:i,brandsLoading:l,logoIcon:g,onGetProducts:u,sortOptions:f,sortOrderOptions:s,categoryLabel:p="Product Category",brandLabel:h="Brand",disableBrands:E,restrictToSingleCategory:G=!1})=>{var m,I,U;let w=async d=>{n({..._e,...t||{},...d})},y=se(()=>({..._e,...t||{}}),[t]),[Z,A]=jr(async d=>await u(d),[u]);eo(async()=>{await A({brand:y.brand,categories:y.categories,keyword:y.keyword,sort:y.sort,sortOrder:y.sortOrder,count:y.count})},250,[y]);let N=se(()=>{let d=[];return r==null||r.forEach(b=>{let T=Xe(b,void 0);d.push(...T)}),d},[r]),B=se(()=>[{value:"",label:"All categories"},...N.map(d=>({label:d.name,value:d.id}))],[N]),O=se(()=>(o==null?void 0:o.map(d=>({id:d.id.toString(),name:d.name})))||[],[o]),oe=d=>{if(!d)return;let b=(t==null?void 0:t.categories)||[];w({categories:[...b,d]})},X=d=>{var b;w({categories:(b=t==null?void 0:t.categories)==null?void 0:b.filter(T=>T!==d)})},H=d=>{w({brand:d.target.value})},P=d=>{w({count:d||1})};return a?e("div",null,"Loading..."):e(qe.Provider,{value:{categories:r,logoIcon:g}},e("div",{css:L`
|
|
24
24
|
> :not(:last-child) {
|
|
25
25
|
margin-bottom: var(--spacing-md);
|
|
26
26
|
}
|
|
27
|
-
`},G?e(ce,{id:"selection-field-product-category",label:p,disabled:a,value:(I=(m=
|
|
27
|
+
`},G?e(ce,{id:"selection-field-product-category",label:p,disabled:a,value:(I=(m=y.categories)==null?void 0:m[0])!=null?I:"",options:B,onChange:d=>{w({categories:d.target.value===""?[]:[d.target.value]})}}):e(Qe,{loading:i||!1,id:"selection-field-product-category",label:p,onAdd:oe,onRemove:X,selectedValues:y.categories,values:N}),e("div",{css:L`
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-wrap: wrap;
|
|
30
30
|
column-gap: var(--spacing-lg);
|
|
@@ -34,10 +34,10 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
34
34
|
}
|
|
35
35
|
`},E?null:e("div",{css:L`
|
|
36
36
|
width: 50%;
|
|
37
|
-
`},e(ce,{id:"brand",name:"brand",label:h,disabled:l,value:
|
|
37
|
+
`},e(ce,{id:"brand",name:"brand",label:h,disabled:l,value:y.brand,onChange:H,options:[{value:"",label:"Choose..."},...O.map(d=>({value:d.id,label:d.name}))]})),e("div",{css:L`
|
|
38
38
|
flex-grow: 1;
|
|
39
39
|
position: relative;
|
|
40
|
-
`},e(We,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:
|
|
40
|
+
`},e(We,{id:"keyword-search",name:"keyword-search",label:"Keyword",value:y.keyword,placeholder:"Enter keyword",onChange:d=>w({keyword:d.target.value})}))),e("div",{css:L`
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-wrap: wrap;
|
|
43
43
|
column-gap: var(--spacing-lg);
|
|
@@ -51,20 +51,20 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
51
51
|
width: 33.333333%;
|
|
52
52
|
}
|
|
53
53
|
position: relative;
|
|
54
|
-
`},e(We,{id:"count",name:"count",type:"number",min:1,step:1,value:
|
|
54
|
+
`},e(We,{id:"count",name:"count",type:"number",min:1,step:1,value:y.count,onChange:d=>P(d.target.valueAsNumber),label:"Count"}),e("div",{css:L`
|
|
55
55
|
position: absolute;
|
|
56
56
|
bottom: var(--spacing-sm);
|
|
57
57
|
right: var(--spacing-sm);
|
|
58
58
|
display: flex;
|
|
59
59
|
gap: var(--spacing-sm);
|
|
60
|
-
`},e(Ze,{onCountChange:()=>P(
|
|
60
|
+
`},e(Ze,{onCountChange:()=>P(y.count-1),countIcon:"decrement",disabled:y.count===1}),e(Ze,{onCountChange:()=>P(y.count+1),countIcon:"increment"}))),Array.isArray(f)&&f.length>0?e("div",{css:L`
|
|
61
61
|
flex-grow: 1;
|
|
62
62
|
${de("md")} {
|
|
63
63
|
width: 33.333333%;
|
|
64
64
|
}
|
|
65
|
-
`},e(ce,{id:"sort",name:"sort",label:"Sort",value:
|
|
65
|
+
`},e(ce,{id:"sort",name:"sort",label:"Sort",value:y.sort,onChange:d=>w({sort:d.target.value}),options:[{value:"",label:"Select a sort"},...f.map(d=>({value:d.sortKey,label:d.name}))]})):null,Array.isArray(s)&&s.length>0?e("div",{css:L`
|
|
66
66
|
flex-grow: 1;
|
|
67
|
-
`},e(ce,{id:"sort-order",name:"sort-order",label:"Sort Order",value:
|
|
67
|
+
`},e(ce,{id:"sort-order",name:"sort-order",label:"Sort Order",value:y.sortOrder,onChange:d=>w({sortOrder:d.target.value}),options:s.map(d=>({value:d.sortOrderKey,label:d.name}))})):null),e("div",null,e("h3",{css:L`
|
|
68
68
|
font-size: var(--fs-md);
|
|
69
69
|
line-height: var(--spacing-md);
|
|
70
70
|
font-weight: var(--fw-bold);
|
|
@@ -99,17 +99,18 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
99
99
|
color: currentColor;
|
|
100
100
|
display: inline-flex;
|
|
101
101
|
justify-content: space-between;
|
|
102
|
-
padding: var(--spacing-
|
|
102
|
+
padding: var(--spacing-sm) var(--spacing-base);
|
|
103
103
|
margin-left: auto;
|
|
104
104
|
text-decoration: none;
|
|
105
|
+
gap: var(--spacing-base);
|
|
105
106
|
&:hover {
|
|
106
107
|
background: var(--gray-50);
|
|
107
108
|
}
|
|
108
109
|
`,et=D`
|
|
109
110
|
font-size: var(--fs-sm);
|
|
110
111
|
`,tt=D`
|
|
111
|
-
width:
|
|
112
|
-
height:
|
|
112
|
+
width: 1rem;
|
|
113
|
+
height: 1rem;
|
|
113
114
|
`,he=D`
|
|
114
115
|
margin-right: var(--spacing-lg);
|
|
115
116
|
font-size: var(--fs-sm);
|
|
@@ -354,7 +355,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
354
355
|
`,Pe=C`
|
|
355
356
|
width: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
356
357
|
height: calc(var(--spacing-lg) + var(--spacing-xs));
|
|
357
|
-
`;import{css as z}from"@emotion/react";import{InputSelect as Mo,scrollbarStyles as Vo,Button as Le,Callout as Do,InputKeywordSearch as zo,LoadingIndicator as Uo,Menu as Go,MenuItem as Ao,LoadingOverlay as Bo}from"@uniformdev/design-system";import{useState as Lo,useEffect as Wt,useRef as Ro}from"react";function _t(t,{delay:n=500,minDuration:o=200}={delay:500,minDuration:200}){let[r,a]=Lo("IDLE"),i=Ro(void 0);return Wt(()=>{t&&r==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!t)return a("IDLE");i.current=setTimeout(()=>{a("EXPIRE")},o),a("DISPLAY")},n),a("DELAY")),!t&&r!=="DISPLAY"&&(clearTimeout(i.current),a("IDLE"))},[t,r,n,o]),Wt(()=>()=>clearTimeout(i.current),[]),r==="DISPLAY"||r==="EXPIRE"}var Oo=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&n!=="any"&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),e(Do,{type:"info"},o)},Zt=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:a,select:i,multiSelect:l,multiSelectId:g,rowComponent:u,selectedItemComponent:f,totalResults:s,resultsLoading:p,requireContentType:h,onAddNew:E,onEditClosed:G,onCancel:w,noResultsComponent:
|
|
358
|
+
`;import{css as z}from"@emotion/react";import{InputSelect as Mo,scrollbarStyles as Vo,Button as Le,Callout as Do,InputKeywordSearch as zo,LoadingIndicator as Uo,Menu as Go,MenuItem as Ao,LoadingOverlay as Bo}from"@uniformdev/design-system";import{useState as Lo,useEffect as Wt,useRef as Ro}from"react";function _t(t,{delay:n=500,minDuration:o=200}={delay:500,minDuration:200}){let[r,a]=Lo("IDLE"),i=Ro(void 0);return Wt(()=>{t&&r==="IDLE"&&(clearTimeout(i.current),i.current=setTimeout(()=>{if(!t)return a("IDLE");i.current=setTimeout(()=>{a("EXPIRE")},o),a("DISPLAY")},n),a("DELAY")),!t&&r!=="DISPLAY"&&(clearTimeout(i.current),a("IDLE"))},[t,r,n,o]),Wt(()=>()=>clearTimeout(i.current),[]),r==="DISPLAY"||r==="EXPIRE"}var Oo=({searchText:t,selectedContentType:n})=>{let o="No content found";return n&&n!=="any"&&(o=`No ${n} content was found`),t&&(o=`${o} for keyword '${t}'.`),e(Do,{type:"info"},o)},Zt=({search:t,results:n,contentTypes:o,selectedItems:r,logoIcon:a,select:i,multiSelect:l,multiSelectId:g,rowComponent:u,selectedItemComponent:f,totalResults:s,resultsLoading:p,requireContentType:h,onAddNew:E,onEditClosed:G,onCancel:w,noResultsComponent:y,helpComponent:Z,onSort:A,typeSelectorLabel:N="Content Type Select",typeSelectorAllTypesOptionText:B="All content types",loadingIndicatorDelay:O=1e3})=>{var ze,Ue,Ge;let X=()=>h?Array.isArray(o)&&o.length>0?o[0].id:"":"any",[H,P]=k.useState(""),[m,I]=k.useState(X),[U,d]=k.useState(!1),[b,T]=k.useState([]),[Lr,Te]=k.useState(!1),ve=k.useRef(`x${ko()}`),ne=xo(H,750);k.useEffect(()=>{t(ne,{count:5,offset:0,contentType:m==="any"?void 0:m})},[ne,m]);let Rr=_t(p,{delay:O}),xr=c=>{b.some(v=>v.id===c.id)?T(v=>v.filter($=>$.id!==c.id)):T(l?v=>[...v,c]:[c])},kr=r==null?void 0:r.map(c=>c.id+c.title).join(",");k.useEffect(()=>{Array.isArray(r)&&T(r)},[kr]);let Ir=()=>{I(X()),P(""),T(r!=null&&r.length?r:[])},Er=()=>{d(c=>!c),U||Ir()},Me=c=>{let v=(b==null?void 0:b.filter($=>$.id!==c.id))||[];T(v),i(v,"")},Tr=c=>{c.preventDefault(),i(b,m),d(!1)},Mr=c=>{c.preventDefault(),d(!1),w&&w()},Vr=()=>{t(ne,{count:5,offset:(n==null?void 0:n.length)||0,contentType:m==="any"?void 0:m}),Te(!0);let c=setTimeout(()=>{Te(!1)},750);return()=>clearTimeout(c)},Dr=!(r==null?void 0:r.length)||l,zr=u||zt,Ve=f||xt,Ur=y||Oo,De=a&&typeof a!="string"?a:null,Gr=De?e(De,{css:Pe}):e("img",{src:a,alt:"Logo",css:Pe}),Ar=c=>{var v,$;if(c.destination&&c.source.droppableId===((v=c.destination)==null?void 0:v.droppableId)){let x=[...r||[]],[j]=($=x==null?void 0:x.splice(c.source.index,1))!=null?$:[];return x==null||x.splice(c.destination.index,0,j),A&&(T(x),A==null||A(x)),x}};return e("div",{css:z`
|
|
358
359
|
width: 100%;
|
|
359
360
|
`},e("div",{css:z`
|
|
360
361
|
position: relative;
|
|
@@ -369,7 +370,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
369
370
|
margin-bottom: var(--spacing-base);
|
|
370
371
|
`},e(Mo,{onChange:c=>I(c.target.value),value:m,label:N,showLabel:!1,options:[...h?[]:[{value:"any",label:B}],...o?o.map(c=>({value:c.id,label:c.name})):[]]}),e("div",{css:z`
|
|
371
372
|
flex-grow: 1;
|
|
372
|
-
`},e(zo,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:P,disabledFieldSubmission:!0,value:H}))),e("div",{css:[Ht,Vo],id:ve.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},e(Bo,{isActive:Rr}),Array.isArray(n)&&n.length>0?n.map(c=>e(zr,{key:c.id,isSelected:
|
|
373
|
+
`},e(zo,{inputFieldName:"searchText",placeholder:"Enter keyword to narrow your results",onSearchTextChanged:P,disabledFieldSubmission:!0,value:H}))),e("div",{css:[Ht,Vo],id:ve.current,role:"listbox",tabIndex:0,"data-test-id":"entry-list"},e(Bo,{isActive:Rr}),Array.isArray(n)&&n.length>0?n.map(c=>e(zr,{key:c.id,isSelected:b.some(v=>v.id===c.id),result:c,triggerSelection:()=>xr(c)})):e(Ur,{searchText:ne||H,selectedContentType:(Ue=(ze=o==null?void 0:o.find(c=>c.id===m))==null?void 0:ze.name)!=null?Ue:m}),!p&&typeof s!="undefined"&&n&&(n==null?void 0:n.length)<s&&e("button",{type:"button",css:At,onClick:Vr},Lr?e(Uo,null):"Load More")),e("div",{css:z`
|
|
373
374
|
display: flex;
|
|
374
375
|
justify-content: space-between;
|
|
375
376
|
`},e("div",null,E&&((Ge=o==null?void 0:o.length)!=null?Ge:0)>0?e(Go,{menuLabel:"Add new menu",menuTrigger:e(Le,{buttonType:"secondary"},"Add New")},o==null?void 0:o.map(c=>e(Ao,{key:c.id,css:z`
|
|
@@ -378,9 +379,9 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
378
379
|
`,onClick:()=>E(c)},c.name))):null),e("div",{css:z`
|
|
379
380
|
display: flex;
|
|
380
381
|
gap: var(--spacing-base);
|
|
381
|
-
`},e(Le,{buttonType:"unimportant",onClick:Mr},"Cancel"),e(Le,{disabled:!
|
|
382
|
+
`},e(Le,{buttonType:"unimportant",onClick:Mr},"Cancel"),e(Le,{disabled:!b.length,onClick:Tr,"data-test-id":"entry-accept-button"},"Accept"))))):null,U?null:l&&b.length>1?e(Eo,{onDragEnd:c=>Ar(c)},e(Io,{droppableId:g||"canvas-multi-select"},c=>e("div",{...c.droppableProps,ref:c.innerRef,css:z`
|
|
382
383
|
margin-block: var(--spacing-sm) 0;
|
|
383
|
-
`},
|
|
384
|
+
`},b==null?void 0:b.map((v,$)=>{if(v!=null&&v.id)return e(To,{key:v.id,draggableId:v.id,index:$},x=>e("div",{css:Kt,ref:x.innerRef,...x.draggableProps,...x.dragHandleProps},e("span",{css:Nt},e(te,{css:[Ce,Qt],width:24,height:24}),e(te,{css:Ce,width:24,height:24})),e(Ve,{key:`selected-item-${v.id}`,logoIcon:a,selectedItem:v,onDeselect:j=>Me(j),onEditClosed:G?j=>G(j):void 0})))}),c.placeholder))):b==null?void 0:b.map(c=>e(Ve,{key:`selected-item-${c.id}`,logoIcon:a,selectedItem:c,onDeselect:v=>Me(v),onEditClosed:G?v=>G(v):void 0}))))};import{css as _}from"@emotion/react";var Xt=_`
|
|
384
385
|
cursor: pointer;
|
|
385
386
|
padding: var(--spacing-sm) 0;
|
|
386
387
|
margin-right: var(--spacing-sm);
|
|
@@ -504,7 +505,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
504
505
|
margin-right: var(--spacing-xs);
|
|
505
506
|
`},"SKU:"),t.sku||t.id),t.price!==void 0?e("li",null,e("span",{css:q`
|
|
506
507
|
margin-right: var(--spacing-xs);
|
|
507
|
-
`},"Price:"),e("span",null,t.price)):null))),e("div",{css:dr},t.editLink?e("a",{href:t.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:xe},e("span",{css:ke},"Edit"),e(V,{src:r,alt:"Logo",css:cr})):null,e("button",{type:"button",onClick:()=>{n==null||n(t)},css:xe},e("span",{css:ke},"Unlink"),e(Ho,{icon:Fo,iconColor:"red",size:16})))))}import{Callout as _o}from"@uniformdev/design-system";import{useAsync as Zo,useAsyncFn as Xo}from"react-use";function $i({selectedProducts:t,setSelectedProducts:n,onGetCategories:o,onSearchProducts:r,logoIcon:a,multiSelect:i,multiSelectId:l,selectedItemComponent:g,rowComponent:u,errorComponent:f,helpComponent:s,noResultsComponent:p,onSort:h,typeSelectorAllTypesOptionText:E="All categories",typeSelectorLabel:G="Select Category"}){var H;let{value:w,loading:
|
|
508
|
+
`},"Price:"),e("span",null,t.price)):null))),e("div",{css:dr},t.editLink?e("a",{href:t.editLink,title:"edit",rel:"noopener noreferrer",target:"_blank",css:xe},e("span",{css:ke},"Edit"),e(V,{src:r,alt:"Logo",css:cr})):null,e("button",{type:"button",onClick:()=>{n==null||n(t)},css:xe},e("span",{css:ke},"Unlink"),e(Ho,{icon:Fo,iconColor:"red",size:16})))))}import{Callout as _o}from"@uniformdev/design-system";import{useAsync as Zo,useAsyncFn as Xo}from"react-use";function $i({selectedProducts:t,setSelectedProducts:n,onGetCategories:o,onSearchProducts:r,logoIcon:a,multiSelect:i,multiSelectId:l,selectedItemComponent:g,rowComponent:u,errorComponent:f,helpComponent:s,noResultsComponent:p,onSort:h,typeSelectorAllTypesOptionText:E="All categories",typeSelectorLabel:G="Select Category"}){var H;let{value:w,loading:y,error:Z}=Zo(async()=>await o(),[o]),A=w==null?void 0:w.map(P=>P.id).join(","),N=Qo(()=>w?w.map(m=>({id:m.id,name:m.name})):void 0,[A]),B=Wo(),[O,oe]=Xo(async(P,m)=>{let I=await r({text:P,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&&(B.current=[]),(B.current=B.current||[]).push(...I.products),I},[r]),X=async P=>{await n(P)};return Z||O.error?e(f||(({categoriesError:m,searchError:I})=>e(_o,{type:"error"},"There was an error: ",(m==null?void 0:m.message)||(I==null?void 0:I.message))),{categoriesError:Z,searchError:O.error}):e(pr.Provider,{value:{categories:w,logoIcon:a}},e(Zt,{search:oe,results:B.current,logoIcon:a,selectedItems:t,select:X,multiSelectId:l||"product-search-multi-select",multiSelect:i,contentTypes:N,selectedItemComponent:g||lr,rowComponent:u||or,totalResults:(H=O.value)==null?void 0:H.total,resultsLoading:O.loading||y,helpComponent:s,noResultsComponent:p,onSort:h,typeSelectorAllTypesOptionText:E,typeSelectorLabel:G}))}var pr=Ko.createContext(void 0),ge=()=>{let t=No(pr);if(!t)throw new Error("useProductSearchContext must be used within a <ProductSearchContext> provider");return t};import{css as R}from"@emotion/react";import{mq as qo}from"@uniformdev/design-system";var mr=R`
|
|
508
509
|
border: 1px solid var(--gray-200);
|
|
509
510
|
background: var(--gray-50);
|
|
510
511
|
border-radius: var(--rounded-base);
|
|
@@ -530,6 +531,7 @@ var Br=Object.defineProperty;var Or=(t,n)=>{for(var o in n)Br(t,o,{get:n[o],enum
|
|
|
530
531
|
font-weight: var(--fw-bold);
|
|
531
532
|
line-height: 1;
|
|
532
533
|
margin: 0;
|
|
534
|
+
word-break: break-word;
|
|
533
535
|
`,hr=R`
|
|
534
536
|
width: 1.5rem;
|
|
535
537
|
height: 1.5rem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/mesh-sdk-react",
|
|
3
|
-
"version": "16.1.1-alpha.
|
|
3
|
+
"version": "16.1.1-alpha.319+8f2d7a7f9",
|
|
4
4
|
"description": "Uniform Mesh Framework SDK for React",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"storybook:publish": "pnpm build && pnpm build-storybook -o ./out"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@uniformdev/design-system": "^16.1.1-alpha.
|
|
48
|
-
"@uniformdev/mesh-sdk": "^16.1.1-alpha.
|
|
47
|
+
"@uniformdev/design-system": "^16.1.1-alpha.319+8f2d7a7f9",
|
|
48
|
+
"@uniformdev/mesh-sdk": "^16.1.1-alpha.319+8f2d7a7f9",
|
|
49
49
|
"react-beautiful-dnd": "13.1.0",
|
|
50
50
|
"react-icons": "4.4.0",
|
|
51
51
|
"react-use": "17.4.0",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "8f2d7a7f9ea39b7873f9d3bab3d6496a005bb4c7"
|
|
86
86
|
}
|