@bikdotai/bik-component-library 0.0.611-beat.1 → 0.0.612-beta-vsp.0
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/dropdown/DropdownPopover/index.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.d.ts +2 -0
- package/dist/cjs/components/dropdown/hooks/useDropdown.d.ts +2 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/dist/cjs/components/template-preview/models/TemplateMeta.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
- package/dist/esm/components/dropdown/DropdownPopover/index.js +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.d.ts +2 -0
- package/dist/esm/components/dropdown/hooks/useDropdown.d.ts +2 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
- package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/dist/esm/components/template-preview/models/TemplateMeta.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/template-context-mapper/utils/validateName.js +0 -1
- package/dist/esm/components/template-context-mapper/utils/validateName.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),t=require("react"),n=require("react-popper"),r=require("../../dropShadow/DropShadow.js"),l=require("../../tooltips/Tooltip.js"),s=require("../Common.styled.js"),i=require("../OpenedDropdown/components/OpennedDropdown.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const d=a(t).default.forwardRef(((a,d)=>{var{children:p,onDropdownVisbilityChange:c,version:u="1.0",tooltipContent:v,tooltipDirection:j,showTooltipArrow:w}=a,b=e.__rest(a,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow"]);const h=d,[f,D]=t.useState(!1),[O,g]=t.useState(null),[x,y]=t.useState(null),m=t.useRef(null),{styles:S,attributes:C}=n.usePopper(O,x,{placement:b.placement,strategy:b.strategy}),q=e=>{var o,t;"2.0"===u&&b.isMultiSelect&&e&&(null===(o=b.onSelect)||void 0===o||o.call(b,[...e])),D(!1),null===(t=null==b?void 0:b.onClose)||void 0===t||t.call(b)};t.useImperativeHandle(h,(()=>({openDropdown:f})),[]),t.useEffect((()=>{(null==h?void 0:h.current)&&(h.current.openDropdown=f)}),[f]),t.useEffect((()=>{null==c||c(f)}),[f]);const E=()=>o.jsxs(o.Fragment,{children:[o.jsxs("div",Object.assign({style:{position:"relative"},ref:g},{children:[o.jsx(s.OverLapAbs,Object.assign({ref:m,allowEvents:b.allowEvents,disabled:b.disabled,onClick:e=>{var o;null===(o=b.onDropdownOpen)||void 0===o||o.call(b),f?(D(!1),e.preventDefault()):b.disabled||D(!0)}},{children:b.allowEvents?p:null})),b.allowEvents?null:p]})),f&&o.jsx(s.OpenDropdownContainer,Object.assign({ref:y,style:Object.assign(Object.assign({},S.popper),{zIndex:3})},C.popper,{children:o.jsx(r.DropShadow,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:o.jsx(i.OpenedDropdown,Object.assign({},b,{onSelect:e=>{var o;"2.0"===u&&b.isMultiSelect||(null===(o=b.onSelect)||void 0===o||o.call(b,e),D(!1))},onClose:q,version:u,headerRef:m}))}))}))]});return o.jsx(o.Fragment,{children:f||void 0===v?E():o.jsx(l.Tooltip,Object.assign({body:v,placement:j,hideArrow:!w},{children:o.jsx("div",Object.assign({"data-test":b["data-test"]},{children:E()}))}))})}));d.displayName="DropdownPopover",exports.DropdownPopover=d;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),t=require("react"),n=require("react-popper"),r=require("../../dropShadow/DropShadow.js"),l=require("../../tooltips/Tooltip.js"),s=require("../Common.styled.js"),i=require("../OpenedDropdown/components/OpennedDropdown.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const d=a(t).default.forwardRef(((a,d)=>{var{children:p,onDropdownVisbilityChange:c,version:u="1.0",tooltipContent:v,tooltipDirection:j,showTooltipArrow:w}=a,b=e.__rest(a,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow"]);const h=d,[f,D]=t.useState(!1),[O,g]=t.useState(null),[x,y]=t.useState(null),m=t.useRef(null),{styles:S,attributes:C}=n.usePopper(O,x,{placement:b.placement,strategy:b.strategy}),q=e=>{var o,t;"2.0"===u&&b.isMultiSelect&&e&&(null===(o=b.onSelect)||void 0===o||o.call(b,[...e])),D(!1),null===(t=null==b?void 0:b.onClose)||void 0===t||t.call(b)};t.useImperativeHandle(h,(()=>({openDropdown:f})),[]),t.useEffect((()=>{(null==h?void 0:h.current)&&(h.current.openDropdown=f)}),[f]),t.useEffect((()=>{null==c||c(f)}),[f]);const E=()=>o.jsxs(o.Fragment,{children:[o.jsxs("div",Object.assign({style:{position:"relative"},ref:g},{children:[o.jsx(s.OverLapAbs,Object.assign({ref:m,allowEvents:b.allowEvents,disabled:b.disabled,onClick:e=>{var o;null===(o=b.onDropdownOpen)||void 0===o||o.call(b),f?(D(!1),e.preventDefault()):b.disabled||D(!0)}},{children:b.allowEvents?p:null})),b.allowEvents?null:p]})),f&&o.jsx(s.OpenDropdownContainer,Object.assign({ref:y,style:Object.assign(Object.assign({},S.popper),{zIndex:3})},C.popper,{"data-test":b["data-test"]},{children:o.jsx(r.DropShadow,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:o.jsx(i.OpenedDropdown,Object.assign({},b,{onSelect:e=>{var o;"2.0"===u&&b.isMultiSelect||(null===(o=b.onSelect)||void 0===o||o.call(b,e),D(!1))},onClose:q,version:u,headerRef:m}))}))}))]});return o.jsx(o.Fragment,{children:f||void 0===v?E():o.jsx(l.Tooltip,Object.assign({body:v,placement:j,hideArrow:!w},{children:o.jsx("div",Object.assign({"data-test":b["data-test"]},{children:E()}))}))})}));d.displayName="DropdownPopover",exports.DropdownPopover=d;
|
|
@@ -15,6 +15,7 @@ export declare function iterateOnOptions(options: DropdownOption[], newVal: Part
|
|
|
15
15
|
selectedLabel?: string | undefined;
|
|
16
16
|
children?: SingleOption[] | undefined;
|
|
17
17
|
parent?: SingleOption | undefined;
|
|
18
|
+
'data-test'?: string | undefined;
|
|
18
19
|
} | {
|
|
19
20
|
label?: string | undefined;
|
|
20
21
|
value?: string | undefined;
|
|
@@ -30,6 +31,7 @@ export declare function iterateOnOptions(options: DropdownOption[], newVal: Part
|
|
|
30
31
|
selectedLabel?: string | undefined;
|
|
31
32
|
children?: SingleOption[] | undefined;
|
|
32
33
|
parent?: SingleOption | undefined;
|
|
34
|
+
'data-test'?: string | undefined;
|
|
33
35
|
options: SingleOption[];
|
|
34
36
|
})[];
|
|
35
37
|
export declare function iterateOnOptionsRaw(options: DropdownOption[], cb: (option: SingleOption) => void): void;
|
|
@@ -22,6 +22,7 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
|
|
|
22
22
|
selectedLabel?: string | undefined;
|
|
23
23
|
children?: SingleOption[] | undefined;
|
|
24
24
|
parent?: SingleOption | undefined;
|
|
25
|
+
'data-test'?: string | undefined;
|
|
25
26
|
} | {
|
|
26
27
|
label?: string | undefined;
|
|
27
28
|
value?: string | undefined;
|
|
@@ -37,6 +38,7 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
|
|
|
37
38
|
selectedLabel?: string | undefined;
|
|
38
39
|
children?: SingleOption[] | undefined;
|
|
39
40
|
parent?: SingleOption | undefined;
|
|
41
|
+
'data-test'?: string | undefined;
|
|
40
42
|
options: SingleOption[];
|
|
41
43
|
})[] | undefined;
|
|
42
44
|
selectAllHandler: (newState: SelectAllCheckboxState) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
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");require("../../curtain/CurtainHelper.js");var n=require("../../variable-picker-v3/model.js"),t=require("lodash"),o=require("react"),i=require("styled-components"),l=require("../../input/Input.js"),a=require("../../input-with-vars/InputWithVariables.js"),s=require("../../template-preview/models/TemplateMeta.js"),d=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../context/templateModalContext.js"),u=require("../utils/constants.js"),p=require("../utils/getDataFromTemplateComponent.js"),c=require("../utils/validateIsUrl.js"),v=require("./BackTrackComponent.js"),m=require("./DiscountCodeComponent.js"),b=require("./EditMediaModal.js"),g=require("./EditMediaV2.js"),h=require("./EditMediaV2.style.js"),j=require("./useEditWhtasappTemplateMedia.js"),f=require("./VariableConnector.js"),C=require("./VariableConnectorsPanel.js"),x=require("./VariableConnectorWhatsApp.js"),O=require("./VariableEditorHeader.js"),T=require("./WhatsAppTemplateCardButtonV2.js");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const E=y(i).default.div`
|
|
2
2
|
padding-top: 24px;
|
|
3
3
|
padding-left: 10px;
|
|
4
4
|
padding-right: 10px;
|
|
5
5
|
margin-bottom: 8px;
|
|
6
6
|
line-height: normal;
|
|
7
|
-
`;exports.default=o=>{let{template:T,onTemplateChange:E,whatsappSpecificPickerMeta:V,showVariableModal:B,variableListForImage:M,setDiscountCode:k,fileName:I,setFileName:R}=o;var q,D,L,U,A,P,w,_,N,S,F,H,Q,Y,K,W,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,ue,re,pe,ce,ve,me,be,ge;const fe=T.isCarouselType,{originalVariableList:je,pod:he,extras:Ce,selectedCarouselIndex:xe,isProductCarouselType:Oe,disableCopyCode:Te}=s.useTemplateModalContext(),{descriptionComponents:ye,urlBtns:Ee,qrbBtns:Ve,imageComponent:Be,bodyVariables:Me,headerVariables:ke}=u.getAllDataFromTemplateComponent(T),Ie=t.useRef(null),[Re,qe]=t.useState(!1),[De,Le]=t.useState(-1===xe?{descriptionComponents:ye,urlBtns:Ee,qrbBtns:Ve,imageComponent:Be,bodyVariables:Me,headerVariables:ke}:{}),{uploadMediaLink:Ue,uploadMediaFiles:Ae,validateMimeType:Pe}=V,we=f.useEditWhatsappTemplateMedia({uploadMediaLink:Ue,uploadMediaFiles:Ae,updateTemplateImageUrl:function(e,t){var o,i,l,a,s,d,u,r;let p;p=null!=xe&&xe>-1?{components:null===(i=null===(o=T.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[xe].components,mapping:null===(a=null===(l=null==T?void 0:T.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[xe]}:Object.assign({},T);const c=null===(s=null==p?void 0:p.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==p?void 0:p.components[c])){const n=Object.assign(Object.assign({},p.components[c]),{format:t,example:{header_handle:[e]}}),o=[...p.components];o[c]=n,p=Object.assign(Object.assign({},p),{components:o})}p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0}));if(null!=xe&&xe>-1){const e=n.cloneDeep(T);e.components[1].cards[xe].components=p.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(u=null==e?void 0:e.mapping)||void 0===u?void 0:u.cards.length)>0&&(e.mapping.cards[xe]=null!==(r=p.mapping)&&void 0!==r?r:{}),null==E||E(Object.assign({},e)),Ne(!0)}else null==E||E(Object.assign({},p))},validateMimeType:Pe,mediaComponent:fe?De.imageComponent:Be,fileRef:Ie}),[_e,Ne]=t.useState(!1),[Se,Fe]=t.useState(I),[He,Qe]=t.useState();function Ye(e,t,o){var i,l,a,s,d,u,r,p,c,v;const m=null!=xe&&xe>-1?{components:null===(i=Object.assign({},T).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},T).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},T),b=n.cloneDeep(m),g="custom"===t&&"string"==typeof e,f=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=xe&&xe>-1&&Oe){const t=Object.assign({},T).components.map((e=>{var n;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(n=e.cards)||void 0===n?void 0:n.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var n,t,i;if("BUTTONS"===e.type){const l=null===(n=e.buttons)||void 0===n?void 0:n.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),i=null===(s=null===(a=Object.assign({},T).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var t;return Object.assign(Object.assign({},n),{buttons:null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.map((n=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=n.cloneDeep(T);return l.components=t,l.mapping.cards=i,void(null==E||E(Object.assign({},l)))}const j=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==j&&j>-1){const n=null===(d=null==b?void 0:b.components[j].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==n?void 0:n.length)>0){const i="custom"===t&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=n[o];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(p=null===(r=null===(u=b.components)||void 0===u?void 0:u[j])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[j]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[j]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?qe(!0):(qe(!1),null==k||k(""))}if(null!=xe&&xe>-1){const e=n.cloneDeep(T);e.components[1].cards[xe].components=b.components,e.mapping.cards[xe]=b.mapping,null==E||E(Object.assign({},e))}else null==E||E(b)}function Ke(e,t,o){var i,l,a,s,d,u,r;const p=null!=xe&&xe>-1?{components:null===(i=Object.assign({},T).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},T).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},T);if(null!=xe&&xe>-1&&Oe){const t=Object.assign({},T).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[o])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=n.cloneDeep(T);return i.components=t,void(null==E||E(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==p?void 0:p.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(n){let t=n[o];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(r=null===(u=null===(d=p.components)||void 0===d?void 0:d[c])||void 0===u?void 0:u.buttons)&&void 0!==r?r:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),a=[...p.components];a[c]=l,p.components=a}}if(null!=xe&&xe>-1){const e=n.cloneDeep(T);e.components[1].cards[xe].components=p.components,null==E||E(Object.assign({},e))}else null==E||E(p)}t.useEffect((()=>{var e,n;if(null===(e=T.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))qe(!0);else{qe(!1);const e=null===(n=null==Ce?void 0:Ce.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[T]),t.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1){const i={components:null===(n=null===(e=T.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==T?void 0:T.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=u.getAllDataFromTemplateComponent(i);Le({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=xe&&-1===xe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=u.getAllDataFromTemplateComponent(T);Le({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[xe]),t.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1&&_e){const i={components:null===(n=null===(e=T.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==T?void 0:T.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=u.getAllDataFromTemplateComponent(i);Le({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Ne(!1)}}),[_e]);const We=fe?De.imageComponent:Be;return we.openEditMedia?e.jsx(h.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(m.default,{mediaComponentFormat:null!==(q=We.format)&&void 0!==q?q:l.HEADER_TYPES.IMAGE,uploadMedia:we.uploadMedia,variableListForImage:M||[],useEditWhatsappTemplateMediaResponse:we,setOpenEditMedia:we.setOpenEditMedia,openEditMedia:we.openEditMedia,editIconRef:we.editIconRef,fileRef:Ie})})):e.jsxs(h.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Oe?"420px":"auto"}},{children:[!!De.imageComponent&&!Oe&&e.jsxs(g.EditTemplateMediaContainer,{children:[e.jsx(b.default,{imageName:null!==(L=null===(D=null==We?void 0:We.example)||void 0===D?void 0:D.header_handle)&&void 0!==L?L:[],handleImageChange:we.handleImageChange,mediaType:null==We?void 0:We.format,error:we.error,isLoading:we.loading,setOpenEditMedia:we.setOpenEditMedia,selectedVariable:r.isVariable(null!==(P=null===(A=null===(U=null==We?void 0:We.example)||void 0===U?void 0:U.header_handle)||void 0===A?void 0:A[0])&&void 0!==P?P:"")?null===(_=null===(w=null==We?void 0:We.example)||void 0===w?void 0:w.header_handle)||void 0===_?void 0:_[0]:(null===(S=null===(N=null==T?void 0:T.mapping)||void 0===N?void 0:N.header)||void 0===S?void 0:S[0])?null===(H=null===(F=null==T?void 0:T.mapping)||void 0===F?void 0:F.header)||void 0===H?void 0:H[0]:we.selectedVariable}),(null==Be?void 0:Be.format)==l.HEADER_TYPES.DOCUMENT?e.jsx(y,{children:e.jsx(i.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Se,errorMessage:He||void 0,onBlur:()=>{if(!Se)return null==R||R(""),void Qe("PDF name is Required");const e=p.validateInputName(Se);null==R||R(Se),Qe(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{Qe(""),Fe(e)}})}):e.jsx(e.Fragment,{})]}),(null===(Q=De.bodyVariables)||void 0===Q?void 0:Q.length)>0&&e.jsx(x.default,{containerStyle:{paddingTop:De.mediaComponent?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===(Y=De.descriptionComponents)||void 0===Y?void 0:Y.map(((n,t)=>e.jsx(C.default,{originalVariableList:null!=xe&&xe>-1?je.cards[xe]:je,type:n.type,descriptionComponent:n.component,showVariableModal:B},t))),(null===($=null===(W=null!=xe&&xe>-1?null===(K=je.cards[xe])||void 0===K?void 0:K.buttons:null==je?void 0:je.buttons)||void 0===W?void 0:W.filter((e=>"URL"===e.type)))||void 0===$?void 0:$.length)>0&&e.jsx(x.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(z=null===(X=null!=xe&&xe>-1?null===(G=je.cards[xe])||void 0===G?void 0:G.buttons:null==je?void 0:je.buttons)||void 0===X?void 0:X.filter((e=>he===a.POD.CHATBOT||"URL"===e.type)))||void 0===z?void 0:z.map(((n,t)=>{const o=n.buttonVariable===d.STATIC_URL_VARIABLE_NAME;if("URL"===n.type)return e.jsx(O.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==V?void 0:V.CTAoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},je.cards[xe]):Object.assign({},je),updateSelectedURLTemplateBtn:Ye},`${t}_${xe}`)})),he===a.POD.CHATBOT&&(null===(Z=null===(J=Ve[0])||void 0===J?void 0:J.component)||void 0===Z?void 0:Z.buttons)&&(null===(te=null===(ne=null===(ee=Ve[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)||void 0===te?void 0:te.length)>0&&e.jsx(c.BackTrackComponent,{backTrackMessage:null===(oe=null==Ce?void 0:Ce.backTrackExtra)||void 0===oe?void 0:oe[0],setBackTrackMessage:null===(ie=null==Ce?void 0:Ce.backTrackExtra)||void 0===ie?void 0:ie[1]}),(null===(se=null===(ae=null!=xe&&xe>-1?null===(le=je.cards[xe])||void 0===le?void 0:le.buttons:null==je?void 0:je.buttons)||void 0===ae?void 0:ae.filter((e=>"QUICK_REPLY"===e.type)))||void 0===se?void 0:se.length)>0&&(he!==a.POD.CHATBOT?e.jsx(x.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"}):e.jsx(c.BackTrackComponent,{backTrackMessage:null===(de=null==Ce?void 0:Ce.backTrackExtra)||void 0===de?void 0:de[0],setBackTrackMessage:null===(ue=null==Ce?void 0:Ce.backTrackExtra)||void 0===ue?void 0:ue[1]})),null===(ce=null===(pe=null!=xe&&xe>-1?null===(re=je.cards[xe])||void 0===re?void 0:re.buttons:null==je?void 0:je.buttons)||void 0===pe?void 0:pe.filter((e=>"QUICK_REPLY"===e.type)))||void 0===ce?void 0:ce.map(((n,t)=>{if("QUICK_REPLY"===n.type&&he!==a.POD.CHATBOT)return e.jsx(O.default,{variableListIndex:t,QRBoptions:null==V?void 0:V.QRBoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},je.cards[xe]):Object.assign({},je),updateSelectedQRBTemplateBtn:Ke},`${t}_${xe}`)})),he===a.POD.CHATBOT&&Re&&e.jsx(v.DiscountCodeComponent,{discountCode:null===(ve=null==Ce?void 0:Ce.discountCodeExtra)||void 0===ve?void 0:ve[0],setDiscountCode:null===(me=null==Ce?void 0:Ce.discountCodeExtra)||void 0===me?void 0:me[1]}),null===(ge=null!=xe&&xe>-1?null===(be=je.cards[xe])||void 0===be?void 0:be.buttons:null==je?void 0:je.buttons)||void 0===ge?void 0:ge.map(((n,t)=>{var o,l,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:Te?e.jsx("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e.jsx(i.Input,{state:"disabled",labelText:null!==(o=n.text)&&void 0!==o?o:"Copy Code",value:null!==(l=n.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):e.jsx(j.default,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=n.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))};
|
|
7
|
+
`;exports.default=i=>{let{template:y,onTemplateChange:V,whatsappSpecificPickerMeta:B,showVariableModal:M,variableListForImage:k,setDiscountCode:I,fileName:q,setFileName:R}=i;var D,L,U,w,A,P,_,S,H,N,F,Q,Y,W,K,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,re,ue,pe,ce,ve,me,be,ge,he;const je=y.isCarouselType,{originalVariableList:fe,pod:Ce,extras:xe,selectedCarouselIndex:Oe,isProductCarouselType:Te,disableCopyCode:ye}=r.useTemplateModalContext(),{descriptionComponents:Ee,urlBtns:Ve,qrbBtns:Be,imageComponent:Me,bodyVariables:ke,headerVariables:Ie}=p.getAllDataFromTemplateComponent(y),qe=o.useRef(null),[Re,De]=o.useState(!1),[Le,Ue]=o.useState(-1===Oe?{descriptionComponents:Ee,urlBtns:Ve,qrbBtns:Be,imageComponent:Me,bodyVariables:ke,headerVariables:Ie}:{}),{uploadMediaLink:we,uploadMediaFiles:Ae,validateMimeType:Pe}=B,_e=j.useEditWhatsappTemplateMedia({uploadMediaLink:we,uploadMediaFiles:Ae,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=Oe&&Oe>-1?{components:null===(i=null===(o=y.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Oe].components,mapping:null===(a=null===(l=null==y?void 0:y.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Oe]}:Object.assign({},y);const c=null===(s=null==p?void 0:p.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==p?void 0:p.components[c])){const t=Object.assign(Object.assign({},p.components[c]),{format:n,example:{header_handle:[e]}}),o=[...p.components];o[c]=t,p=Object.assign(Object.assign({},p),{components:o})}p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0}));if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=p.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Oe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==V||V(Object.assign({},e)),He(!0)}else null==V||V(Object.assign({},p))},validateMimeType:Pe,mediaComponent:je?Le.imageComponent:Me,fileRef:qe}),[Se,He]=o.useState(!1),[Ne,Fe]=o.useState();function Qe(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},y),b=t.cloneDeep(m),g="custom"===n&&"string"==typeof e,h=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Oe&&Oe>-1&&Te){const n=Object.assign({},y).components.map((e=>{var n;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(n=e.cards)||void 0===n?void 0:n.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var n,t,i;if("BUTTONS"===e.type){const l=null===(n=e.buttons)||void 0===n?void 0:n.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[h]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),i=null===(s=null===(a=Object.assign({},y).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var t;return Object.assign(Object.assign({},n),{buttons:null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.map((n=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=t.cloneDeep(y);return l.components=n,l.mapping.cards=i,void(null==V||V(Object.assign({},l)))}const j=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==j&&j>-1){const t=null===(d=null==b?void 0:b.components[j].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[o];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(p=null===(u=null===(r=b.components)||void 0===r?void 0:r[j])||void 0===u?void 0:u.buttons)&&void 0!==p?p:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[j]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[j]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?De(!0):(De(!1),null==I||I(""))}if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=b.components,e.mapping.cards[Oe]=b.mapping,null==V||V(Object.assign({},e))}else null==V||V(b)}function Ye(e,n,o){var i,l,a,s,d,r,u;const p=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},y);if(null!=Oe&&Oe>-1&&Te){const n=Object.assign({},y).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[o])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=t.cloneDeep(y);return i.components=n,void(null==V||V(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==p?void 0:p.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(n){let t=n[o];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(u=null===(r=null===(d=p.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==u?u:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),a=[...p.components];a[c]=l,p.components=a}}if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=p.components,null==V||V(Object.assign({},e))}else null==V||V(p)}o.useEffect((()=>{var e,n;if(null===(e=y.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))De(!0);else{De(!1);const e=null===(n=null==xe?void 0:xe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[y]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Oe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=Oe&&-1===Oe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(y);Ue({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[Oe]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1&&Se){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Oe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),He(!1)}}),[Se]);const We=je?Le.imageComponent:Me;return _e.openEditMedia?e.jsx(C.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(b.default,{mediaComponentFormat:null!==(D=We.format)&&void 0!==D?D:s.HEADER_TYPES.IMAGE,uploadMedia:_e.uploadMedia,variableListForImage:k||[],useEditWhatsappTemplateMediaResponse:_e,setOpenEditMedia:_e.setOpenEditMedia,openEditMedia:_e.openEditMedia,editIconRef:_e.editIconRef,fileRef:qe})})):e.jsxs(C.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Te?"420px":"auto"}},{children:[!!Le.imageComponent&&!Te&&e.jsxs(h.EditTemplateMediaContainer,{children:[e.jsx(g.default,{imageName:null!==(U=null===(L=null==We?void 0:We.example)||void 0===L?void 0:L.header_handle)&&void 0!==U?U:[],handleImageChange:_e.handleImageChange,mediaType:null==We?void 0:We.format,error:_e.error,isLoading:_e.loading,setOpenEditMedia:_e.setOpenEditMedia,selectedVariable:c.isVariable(null!==(P=null===(A=null===(w=null==We?void 0:We.example)||void 0===w?void 0:w.header_handle)||void 0===A?void 0:A[0])&&void 0!==P?P:"")?null===(S=null===(_=null==We?void 0:We.example)||void 0===_?void 0:_.header_handle)||void 0===S?void 0:S[0]:(null===(N=null===(H=null==y?void 0:y.mapping)||void 0===H?void 0:H.header)||void 0===N?void 0:N[0])?null===(Q=null===(F=null==y?void 0:y.mapping)||void 0===F?void 0:F.header)||void 0===Q?void 0:Q[0]:_e.selectedVariable}),(null==Me?void 0:Me.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(E,{children:e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",pickerType:n.PickerType.EMBEDDED,errorMessage:Ne||void 0,noMaxCharCheck:!0,allowMix:!1,onChange:e=>{Fe("")},showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:"",variableType:"string"},variablesList:k})}):e.jsx(e.Fragment,{})]}),(null===(Y=Le.bodyVariables)||void 0===Y?void 0:Y.length)>0&&e.jsx(O.default,{containerStyle:{paddingTop:Le.mediaComponent?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===(W=Le.descriptionComponents)||void 0===W?void 0:W.map(((n,t)=>e.jsx(x.default,{originalVariableList:null!=Oe&&Oe>-1?fe.cards[Oe]:fe,type:n.type,descriptionComponent:n.component,showVariableModal:M},t))),(null===(G=null===($=null!=Oe&&Oe>-1?null===(K=fe.cards[Oe])||void 0===K?void 0:K.buttons:null==fe?void 0:fe.buttons)||void 0===$?void 0:$.filter((e=>"URL"===e.type)))||void 0===G?void 0:G.length)>0&&e.jsx(O.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(J=null===(z=null!=Oe&&Oe>-1?null===(X=fe.cards[Oe])||void 0===X?void 0:X.buttons:null==fe?void 0:fe.buttons)||void 0===z?void 0:z.filter((e=>Ce===d.POD.CHATBOT||"URL"===e.type)))||void 0===J?void 0:J.map(((n,t)=>{const o=n.buttonVariable===u.STATIC_URL_VARIABLE_NAME;if("URL"===n.type)return e.jsx(T.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==B?void 0:B.CTAoptions,button:n,currentVariableList:null!=Oe&&Oe>-1?Object.assign({},fe.cards[Oe]):Object.assign({},fe),updateSelectedURLTemplateBtn:Qe},`${t}_${Oe}`)})),Ce===d.POD.CHATBOT&&(null===(ee=null===(Z=Be[0])||void 0===Z?void 0:Z.component)||void 0===ee?void 0:ee.buttons)&&(null===(oe=null===(te=null===(ne=Be[0])||void 0===ne?void 0:ne.component)||void 0===te?void 0:te.buttons)||void 0===oe?void 0:oe.length)>0&&e.jsx(v.BackTrackComponent,{backTrackMessage:null===(ie=null==xe?void 0:xe.backTrackExtra)||void 0===ie?void 0:ie[0],setBackTrackMessage:null===(le=null==xe?void 0:xe.backTrackExtra)||void 0===le?void 0:le[1]}),(null===(de=null===(se=null!=Oe&&Oe>-1?null===(ae=fe.cards[Oe])||void 0===ae?void 0:ae.buttons:null==fe?void 0:fe.buttons)||void 0===se?void 0:se.filter((e=>"QUICK_REPLY"===e.type)))||void 0===de?void 0:de.length)>0&&(Ce!==d.POD.CHATBOT?e.jsx(O.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"}):e.jsx(v.BackTrackComponent,{backTrackMessage:null===(re=null==xe?void 0:xe.backTrackExtra)||void 0===re?void 0:re[0],setBackTrackMessage:null===(ue=null==xe?void 0:xe.backTrackExtra)||void 0===ue?void 0:ue[1]})),null===(ve=null===(ce=null!=Oe&&Oe>-1?null===(pe=fe.cards[Oe])||void 0===pe?void 0:pe.buttons:null==fe?void 0:fe.buttons)||void 0===ce?void 0:ce.filter((e=>"QUICK_REPLY"===e.type)))||void 0===ve?void 0:ve.map(((n,t)=>{if("QUICK_REPLY"===n.type&&Ce!==d.POD.CHATBOT)return e.jsx(T.default,{variableListIndex:t,QRBoptions:null==B?void 0:B.QRBoptions,button:n,currentVariableList:null!=Oe&&Oe>-1?Object.assign({},fe.cards[Oe]):Object.assign({},fe),updateSelectedQRBTemplateBtn:Ye},`${t}_${Oe}`)})),Ce===d.POD.CHATBOT&&Re&&e.jsx(m.DiscountCodeComponent,{discountCode:null===(me=null==xe?void 0:xe.discountCodeExtra)||void 0===me?void 0:me[0],setDiscountCode:null===(be=null==xe?void 0:xe.discountCodeExtra)||void 0===be?void 0:be[1]}),null===(he=null!=Oe&&Oe>-1?null===(ge=fe.cards[Oe])||void 0===ge?void 0:ge.buttons:null==fe?void 0:fe.buttons)||void 0===he?void 0:he.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:ye?e.jsx("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e.jsx(l.Input,{state:"disabled",labelText:null!==(o=n.text)&&void 0!==o?o:"Copy Code",value:null!==(i=n.buttonVariable)&&void 0!==i?i:"",onChangeText:()=>{}})})):e.jsx(f.default,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=n.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))};
|
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("lodash"),l=require("react"),s=require("../../dropdown/Dropdown.js"),a=require("../../input/Input.js"),n=require("../../template-preview/constants/regexPatterns.js"),i=require("../../template-preview/models/TemplateMeta.js"),o=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js"),c=require("../context/templateModalContext.js"),d=require("../utils/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),s=require("../../dropdown/Dropdown.js"),a=require("../../input/Input.js"),n=require("../../template-preview/constants/regexPatterns.js"),i=require("../../template-preview/models/TemplateMeta.js"),o=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js"),c=require("../context/templateModalContext.js"),d=require("../utils/constants.js"),b=require("../utils/validateIsUrl.js"),p=require("./VariableConnector.js");exports.default=j=>{let{variableListIndex:v,button:O,updateSelectedURLTemplateBtn:m,updateSelectedQRBTemplateBtn:g,currentVariableList:x,CTAoptions:f,QRBoptions:y,disableEdit:L}=j;var R,U,T,h,C;const[I,V]=l.useState(""),[_,q]=l.useState(),E=null==f?void 0:f.map((e=>Object.assign(Object.assign({},e),{selected:(null==_?void 0:_.value)===e.value}))),P=null==y?void 0:y.map((e=>Object.assign(Object.assign({},e),{selected:(null==_?void 0:_.value)===e.value}))),{isError:w,disableEditVariable:N,pod:S,selectedCarouselIndex:A,originalVariableList:B,setOriginalVariableList:H,isProductCarouselType:M,ctaOptionsErrors:Q,setCtaOptionsErrors:k}=c.useTemplateModalContext();function D(e){if(V(e),null!=A&&A>-1&&M){const l=t.cloneDeep(B);if("URL"===O.type){const t=l.cards.map((t=>{let l=t.buttons.filter((e=>"URL"===e.type))[v];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=t.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},t),{buttons:s})}));null==H||H((e=>Object.assign(Object.assign({},e),{cards:t}))),null==m||m(`https://${e}`,"custom",v)}return}let l=x.buttons.filter((e=>"URL"===e.type))[v];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=x.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),a=Object.assign({},null!=A&&A>-1?B.cards[A]:B);if(a.buttons=s,null!=A&&A>-1){const e=[...B.cards];e[A]=a,null==H||H((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==H||H((e=>Object.assign(Object.assign({},e),{buttons:[...s]})));null==m||m(`https://${e}`,"custom",v)}return l.useEffect((()=>{var e;if(O.buttonVariable&&n.editableVarPattern.test(O.buttonVariable))O.buttonVariable===d.STATIC_URL_VARIABLE_NAME?q(i.STATIC_URL_CTA_OPTION):q(i.CUSTOM_URL_NAME),V((null===(e=O.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===O.type?f:y;e="URL"===O.type?t.findIndex((e=>e.placeHolder===O.buttonVariable)):t.findIndex((e=>e.label===O.flowName)),e>-1?q(t[e]):null==k||k((e=>Object.assign(Object.assign({},e),{[v]:"Required field!"})))}}),[]),S!==o.POD.CHATBOT?e.jsxs(p.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:u.COLORS.content.primary}},{children:[O.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(s.Dropdown,{disabled:N||L,truncatedText:!1,options:"URL"===O.type?"static_link"===(null==_?void 0:_.value)?[i.STATIC_URL_CTA_OPTION]:E:P,isSearchable:!0,onSelect:function(e,l){null==k||k((e=>(delete e[v],Object.assign({},e))));const s=e;q(s);const a=("URL"===O.type?f:y).find((e=>e.placeHolder===s.placeHolder));if(a)if("custom_link"!==a.value){if(null!=A&&A>-1&&M){const e=t.cloneDeep(B);if("URL"===O.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"URL"===e.type))[v];t=Object.assign(Object.assign({},t),{buttonVariable:s.placeHolder});const l=e.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==m||m({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder",v),null==H||H((e=>Object.assign(Object.assign({},e),{cards:t})))}else if("QUICK_REPLY"===O.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"QUICK_REPLY"===e.type))[v];t=Object.assign(Object.assign({},t),{flowName:s.label,flowId:s.value});const l=e.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==g||g({flowName:s.label,flowId:s.value},"placeholder",v),null==H||H((e=>Object.assign(Object.assign({},e),{cards:t})))}return}let e;if("URL"===O.type){let t=x.buttons.filter((e=>"URL"===e.type))[v];t=Object.assign(Object.assign({},t),{buttonVariable:s.placeHolder,example:[(null==s?void 0:s.value)||"https://d.bik.ai/"]}),e=x.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==m||m({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder",v)}else{let t=x.buttons.filter((e=>"QUICK_REPLY"===e.type))[v];t=Object.assign(Object.assign({},t),{flowName:s.label,flowId:s.value}),e=x.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==g||g({flowName:s.label,flowId:s.value},"placeholder",v)}const l=Object.assign({},null!=A&&A>-1?B.cards[A]:B);if(l.buttons=e,null!=A&&A>-1){const e=[...B.cards];e[A]=l,null==H||H((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==H||H((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else D("")},defaultOptions:_?[Object.assign(Object.assign({},_),{selected:!0})]:[],error:w?null==Q?void 0:Q[v]:void 0})})),("custom_link"===(null==_?void 0:_.value)||"static_link"===(null==_?void 0:_.value))&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(a.Input,{state:N||L?"disabled":"none",errorMessage:w?I?b.validateIsUrl(I)?"":"Enter valid URL":"Required field":"",value:I,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:D,maxCharLimit:2e3})}))]}):e.jsx(p.default,{index:v,variable:{variableName:null!==(R=O.text)&&void 0!==R?R:"",updatedValue:"((customPlaceholderName))"===O.buttonVariable?`${null===(U=O.example)||void 0===U?void 0:U[0]}`:null!==(T=O.buttonVariable)&&void 0!==T?T:"",type:"link",isEditableVariable:!0,index:null!==(h=O.index)&&void 0!==h?h:0,queryParams:null!==(C=O.queryParams)&&void 0!==C?C:[]},showVariableModal:!0,componentType:"BUTTONS",buttonType:O.type,CTAoptions:f})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var E,T,e,A;Object.defineProperty(exports,"__esModule",{value:!0}),exports.TEMPLATE_EDITOR=void 0,(E=exports.TEMPLATE_EDITOR||(exports.TEMPLATE_EDITOR={})).SEND_GRID="sendgrid",E.BEE="bee",exports.TEMPLATE_STATUS=void 0,(T=exports.TEMPLATE_STATUS||(exports.TEMPLATE_STATUS={})).APPROVED="APPROVED",T.DISABLED="DISABLED",T.FLAGGED="FLAGGED",T.PENDING="PENDING",T.DRAFT="DRAFT",T.REJECTED="REJECTED",T.PENDING_DELETION="PENDING_DELETION",T.IN_REVIEW="IN REVIEW",T.PAUSED="PAUSED",T.ACTIVE="ACTIVE",T.LIBRARY="LIBRARY",exports.HEADER_TYPES=void 0,(e=exports.HEADER_TYPES||(exports.HEADER_TYPES={})).NONE="NONE",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.DOCUMENT="DOCUMENT",exports.ACTIONS_TYPES=void 0,(A=exports.ACTIONS_TYPES||(exports.ACTIONS_TYPES={})).NONE="NONE",A.CTA_BTN="CTA_BTN",A.QUICK_REPLY="QUICK_REPLY";exports.CUSTOM_URL_NAME={value:"custom_link",label:"Custom URL",placeHolder:"custom placeholder"},exports.STATIC_URL_CTA_OPTION={label:"
|
|
1
|
+
"use strict";var E,T,e,A;Object.defineProperty(exports,"__esModule",{value:!0}),exports.TEMPLATE_EDITOR=void 0,(E=exports.TEMPLATE_EDITOR||(exports.TEMPLATE_EDITOR={})).SEND_GRID="sendgrid",E.BEE="bee",exports.TEMPLATE_STATUS=void 0,(T=exports.TEMPLATE_STATUS||(exports.TEMPLATE_STATUS={})).APPROVED="APPROVED",T.DISABLED="DISABLED",T.FLAGGED="FLAGGED",T.PENDING="PENDING",T.DRAFT="DRAFT",T.REJECTED="REJECTED",T.PENDING_DELETION="PENDING_DELETION",T.IN_REVIEW="IN REVIEW",T.PAUSED="PAUSED",T.ACTIVE="ACTIVE",T.LIBRARY="LIBRARY",exports.HEADER_TYPES=void 0,(e=exports.HEADER_TYPES||(exports.HEADER_TYPES={})).NONE="NONE",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.DOCUMENT="DOCUMENT",exports.ACTIONS_TYPES=void 0,(A=exports.ACTIONS_TYPES||(exports.ACTIONS_TYPES={})).NONE="NONE",A.CTA_BTN="CTA_BTN",A.QUICK_REPLY="QUICK_REPLY";exports.CUSTOM_URL_NAME={value:"custom_link",label:"Custom URL",placeHolder:"custom placeholder"},exports.STATIC_URL_CTA_OPTION={label:"Custom URL (No tracking)",value:"static_link",placeHolder:"{{staticUrl}}"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../../_virtual/_tslib.js";import{jsx as e,Fragment as t,jsxs as l}from"react/jsx-runtime";import n,{useState as r,useRef as i,useImperativeHandle as s,useEffect as
|
|
1
|
+
import{__rest as o}from"../../../_virtual/_tslib.js";import{jsx as e,Fragment as t,jsxs as l}from"react/jsx-runtime";import n,{useState as r,useRef as i,useImperativeHandle as s,useEffect as a}from"react";import{usePopper as d}from"react-popper";import{DropShadow as p}from"../../dropShadow/DropShadow.js";import{Tooltip as c}from"../../tooltips/Tooltip.js";import{OverLapAbs as v,OpenDropdownContainer as m}from"../Common.styled.js";import{OpenedDropdown as u}from"../OpenedDropdown/components/OpennedDropdown.js";const w=n.forwardRef(((n,w)=>{var{children:b,onDropdownVisbilityChange:h,version:f="1.0",tooltipContent:j,tooltipDirection:g,showTooltipArrow:D}=n,O=o(n,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow"]);const y=w,[C,S]=r(!1),[E,x]=r(null),[A,R]=r(null),T=i(null),{styles:z,attributes:M}=d(E,A,{placement:O.placement,strategy:O.strategy}),V=o=>{var e,t;"2.0"===f&&O.isMultiSelect&&o&&(null===(e=O.onSelect)||void 0===e||e.call(O,[...o])),S(!1),null===(t=null==O?void 0:O.onClose)||void 0===t||t.call(O)};s(y,(()=>({openDropdown:C})),[]),a((()=>{(null==y?void 0:y.current)&&(y.current.openDropdown=C)}),[C]),a((()=>{null==h||h(C)}),[C]);const _=()=>l(t,{children:[l("div",Object.assign({style:{position:"relative"},ref:x},{children:[e(v,Object.assign({ref:T,allowEvents:O.allowEvents,disabled:O.disabled,onClick:o=>{var e;null===(e=O.onDropdownOpen)||void 0===e||e.call(O),C?(S(!1),o.preventDefault()):O.disabled||S(!0)}},{children:O.allowEvents?b:null})),O.allowEvents?null:b]})),C&&e(m,Object.assign({ref:R,style:Object.assign(Object.assign({},z.popper),{zIndex:3})},M.popper,{"data-test":O["data-test"]},{children:e(p,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:e(u,Object.assign({},O,{onSelect:o=>{var e;"2.0"===f&&O.isMultiSelect||(null===(e=O.onSelect)||void 0===e||e.call(O,o),S(!1))},onClose:V,version:f,headerRef:T}))}))}))]});return e(t,{children:C||void 0===j?_():e(c,Object.assign({body:j,placement:g,hideArrow:!D},{children:e("div",Object.assign({"data-test":O["data-test"]},{children:_()}))}))})}));w.displayName="DropdownPopover";export{w as DropdownPopover};
|
|
@@ -15,6 +15,7 @@ export declare function iterateOnOptions(options: DropdownOption[], newVal: Part
|
|
|
15
15
|
selectedLabel?: string | undefined;
|
|
16
16
|
children?: SingleOption[] | undefined;
|
|
17
17
|
parent?: SingleOption | undefined;
|
|
18
|
+
'data-test'?: string | undefined;
|
|
18
19
|
} | {
|
|
19
20
|
label?: string | undefined;
|
|
20
21
|
value?: string | undefined;
|
|
@@ -30,6 +31,7 @@ export declare function iterateOnOptions(options: DropdownOption[], newVal: Part
|
|
|
30
31
|
selectedLabel?: string | undefined;
|
|
31
32
|
children?: SingleOption[] | undefined;
|
|
32
33
|
parent?: SingleOption | undefined;
|
|
34
|
+
'data-test'?: string | undefined;
|
|
33
35
|
options: SingleOption[];
|
|
34
36
|
})[];
|
|
35
37
|
export declare function iterateOnOptionsRaw(options: DropdownOption[], cb: (option: SingleOption) => void): void;
|
|
@@ -22,6 +22,7 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
|
|
|
22
22
|
selectedLabel?: string | undefined;
|
|
23
23
|
children?: SingleOption[] | undefined;
|
|
24
24
|
parent?: SingleOption | undefined;
|
|
25
|
+
'data-test'?: string | undefined;
|
|
25
26
|
} | {
|
|
26
27
|
label?: string | undefined;
|
|
27
28
|
value?: string | undefined;
|
|
@@ -37,6 +38,7 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
|
|
|
37
38
|
selectedLabel?: string | undefined;
|
|
38
39
|
children?: SingleOption[] | undefined;
|
|
39
40
|
parent?: SingleOption | undefined;
|
|
41
|
+
'data-test'?: string | undefined;
|
|
40
42
|
options: SingleOption[];
|
|
41
43
|
})[] | undefined;
|
|
42
44
|
selectAllHandler: (newState: SelectAllCheckboxState) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsx as o,jsxs as n,Fragment as e}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useRef as i,useState as l,useEffect as a}from"react";import s from"styled-components";import{Input as d}from"../../input/Input.js";import{HEADER_TYPES as r}from"../../template-preview/models/TemplateMeta.js";import{POD as p}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as u}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as c}from"../utils/constants.js";import{getAllDataFromTemplateComponent as m}from"../utils/getDataFromTemplateComponent.js";import{isVariable as v}from"../utils/validateIsUrl.js";import{validateInputName as b}from"../utils/validateName.js";import{BackTrackComponent as g}from"./BackTrackComponent.js";import{DiscountCodeComponent as f}from"./DiscountCodeComponent.js";import h from"./EditMediaModal.js";import j from"./EditMediaV2.js";import{EditTemplateMediaContainer as O}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as C}from"./useEditWhtasappTemplateMedia.js";import T from"./VariableConnector.js";import{Container as x}from"./VariableConnectorsPanel.js";import y from"./VariableConnectorWhatsApp.js";import E from"./VariableEditorHeader.js";import V from"./WhatsAppTemplateCardButtonV2.js";const B=s=>{let{template:B,onTemplateChange:k,whatsappSpecificPickerMeta:I,showVariableModal:L,variableListForImage:R,setDiscountCode:U,fileName:w,setFileName:N}=s;var P,A,_,D,H,S,F,Q,q,Y,K,W,$,G,X,z,J,Z,oo,no,eo,to,io,lo,ao,so,ro,po,uo,co,mo,vo,bo,go,fo,ho,jo,Oo,Co;const To=B.isCarouselType,{originalVariableList:xo,pod:yo,extras:Eo,selectedCarouselIndex:Vo,isProductCarouselType:Bo,disableCopyCode:Mo}=u(),{descriptionComponents:ko,urlBtns:Io,qrbBtns:Lo,imageComponent:Ro,bodyVariables:Uo,headerVariables:wo}=m(B),No=i(null),[Po,Ao]=l(!1),[_o,Do]=l(-1===Vo?{descriptionComponents:ko,urlBtns:Io,qrbBtns:Lo,imageComponent:Ro,bodyVariables:Uo,headerVariables:wo}:{}),{uploadMediaLink:Ho,uploadMediaFiles:So,validateMimeType:Fo}=I,Qo=C({uploadMediaLink:Ho,uploadMediaFiles:So,updateTemplateImageUrl:function(o,n){var e,i,l,a,s,d,r,p;let u;u=null!=Vo&&Vo>-1?{components:null===(i=null===(e=B.components[1])||void 0===e?void 0:e.cards)||void 0===i?void 0:i[Vo].components,mapping:null===(a=null===(l=null==B?void 0:B.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Vo]}:Object.assign({},B);const c=null===(s=null==u?void 0:u.components)||void 0===s?void 0:s.findIndex((o=>{if("HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format)return!0}));if(void 0!==c&&c>-1&&(null==u?void 0:u.components[c])){const e=Object.assign(Object.assign({},u.components[c]),{format:n,example:{header_handle:[o]}}),t=[...u.components];t[c]=e,u=Object.assign(Object.assign({},u),{components:t})}u.mapping&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:void 0}));if(null!=Vo&&Vo>-1){const o=t(B);o.components[1].cards[Vo].components=u.components,(null===(d=null==o?void 0:o.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==o?void 0:o.mapping)||void 0===r?void 0:r.cards.length)>0&&(o.mapping.cards[Vo]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==k||k(Object.assign({},o)),Yo(!0)}else null==k||k(Object.assign({},u))},validateMimeType:Fo,mediaComponent:To?_o.imageComponent:Ro,fileRef:No}),[qo,Yo]=l(!1),[Ko,Wo]=l(w),[$o,Go]=l();function Xo(o,n,e){var i,l,a,s,d,r,p,u,c,m;const v=null!=Vo&&Vo>-1?{components:null===(i=Object.assign({},B).components[1].cards)||void 0===i?void 0:i[Vo].components,mapping:null===(l=Object.assign({},B).mapping.cards)||void 0===l?void 0:l[Vo]}:Object.assign({},B),b=t(v),g="custom"===n&&"string"==typeof o,f=g?o:"string"!=typeof o?o.defaultValue?o.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Vo&&Vo>-1&&Bo){const n=Object.assign({},B).components.map((o=>{var n;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(n=o.cards)||void 0===n?void 0:n.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var n,t,i;if("BUTTONS"===o.type){const l=null===(n=o.buttons)||void 0===n?void 0:n.filter((o=>"URL"===o.type));let a=null!==(t=null==l?void 0:l[e])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=o.buttons)||void 0===i?void 0:i.map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==a?void 0:a.text)?a:o));return Object.assign(Object.assign({},o),{buttons:s})}return o}))})))}):o})),i=null===(s=null===(a=Object.assign({},B).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var e;return Object.assign(Object.assign({},n),{buttons:null===(e=null==n?void 0:n.buttons)||void 0===e?void 0:e.map((n=>g?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:""))})})),l=t(B);return l.components=n,l.mapping.cards=i,void(null==k||k(Object.assign({},l)))}const h=null==b?void 0:b.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((o=>"URL"===o.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof o,l=i?o:"string"!=typeof o&&o.defaultValue?o.defaultValue:"https://d.bik.ai/";let a=t[e];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(u=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==u?u:[]].map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==a?void 0:a.text)?a:o)),d=Object.assign(Object.assign({},b.components[h]),{buttons:s}),m=null===(c=b.mapping)||void 0===c?void 0:c.buttons;m&&m.length>0&&(m[e]=i?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:"");const v=Object.assign(Object.assign({},b.mapping),{buttons:m});b.mapping=v;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof o){"checkout.checkoutUrl"===(null===(m=o.placeHolder)||void 0===m?void 0:m.slice(2,-2))?Ao(!0):(Ao(!1),null==U||U(""))}if(null!=Vo&&Vo>-1){const o=t(B);o.components[1].cards[Vo].components=b.components,o.mapping.cards[Vo]=b.mapping,null==k||k(Object.assign({},o))}else null==k||k(b)}function zo(o,n,e){var i,l,a,s,d,r,p;const u=null!=Vo&&Vo>-1?{components:null===(i=Object.assign({},B).components[1].cards)||void 0===i?void 0:i[Vo].components,mapping:null===(l=Object.assign({},B).mapping.cards)||void 0===l?void 0:l[Vo]}:Object.assign({},B);if(null!=Vo&&Vo>-1&&Bo){const n=Object.assign({},B).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((o=>"QUICK_REPLY"===o.type));let s=null!==(i=null==a?void 0:a[e])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:o.flowId,flowName:o.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==s?void 0:s.text)?s:o));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=t(B);return i.components=n,void(null==k||k(Object.assign({},i)))}const c=null==u?void 0:u.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==u?void 0:u.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((o=>"QUICK_REPLY"===o.type));if(n){let t=n[e];t=Object.assign(Object.assign({},t),{flowId:o.flowId,flowName:o.flowName});const i=[...null!==(p=null===(r=null===(d=u.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==t?void 0:t.text)?t:o)),l=Object.assign(Object.assign({},u.components[c]),{buttons:i}),a=[...u.components];a[c]=l,u.components=a}}if(null!=Vo&&Vo>-1){const o=t(B);o.components[1].cards[Vo].components=u.components,null==k||k(Object.assign({},o))}else null==k||k(u)}a((()=>{var o,n;if(null===(o=B.mapping.buttons)||void 0===o?void 0:o.find((o=>"checkout.checkoutUrl"===o.slice(2,-2))))Ao(!0);else{Ao(!1);const o=null===(n=null==Eo?void 0:Eo.discountCodeExtra)||void 0===n?void 0:n[1];null==o||o("")}}),[B]),a((()=>{var o,n,e,t;if(null!=Vo&&Vo>-1){const i={components:null===(n=null===(o=B.components[1])||void 0===o?void 0:o.cards)||void 0===n?void 0:n[Vo].components,mapping:null===(t=null===(e=null==B?void 0:B.mapping)||void 0===e?void 0:e.cards)||void 0===t?void 0:t[Vo]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=m(i);Do({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Vo&&-1===Vo){const{descriptionComponents:o,urlBtns:n,qrbBtns:e,imageComponent:t,bodyVariables:i,headerVariables:l}=m(B);Do({descriptionComponents:o,urlBtns:n,qrbBtns:e,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Vo]),a((()=>{var o,n,e,t;if(null!=Vo&&Vo>-1&&qo){const i={components:null===(n=null===(o=B.components[1])||void 0===o?void 0:o.cards)||void 0===n?void 0:n[Vo].components,mapping:null===(t=null===(e=null==B?void 0:B.mapping)||void 0===e?void 0:e.cards)||void 0===t?void 0:t[Vo]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=m(i);Do({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Yo(!1)}}),[qo]);const Jo=To?_o.imageComponent:Ro;return Qo.openEditMedia?o(x,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:o(h,{mediaComponentFormat:null!==(P=Jo.format)&&void 0!==P?P:r.IMAGE,uploadMedia:Qo.uploadMedia,variableListForImage:R||[],useEditWhatsappTemplateMediaResponse:Qo,setOpenEditMedia:Qo.setOpenEditMedia,openEditMedia:Qo.openEditMedia,editIconRef:Qo.editIconRef,fileRef:No})})):n(x,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Bo?"420px":"auto"}},{children:[!!_o.imageComponent&&!Bo&&n(O,{children:[o(j,{imageName:null!==(_=null===(A=null==Jo?void 0:Jo.example)||void 0===A?void 0:A.header_handle)&&void 0!==_?_:[],handleImageChange:Qo.handleImageChange,mediaType:null==Jo?void 0:Jo.format,error:Qo.error,isLoading:Qo.loading,setOpenEditMedia:Qo.setOpenEditMedia,selectedVariable:v(null!==(S=null===(H=null===(D=null==Jo?void 0:Jo.example)||void 0===D?void 0:D.header_handle)||void 0===H?void 0:H[0])&&void 0!==S?S:"")?null===(Q=null===(F=null==Jo?void 0:Jo.example)||void 0===F?void 0:F.header_handle)||void 0===Q?void 0:Q[0]:(null===(Y=null===(q=null==B?void 0:B.mapping)||void 0===q?void 0:q.header)||void 0===Y?void 0:Y[0])?null===(W=null===(K=null==B?void 0:B.mapping)||void 0===K?void 0:K.header)||void 0===W?void 0:W[0]:Qo.selectedVariable}),(null==Ro?void 0:Ro.format)==r.DOCUMENT?o(M,{children:o(d,{labelText:"PDF Name",placeholder:"Enter the name",value:Ko,errorMessage:$o||void 0,onBlur:()=>{if(!Ko)return null==N||N(""),void Go("PDF name is Required");const o=b(Ko);null==N||N(Ko),Go(o?"Please enter a valid PDF name":void 0)},onChangeText:o=>{Go(""),Wo(o)}})}):o(e,{})]}),(null===($=_o.bodyVariables)||void 0===$?void 0:$.length)>0&&o(E,{containerStyle:{paddingTop:_o.mediaComponent?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===(G=_o.descriptionComponents)||void 0===G?void 0:G.map(((n,e)=>o(y,{originalVariableList:null!=Vo&&Vo>-1?xo.cards[Vo]:xo,type:n.type,descriptionComponent:n.component,showVariableModal:L},e))),(null===(J=null===(z=null!=Vo&&Vo>-1?null===(X=xo.cards[Vo])||void 0===X?void 0:X.buttons:null==xo?void 0:xo.buttons)||void 0===z?void 0:z.filter((o=>"URL"===o.type)))||void 0===J?void 0:J.length)>0&&o(E,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(no=null===(oo=null!=Vo&&Vo>-1?null===(Z=xo.cards[Vo])||void 0===Z?void 0:Z.buttons:null==xo?void 0:xo.buttons)||void 0===oo?void 0:oo.filter((o=>yo===p.CHATBOT||"URL"===o.type)))||void 0===no?void 0:no.map(((n,e)=>{const t=n.buttonVariable===c;if("URL"===n.type)return o(V,{variableListIndex:e,disableEdit:t,CTAoptions:null==I?void 0:I.CTAoptions,button:n,currentVariableList:null!=Vo&&Vo>-1?Object.assign({},xo.cards[Vo]):Object.assign({},xo),updateSelectedURLTemplateBtn:Xo},`${e}_${Vo}`)})),yo===p.CHATBOT&&(null===(to=null===(eo=Lo[0])||void 0===eo?void 0:eo.component)||void 0===to?void 0:to.buttons)&&(null===(ao=null===(lo=null===(io=Lo[0])||void 0===io?void 0:io.component)||void 0===lo?void 0:lo.buttons)||void 0===ao?void 0:ao.length)>0&&o(g,{backTrackMessage:null===(so=null==Eo?void 0:Eo.backTrackExtra)||void 0===so?void 0:so[0],setBackTrackMessage:null===(ro=null==Eo?void 0:Eo.backTrackExtra)||void 0===ro?void 0:ro[1]}),(null===(co=null===(uo=null!=Vo&&Vo>-1?null===(po=xo.cards[Vo])||void 0===po?void 0:po.buttons:null==xo?void 0:xo.buttons)||void 0===uo?void 0:uo.filter((o=>"QUICK_REPLY"===o.type)))||void 0===co?void 0:co.length)>0&&(yo!==p.CHATBOT?o(E,{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"}):o(g,{backTrackMessage:null===(mo=null==Eo?void 0:Eo.backTrackExtra)||void 0===mo?void 0:mo[0],setBackTrackMessage:null===(vo=null==Eo?void 0:Eo.backTrackExtra)||void 0===vo?void 0:vo[1]})),null===(fo=null===(go=null!=Vo&&Vo>-1?null===(bo=xo.cards[Vo])||void 0===bo?void 0:bo.buttons:null==xo?void 0:xo.buttons)||void 0===go?void 0:go.filter((o=>"QUICK_REPLY"===o.type)))||void 0===fo?void 0:fo.map(((n,e)=>{if("QUICK_REPLY"===n.type&&yo!==p.CHATBOT)return o(V,{variableListIndex:e,QRBoptions:null==I?void 0:I.QRBoptions,button:n,currentVariableList:null!=Vo&&Vo>-1?Object.assign({},xo.cards[Vo]):Object.assign({},xo),updateSelectedQRBTemplateBtn:zo},`${e}_${Vo}`)})),yo===p.CHATBOT&&Po&&o(f,{discountCode:null===(ho=null==Eo?void 0:Eo.discountCodeExtra)||void 0===ho?void 0:ho[0],setDiscountCode:null===(jo=null==Eo?void 0:Eo.discountCodeExtra)||void 0===jo?void 0:jo[1]}),null===(Co=null!=Vo&&Vo>-1?null===(Oo=xo.cards[Vo])||void 0===Oo?void 0:Oo.buttons:null==xo?void 0:xo.buttons)||void 0===Co?void 0:Co.map(((n,t)=>{var i,l,a,s,r;if("COPY_CODE"===n.type)return o(e,{children:Mo?o("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:o(d,{state:"disabled",labelText:null!==(i=n.text)&&void 0!==i?i:"Copy Code",value:null!==(l=n.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):o(T,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(r=n.index)&&void 0!==r?r:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))},M=s.div`
|
|
1
|
+
import{jsx as o,jsxs as e,Fragment as n}from"react/jsx-runtime";import"../../curtain/CurtainHelper.js";import{PickerType as t}from"../../variable-picker-v3/model.js";import{cloneDeep as i}from"lodash";import{useRef as l,useState as a,useEffect as s}from"react";import d from"styled-components";import{Input as r}from"../../input/Input.js";import{InputWithVariables as p}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as u}from"../../template-preview/models/TemplateMeta.js";import{POD as c}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as m}from"../utils/constants.js";import{getAllDataFromTemplateComponent as b}from"../utils/getDataFromTemplateComponent.js";import{isVariable as g}from"../utils/validateIsUrl.js";import{BackTrackComponent as f}from"./BackTrackComponent.js";import{DiscountCodeComponent as h}from"./DiscountCodeComponent.js";import j from"./EditMediaModal.js";import O from"./EditMediaV2.js";import{EditTemplateMediaContainer as C}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as T}from"./useEditWhtasappTemplateMedia.js";import x from"./VariableConnector.js";import{Container as y}from"./VariableConnectorsPanel.js";import E from"./VariableConnectorWhatsApp.js";import V from"./VariableEditorHeader.js";import B from"./WhatsAppTemplateCardButtonV2.js";const M=d=>{let{template:M,onTemplateChange:I,whatsappSpecificPickerMeta:L,showVariableModal:R,variableListForImage:U,setDiscountCode:w,fileName:N,setFileName:H}=d;var A,P,_,D,S,Q,q,F,Y,K,W,$,G,X,z,J,Z,oo,eo,no,to,io,lo,ao,so,ro,po,uo,co,vo,mo,bo,go,fo,ho,jo,Oo,Co,To;const xo=M.isCarouselType,{originalVariableList:yo,pod:Eo,extras:Vo,selectedCarouselIndex:Bo,isProductCarouselType:Mo,disableCopyCode:ko}=v(),{descriptionComponents:Io,urlBtns:Lo,qrbBtns:Ro,imageComponent:Uo,bodyVariables:wo,headerVariables:No}=b(M),Ho=l(null),[Ao,Po]=a(!1),[_o,Do]=a(-1===Bo?{descriptionComponents:Io,urlBtns:Lo,qrbBtns:Ro,imageComponent:Uo,bodyVariables:wo,headerVariables:No}:{}),{uploadMediaLink:So,uploadMediaFiles:Qo,validateMimeType:qo}=L,Fo=T({uploadMediaLink:So,uploadMediaFiles:Qo,updateTemplateImageUrl:function(o,e){var n,t,l,a,s,d,r,p;let u;u=null!=Bo&&Bo>-1?{components:null===(t=null===(n=M.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Bo].components,mapping:null===(a=null===(l=null==M?void 0:M.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Bo]}:Object.assign({},M);const c=null===(s=null==u?void 0:u.components)||void 0===s?void 0:s.findIndex((o=>{if("HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format)return!0}));if(void 0!==c&&c>-1&&(null==u?void 0:u.components[c])){const n=Object.assign(Object.assign({},u.components[c]),{format:e,example:{header_handle:[o]}}),t=[...u.components];t[c]=n,u=Object.assign(Object.assign({},u),{components:t})}u.mapping&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:void 0}));if(null!=Bo&&Bo>-1){const o=i(M);o.components[1].cards[Bo].components=u.components,(null===(d=null==o?void 0:o.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==o?void 0:o.mapping)||void 0===r?void 0:r.cards.length)>0&&(o.mapping.cards[Bo]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==I||I(Object.assign({},o)),Ko(!0)}else null==I||I(Object.assign({},u))},validateMimeType:qo,mediaComponent:xo?_o.imageComponent:Uo,fileRef:Ho}),[Yo,Ko]=a(!1),[Wo,$o]=a();function Go(o,e,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Bo&&Bo>-1?{components:null===(t=Object.assign({},M).components[1].cards)||void 0===t?void 0:t[Bo].components,mapping:null===(l=Object.assign({},M).mapping.cards)||void 0===l?void 0:l[Bo]}:Object.assign({},M),b=i(m),g="custom"===e&&"string"==typeof o,f=g?o:"string"!=typeof o?o.defaultValue?o.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Bo&&Bo>-1&&Mo){const e=Object.assign({},M).components.map((o=>{var e;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(e=o.cards)||void 0===e?void 0:e.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var e,t,i;if("BUTTONS"===o.type){const l=null===(e=o.buttons)||void 0===e?void 0:e.filter((o=>"URL"===o.type));let a=null!==(t=null==l?void 0:l[n])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=o.buttons)||void 0===i?void 0:i.map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==a?void 0:a.text)?a:o));return Object.assign(Object.assign({},o),{buttons:s})}return o}))})))}):o})),t=null===(s=null===(a=Object.assign({},M).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((e=>{var n;return Object.assign(Object.assign({},e),{buttons:null===(n=null==e?void 0:e.buttons)||void 0===n?void 0:n.map((e=>g?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:""))})})),l=i(M);return l.components=e,l.mapping.cards=t,void(null==I||I(Object.assign({},l)))}const h=null==b?void 0:b.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((o=>"URL"===o.type));if((null==t?void 0:t.length)>0){const i="custom"===e&&"string"==typeof o,l=i?o:"string"!=typeof o&&o.defaultValue?o.defaultValue:"https://d.bik.ai/";let a=t[n];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(u=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==u?u:[]].map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==a?void 0:a.text)?a:o)),d=Object.assign(Object.assign({},b.components[h]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[n]=i?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof o){"checkout.checkoutUrl"===(null===(v=o.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Po(!0):(Po(!1),null==w||w(""))}if(null!=Bo&&Bo>-1){const o=i(M);o.components[1].cards[Bo].components=b.components,o.mapping.cards[Bo]=b.mapping,null==I||I(Object.assign({},o))}else null==I||I(b)}function Xo(o,e,n){var t,l,a,s,d,r,p;const u=null!=Bo&&Bo>-1?{components:null===(t=Object.assign({},M).components[1].cards)||void 0===t?void 0:t[Bo].components,mapping:null===(l=Object.assign({},M).mapping.cards)||void 0===l?void 0:l[Bo]}:Object.assign({},M);if(null!=Bo&&Bo>-1&&Mo){const e=Object.assign({},M).components.map((e=>{var t;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(t=e.cards)||void 0===t?void 0:t.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var t,i,l;if("BUTTONS"===e.type){const a=null===(t=null==e?void 0:e.buttons)||void 0===t?void 0:t.filter((o=>"QUICK_REPLY"===o.type));let s=null!==(i=null==a?void 0:a[n])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:o.flowId,flowName:o.flowName});const d=null===(l=null==e?void 0:e.buttons)||void 0===l?void 0:l.map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==s?void 0:s.text)?s:o));return Object.assign(Object.assign({},e),{buttons:d})}return e}))})))}):e})),t=i(M);return t.components=e,void(null==I||I(Object.assign({},t)))}const c=null==u?void 0:u.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==c&&c>-1){const e=null===(s=null===(a=null==u?void 0:u.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((o=>"QUICK_REPLY"===o.type));if(e){let t=e[n];t=Object.assign(Object.assign({},t),{flowId:o.flowId,flowName:o.flowName});const i=[...null!==(p=null===(r=null===(d=u.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==t?void 0:t.text)?t:o)),l=Object.assign(Object.assign({},u.components[c]),{buttons:i}),a=[...u.components];a[c]=l,u.components=a}}if(null!=Bo&&Bo>-1){const o=i(M);o.components[1].cards[Bo].components=u.components,null==I||I(Object.assign({},o))}else null==I||I(u)}s((()=>{var o,e;if(null===(o=M.mapping.buttons)||void 0===o?void 0:o.find((o=>"checkout.checkoutUrl"===o.slice(2,-2))))Po(!0);else{Po(!1);const o=null===(e=null==Vo?void 0:Vo.discountCodeExtra)||void 0===e?void 0:e[1];null==o||o("")}}),[M]),s((()=>{var o,e,n,t;if(null!=Bo&&Bo>-1){const i={components:null===(e=null===(o=M.components[1])||void 0===o?void 0:o.cards)||void 0===e?void 0:e[Bo].components,mapping:null===(t=null===(n=null==M?void 0:M.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Bo]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Do({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Bo&&-1===Bo){const{descriptionComponents:o,urlBtns:e,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(M);Do({descriptionComponents:o,urlBtns:e,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Bo]),s((()=>{var o,e,n,t;if(null!=Bo&&Bo>-1&&Yo){const i={components:null===(e=null===(o=M.components[1])||void 0===o?void 0:o.cards)||void 0===e?void 0:e[Bo].components,mapping:null===(t=null===(n=null==M?void 0:M.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Bo]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Do({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Ko(!1)}}),[Yo]);const zo=xo?_o.imageComponent:Uo;return Fo.openEditMedia?o(y,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:o(j,{mediaComponentFormat:null!==(A=zo.format)&&void 0!==A?A:u.IMAGE,uploadMedia:Fo.uploadMedia,variableListForImage:U||[],useEditWhatsappTemplateMediaResponse:Fo,setOpenEditMedia:Fo.setOpenEditMedia,openEditMedia:Fo.openEditMedia,editIconRef:Fo.editIconRef,fileRef:Ho})})):e(y,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Mo?"420px":"auto"}},{children:[!!_o.imageComponent&&!Mo&&e(C,{children:[o(O,{imageName:null!==(_=null===(P=null==zo?void 0:zo.example)||void 0===P?void 0:P.header_handle)&&void 0!==_?_:[],handleImageChange:Fo.handleImageChange,mediaType:null==zo?void 0:zo.format,error:Fo.error,isLoading:Fo.loading,setOpenEditMedia:Fo.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(S=null===(D=null==zo?void 0:zo.example)||void 0===D?void 0:D.header_handle)||void 0===S?void 0:S[0])&&void 0!==Q?Q:"")?null===(F=null===(q=null==zo?void 0:zo.example)||void 0===q?void 0:q.header_handle)||void 0===F?void 0:F[0]:(null===(K=null===(Y=null==M?void 0:M.mapping)||void 0===Y?void 0:Y.header)||void 0===K?void 0:K[0])?null===($=null===(W=null==M?void 0:M.mapping)||void 0===W?void 0:W.header)||void 0===$?void 0:$[0]:Fo.selectedVariable}),(null==Uo?void 0:Uo.format)==u.DOCUMENT?o(k,{children:o(p,{labelText:"PDF Name",placeHolder:"Enter the name",pickerType:t.EMBEDDED,errorMessage:Wo||void 0,noMaxCharCheck:!0,allowMix:!1,onChange:o=>{$o("")},showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:"",variableType:"string"},variablesList:U})}):o(n,{})]}),(null===(G=_o.bodyVariables)||void 0===G?void 0:G.length)>0&&o(V,{containerStyle:{paddingTop:_o.mediaComponent?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===(X=_o.descriptionComponents)||void 0===X?void 0:X.map(((e,n)=>o(E,{originalVariableList:null!=Bo&&Bo>-1?yo.cards[Bo]:yo,type:e.type,descriptionComponent:e.component,showVariableModal:R},n))),(null===(Z=null===(J=null!=Bo&&Bo>-1?null===(z=yo.cards[Bo])||void 0===z?void 0:z.buttons:null==yo?void 0:yo.buttons)||void 0===J?void 0:J.filter((o=>"URL"===o.type)))||void 0===Z?void 0:Z.length)>0&&o(V,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(no=null===(eo=null!=Bo&&Bo>-1?null===(oo=yo.cards[Bo])||void 0===oo?void 0:oo.buttons:null==yo?void 0:yo.buttons)||void 0===eo?void 0:eo.filter((o=>Eo===c.CHATBOT||"URL"===o.type)))||void 0===no?void 0:no.map(((e,n)=>{const t=e.buttonVariable===m;if("URL"===e.type)return o(B,{variableListIndex:n,disableEdit:t,CTAoptions:null==L?void 0:L.CTAoptions,button:e,currentVariableList:null!=Bo&&Bo>-1?Object.assign({},yo.cards[Bo]):Object.assign({},yo),updateSelectedURLTemplateBtn:Go},`${n}_${Bo}`)})),Eo===c.CHATBOT&&(null===(io=null===(to=Ro[0])||void 0===to?void 0:to.component)||void 0===io?void 0:io.buttons)&&(null===(so=null===(ao=null===(lo=Ro[0])||void 0===lo?void 0:lo.component)||void 0===ao?void 0:ao.buttons)||void 0===so?void 0:so.length)>0&&o(f,{backTrackMessage:null===(ro=null==Vo?void 0:Vo.backTrackExtra)||void 0===ro?void 0:ro[0],setBackTrackMessage:null===(po=null==Vo?void 0:Vo.backTrackExtra)||void 0===po?void 0:po[1]}),(null===(vo=null===(co=null!=Bo&&Bo>-1?null===(uo=yo.cards[Bo])||void 0===uo?void 0:uo.buttons:null==yo?void 0:yo.buttons)||void 0===co?void 0:co.filter((o=>"QUICK_REPLY"===o.type)))||void 0===vo?void 0:vo.length)>0&&(Eo!==c.CHATBOT?o(V,{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"}):o(f,{backTrackMessage:null===(mo=null==Vo?void 0:Vo.backTrackExtra)||void 0===mo?void 0:mo[0],setBackTrackMessage:null===(bo=null==Vo?void 0:Vo.backTrackExtra)||void 0===bo?void 0:bo[1]})),null===(ho=null===(fo=null!=Bo&&Bo>-1?null===(go=yo.cards[Bo])||void 0===go?void 0:go.buttons:null==yo?void 0:yo.buttons)||void 0===fo?void 0:fo.filter((o=>"QUICK_REPLY"===o.type)))||void 0===ho?void 0:ho.map(((e,n)=>{if("QUICK_REPLY"===e.type&&Eo!==c.CHATBOT)return o(B,{variableListIndex:n,QRBoptions:null==L?void 0:L.QRBoptions,button:e,currentVariableList:null!=Bo&&Bo>-1?Object.assign({},yo.cards[Bo]):Object.assign({},yo),updateSelectedQRBTemplateBtn:Xo},`${n}_${Bo}`)})),Eo===c.CHATBOT&&Ao&&o(h,{discountCode:null===(jo=null==Vo?void 0:Vo.discountCodeExtra)||void 0===jo?void 0:jo[0],setDiscountCode:null===(Oo=null==Vo?void 0:Vo.discountCodeExtra)||void 0===Oo?void 0:Oo[1]}),null===(To=null!=Bo&&Bo>-1?null===(Co=yo.cards[Bo])||void 0===Co?void 0:Co.buttons:null==yo?void 0:yo.buttons)||void 0===To?void 0:To.map(((e,t)=>{var i,l,a,s,d;if("COPY_CODE"===e.type)return o(n,{children:ko?o("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:o(r,{state:"disabled",labelText:null!==(i=e.text)&&void 0!==i?i:"Copy Code",value:null!==(l=e.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):o(x,{index:t,variable:{variableName:null!==(a=e.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=e.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=e.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:e.type},t)})}))]}))},k=d.div`
|
|
2
2
|
padding-top: 24px;
|
|
3
3
|
padding-left: 10px;
|
|
4
4
|
padding-right: 10px;
|
|
5
5
|
margin-bottom: 8px;
|
|
6
6
|
line-height: normal;
|
|
7
|
-
`;export{
|
|
7
|
+
`;export{M 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{cloneDeep as l}from"lodash";import{useState as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{cloneDeep as l}from"lodash";import{useState as s,useEffect as a}from"react";import{Dropdown as n}from"../../dropdown/Dropdown.js";import{Input as i}from"../../input/Input.js";import{editableVarPattern as o}from"../../template-preview/constants/regexPatterns.js";import{STATIC_URL_CTA_OPTION as r,CUSTOM_URL_NAME as u}from"../../template-preview/models/TemplateMeta.js";import{POD as c}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as d}from"../../TypographyStyle.js";import{COLORS as b}from"../../../constants/Theme.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as m}from"../utils/constants.js";import{validateIsUrl as j}from"../utils/validateIsUrl.js";import v,{Container as g}from"./VariableConnector.js";const O=O=>{let{variableListIndex:f,button:x,updateSelectedURLTemplateBtn:y,updateSelectedQRBTemplateBtn:h,currentVariableList:L,CTAoptions:R,QRBoptions:U,disableEdit:V}=O;var T,w,C,I,E;const[P,H]=s(""),[N,B]=s(),_=null==R?void 0:R.map((e=>Object.assign(Object.assign({},e),{selected:(null==N?void 0:N.value)===e.value}))),Q=null==U?void 0:U.map((e=>Object.assign(Object.assign({},e),{selected:(null==N?void 0:N.value)===e.value}))),{isError:k,disableEditVariable:S,pod:K,selectedCarouselIndex:Y,originalVariableList:$,setOriginalVariableList:q,isProductCarouselType:A,ctaOptionsErrors:M,setCtaOptionsErrors:D}=p();function W(e){if(H(e),null!=Y&&Y>-1&&A){const t=l($);if("URL"===x.type){const l=t.cards.map((t=>{let l=t.buttons.filter((e=>"URL"===e.type))[f];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=t.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},t),{buttons:s})}));null==q||q((e=>Object.assign(Object.assign({},e),{cards:l}))),null==y||y(`https://${e}`,"custom",f)}return}let t=L.buttons.filter((e=>"URL"===e.type))[f];t=Object.assign(Object.assign({},t),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=L.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),a=Object.assign({},null!=Y&&Y>-1?$.cards[Y]:$);if(a.buttons=s,null!=Y&&Y>-1){const e=[...$.cards];e[Y]=a,null==q||q((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==q||q((e=>Object.assign(Object.assign({},e),{buttons:[...s]})));null==y||y(`https://${e}`,"custom",f)}return a((()=>{var e;if(x.buttonVariable&&o.test(x.buttonVariable))x.buttonVariable===m?B(r):B(u),H((null===(e=x.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===x.type?R:U;e="URL"===x.type?t.findIndex((e=>e.placeHolder===x.buttonVariable)):t.findIndex((e=>e.label===x.flowName)),e>-1?B(t[e]):null==D||D((e=>Object.assign(Object.assign({},e),{[f]:"Required field!"})))}}),[]),K!==c.CHATBOT?e(g,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(d,Object.assign({style:{color:b.content.primary}},{children:[x.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(n,{disabled:S||V,truncatedText:!1,options:"URL"===x.type?"static_link"===(null==N?void 0:N.value)?[r]:_:Q,isSearchable:!0,onSelect:function(e,t){null==D||D((e=>(delete e[f],Object.assign({},e))));const s=e;B(s);const a=("URL"===x.type?R:U).find((e=>e.placeHolder===s.placeHolder));if(a)if("custom_link"!==a.value){if(null!=Y&&Y>-1&&A){const e=l($);if("URL"===x.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"URL"===e.type))[f];t=Object.assign(Object.assign({},t),{buttonVariable:s.placeHolder});const l=e.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==y||y({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder",f),null==q||q((e=>Object.assign(Object.assign({},e),{cards:t})))}else if("QUICK_REPLY"===x.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"QUICK_REPLY"===e.type))[f];t=Object.assign(Object.assign({},t),{flowName:s.label,flowId:s.value});const l=e.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==h||h({flowName:s.label,flowId:s.value},"placeholder",f),null==q||q((e=>Object.assign(Object.assign({},e),{cards:t})))}return}let e;if("URL"===x.type){let t=L.buttons.filter((e=>"URL"===e.type))[f];t=Object.assign(Object.assign({},t),{buttonVariable:s.placeHolder,example:[(null==s?void 0:s.value)||"https://d.bik.ai/"]}),e=L.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==y||y({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder",f)}else{let t=L.buttons.filter((e=>"QUICK_REPLY"===e.type))[f];t=Object.assign(Object.assign({},t),{flowName:s.label,flowId:s.value}),e=L.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==h||h({flowName:s.label,flowId:s.value},"placeholder",f)}const t=Object.assign({},null!=Y&&Y>-1?$.cards[Y]:$);if(t.buttons=e,null!=Y&&Y>-1){const e=[...$.cards];e[Y]=t,null==q||q((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==q||q((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else W("")},defaultOptions:N?[Object.assign(Object.assign({},N),{selected:!0})]:[],error:k?null==M?void 0:M[f]:void 0})})),("custom_link"===(null==N?void 0:N.value)||"static_link"===(null==N?void 0:N.value))&&t("div",Object.assign({style:{marginBottom:20}},{children:t(i,{state:S||V?"disabled":"none",errorMessage:k?P?j(P)?"":"Enter valid URL":"Required field":"",value:P,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:W,maxCharLimit:2e3})}))]}):t(v,{index:f,variable:{variableName:null!==(T=x.text)&&void 0!==T?T:"",updatedValue:"((customPlaceholderName))"===x.buttonVariable?`${null===(w=x.example)||void 0===w?void 0:w[0]}`:null!==(C=x.buttonVariable)&&void 0!==C?C:"",type:"link",isEditableVariable:!0,index:null!==(I=x.index)&&void 0!==I?I:0,queryParams:null!==(E=x.queryParams)&&void 0!==E?E:[]},showVariableModal:!0,componentType:"BUTTONS",buttonType:x.type,CTAoptions:R})};export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E,D,N,I;!function(E){E.SEND_GRID="sendgrid",E.BEE="bee"}(E||(E={})),function(E){E.APPROVED="APPROVED",E.DISABLED="DISABLED",E.FLAGGED="FLAGGED",E.PENDING="PENDING",E.DRAFT="DRAFT",E.REJECTED="REJECTED",E.PENDING_DELETION="PENDING_DELETION",E.IN_REVIEW="IN REVIEW",E.PAUSED="PAUSED",E.ACTIVE="ACTIVE",E.LIBRARY="LIBRARY"}(D||(D={})),function(E){E.NONE="NONE",E.TEXT="TEXT",E.IMAGE="IMAGE",E.VIDEO="VIDEO",E.DOCUMENT="DOCUMENT"}(N||(N={})),function(E){E.NONE="NONE",E.CTA_BTN="CTA_BTN",E.QUICK_REPLY="QUICK_REPLY"}(I||(I={}));const A={value:"custom_link",label:"Custom URL",placeHolder:"custom placeholder"},T={label:"
|
|
1
|
+
var E,D,N,I;!function(E){E.SEND_GRID="sendgrid",E.BEE="bee"}(E||(E={})),function(E){E.APPROVED="APPROVED",E.DISABLED="DISABLED",E.FLAGGED="FLAGGED",E.PENDING="PENDING",E.DRAFT="DRAFT",E.REJECTED="REJECTED",E.PENDING_DELETION="PENDING_DELETION",E.IN_REVIEW="IN REVIEW",E.PAUSED="PAUSED",E.ACTIVE="ACTIVE",E.LIBRARY="LIBRARY"}(D||(D={})),function(E){E.NONE="NONE",E.TEXT="TEXT",E.IMAGE="IMAGE",E.VIDEO="VIDEO",E.DOCUMENT="DOCUMENT"}(N||(N={})),function(E){E.NONE="NONE",E.CTA_BTN="CTA_BTN",E.QUICK_REPLY="QUICK_REPLY"}(I||(I={}));const A={value:"custom_link",label:"Custom URL",placeHolder:"custom placeholder"},T={label:"Custom URL (No tracking)",value:"static_link",placeHolder:"{{staticUrl}}"};export{I as ACTIONS_TYPES,A as CUSTOM_URL_NAME,N as HEADER_TYPES,T as STATIC_URL_CTA_OPTION,E as TEMPLATE_EDITOR,D as TEMPLATE_STATUS};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.validateInputName=e=>!!/[^a-zA-Z0-9._ ]/.test(e);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const t=t=>!!/[^a-zA-Z0-9._ ]/.test(t);export{t as validateInputName};
|