@bikdotai/bik-component-library 0.0.662-3 → 0.0.662-5
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/cjs/components/ai-assist/AiAssist.js +1 -1
- package/dist/cjs/components/ai-assist/AiAssist.style.js +9 -8
- package/dist/cjs/components/text-picker/TextPickerModal.js +2 -1
- package/dist/esm/components/ai-assist/AiAssist.js +1 -1
- package/dist/esm/components/ai-assist/AiAssist.style.js +9 -8
- package/dist/esm/components/text-picker/TextPickerModal.js +2 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../assets/icons/chevronRight2.svg.js"),i=require("react"),n=require("../../constants/Theme.js"),c=require("../buttonGroup/ButtonGroup.js"),a=require("../product-picker-v2/modal.js"),o=require("../switch/Switch.js"),l=require("../text-picker/TextPickerModal.js"),r=require("../TypographyStyle.js"),d=require("./AiAssist.style.js"),O=require("./Components/SelectionModal.js"),u=require("./constants.js"),T=require("./model.js");exports.AiAssist=j=>{const{preSelectedData:p,onChange:g,productPickerData:D,storeId:b,checkListType:h,documentPickerData:C,intentPickerData:A}=j,[y,v]=i.useState(null!=p?p:T.DefaultAiAssistData),[m
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../assets/icons/chevronRight2.svg.js"),i=require("react"),n=require("../../constants/Theme.js"),c=require("../buttonGroup/ButtonGroup.js"),a=require("../product-picker-v2/modal.js"),o=require("../switch/Switch.js"),l=require("../text-picker/TextPickerModal.js"),r=require("../TypographyStyle.js"),d=require("./AiAssist.style.js"),O=require("./Components/SelectionModal.js"),u=require("./constants.js"),T=require("./model.js");exports.AiAssist=j=>{const{preSelectedData:p,onChange:g,productPickerData:D,storeId:b,checkListType:h,documentPickerData:C,intentPickerData:A}=j,[y,v]=i.useState(null!=p?p:T.DefaultAiAssistData),[U,m]=i.useState(),[x,E]=i.useState(),[N,M]=i.useState({}),[S,f]=i.useState(0),[P,R]=i.useState({}),[L,I]=i.useState({}),k=i.useMemo((()=>y.PRODUCT),[y]),F=i.useMemo((()=>y.DOCUMENT),[y]);i.useEffect((()=>g(y)),[y]),i.useEffect((()=>{p&&p.DOCUMENT&&Array.isArray(p.DOCUMENT.intents)&&(R((()=>{const e={};return p.DOCUMENT.intents.forEach((t=>{e[t]=[t]})),e})),v(p)),p&&p.DOCUMENT&&Array.isArray(p.DOCUMENT.documentData)&&(I((()=>{const e={};return p.DOCUMENT.documentData.forEach((t=>{e[t.type]=[...e[t.type]||[],t.id]})),e})),v(p))}),[p]);return i.useEffect((()=>{console.log("KB",y)}),[y]),t.jsxs(t.Fragment,{children:[t.jsxs(d.AiAssistMainContainer,{children:[t.jsx(r.TitleRegular,{children:"Choose Data"}),t.jsxs("div",Object.assign({className:"ai-assist-data-selection"},{children:[t.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:[t.jsx(r.BodyPrimary,{children:"Choose all store data"}),t.jsx("div",Object.assign({style:{marginLeft:"auto"}},{children:t.jsx(o.Switch,{onValueChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){yield(e=>{v((t=>Object.assign(Object.assign({},t),{selectionType:e?T.AiAssistDataSelectionType.FULL:T.AiAssistDataSelectionType.PARTIAL})))})(t)})),value:y.selectionType===T.AiAssistDataSelectionType.FULL})}))]})),y.selectionType!==T.AiAssistDataSelectionType.FULL&&t.jsxs(t.Fragment,{children:[t.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[t.jsx(r.TitleRegular,{children:"Select Products"}),t.jsx(c.ButtonGroup,{buttonGroup:u.AiAssistProductSelectionType,gap:"16px",onButtonClick:e=>{m(void 0),(e=>{v((t=>Object.assign(Object.assign({},t),{PRODUCT:Object.assign(Object.assign({},t.PRODUCT),{selectionType:e})})))})(e)},size:"large",activeButtonId:y.PRODUCT.selectionType,iconPosition:"left",iconHeight:"24px",iconWidth:"24px",borderRadius:"8px",height:"60px",iconGap:"8px"}),t.jsxs(d.AiAssistSelectionCard,Object.assign({disable:k.selectionType===T.AiAssistDataSelectionType.FULL,onClick:()=>{k.selectionType!==T.AiAssistDataSelectionType.FULL&&m(T.AiAssistDataType.PRODUCT)}},{children:[t.jsx(r.TitleSmall,Object.assign({color:n.COLORS.content.secondary},{children:k.selectionType===T.AiAssistDataSelectionType.FULL?"All products selected":`${k.productData.length} products selected`})),t.jsx(s.default,{width:20,height:20})]}))]})),t.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[t.jsx(r.TitleRegular,{children:"Select Documents"}),t.jsx(c.ButtonGroup,{buttonGroup:u.AiAssistDocumentSelectionType,gap:"16px",onButtonClick:e=>{m(void 0),(e=>{v((t=>Object.assign(Object.assign({},t),{DOCUMENT:Object.assign(Object.assign({},t.DOCUMENT),{selectionType:e})})))})(e)},size:"large",activeButtonId:y.DOCUMENT.selectionType,iconPosition:"top",iconHeight:"24px",iconWidth:"24px",borderRadius:"8px",height:"90px",iconGap:"12px"}),t.jsxs(d.AiAssistSelectionCard,Object.assign({disable:F.selectionType===T.AiAssistDataSelectionType.FULL,onClick:()=>{F.selectionType===T.AiAssistDataSelectionType.INTENT?m("INTENT"):F.selectionType===T.AiAssistDataSelectionType.PARTIAL&&m(T.AiAssistDataType.DOCUMENT)}},{children:[t.jsx(r.TitleSmall,Object.assign({color:n.COLORS.content.secondary},{children:F.selectionType===T.AiAssistDataSelectionType.FULL?"All documents selected":F.selectionType===T.AiAssistDataSelectionType.INTENT?`${F.intents.length} intents selected`:`${F.documentData.length} documents selected`})),t.jsx(s.default,{width:20,height:20})]}))]}))]})]}))]}),"PRODUCT"==U&&t.jsx(a.ProductPickerModal,{searchFetcher:D.searchFetcher,productFetcher:D.productFetcher,collectionFetcher:D.collectionFetcher,searchInCollectionFetcher:D.searchInCollectionFetcher,storeId:b,selectedItems:N,onAdd:e=>{Object.values(e).forEach((e=>{e.products})),f(0),M(Object.assign({},e)),v((t=>Object.assign(Object.assign({},t),{PRODUCT:Object.assign(Object.assign({},t.PRODUCT),{productData:Object.values(e).flatMap((e=>e.products?Object.values(e.products).map((e=>({id:e.id,name:e.name,imageUrl:e.image,description:e.description}))):[])),collectionData:Object.entries(e).map((e=>{let[t,s]=e;var i;return{id:t,name:s.name,imageUrl:s.image,description:null!==(i=null==s?void 0:s.description)&&void 0!==i?i:""}}))})}))),m(void 0),E(void 0)},onClickSave:S,onClose:()=>{f(0),m(void 0),E(void 0)},limit:50,visible:!!U&&(0==k.productData.length||x===T.AiAssistDataType.PRODUCT),renderWithoutModal:!1,pickerType:"PRODUCT",hideSelectionCount:!1,hideVariantCheckbox:!1,hideProductVariants:!0,hideCollectionCheckbox:!1}),"DOCUMENT"==U&&t.jsx(l.TextPickerModal,{visible:!!U&&(0==F.documentData.length||x===T.AiAssistDataType.DOCUMENT),categories:C,selectedItems:L,onAdd:e=>{var t;t=e,I(Object.assign({},t)),v((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{documentData:Object.entries(t).flatMap((e=>{let[t,s]=e;return s.map((e=>{var s,i;return{id:e,type:t,name:(null===(i=null===(s=C.find((e=>e.id===t)))||void 0===s?void 0:s.items.find((t=>t.id===e)))||void 0===i?void 0:i.name)||""}}))}))})}))),m(void 0),E(void 0)},onClose:()=>{m(void 0),E(void 0)},title:"Select Documents"}),"INTENT"==U&&t.jsx(l.TextPickerModal,{visible:!!U&&(0==F.intents.length||"INTENT"===x),isOneDimensional:!0,categories:A,selectedItems:P,onAdd:e=>{return t=e,R(Object.assign({},t)),v((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{intents:Object.values(t).flat()})}))),m(void 0),void E(void 0);var t},onClose:()=>{m(void 0),E(void 0)},title:"Select Intents"}),!!U&&t.jsx(O.SelectionModal,{selectionType:U,localAiAssistSelectedData:y,checkListType:h,isOpen:!!U&&("PRODUCT"==U&&k.productData.length>0||"DOCUMENT"==U&&F.documentData.length>0||"INTENT"==U&&F.intents.length>0),onClose:()=>{m(void 0),E(void 0)},onRemoveAll:()=>{"PRODUCT"==U?(v((e=>Object.assign(Object.assign({},e),{PRODUCT:Object.assign(Object.assign({},e.PRODUCT),{productData:[],collectionData:[]})}))),M({}),m(void 0),E(void 0)):"DOCUMENT"==U?(v((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{documentData:[]})}))),I({}),m(void 0),E(void 0)):"INTENT"==U&&(v((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{intents:[]})}))),R({}),m(void 0),E(void 0))},onRemoveSelected:(e,t)=>((e,t)=>{if("PRODUCT"==U){const s=Object.assign({},N);Object.entries(s).forEach((e=>{let[i,n]=e;s[i].products=Array.isArray(null==n?void 0:n.products)?Object.fromEntries(n.products.filter((e=>e.id!==t)).map((e=>[e.id,e]))):{}})),M(s),v((t=>Object.assign(Object.assign({},t),{PRODUCT:Object.assign(Object.assign({},t.PRODUCT),{productData:t.PRODUCT.productData.filter(((t,s)=>s!==e))})})))}else if("DOCUMENT"==U){const s=Object.assign({},L);Object.entries(s).forEach((e=>{let[i,n]=e;s[i]=n.filter((e=>e!==t))})),I(s),v((t=>Object.assign(Object.assign({},t),{DOCUMENT:Object.assign(Object.assign({},t.DOCUMENT),{documentData:t.DOCUMENT.documentData.filter(((t,s)=>s!==e))})})))}else"INTENT"==U&&(R((e=>{const s=Object.assign({},e);return Object.entries(s).forEach((e=>{let[i,n]=e;s[i]=n.filter((e=>e!==t))})),s})),v((t=>Object.assign(Object.assign({},t),{DOCUMENT:Object.assign(Object.assign({},t.DOCUMENT),{intents:t.DOCUMENT.intents.filter(((t,s)=>s!==e))})}))))})(e,t),onAdd:()=>E(U)})]})};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("../../constants/Theme.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("../../constants/Theme.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);o.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: row;
|
|
4
4
|
width: 100vw;
|
|
5
5
|
height: 90vh;
|
|
6
6
|
background-color: ${r.COLORS.surface.subdued};
|
|
7
7
|
margin: 16px;
|
|
8
|
-
|
|
8
|
+
`;const d=o.default.div`
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
gap: 2px;
|
|
12
|
-
width: 33%;
|
|
12
|
+
// width: 33%;
|
|
13
|
+
width: 100%;
|
|
13
14
|
height: 100%;
|
|
14
15
|
background-color: #fff;
|
|
15
16
|
border-radius: 8px;
|
|
16
17
|
border: 1px solid ${r.COLORS.stroke.primary};
|
|
17
|
-
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
|
18
|
+
// box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
|
18
19
|
padding: 16px;
|
|
19
|
-
margin: 16px 2px; // TODO: remove this margin when integrating with the main component
|
|
20
|
+
// margin: 16px 2px; // TODO: remove this margin when integrating with the main component
|
|
20
21
|
position: relative;
|
|
21
22
|
overflow: hidden;
|
|
22
23
|
z-index: 1;
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
background-color: ${r.COLORS.background.brandLight};
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
`,
|
|
48
|
+
`,a=o.default.div`
|
|
48
49
|
display: flex;
|
|
49
50
|
flex-direction: row;
|
|
50
51
|
gap: 8px;
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
&:active {
|
|
63
64
|
background-color: ${e=>e.disable?r.COLORS.surface.subdued:r.COLORS.background.brandLight};
|
|
64
65
|
}
|
|
65
|
-
`,
|
|
66
|
+
`,t=o.default.div`
|
|
66
67
|
display: flex;
|
|
67
68
|
flex-direction: column;
|
|
68
69
|
gap: 16px;
|
|
@@ -108,4 +109,4 @@
|
|
|
108
109
|
padding: 16px;
|
|
109
110
|
background-color: ${r.COLORS.surface.standard};
|
|
110
111
|
}
|
|
111
|
-
`;exports.AiAssistMainContainer=d,exports.AiAssistSelectionCard=
|
|
112
|
+
`;exports.AiAssistMainContainer=d,exports.AiAssistSelectionCard=a,exports.AiAssistSelectionModalMainContainer=t;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
padding: 12px 24px;
|
|
7
7
|
border-bottom: 1px solid ${r.COLORS.stroke.primary};
|
|
8
8
|
`,j=x.default.div`
|
|
9
|
+
max-height: calc(-365px + 100vh);
|
|
9
10
|
flex: 1;
|
|
10
11
|
overflow-y: auto;
|
|
11
12
|
`,v=x.default.div`
|
|
@@ -22,4 +23,4 @@
|
|
|
22
23
|
color: ${r.COLORS.content.secondary};
|
|
23
24
|
text-align: center;
|
|
24
25
|
padding: 32px;
|
|
25
|
-
`;exports.TextPickerModal=n=>{var g,x;const{visible:b,isOneDimensional:y=!1,categories:f,selectedItems:O,onAdd:k,onClose:S,title:T="Select Text",subtitle:w,width:
|
|
26
|
+
`;exports.TextPickerModal=n=>{var g,x;const{visible:b,isOneDimensional:y=!1,categories:f,selectedItems:O,onAdd:k,onClose:S,title:T="Select Text",subtitle:w,width:P="640px",zIndex:L}=n,q=null!==(g=n.maxDocuments)&&void 0!==g?g:1/0,[R,B]=i.useState("categories"),[I,A]=i.useState(""),[F,$]=i.useState(O),[D,M]=i.useState(null),z=f.filter((e=>e.name.toLowerCase().includes(I.toLowerCase()))),E=D?D.items.filter((e=>e.name.toLowerCase().includes(I.toLowerCase()))):[],_=Object.values(F).reduce(((e,t)=>e+t.length),0),N=w||"",G=e=>{var t;return e.items.length>0&&(null===(t=F[e.id])||void 0===t?void 0:t.length)===e.items.length},H=e=>{var t;return!!(null===(t=F[e.id])||void 0===t?void 0:t.length)&&F[e.id].length<e.items.length},J=()=>{var e;return!!D&&E.length>0&&(null===(e=F[D.id])||void 0===e?void 0:e.length)===E.length},K=(e,t)=>{D&&$((i=>{const n=i[D.id]||[];return t&&_>=q?i:t?n.includes(e)?i:Object.assign(Object.assign({},i),{[D.id]:[...n,e]}):Object.assign(Object.assign({},i),{[D.id]:n.filter((t=>t!==e))})}))};return e.jsx(l.StyledModal,Object.assign({open:b,onClose:S,headingTitle:T,headingSubtitle:N,centralContainerStyles:{width:P,zIndex:L},hideCrossButton:!1,primaryButton:n.primaryButton?Object.assign(Object.assign({},n.primaryButton),{buttonText:n.primaryButton.isLoading?"Loading...":n.primaryButton.buttonText||"Add",disabled:null!==(x=n.primaryButton.disabled)&&void 0!==x&&x||0===_||q!==1/0&&_>q,onClick:n.primaryButton.onClick||(()=>k(F))}):{buttonText:"Add",disabled:0===_||q!==1/0&&_>q,onClick:()=>k(F)},footerLeftCustomElement:e.jsx(c.TextPickerFooter,{totalSelected:_,maxDocuments:q}),footerContainerStyle:{borderTop:`1px solid ${r.COLORS.stroke.primary}`,position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard},wrapperStyle:{height:"calc(100vh - 168px)"}},{children:e.jsx(m,{children:"categories"===R?e.jsxs(e.Fragment,{children:[e.jsx(p,{children:e.jsx(o.Input,{placeholder:"Search ...",value:I,onChangeText:A,height:"40px"})}),e.jsx(j,{children:0===z.length?e.jsx(C,{children:"No categories found. Try a different search."}):e.jsxs(e.Fragment,{children:[e.jsx(h.TextPickerSelectAllRow,{isChecked:z.length>0&&z.every((e=>G(e))),isPartiallyChecked:z.some((e=>H(e)))&&!z.every((e=>G(e))),onCheck:e=>{$((t=>{if(e){const e=Object.assign({},t);return z.forEach((t=>{e[t.id]=t.items.map((e=>e.id))})),e}{const e=Object.assign({},t);return z.forEach((t=>{e[t.id]=[]})),e}}))}}),z.map((t=>{var i;return e.jsx(a.TextPickerCategoryCard,{id:t.id,name:t.name,itemsCount:t.items.length,selectedCount:(null===(i=F[t.id])||void 0===i?void 0:i.length)||0,isOneDimensional:y,isChecked:G(t),isPartiallyChecked:H(t)&&!G(t),onCheck:(e,i)=>((e,t,i)=>{i&&i.stopPropagation(),$((i=>Object.assign(Object.assign({},i),{[e.id]:t?e.items.map((e=>e.id)):[]})))})(t,e,i),onClick:()=>(e=>{y||(M(e),B("items"),A(""))})(t)},t.id)}))]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(v,{children:[e.jsx(s.IconButton,{Icon:t.default,height:16,width:16,onClick:()=>{B("categories"),M(null),A("")},style:{marginRight:8},"aria-label":"Back"}),e.jsx(d.BodyCaption,Object.assign({style:{color:r.COLORS.content.secondary}},{children:null==D?void 0:D.name}))]}),e.jsx(p,{children:e.jsx(o.Input,{placeholder:"Search ...",value:I,onChangeText:A,height:"40px"})}),e.jsx(j,{children:0===E.length?e.jsx(C,{children:"No items found. Try a different search."}):e.jsxs(e.Fragment,{children:[e.jsx(h.TextPickerSelectAllRow,{isChecked:J(),isPartiallyChecked:(()=>{var e;return!!D&&!!(null===(e=F[D.id])||void 0===e?void 0:e.length)&&F[D.id].length<E.length})()&&!J(),onCheck:e=>{D&&$((t=>e?Object.assign(Object.assign({},t),{[D.id]:E.map((e=>e.id))}):Object.assign(Object.assign({},t),{[D.id]:[]})))}}),E.map((t=>{var i;return e.jsx(u.TextPickerItemRow,{item:t,selected:!(!D||!(null===(i=F[D.id])||void 0===i?void 0:i.includes(t.id))),onCheck:e=>K(t.id,e),onClick:()=>{var e;return K(t.id,!!D&&!(null===(e=F[D.id])||void 0===e?void 0:e.includes(t.id)))}},t.id)}))]})})]})})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsxs as t,Fragment as i,jsx as s}from"react/jsx-runtime";import n from"../../assets/icons/chevronRight2.svg.js";import{useState as c,useMemo as o,useEffect as a}from"react";import{COLORS as r}from"../../constants/Theme.js";import{ButtonGroup as l}from"../buttonGroup/ButtonGroup.js";import{ProductPickerModal as d}from"../product-picker-v2/modal.js";import{Switch as O}from"../switch/Switch.js";import{TextPickerModal as p}from"../text-picker/TextPickerModal.js";import{TitleRegular as g,BodyPrimary as T,TitleSmall as j}from"../TypographyStyle.js";import{AiAssistMainContainer as b,AiAssistSelectionCard as u}from"./AiAssist.style.js";import{SelectionModal as D}from"./Components/SelectionModal.js";import{AiAssistProductSelectionType as m,AiAssistDocumentSelectionType as h}from"./constants.js";import{DefaultAiAssistData as C,AiAssistDataSelectionType as v,AiAssistDataType as U}from"./model.js";const N=N=>{const{preSelectedData:E,onChange:f,productPickerData:y,storeId:M,checkListType:P,documentPickerData:x,intentPickerData:R}=N,[A,I]=c(null!=E?E:C),[L,k]=c(),[F,S]=c(),[B,G]=c({}),[w,V]=c(0),[W,$]=c({}),[z,H]=c({}),_=o((()=>A.PRODUCT),[A]),K=o((()=>A.DOCUMENT),[A]);a((()=>f(A)),[A]),a((()=>{E&&E.DOCUMENT&&Array.isArray(E.DOCUMENT.intents)&&($((()=>{const e={};return E.DOCUMENT.intents.forEach((t=>{e[t]=[t]})),e})),I(E)),E&&E.DOCUMENT&&Array.isArray(E.DOCUMENT.documentData)&&(H((()=>{const e={};return E.DOCUMENT.documentData.forEach((t=>{e[t.type]=[...e[t.type]||[],t.id]})),e})),I(E))}),[E]);return a((()=>{console.log("KB",A)}),[A]),t(i,{children:[t(b,{children:[s(g,{children:"Choose Data"}),t("div",Object.assign({className:"ai-assist-data-selection"},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:[s(T,{children:"Choose all store data"}),s("div",Object.assign({style:{marginLeft:"auto"}},{children:s(O,{onValueChange:t=>e(void 0,void 0,void 0,(function*(){yield(e=>{I((t=>Object.assign(Object.assign({},t),{selectionType:e?v.FULL:v.PARTIAL})))})(t)})),value:A.selectionType===v.FULL})}))]})),A.selectionType!==v.FULL&&t(i,{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[s(g,{children:"Select Products"}),s(l,{buttonGroup:m,gap:"16px",onButtonClick:e=>{k(void 0),(e=>{I((t=>Object.assign(Object.assign({},t),{PRODUCT:Object.assign(Object.assign({},t.PRODUCT),{selectionType:e})})))})(e)},size:"large",activeButtonId:A.PRODUCT.selectionType,iconPosition:"left",iconHeight:"24px",iconWidth:"24px",borderRadius:"8px",height:"60px",iconGap:"8px"}),t(u,Object.assign({disable:_.selectionType===v.FULL,onClick:()=>{_.selectionType!==v.FULL&&k(U.PRODUCT)}},{children:[s(j,Object.assign({color:r.content.secondary},{children:_.selectionType===v.FULL?"All products selected":`${_.productData.length} products selected`})),s(n,{width:20,height:20})]}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[s(g,{children:"Select Documents"}),s(l,{buttonGroup:h,gap:"16px",onButtonClick:e=>{k(void 0),(e=>{I((t=>Object.assign(Object.assign({},t),{DOCUMENT:Object.assign(Object.assign({},t.DOCUMENT),{selectionType:e})})))})(e)},size:"large",activeButtonId:A.DOCUMENT.selectionType,iconPosition:"top",iconHeight:"24px",iconWidth:"24px",borderRadius:"8px",height:"90px",iconGap:"12px"}),t(u,Object.assign({disable:K.selectionType===v.FULL,onClick:()=>{K.selectionType===v.INTENT?k("INTENT"):K.selectionType===v.PARTIAL&&k(U.DOCUMENT)}},{children:[s(j,Object.assign({color:r.content.secondary},{children:K.selectionType===v.FULL?"All documents selected":K.selectionType===v.INTENT?`${K.intents.length} intents selected`:`${K.documentData.length} documents selected`})),s(n,{width:20,height:20})]}))]}))]})]}))]}),"PRODUCT"==L&&s(d,{searchFetcher:y.searchFetcher,productFetcher:y.productFetcher,collectionFetcher:y.collectionFetcher,searchInCollectionFetcher:y.searchInCollectionFetcher,storeId:M,selectedItems:B,onAdd:e=>{Object.values(e).forEach((e=>{e.products})),V(0),G(Object.assign({},e)),I((t=>Object.assign(Object.assign({},t),{PRODUCT:Object.assign(Object.assign({},t.PRODUCT),{productData:Object.values(e).flatMap((e=>e.products?Object.values(e.products).map((e=>({id:e.id,name:e.name,imageUrl:e.image,description:e.description}))):[])),collectionData:Object.entries(e).map((e=>{let[t,i]=e;var s;return{id:t,name:i.name,imageUrl:i.image,description:null!==(s=null==i?void 0:i.description)&&void 0!==s?s:""}}))})}))),k(void 0),S(void 0)},onClickSave:w,onClose:()=>{V(0),k(void 0),S(void 0)},limit:50,visible:!!L&&(0==_.productData.length||F===U.PRODUCT),renderWithoutModal:!1,pickerType:"PRODUCT",hideSelectionCount:!1,hideVariantCheckbox:!1,hideProductVariants:!0,hideCollectionCheckbox:!1}),"DOCUMENT"==L&&s(p,{visible:!!L&&(0==K.documentData.length||F===U.DOCUMENT),categories:x,selectedItems:z,onAdd:e=>{var t;t=e,H(Object.assign({},t)),I((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{documentData:Object.entries(t).flatMap((e=>{let[t,i]=e;return i.map((e=>{var i,s;return{id:e,type:t,name:(null===(s=null===(i=x.find((e=>e.id===t)))||void 0===i?void 0:i.items.find((t=>t.id===e)))||void 0===s?void 0:s.name)||""}}))}))})}))),k(void 0),S(void 0)},onClose:()=>{k(void 0),S(void 0)},title:"Select Documents"}),"INTENT"==L&&s(p,{visible:!!L&&(0==K.intents.length||"INTENT"===F),isOneDimensional:!0,categories:R,selectedItems:W,onAdd:e=>{return t=e,$(Object.assign({},t)),I((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{intents:Object.values(t).flat()})}))),k(void 0),void S(void 0);var t},onClose:()=>{k(void 0),S(void 0)},title:"Select Intents"}),!!L&&s(D,{selectionType:L,localAiAssistSelectedData:A,checkListType:P,isOpen:!!L&&("PRODUCT"==L&&_.productData.length>0||"DOCUMENT"==L&&K.documentData.length>0||"INTENT"==L&&K.intents.length>0),onClose:()=>{k(void 0),S(void 0)},onRemoveAll:()=>{"PRODUCT"==L?(I((e=>Object.assign(Object.assign({},e),{PRODUCT:Object.assign(Object.assign({},e.PRODUCT),{productData:[],collectionData:[]})}))),G({}),k(void 0),S(void 0)):"DOCUMENT"==L?(I((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{documentData:[]})}))),H({}),k(void 0),S(void 0)):"INTENT"==L&&(I((e=>Object.assign(Object.assign({},e),{DOCUMENT:Object.assign(Object.assign({},e.DOCUMENT),{intents:[]})}))),$({}),k(void 0),S(void 0))},onRemoveSelected:(e,t)=>((e,t)=>{if("PRODUCT"==L){const i=Object.assign({},B);Object.entries(i).forEach((e=>{let[s,n]=e;i[s].products=Array.isArray(null==n?void 0:n.products)?Object.fromEntries(n.products.filter((e=>e.id!==t)).map((e=>[e.id,e]))):{}})),G(i),I((t=>Object.assign(Object.assign({},t),{PRODUCT:Object.assign(Object.assign({},t.PRODUCT),{productData:t.PRODUCT.productData.filter(((t,i)=>i!==e))})})))}else if("DOCUMENT"==L){const i=Object.assign({},z);Object.entries(i).forEach((e=>{let[s,n]=e;i[s]=n.filter((e=>e!==t))})),H(i),I((t=>Object.assign(Object.assign({},t),{DOCUMENT:Object.assign(Object.assign({},t.DOCUMENT),{documentData:t.DOCUMENT.documentData.filter(((t,i)=>i!==e))})})))}else"INTENT"==L&&($((e=>{const i=Object.assign({},e);return Object.entries(i).forEach((e=>{let[s,n]=e;i[s]=n.filter((e=>e!==t))})),i})),I((t=>Object.assign(Object.assign({},t),{DOCUMENT:Object.assign(Object.assign({},t.DOCUMENT),{intents:t.DOCUMENT.intents.filter(((t,i)=>i!==e))})}))))})(e,t),onAdd:()=>S(L)})]})};export{N as AiAssist};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import r from"styled-components";import{COLORS as e}from"../../constants/Theme.js";
|
|
1
|
+
import r from"styled-components";import{COLORS as e}from"../../constants/Theme.js";r.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: row;
|
|
4
4
|
width: 100vw;
|
|
5
5
|
height: 90vh;
|
|
6
6
|
background-color: ${e.surface.subdued};
|
|
7
7
|
margin: 16px;
|
|
8
|
-
|
|
8
|
+
`;const o=r.div`
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
gap: 2px;
|
|
12
|
-
width: 33%;
|
|
12
|
+
// width: 33%;
|
|
13
|
+
width: 100%;
|
|
13
14
|
height: 100%;
|
|
14
15
|
background-color: #fff;
|
|
15
16
|
border-radius: 8px;
|
|
16
17
|
border: 1px solid ${e.stroke.primary};
|
|
17
|
-
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
|
18
|
+
// box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
|
18
19
|
padding: 16px;
|
|
19
|
-
margin: 16px 2px; // TODO: remove this margin when integrating with the main component
|
|
20
|
+
// margin: 16px 2px; // TODO: remove this margin when integrating with the main component
|
|
20
21
|
position: relative;
|
|
21
22
|
overflow: hidden;
|
|
22
23
|
z-index: 1;
|
|
@@ -44,7 +45,7 @@ import r from"styled-components";import{COLORS as e}from"../../constants/Theme.j
|
|
|
44
45
|
background-color: ${e.background.brandLight};
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
`,
|
|
48
|
+
`,i=r.div`
|
|
48
49
|
display: flex;
|
|
49
50
|
flex-direction: row;
|
|
50
51
|
gap: 8px;
|
|
@@ -62,7 +63,7 @@ import r from"styled-components";import{COLORS as e}from"../../constants/Theme.j
|
|
|
62
63
|
&:active {
|
|
63
64
|
background-color: ${r=>r.disable?e.surface.subdued:e.background.brandLight};
|
|
64
65
|
}
|
|
65
|
-
`,
|
|
66
|
+
`,d=r.div`
|
|
66
67
|
display: flex;
|
|
67
68
|
flex-direction: column;
|
|
68
69
|
gap: 16px;
|
|
@@ -108,4 +109,4 @@ import r from"styled-components";import{COLORS as e}from"../../constants/Theme.j
|
|
|
108
109
|
padding: 16px;
|
|
109
110
|
background-color: ${e.surface.standard};
|
|
110
111
|
}
|
|
111
|
-
`;export{
|
|
112
|
+
`;export{o as AiAssistMainContainer,i as AiAssistSelectionCard,d as AiAssistSelectionModalMainContainer};
|
|
@@ -6,6 +6,7 @@ import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import n from"..
|
|
|
6
6
|
padding: 12px 24px;
|
|
7
7
|
border-bottom: 1px solid ${l.stroke.primary};
|
|
8
8
|
`,v=r.div`
|
|
9
|
+
max-height: calc(-365px + 100vh);
|
|
9
10
|
flex: 1;
|
|
10
11
|
overflow-y: auto;
|
|
11
12
|
`,b=r.div`
|
|
@@ -22,4 +23,4 @@ import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import n from"..
|
|
|
22
23
|
color: ${l.content.secondary};
|
|
23
24
|
text-align: center;
|
|
24
25
|
padding: 32px;
|
|
25
|
-
`,y=r=>{var y,C;const{visible:j,isOneDimensional:k=!1,categories:O,selectedItems:T,onAdd:w,onClose:B,title:S="Select Text",subtitle:I,width:
|
|
26
|
+
`,y=r=>{var y,C;const{visible:j,isOneDimensional:k=!1,categories:O,selectedItems:T,onAdd:w,onClose:B,title:S="Select Text",subtitle:I,width:P="640px",zIndex:L}=r,$=null!==(y=r.maxDocuments)&&void 0!==y?y:1/0,[A,D]=o("categories"),[z,E]=o(""),[R,N]=o(T),[F,M]=o(null),_=O.filter((e=>e.name.toLowerCase().includes(z.toLowerCase()))),q=F?F.items.filter((e=>e.name.toLowerCase().includes(z.toLowerCase()))):[],G=Object.values(R).reduce(((e,t)=>e+t.length),0),H=I||"",J=e=>{var t;return e.items.length>0&&(null===(t=R[e.id])||void 0===t?void 0:t.length)===e.items.length},K=e=>{var t;return!!(null===(t=R[e.id])||void 0===t?void 0:t.length)&&R[e.id].length<e.items.length},Q=()=>{var e;return!!F&&q.length>0&&(null===(e=R[F.id])||void 0===e?void 0:e.length)===q.length},U=(e,t)=>{F&&N((i=>{const n=i[F.id]||[];return t&&G>=$?i:t?n.includes(e)?i:Object.assign(Object.assign({},i),{[F.id]:[...n,e]}):Object.assign(Object.assign({},i),{[F.id]:n.filter((t=>t!==e))})}))};return e(a,Object.assign({open:j,onClose:B,headingTitle:S,headingSubtitle:H,centralContainerStyles:{width:P,zIndex:L},hideCrossButton:!1,primaryButton:r.primaryButton?Object.assign(Object.assign({},r.primaryButton),{buttonText:r.primaryButton.isLoading?"Loading...":r.primaryButton.buttonText||"Add",disabled:null!==(C=r.primaryButton.disabled)&&void 0!==C&&C||0===G||$!==1/0&&G>$,onClick:r.primaryButton.onClick||(()=>w(R))}):{buttonText:"Add",disabled:0===G||$!==1/0&&G>$,onClick:()=>w(R)},footerLeftCustomElement:e(h,{totalSelected:G,maxDocuments:$}),footerContainerStyle:{borderTop:`1px solid ${l.stroke.primary}`,position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard},wrapperStyle:{height:"calc(100vh - 168px)"}},{children:e(p,{children:t(i,"categories"===A?{children:[e(f,{children:e(s,{placeholder:"Search ...",value:z,onChangeText:E,height:"40px"})}),e(v,{children:0===_.length?e(x,{children:"No categories found. Try a different search."}):t(i,{children:[e(g,{isChecked:_.length>0&&_.every((e=>J(e))),isPartiallyChecked:_.some((e=>K(e)))&&!_.every((e=>J(e))),onCheck:e=>{N((t=>{if(e){const e=Object.assign({},t);return _.forEach((t=>{e[t.id]=t.items.map((e=>e.id))})),e}{const e=Object.assign({},t);return _.forEach((t=>{e[t.id]=[]})),e}}))}}),_.map((t=>{var i;return e(m,{id:t.id,name:t.name,itemsCount:t.items.length,selectedCount:(null===(i=R[t.id])||void 0===i?void 0:i.length)||0,isOneDimensional:k,isChecked:J(t),isPartiallyChecked:K(t)&&!J(t),onCheck:(e,i)=>((e,t,i)=>{i&&i.stopPropagation(),N((i=>Object.assign(Object.assign({},i),{[e.id]:t?e.items.map((e=>e.id)):[]})))})(t,e,i),onClick:()=>(e=>{k||(M(e),D("items"),E(""))})(t)},t.id)}))]})})]}:{children:[t(b,{children:[e(d,{Icon:n,height:16,width:16,onClick:()=>{D("categories"),M(null),E("")},style:{marginRight:8},"aria-label":"Back"}),e(c,Object.assign({style:{color:l.content.secondary}},{children:null==F?void 0:F.name}))]}),e(f,{children:e(s,{placeholder:"Search ...",value:z,onChangeText:E,height:"40px"})}),e(v,{children:0===q.length?e(x,{children:"No items found. Try a different search."}):t(i,{children:[e(g,{isChecked:Q(),isPartiallyChecked:(()=>{var e;return!!F&&!!(null===(e=R[F.id])||void 0===e?void 0:e.length)&&R[F.id].length<q.length})()&&!Q(),onCheck:e=>{F&&N((t=>e?Object.assign(Object.assign({},t),{[F.id]:q.map((e=>e.id))}):Object.assign(Object.assign({},t),{[F.id]:[]})))}}),q.map((t=>{var i;return e(u,{item:t,selected:!(!F||!(null===(i=R[F.id])||void 0===i?void 0:i.includes(t.id))),onCheck:e=>U(t.id,e),onClick:()=>{var e;return U(t.id,!!F&&!(null===(e=R[F.id])||void 0===e?void 0:e.includes(t.id)))}},t.id)}))]})})]})})}))};export{y as TextPickerModal};
|