@bikdotai/bik-component-library 0.0.359-beta.25 → 0.0.359-beta.26
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/bik-layout/MockMenus.d.ts +0 -1
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +2 -1
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/Body.d.ts +1 -0
- package/dist/cjs/components/template-context-mapper/modalElements/Body.js +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.d.ts +11 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.js +1 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts +2 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +2 -1
- package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +2 -1
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/Body.d.ts +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/Body.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.d.ts +11 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.js +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts +2 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +2 -1
- package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/package.json +1 -1
|
@@ -20,9 +20,10 @@ export interface TemplateContextMapperProps {
|
|
|
20
20
|
zIndex?: number;
|
|
21
21
|
showVariableModal?: boolean;
|
|
22
22
|
variableList?: VariableListInterfaceV2[];
|
|
23
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
23
24
|
onBackPress?: () => void;
|
|
24
25
|
discountCode?: string;
|
|
25
26
|
setDiscountCode?: (code: string) => void;
|
|
26
27
|
enabledCustomText?: boolean;
|
|
27
28
|
}
|
|
28
|
-
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),o=require("../template-preview/models/Channels.js"),s=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),o=require("../template-preview/models/Channels.js"),s=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),r=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:g,templateVariables:h,onTemplateSelect:b,globalPlaceholders:v,showOnlyContent:C,whatsappSpecificPickerMeta:S,zIndex:T,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:E,onBackPress:P,enabledCustomText:L,variableListForImage:f}=d;var w,q;t.useEffect((()=>{I(g)}),[g]);const[y,A]=t.useState(m===o.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[N,I]=t.useState(g),[k,D]=t.useState(!1),[V,_]=t.useState(c),[H,O]=t.useState(null!=h?h:[]),[F,B]=t.useState(!1);const Y=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(v)),[v]);return e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:V,setTemplate:_,device:y,setDevice:A,display_content:N,setDisplayContent:I,originalVariableList:H,setOriginalVariableList:O,isError:k,setIsError:D,channel:m,globalNormalizedPlaceholders:Y,templateSelectionTriggered:F,setTemplateSelectionTriggered:B,enabledCustomText:L}},{children:C?e.jsx(r.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:T,centralContainerStyles:{width:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==V?void 0:V.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(w=null==V?void 0:V.category)&&void 0!==w?w:"")} • ${null!==(q=null==V?void 0:V.templateCategory)&&void 0!==q?q:""}`:"",onBackPress:()=>{null==P||P()}},{children:[e.jsx(r.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:S,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:E,variableListForImage:f&&(null==f?void 0:f.length)>0?f:x}),b?e.jsx(i.default,{onSelect:function(){const e=null==b?void 0:b(V,H,null!=N?N:"");console.log("template",V),e?D(!!e):B(!0)}}):e.jsx(e.Fragment,{})]}))}))};
|
|
@@ -6,6 +6,7 @@ export interface BodyProps {
|
|
|
6
6
|
whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
|
|
7
7
|
showVariableModal?: boolean;
|
|
8
8
|
variableList?: VariableListInterfaceV2[];
|
|
9
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
9
10
|
discountCode?: string;
|
|
10
11
|
setDiscountCode?: (code: string) => void;
|
|
11
12
|
}
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
overflow-y: 'auto';
|
|
10
10
|
padding-bottom: 24px;
|
|
11
11
|
border-left: ${o.COLORS.stroke.primary} 1px solid;
|
|
12
|
-
`,
|
|
12
|
+
`,g=h.default.div`
|
|
13
13
|
padding: ${e=>e.showOnlyContent?"16px 14px":"16px 32px"};
|
|
14
14
|
flex: 1;
|
|
15
15
|
height: 475px;
|
|
16
16
|
overflow-y: auto;
|
|
17
|
-
`;exports.default=l=>{const{showVariableMapping:p,showOnlyContent:h,whatsappSpecificPickerMeta:
|
|
17
|
+
`;exports.default=l=>{const{showVariableMapping:p,showOnlyContent:h,whatsappSpecificPickerMeta:x,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w,variableListForImage:C}=l,E=t.useRef(),y=t.useRef(),{device:L,display_content:P,channel:T,template:M,setTemplate:_}=i.useTemplateModalContext();const A=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(m,{children:[e.jsx(g,Object.assign({showOnlyContent:h,showVariableMapping:p},{children:"mobile"===L?e.jsx(u.default,{ref:y,display_content:null!=P?P:"",channel:T,template:M}):T!==n.CHANNEL_TYPE.MESSAGE?e.jsx(s.default,{ref:E,channel:T,display_content:null!=P?P:""}):e.jsx(e.Fragment,{})})),p&&e.jsx(f,Object.assign({channel:T},{children:T!==n.CHANNEL_TYPE.WHATSAPP?e.jsx(c.default,{onFocus:T===n.CHANNEL_TYPE.EMAIL?function(e){var t,l,i;const s=null===document||void 0===document?void 0:document.getElementById("mobile"===L?"template_html_mobile":"template_html_desktop"),d=a.getVariableNameForEmailByIndex(e+1),u=T===n.CHANNEL_TYPE.EMAIL?null===(t=null==s?void 0:s.contentWindow)||void 0===t?void 0:t.document.getElementById(d):document.getElementById(d),c=A(u),p=null==u?void 0:u.offsetLeft;"desktop"===L?c&&E.current&&(null===(l=null==s?void 0:s.contentWindow)||void 0===l||l.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,L)):c&&y.current&&(null===(i=null==s?void 0:s.contentWindow)||void 0===i||i.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,L))}:void 0,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w}):e.jsx(d.default,{whatsappSpecificPickerMeta:x,template:M,onTemplateChange:e=>{null==_||_(e)},showVariableModal:v,variableList:b,variableListForImage:C})}))]})};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VariableListInterfaceV2 } from "../../add-variableV2";
|
|
3
|
+
import { HEADER_TYPES } from "../../template-preview";
|
|
4
|
+
declare const EditMediaModal: React.FC<{
|
|
5
|
+
setOpenEditMedia: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
|
+
openEditMedia: boolean;
|
|
7
|
+
mediaComponentFormat: HEADER_TYPES;
|
|
8
|
+
variableListForImage: VariableListInterfaceV2[];
|
|
9
|
+
uploadMedia: (urlOrVariable: string) => void;
|
|
10
|
+
}>;
|
|
11
|
+
export default EditMediaModal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../button/Button.js"),s=require("../../input-with-vars/InputWithVariables.js"),a=require("../../modals/styledModal.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js");var i=require("../../../constants/Theme.js"),r=require("../../template-preview/models/TemplateMeta.js"),l=require("../../TypographyStyle.js"),d=require("../../../assets/icons/file.svg.js"),o=require("../../../assets/icons/filePdf.svg.js"),n=require("../../../assets/icons/image.svg.js"),u=require("../../../assets/icons/upload.svg.js");exports.default=c=>{let{setOpenEditMedia:p,mediaComponentFormat:h,variableListForImage:j,openEditMedia:g,uploadMedia:x}=c;return e.jsx(a.StyledModal,Object.assign({open:g,zIndex:2e3,onClose:()=>p(!1),width:"440px"},{children:e.jsxs("div",Object.assign({style:{padding:24,borderRadius:4}},{children:[e.jsx(l.TitleMedium,Object.assign({style:{marginBottom:16}},{children:"Update media"})),e.jsxs("div",Object.assign({style:{padding:24,border:`1px dashed ${i.DEFAULT_THEME.colorsV2.stroke.primary}`,backgroundColor:i.DEFAULT_THEME.colorsV2.surface.subdued}},{children:[e.jsxs("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",gap:16}},{children:[e.jsx("div",Object.assign({style:{height:80,width:80,borderRadius:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:i.DEFAULT_THEME.colorsV2.background.base}},{children:h===r.HEADER_TYPES.IMAGE?e.jsx(n.default,{width:40,height:40}):h===r.HEADER_TYPES.VIDEO?e.jsx(d.default,{width:40,height:40}):e.jsx(o.default,{width:40,height:40})})),e.jsx(l.TitleMedium,{children:h===r.HEADER_TYPES.IMAGE?"Upload an image":h===r.HEADER_TYPES.VIDEO?"Upload a video":"Upload a document"}),e.jsx(l.BodySecondary,{children:h===r.HEADER_TYPES.IMAGE?"JPEG/ PNG format • Max 5MB":h===r.HEADER_TYPES.VIDEO?"Mp4 format video • Max 100MB":"Pdf format a document • Max 16MB"})]})),e.jsxs("div",Object.assign({style:{marginBottom:16}},{children:[e.jsx(l.BodyRegular,{children:"Media"}),e.jsx(s.InputWithVariables,{addVarBoxRight:"46px",allowMix:!1,onChange:e=>{},prevVariable:{actualValue:"",variableType:"string"},variablesList:j,showSideVariablePanel:!0,placeHolder:"Enter url or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&x(t.actualValue)},showAddButton:h===r.HEADER_TYPES.IMAGE})]})),e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4}},{children:[e.jsx("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}}),e.jsx(l.BodyCaption,Object.assign({style:{flex:1}},{children:"Or upload image from device"})),e.jsx("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}})]})),e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(t.Button,{matchParentWidth:!0,buttonText:"Upload",buttonType:"secondary",LeadingIcon:u.default})}))]}))]}))}))};
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ declare const EditMediaTemplateMediaV2: React.FC<{
|
|
|
6
6
|
template: WhatsAppTemplate;
|
|
7
7
|
whatsappSpecificPickerMeta: WhatsAppPickerMeta;
|
|
8
8
|
updateTemplateImageUrl(url: string, format: WhatsAppTemplate['components'][0]['format']): void;
|
|
9
|
-
|
|
9
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
10
10
|
}>;
|
|
11
11
|
export default EditMediaTemplateMediaV2;
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),a=require("../../helpers/FileUploaderHelper.js"),n=require("../../image-cropper/BikImageCropper.js");require("../../image-compress/ImageCompress.js"),require("../../states/StateComponent.js"),require("../../../constants/zindex.js"),require("../../modals/styledModal.js"),require("../../spinner/Spinner.js");var o=require("../../template-preview/models/TemplateMeta.js"),r=require("../context/templateModalContext.js"),l=require("./EditMediaModal.js"),s=require("./EditMediaV2.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(i);exports.default=d=>{let{mediaComponent:p,template:u,updateTemplateImageUrl:m,whatsappSpecificPickerMeta:f,variableListForImage:v}=d;var E,g,j;const[h,M]=i.useState(void 0),[_,b]=i.useState(),[y,A]=i.useState(),[S,x]=i.useState(!1),C=c.default.createRef(),[I,T]=i.useState(!1),[q,R]=i.useState(""),{template:O,setTemplate:w}=r.useTemplateModalContext();let D;function H(){var e;(null===(e=null==C?void 0:C.current)||void 0===e?void 0:e.click)&&C.current.click()}function k(t){var i;return e.__awaiter(this,void 0,void 0,(function*(){const e=new a.FileUploaderHelper;if(t instanceof Blob){const a=e.validate(t);if(a)R(a),x(!1),T(!1);else{const e=p.format===o.HEADER_TYPES.IMAGE,a=yield f.uploadMediaFiles({file:t,fileName:h,isImage:e});if(a.success){const[e]=t.type.split("/");m(null!==(i=a.url)&&void 0!==i?i:"","application"===e?o.HEADER_TYPES.DOCUMENT:o.HEADER_TYPES[e.toUpperCase()])}else R("An unknown technical error occured");T(!1),x(!1)}}else R("An unknown technical error occured"),x(!1),T(!1)}))}return D=p.format===o.HEADER_TYPES.IMAGE?"image/png, image/jpeg":p.format===o.HEADER_TYPES.VIDEO?"video/mp4":"application/pdf",t.jsxs(t.Fragment,{children:[t.jsx(l.default,{mediaComponentFormat:null!==(E=p.format)&&void 0!==E?E:o.HEADER_TYPES.IMAGE,uploadMedia:function(t){var i;return e.__awaiter(this,void 0,void 0,(function*(){if(R(""),t)if(t.startsWith("https"))try{T(!0);const e=yield fetch(t),i=yield e.blob();yield k(i)}catch(e){R("An unknown technical error occurred")}else if(/^{{.*}}$/.test(t)){A(t);const e=Object.assign({},O);if(e.components){const t=null===(i=null==e?void 0:e.components)||void 0===i?void 0:i.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==t&&t>-1&&(null==e?void 0:e.components[t])){const i=Object.assign(Object.assign({},e.components[t]),{format:p.format,example:{header_handle:["https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"]}}),a=[...e.components];a[t]=i,e.components=a}}e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]})),null==w||w(Object.assign({},e)),x(!1),T(!1)}else T(!1),R("Invalid URL or variable");else H()}))},variableListForImage:v||[],setOpenEditMedia:x,openEditMedia:S}),!!_&&t.jsx(n.BikImageCropper,{aspectRatio:15/8,src:_,onCropComplete:function(t){return e.__awaiter(this,void 0,void 0,(function*(){T(!1),R("");const e=yield fetch(t);k(yield e.blob()).then((()=>{b(void 0)}))}))},onCancel:()=>{T(!1),b("")}}),t.jsx("input",{ref:C,style:{display:"none"},type:"file",onChange:function(e){var t;R(""),T(!0);const i=null===(t=e.target.files)||void 0===t?void 0:t[0];if(p.format===o.HEADER_TYPES.IMAGE){const e=new FileReader;b(""),M(""),e.onload=()=>{b(e.result),M(null==i?void 0:i.name)},i&&e.readAsDataURL(i)}else k(i)},accept:D}),t.jsx(s.default,{imageName:null!==(j=null===(g=null==p?void 0:p.example)||void 0===g?void 0:g.header_handle)&&void 0!==j?j:[],handleImageChange:H,mediaType:null==p?void 0:p.format,error:q,isLoading:I,setOpenEditMedia:x,selectedVariable:y})]})};
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface EditWhatsAppTemplateV2Props {
|
|
|
8
8
|
onTemplateChange?: (template: WhatsAppTemplate | EmailTemplateType | SMSTemplateType) => void;
|
|
9
9
|
showVariableModal?: boolean;
|
|
10
10
|
variableList?: VariableListInterfaceV2[];
|
|
11
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
11
12
|
}
|
|
12
|
-
declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, variableListForImage, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export default EditWhatsAppTemplateV2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../context/templateModalContext.js"),o=require("../utils/getDataFromTemplateComponent.js"),n=require("./EditMediaV2.style.js"),i=require("./EditWhatsAppTemplateMediaV2.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../context/templateModalContext.js"),o=require("../utils/getDataFromTemplateComponent.js"),n=require("./EditMediaV2.style.js"),i=require("./EditWhatsAppTemplateMediaV2.js"),a=require("./VariableConnectorsPanel.js"),l=require("./VariableConnectorWhatsApp.js"),s=require("./VariableEditorHeader.js"),d=require("./WhatsAppTemplateCardButtonV2.js");exports.default=r=>{let{template:p,onTemplateChange:u,whatsappSpecificPickerMeta:c,showVariableModal:m,variableList:b,variableListForImage:v}=r;var g,h,f,j,x,T,O,y,C,E,V,w;const{originalVariableList:I}=t.useTemplateModalContext(),{descriptionComponents:L,urlBtns:B,qrbBtns:M,imageComponent:q,bodyVariables:R,headerVariables:A}=o.getAllDataFromTemplateComponent(p);function U(e,t){var o,n,i,a;const l=Object.assign({},p),s=null==l?void 0:l.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==s&&s>-1){const d=null===(o=null==l?void 0:l.components[s].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==d&&d>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(i=null===(n=l.components)||void 0===n?void 0:n[s])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];r[d]=Object.assign(Object.assign({},r[d]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const p=Object.assign(Object.assign({},l.components[s]),{buttons:r}),u=Object.assign(Object.assign({},l.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});l.mapping=u;const c=[...l.components];c[s]=p,l.components=c}}null==u||u(l)}function P(e,t,o){var n;const i=Object.assign({},p),a=null==i?void 0:i.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(n=null==i?void 0:i.components[a].buttons)||void 0===n?void 0:n.filter((e=>"QUICK_REPLY"===e.type));t&&(t[o]=Object.assign(Object.assign({},t[o]),{flowId:e.flowId,flowName:e.flowName}));const l=Object.assign(Object.assign({},i.components[a]),{buttons:t}),s=[...i.components];s[a]=l,i.components=s}null==u||u(i)}return e.jsxs(a.Container,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!q&&e.jsx(n.EditTemplateMediaContainer,{children:e.jsx(i.default,{whatsappSpecificPickerMeta:c,mediaComponent:q,updateTemplateImageUrl:function(e,t){var o;let n=Object.assign({},p);const i=null===(o=null==n?void 0:n.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const o=Object.assign(Object.assign({},n.components[i]),{format:t,example:{header_handle:[e]}}),a=[...n.components];a[i]=o,n=Object.assign(Object.assign({},n),{components:a})}null==u||u(n)},template:p,variableListForImage:v})}),(R.length>0||A.length>0)&&e.jsx(s.default,{containerStyle:{paddingTop:q?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null==L?void 0:L.map(((t,o)=>e.jsx(l.default,{originalVariableList:I,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?p.mapping.header:p.mapping.body,showVariableModal:m,variableList:b},o))),(null===(h=null===(g=B[0])||void 0===g?void 0:g.component)||void 0===h?void 0:h.buttons)&&(null===(x=null===(j=null===(f=B[0])||void 0===f?void 0:f.component)||void 0===j?void 0:j.buttons)||void 0===x?void 0:x.length)>0&&e.jsx(s.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(T=null==I?void 0:I.buttons)||void 0===T?void 0:T.map(((t,o)=>{if("URL"===t.type)return e.jsx(d.default,{CTAoptions:null==c?void 0:c.CTAoptions,button:t,originalVariableList:I,updateSelectedURLTemplateBtn:U},`${o}`)})),(null===(y=null===(O=M[0])||void 0===O?void 0:O.component)||void 0===y?void 0:y.buttons)&&(null===(V=null===(E=null===(C=M[0])||void 0===C?void 0:C.component)||void 0===E?void 0:E.buttons)||void 0===V?void 0:V.length)>0&&e.jsx(s.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}),null===(w=null==I?void 0:I.buttons)||void 0===w?void 0:w.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(d.default,{QRBoptions:null==c?void 0:c.QRBoptions,button:t,originalVariableList:I,updateSelectedQRBTemplateBtn:P},`${o}`)}))]}))};
|
package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export interface TemplateSelectModalContentProps {
|
|
|
9
9
|
whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
|
|
10
10
|
showVariableModal?: boolean;
|
|
11
11
|
variableList?: VariableListInterfaceV2[];
|
|
12
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
12
13
|
discountCode?: string;
|
|
13
14
|
setDiscountCode?: (code: string) => void;
|
|
14
15
|
}
|
|
15
|
-
declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, variableListForImage, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export default TemplateSelectModalContent;
|
package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../template-preview/models/Channels.js"),t=require("./Body.js"),i=require("./Header.js");exports.default=s=>{let{channel:r,showVariableMapping:o,showOnlyContent:l,whatsappSpecificPickerMeta:n,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u,variableListForImage:h}=s;return e.jsx("div",Object.assign({style:{paddingBottom:0}},{children:e.jsxs("div",{children:[r===a.CHANNEL_TYPE.EMAIL&&e.jsx(i.default,{showOnlyContent:l}),e.jsx(t.default,{whatsappSpecificPickerMeta:n,showVariableMapping:!!o,showOnlyContent:l,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u,variableListForImage:h})]})}))};
|
package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../dropdown/Dropdown.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../dropdown/Dropdown.js"),s=require("../../input/Input.js"),a=require("../../template-preview/constants/regexPatterns.js"),n=require("../../template-preview/models/TemplateMeta.js"),i=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),o=require("../../../constants/Theme.js"),u=require("../context/templateModalContext.js"),c=require("../utils/validateIsUrl.js"),d=require("./VariableConnector.js");exports.default=p=>{let{button:b,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:m,originalVariableList:g,CTAoptions:x,QRBoptions:v}=p;const[y,O]=t.useState(""),[f,h]=t.useState(),{setOriginalVariableList:R,isError:U}=u.useTemplateModalContext();function L(e){O(e);const t=[Object.assign(Object.assign({},g.buttons[0]),{type:i.BUTTON_TYPE.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==R||R((e=>Object.assign(Object.assign({},e),{body:[...g.body],buttons:[...t]}))),null==j||j(`https://${e}`,"custom")}return t.useEffect((()=>{var e;if(b.buttonVariable&&a.editableVarPattern.test(b.buttonVariable))h(n.CUSTOM_URL_NAME),O((null===(e=b.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===b.type?x:v;e="URL"===b.type?t.findIndex((e=>e.placeHolder===b.buttonVariable)):t.findIndex((e=>e.label===b.flowName)),e>-1&&h(t[e])}}),[]),e.jsxs(d.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:o.COLORS.content.primary}},{children:[b.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(l.Dropdown,{options:"URL"===b.type?x:v,isSearchable:!1,onSelect:function(e,t){const l=e;h(l);const s=("URL"===b.type?x:v).find((e=>e.placeHolder===l.placeHolder));if(s)if("custom_link"!==s.value){let e;"URL"===b.type?(e=[Object.assign(Object.assign({},g.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==j||j({defaultValue:s.value,placeHolder:s.placeHolder},"placeholder")):(e=g.buttons.map(((e,t)=>t===b.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==m||m({flowName:l.label,flowId:l.value},"placeholder",b.index)),null==R||R((t=>Object.assign(Object.assign({},t),{body:[...g.body],buttons:[...e]})))}else L("")},defaultOptions:f?[Object.assign(Object.assign({},f),{selected:!0})]:[]})})),"custom_link"===(null==f?void 0:f.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(s.Input,{errorMessage:U?y?c.validateIsUrl(y)?"":"Enter valid URL":"Required field":"",value:y,prefixText:"custom_link"===(null==f?void 0:f.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:L})}))]})};
|
|
@@ -20,9 +20,10 @@ export interface TemplateContextMapperProps {
|
|
|
20
20
|
zIndex?: number;
|
|
21
21
|
showVariableModal?: boolean;
|
|
22
22
|
variableList?: VariableListInterfaceV2[];
|
|
23
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
23
24
|
onBackPress?: () => void;
|
|
24
25
|
discountCode?: string;
|
|
25
26
|
setDiscountCode?: (code: string) => void;
|
|
26
27
|
enabledCustomText?: boolean;
|
|
27
28
|
}
|
|
28
|
-
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import n from"../../utils/StringUtils.js";import{StyledModal as r}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as c}from"./context/templateModalContext.js";import d from"./modalElements/Footer.js";import m from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const u=u=>{let{selectedTemplate:
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import n from"../../utils/StringUtils.js";import{StyledModal as r}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as c}from"./context/templateModalContext.js";import d from"./modalElements/Footer.js";import m from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const u=u=>{let{selectedTemplate:g,closeDialog:h,showVariableMapping:b,channel:v,htmlContent:C,templateVariables:f,onTemplateSelect:M,globalPlaceholders:S,showOnlyContent:T,whatsappSpecificPickerMeta:j,zIndex:w,showVariableModal:L,variableList:P,discountCode:x,setDiscountCode:I,onBackPress:y,enabledCustomText:E,variableListForImage:V}=u;var k,D;o((()=>{z(C)}),[C]);const[A,O]=a(v===s.EMAIL?"desktop":"mobile"),[F,z]=a(C),[B,H]=a(!1),[$,N]=a(g),[U,W]=a(null!=f?f:[]),[_,q]=a(!1);const G=i((()=>p(S)),[S]);return e(c.Provider,Object.assign({value:{template:$,setTemplate:N,device:A,setDevice:O,display_content:F,setDisplayContent:z,originalVariableList:U,setOriginalVariableList:W,isError:B,setIsError:H,channel:v,globalNormalizedPlaceholders:G,templateSelectionTriggered:_,setTemplateSelectionTriggered:q,enabledCustomText:E}},{children:T?e(m,{channel:s.EMAIL,hideHeader:!0}):t(r,Object.assign({zIndex:w,centralContainerStyles:{width:v===s.EMAIL&&b?1e3:650},open:!0,onClose:()=>{null==h||h()},headingTitle:null==$?void 0:$.label,headingSubtitle:v===s.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(k=null==$?void 0:$.category)&&void 0!==k?k:"")} • ${null!==(D=null==$?void 0:$.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==y||y()}},{children:[e(m,{showVariableMapping:b,channel:v,whatsappSpecificPickerMeta:j,showVariableModal:L,variableList:P,discountCode:x,setDiscountCode:I,variableListForImage:V&&(null==V?void 0:V.length)>0?V:P}),M?e(d,{onSelect:function(){const e=null==M?void 0:M($,U,null!=F?F:"");console.log("template",$),e?H(!!e):q(!0)}}):e(l,{})]}))}))};export{u as TemplateContextMapper};
|
|
@@ -6,6 +6,7 @@ export interface BodyProps {
|
|
|
6
6
|
whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
|
|
7
7
|
showVariableModal?: boolean;
|
|
8
8
|
variableList?: VariableListInterfaceV2[];
|
|
9
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
9
10
|
discountCode?: string;
|
|
10
11
|
setDiscountCode?: (code: string) => void;
|
|
11
12
|
}
|
|
@@ -14,4 +14,4 @@ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useRef as
|
|
|
14
14
|
flex: 1;
|
|
15
15
|
height: 475px;
|
|
16
16
|
overflow-y: auto;
|
|
17
|
-
`,g=l=>{const{showVariableMapping:g,showOnlyContent:
|
|
17
|
+
`,g=l=>{const{showVariableMapping:g,showOnlyContent:b,whatsappSpecificPickerMeta:w,showVariableModal:x,variableList:y,discountCode:j,setDiscountCode:M,variableListForImage:C}=l,P=n(),E=n(),{device:T,display_content:k,channel:A,template:L,setTemplate:V}=r();const I=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e(u,{children:[t(v,Object.assign({showOnlyContent:b,showVariableMapping:g},{children:"mobile"===T?t(c,{ref:E,display_content:null!=k?k:"",channel:A,template:L}):A!==i.MESSAGE?t(d,{ref:P,channel:A,display_content:null!=k?k:""}):t(o,{})})),g&&t(f,Object.assign({channel:A},{children:A!==i.WHATSAPP?t(h,{onFocus:A===i.EMAIL?function(e){var t,o,n;const l=null===document||void 0===document?void 0:document.getElementById("mobile"===T?"template_html_mobile":"template_html_desktop"),r=s(e+1),d=A===i.EMAIL?null===(t=null==l?void 0:l.contentWindow)||void 0===t?void 0:t.document.getElementById(r):document.getElementById(r),m=I(d),c=null==d?void 0:d.offsetLeft;"desktop"===T?m&&P.current&&(null===(o=null==l?void 0:l.contentWindow)||void 0===o||o.scrollTo(null!=c?c:0,m),p(r,a.background.warning.light,2,A,T)):m&&E.current&&(null===(n=null==l?void 0:l.contentWindow)||void 0===n||n.scrollTo(null!=c?c:0,m),p(r,a.background.warning.light,2,A,T))}:void 0,showVariableModal:x,variableList:y,discountCode:j,setDiscountCode:M}):t(m,{whatsappSpecificPickerMeta:w,template:L,onTemplateChange:e=>{null==V||V(e)},showVariableModal:x,variableList:y,variableListForImage:C})}))]})};export{g as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VariableListInterfaceV2 } from "../../add-variableV2";
|
|
3
|
+
import { HEADER_TYPES } from "../../template-preview";
|
|
4
|
+
declare const EditMediaModal: React.FC<{
|
|
5
|
+
setOpenEditMedia: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
|
+
openEditMedia: boolean;
|
|
7
|
+
mediaComponentFormat: HEADER_TYPES;
|
|
8
|
+
variableListForImage: VariableListInterfaceV2[];
|
|
9
|
+
uploadMedia: (urlOrVariable: string) => void;
|
|
10
|
+
}>;
|
|
11
|
+
export default EditMediaModal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Button as a}from"../../button/Button.js";import{InputWithVariables as i}from"../../input-with-vars/InputWithVariables.js";import{StyledModal as r}from"../../modals/styledModal.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{DEFAULT_THEME as o}from"../../../constants/Theme.js";import{HEADER_TYPES as s}from"../../template-preview/models/TemplateMeta.js";import{TitleMedium as l,BodySecondary as d,BodyRegular as n,BodyCaption as p}from"../../TypographyStyle.js";import m from"../../../assets/icons/file.svg.js";import c from"../../../assets/icons/filePdf.svg.js";import h from"../../../assets/icons/image.svg.js";import g from"../../../assets/icons/upload.svg.js";const u=u=>{let{setOpenEditMedia:b,mediaComponentFormat:f,variableListForImage:j,openEditMedia:v,uploadMedia:y}=u;return e(r,Object.assign({open:v,zIndex:2e3,onClose:()=>b(!1),width:"440px"},{children:t("div",Object.assign({style:{padding:24,borderRadius:4}},{children:[e(l,Object.assign({style:{marginBottom:16}},{children:"Update media"})),t("div",Object.assign({style:{padding:24,border:`1px dashed ${o.colorsV2.stroke.primary}`,backgroundColor:o.colorsV2.surface.subdued}},{children:[t("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",gap:16}},{children:[e("div",Object.assign({style:{height:80,width:80,borderRadius:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:o.colorsV2.background.base}},{children:f===s.IMAGE?e(h,{width:40,height:40}):f===s.VIDEO?e(m,{width:40,height:40}):e(c,{width:40,height:40})})),e(l,{children:f===s.IMAGE?"Upload an image":f===s.VIDEO?"Upload a video":"Upload a document"}),e(d,{children:f===s.IMAGE?"JPEG/ PNG format • Max 5MB":f===s.VIDEO?"Mp4 format video • Max 100MB":"Pdf format a document • Max 16MB"})]})),t("div",Object.assign({style:{marginBottom:16}},{children:[e(n,{children:"Media"}),e(i,{addVarBoxRight:"46px",allowMix:!1,onChange:e=>{},prevVariable:{actualValue:"",variableType:"string"},variablesList:j,showSideVariablePanel:!0,placeHolder:"Enter url or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&y(t.actualValue)},showAddButton:f===s.IMAGE})]})),t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4}},{children:[e("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}}),e(p,Object.assign({style:{flex:1}},{children:"Or upload image from device"})),e("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}})]})),e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(a,{matchParentWidth:!0,buttonText:"Upload",buttonType:"secondary",LeadingIcon:g})}))]}))]}))}))};export{u as default};
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ declare const EditMediaTemplateMediaV2: React.FC<{
|
|
|
6
6
|
template: WhatsAppTemplate;
|
|
7
7
|
whatsappSpecificPickerMeta: WhatsAppPickerMeta;
|
|
8
8
|
updateTemplateImageUrl(url: string, format: WhatsAppTemplate['components'][0]['format']): void;
|
|
9
|
-
|
|
9
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
10
10
|
}>;
|
|
11
11
|
export default EditMediaTemplateMediaV2;
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,Fragment as o,jsx as i}from"react/jsx-runtime";import n,{useState as a}from"react";import{FileUploaderHelper as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,Fragment as o,jsx as i}from"react/jsx-runtime";import n,{useState as a}from"react";import{FileUploaderHelper as r}from"../../helpers/FileUploaderHelper.js";import{BikImageCropper as l}from"../../image-cropper/BikImageCropper.js";import"../../image-compress/ImageCompress.js";import"../../states/StateComponent.js";import"../../../constants/zindex.js";import"../../modals/styledModal.js";import"../../spinner/Spinner.js";import{HEADER_TYPES as s}from"../../template-preview/models/TemplateMeta.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import d from"./EditMediaModal.js";import m from"./EditMediaV2.js";const c=c=>{let{mediaComponent:f,template:u,updateTemplateImageUrl:v,whatsappSpecificPickerMeta:g,variableListForImage:h}=c;var j,M,b;const[E,y]=a(void 0),[I,C]=a(),[O,A]=a(),[k,w]=a(!1),x=n.createRef(),[T,F]=a(!1),[R,U]=a(""),{template:L,setTemplate:N}=p();let D;function G(){var e;(null===(e=null==x?void 0:x.current)||void 0===e?void 0:e.click)&&x.current.click()}function _(t){var o;return e(this,void 0,void 0,(function*(){const e=new r;if(t instanceof Blob){const i=e.validate(t);if(i)U(i),w(!1),F(!1);else{const e=f.format===s.IMAGE,i=yield g.uploadMediaFiles({file:t,fileName:E,isImage:e});if(i.success){const[e]=t.type.split("/");v(null!==(o=i.url)&&void 0!==o?o:"","application"===e?s.DOCUMENT:s[e.toUpperCase()])}else U("An unknown technical error occured");F(!1),w(!1)}}else U("An unknown technical error occured"),w(!1),F(!1)}))}return D=f.format===s.IMAGE?"image/png, image/jpeg":f.format===s.VIDEO?"video/mp4":"application/pdf",t(o,{children:[i(d,{mediaComponentFormat:null!==(j=f.format)&&void 0!==j?j:s.IMAGE,uploadMedia:function(t){var o;return e(this,void 0,void 0,(function*(){if(U(""),t)if(t.startsWith("https"))try{F(!0);const e=yield fetch(t),o=yield e.blob();yield _(o)}catch(e){U("An unknown technical error occurred")}else if(/^{{.*}}$/.test(t)){A(t);const e=Object.assign({},L);if(e.components){const t=null===(o=null==e?void 0:e.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==t&&t>-1&&(null==e?void 0:e.components[t])){const o=Object.assign(Object.assign({},e.components[t]),{format:f.format,example:{header_handle:["https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"]}}),i=[...e.components];i[t]=o,e.components=i}}e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]})),null==N||N(Object.assign({},e)),w(!1),F(!1)}else F(!1),U("Invalid URL or variable");else G()}))},variableListForImage:h||[],setOpenEditMedia:w,openEditMedia:k}),!!I&&i(l,{aspectRatio:15/8,src:I,onCropComplete:function(t){return e(this,void 0,void 0,(function*(){F(!1),U("");const e=yield fetch(t);_(yield e.blob()).then((()=>{C(void 0)}))}))},onCancel:()=>{F(!1),C("")}}),i("input",{ref:x,style:{display:"none"},type:"file",onChange:function(e){var t;U(""),F(!0);const o=null===(t=e.target.files)||void 0===t?void 0:t[0];if(f.format===s.IMAGE){const e=new FileReader;C(""),y(""),e.onload=()=>{C(e.result),y(null==o?void 0:o.name)},o&&e.readAsDataURL(o)}else _(o)},accept:D}),i(m,{imageName:null!==(b=null===(M=null==f?void 0:f.example)||void 0===M?void 0:M.header_handle)&&void 0!==b?b:[],handleImageChange:G,mediaType:null==f?void 0:f.format,error:R,isLoading:T,setOpenEditMedia:w,selectedVariable:O})]})};export{c as default};
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface EditWhatsAppTemplateV2Props {
|
|
|
8
8
|
onTemplateChange?: (template: WhatsAppTemplate | EmailTemplateType | SMSTemplateType) => void;
|
|
9
9
|
showVariableModal?: boolean;
|
|
10
10
|
variableList?: VariableListInterfaceV2[];
|
|
11
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
11
12
|
}
|
|
12
|
-
declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, variableListForImage, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export default EditWhatsAppTemplateV2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useTemplateModalContext as e}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as n}from"../utils/getDataFromTemplateComponent.js";import{EditTemplateMediaContainer as i}from"./EditMediaV2.style.js";import
|
|
1
|
+
import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useTemplateModalContext as e}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as n}from"../utils/getDataFromTemplateComponent.js";import{EditTemplateMediaContainer as i}from"./EditMediaV2.style.js";import a from"./EditWhatsAppTemplateMediaV2.js";import{Container as l}from"./VariableConnectorsPanel.js";import s from"./VariableConnectorWhatsApp.js";import d from"./VariableEditorHeader.js";import p from"./WhatsAppTemplateCardButtonV2.js";const r=r=>{let{template:c,onTemplateChange:u,whatsappSpecificPickerMeta:m,showVariableModal:b,variableList:v,variableListForImage:g}=r;var h,f,j,T,O,x,y,E,V,C,w,I;const{originalVariableList:L}=e(),{descriptionComponents:B,urlBtns:R,qrbBtns:A,imageComponent:M,bodyVariables:U,headerVariables:S}=n(c);function k(t,o){var e,n,i,a;const l=Object.assign({},c),s=null==l?void 0:l.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==s&&s>-1){const d=null===(e=null==l?void 0:l.components[s].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==d&&d>-1){const e="custom"===o&&"string"==typeof t,p=[...null!==(a=null===(i=null===(n=l.components)||void 0===n?void 0:n[s])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];p[d]=Object.assign(Object.assign({},p[d]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const r=Object.assign(Object.assign({},l.components[s]),{buttons:p}),c=Object.assign(Object.assign({},l.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});l.mapping=c;const u=[...l.components];u[s]=r,l.components=u}}null==u||u(l)}function N(t,o,e){var n;const i=Object.assign({},c),a=null==i?void 0:i.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==a&&a>-1){const o=null===(n=null==i?void 0:i.components[a].buttons)||void 0===n?void 0:n.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const l=Object.assign(Object.assign({},i.components[a]),{buttons:o}),s=[...i.components];s[a]=l,i.components=s}null==u||u(i)}return t(l,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!M&&o(i,{children:o(a,{whatsappSpecificPickerMeta:m,mediaComponent:M,updateTemplateImageUrl:function(t,o){var e;let n=Object.assign({},c);const i=null===(e=null==n?void 0:n.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const e=Object.assign(Object.assign({},n.components[i]),{format:o,example:{header_handle:[t]}}),a=[...n.components];a[i]=e,n=Object.assign(Object.assign({},n),{components:a})}null==u||u(n)},template:c,variableListForImage:g})}),(U.length>0||S.length>0)&&o(d,{containerStyle:{paddingTop:M?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null==B?void 0:B.map(((t,e)=>o(s,{originalVariableList:L,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?c.mapping.header:c.mapping.body,showVariableModal:b,variableList:v},e))),(null===(f=null===(h=R[0])||void 0===h?void 0:h.component)||void 0===f?void 0:f.buttons)&&(null===(O=null===(T=null===(j=R[0])||void 0===j?void 0:j.component)||void 0===T?void 0:T.buttons)||void 0===O?void 0:O.length)>0&&o(d,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(x=null==L?void 0:L.buttons)||void 0===x?void 0:x.map(((t,e)=>{if("URL"===t.type)return o(p,{CTAoptions:null==m?void 0:m.CTAoptions,button:t,originalVariableList:L,updateSelectedURLTemplateBtn:k},`${e}`)})),(null===(E=null===(y=A[0])||void 0===y?void 0:y.component)||void 0===E?void 0:E.buttons)&&(null===(w=null===(C=null===(V=A[0])||void 0===V?void 0:V.component)||void 0===C?void 0:C.buttons)||void 0===w?void 0:w.length)>0&&o(d,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}),null===(I=null==L?void 0:L.buttons)||void 0===I?void 0:I.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(p,{QRBoptions:null==m?void 0:m.QRBoptions,button:t,originalVariableList:L,updateSelectedQRBTemplateBtn:N},`${e}`)}))]}))};export{r as default};
|
package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export interface TemplateSelectModalContentProps {
|
|
|
9
9
|
whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
|
|
10
10
|
showVariableModal?: boolean;
|
|
11
11
|
variableList?: VariableListInterfaceV2[];
|
|
12
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
12
13
|
discountCode?: string;
|
|
13
14
|
setDiscountCode?: (code: string) => void;
|
|
14
15
|
}
|
|
15
|
-
declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, variableListForImage, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export default TemplateSelectModalContent;
|
package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{CHANNEL_TYPE as t}from"../../template-preview/models/Channels.js";import i from"./Body.js";import o from"./Header.js";const s=s=>{let{channel:r,showVariableMapping:n,showOnlyContent:l,whatsappSpecificPickerMeta:d,showVariableModal:p,variableList:c,discountCode:m,setDiscountCode:h,variableListForImage:w}=s;return e("div",Object.assign({style:{paddingBottom:0}},{children:a("div",{children:[r===t.EMAIL&&e(o,{showOnlyContent:l}),e(i,{whatsappSpecificPickerMeta:d,showVariableMapping:!!n,showOnlyContent:l,showVariableModal:p,variableList:c,discountCode:m,setDiscountCode:h,variableListForImage:w})]})}))};export{s as default};
|
package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as o}from"react";import{Dropdown as a}from"../../dropdown/Dropdown.js";import{Input as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as o}from"react";import{Dropdown as a}from"../../dropdown/Dropdown.js";import{Input as s}from"../../input/Input.js";import{editableVarPattern as n}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as i}from"../../template-preview/models/TemplateMeta.js";import{BUTTON_TYPE as r}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as p}from"../../TypographyStyle.js";import{COLORS as c}from"../../../constants/Theme.js";import{useTemplateModalContext as m}from"../context/templateModalContext.js";import{validateIsUrl as d}from"../utils/validateIsUrl.js";import{Container as u}from"./VariableConnector.js";const b=b=>{let{button:f,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:g,originalVariableList:h,CTAoptions:v,QRBoptions:y}=b;const[O,x]=l(""),[R,L]=l(),{setOriginalVariableList:U,isError:w}=m();function T(e){x(e);const t=[Object.assign(Object.assign({},h.buttons[0]),{type:r.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==U||U((e=>Object.assign(Object.assign({},e),{body:[...h.body],buttons:[...t]}))),null==j||j(`https://${e}`,"custom")}return o((()=>{var e;if(f.buttonVariable&&n.test(f.buttonVariable))L(i),x((null===(e=f.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===f.type?v:y;e="URL"===f.type?t.findIndex((e=>e.placeHolder===f.buttonVariable)):t.findIndex((e=>e.label===f.flowName)),e>-1&&L(t[e])}}),[]),e(u,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(p,Object.assign({style:{color:c.content.primary}},{children:[f.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(a,{options:"URL"===f.type?v:y,isSearchable:!1,onSelect:function(e,t){const l=e;L(l);const o=("URL"===f.type?v:y).find((e=>e.placeHolder===l.placeHolder));if(o)if("custom_link"!==o.value){let e;"URL"===f.type?(e=[Object.assign(Object.assign({},h.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==j||j({defaultValue:o.value,placeHolder:o.placeHolder},"placeholder")):(e=h.buttons.map(((e,t)=>t===f.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==g||g({flowName:l.label,flowId:l.value},"placeholder",f.index)),null==U||U((t=>Object.assign(Object.assign({},t),{body:[...h.body],buttons:[...e]})))}else T("")},defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),"custom_link"===(null==R?void 0:R.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(s,{errorMessage:w?O?d(O)?"":"Enter valid URL":"Required field":"",value:O,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:T})}))]})};export{b as default};
|