@bikdotai/bik-component-library 0.0.513 → 0.0.514-beta-dropdwon
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/assets/icons/emoji.svg.js +1 -1
- package/dist/cjs/assets/icons/halfRectangle.svg.js +1 -1
- package/dist/cjs/assets/icons/strikeThrough.svg.js +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
- package/dist/cjs/components/QueryBuilder/components/Connectors/Components/SingleDate.js +1 -1
- package/dist/cjs/components/QueryBuilder/components/Connectors/Components/TwoDate.js +1 -1
- package/dist/cjs/components/SearchFilter/components/DatePickerButton.js +1 -1
- package/dist/cjs/components/SearchFilter/components/DateRangeOnlyButton.js +1 -1
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +0 -4
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsDropdown.d.ts +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.d.ts +10 -0
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.styled.d.ts +1 -0
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.styled.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/custom-date-time/DateSelector/DateSelector.js +1 -1
- package/dist/cjs/components/datePicker/DatePickerWrapper.d.ts +2 -1
- package/dist/cjs/components/datePicker/DatePickerWrapper.js +1 -1
- package/dist/cjs/components/datePicker/index.d.ts +0 -1
- package/dist/cjs/components/discount-modal/StaticCoupon/StaticCoupon.js +1 -1
- package/dist/cjs/components/dropdown/Dropdown.js +1 -1
- package/dist/cjs/components/dropdown/DropdownPopover/index.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/cjs/components/dropdown/type.d.ts +0 -1
- package/dist/cjs/components/helpers/FileUploaderHelper.d.ts +1 -1
- package/dist/cjs/components/helpers/FileUploaderHelper.js +1 -1
- package/dist/cjs/components/image-cropper/BikImageCropper.d.ts +1 -1
- package/dist/cjs/components/image-cropper/BikImageCropper.js +1 -1
- package/dist/cjs/components/input/Input.d.ts +0 -1
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/input/Input.styled.js +1 -1
- package/dist/cjs/components/input-with-vars/InputWithVariables.d.ts +0 -1
- package/dist/cjs/components/input-with-vars/InputWithVariables.js +1 -1
- package/dist/cjs/components/modals/styledModal.d.ts +0 -1
- package/dist/cjs/components/modals/styledModal.js +1 -1
- package/dist/cjs/components/radioButton/RadioButton.d.ts +0 -1
- package/dist/cjs/components/radioButton/RadioButton.js +1 -1
- package/dist/cjs/components/spinner/Spinner.d.ts +0 -6
- package/dist/cjs/components/spinner/Spinner.js +1 -18
- package/dist/cjs/components/states/StateComponent.d.ts +0 -2
- package/dist/cjs/components/states/StateComponent.js +1 -1
- package/dist/cjs/components/states/StateComponent.styled.d.ts +1 -4
- package/dist/cjs/components/states/StateComponent.styled.js +6 -6
- package/dist/cjs/components/states-modal/StateModalComponent.d.ts +0 -2
- package/dist/cjs/components/states-modal/StateModalComponent.js +1 -1
- package/dist/cjs/components/stepper/Stepper.d.ts +0 -2
- package/dist/cjs/components/stepper/Stepper.js +1 -1
- package/dist/cjs/components/stepper/Stepper.styled.d.ts +0 -1
- package/dist/cjs/components/stepper/Stepper.styled.js +7 -7
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +1 -6
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/cjs/components/template-context-mapper/context/templateModalContext.d.ts +0 -10
- package/dist/cjs/components/template-context-mapper/modalElements/Body.js +6 -9
- package/dist/cjs/components/template-context-mapper/modalElements/DesktopPreview.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.d.ts +0 -4
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.d.ts +1 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.js +5 -6
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.style.js +5 -6
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts +11 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/MobilePreview.js +4 -9
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +1 -1
- package/dist/cjs/components/template-context-mapper/utils/validateIsUrl.d.ts +0 -1
- package/dist/cjs/components/template-context-mapper/utils/validateIsUrl.js +1 -1
- package/dist/cjs/components/template-preview/EmailTemplatePreview.styled.js +14 -16
- package/dist/cjs/components/template-preview/SmsTemplatePreview.js +1 -1
- package/dist/cjs/components/template-preview/WhatsApp/ChatUI.js +1 -1
- package/dist/cjs/components/template-preview/WhatsApp/ChatUI.style.d.ts +0 -4
- package/dist/cjs/components/template-preview/WhatsApp/ChatUI.style.js +6 -8
- package/dist/cjs/components/template-preview/WhatsApp/ChatUiV2.js +1 -1
- package/dist/cjs/components/template-preview/WhatsApp/WhatsAppLikePreviewV2.js +5 -5
- package/dist/cjs/hooks/useOutside.d.ts +1 -1
- package/dist/cjs/hooks/useOutside.js +1 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/assets/icons/emoji.svg.js +1 -1
- package/dist/esm/assets/icons/halfRectangle.svg.js +1 -1
- package/dist/esm/assets/icons/strikeThrough.svg.js +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
- package/dist/esm/components/QueryBuilder/components/Connectors/Components/SingleDate.js +1 -1
- package/dist/esm/components/QueryBuilder/components/Connectors/Components/TwoDate.js +1 -1
- package/dist/esm/components/SearchFilter/components/DatePickerButton.js +1 -1
- package/dist/esm/components/SearchFilter/components/DateRangeOnlyButton.js +1 -1
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +0 -4
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsDropdown.d.ts +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.d.ts +10 -0
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.styled.d.ts +1 -0
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.styled.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/custom-date-time/DateSelector/DateSelector.js +1 -1
- package/dist/esm/components/datePicker/DatePickerWrapper.d.ts +2 -1
- package/dist/esm/components/datePicker/DatePickerWrapper.js +1 -1
- package/dist/esm/components/datePicker/index.d.ts +0 -1
- package/dist/esm/components/discount-modal/StaticCoupon/StaticCoupon.js +1 -1
- package/dist/esm/components/dropdown/Dropdown.js +1 -1
- package/dist/esm/components/dropdown/DropdownPopover/index.js +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/esm/components/dropdown/type.d.ts +0 -1
- package/dist/esm/components/helpers/FileUploaderHelper.d.ts +1 -1
- package/dist/esm/components/helpers/FileUploaderHelper.js +1 -1
- package/dist/esm/components/image-cropper/BikImageCropper.d.ts +1 -1
- package/dist/esm/components/image-cropper/BikImageCropper.js +1 -1
- package/dist/esm/components/input/Input.d.ts +0 -1
- package/dist/esm/components/input/Input.js +1 -1
- package/dist/esm/components/input/Input.styled.js +1 -1
- package/dist/esm/components/input-with-vars/InputWithVariables.d.ts +0 -1
- package/dist/esm/components/input-with-vars/InputWithVariables.js +1 -1
- package/dist/esm/components/modals/styledModal.d.ts +0 -1
- package/dist/esm/components/modals/styledModal.js +1 -1
- package/dist/esm/components/radioButton/RadioButton.d.ts +0 -1
- package/dist/esm/components/radioButton/RadioButton.js +1 -1
- package/dist/esm/components/spinner/Spinner.d.ts +0 -6
- package/dist/esm/components/spinner/Spinner.js +1 -18
- package/dist/esm/components/states/StateComponent.d.ts +0 -2
- package/dist/esm/components/states/StateComponent.js +1 -1
- package/dist/esm/components/states/StateComponent.styled.d.ts +1 -4
- package/dist/esm/components/states/StateComponent.styled.js +6 -6
- package/dist/esm/components/states-modal/StateModalComponent.d.ts +0 -2
- package/dist/esm/components/states-modal/StateModalComponent.js +1 -1
- package/dist/esm/components/stepper/Stepper.d.ts +0 -2
- package/dist/esm/components/stepper/Stepper.js +1 -1
- package/dist/esm/components/stepper/Stepper.styled.d.ts +0 -1
- package/dist/esm/components/stepper/Stepper.styled.js +6 -6
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +1 -6
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/esm/components/template-context-mapper/context/templateModalContext.d.ts +0 -10
- package/dist/esm/components/template-context-mapper/modalElements/Body.js +9 -12
- package/dist/esm/components/template-context-mapper/modalElements/DesktopPreview.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.d.ts +0 -4
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.d.ts +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.js +5 -6
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.style.js +3 -4
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts +11 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
- package/dist/esm/components/template-context-mapper/modalElements/MobilePreview.js +4 -9
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
- package/dist/esm/components/template-context-mapper/utils/validateIsUrl.d.ts +0 -1
- package/dist/esm/components/template-context-mapper/utils/validateIsUrl.js +1 -1
- package/dist/esm/components/template-preview/EmailTemplatePreview.styled.js +0 -2
- package/dist/esm/components/template-preview/SmsTemplatePreview.js +1 -1
- package/dist/esm/components/template-preview/WhatsApp/ChatUI.js +2 -2
- package/dist/esm/components/template-preview/WhatsApp/ChatUI.style.d.ts +0 -4
- package/dist/esm/components/template-preview/WhatsApp/ChatUI.style.js +18 -20
- package/dist/esm/components/template-preview/WhatsApp/ChatUiV2.js +4 -4
- package/dist/esm/components/template-preview/WhatsApp/WhatsAppLikePreviewV2.js +5 -5
- package/dist/esm/hooks/useOutside.d.ts +1 -1
- package/dist/esm/hooks/useOutside.js +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/assets/icons/broken_media_image.svg.js +0 -1
- package/dist/cjs/assets/icons/similar.svg.js +0 -1
- package/dist/cjs/components/action-button/ActionButton.styled.d.ts +0 -7
- package/dist/cjs/components/action-button/ActionButton.styled.js +0 -23
- package/dist/cjs/components/action-button/ActionButtons.d.ts +0 -10
- package/dist/cjs/components/action-button/ActionButtons.js +0 -1
- package/dist/cjs/components/action-button/index.d.ts +0 -1
- package/dist/cjs/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.d.ts +0 -29
- package/dist/cjs/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.js +0 -1
- package/dist/cjs/components/template-context-mapper/utils/constants.d.ts +0 -1
- package/dist/cjs/components/template-context-mapper/utils/constants.js +0 -1
- package/dist/esm/assets/icons/broken_media_image.svg.js +0 -1
- package/dist/esm/assets/icons/similar.svg.js +0 -1
- package/dist/esm/components/action-button/ActionButton.styled.d.ts +0 -7
- package/dist/esm/components/action-button/ActionButton.styled.js +0 -23
- package/dist/esm/components/action-button/ActionButtons.d.ts +0 -10
- package/dist/esm/components/action-button/ActionButtons.js +0 -1
- package/dist/esm/components/action-button/index.d.ts +0 -1
- package/dist/esm/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.d.ts +0 -29
- package/dist/esm/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.js +0 -1
- package/dist/esm/components/template-context-mapper/utils/constants.d.ts +0 -1
- package/dist/esm/components/template-context-mapper/utils/constants.js +0 -1
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("styled-components"),l=require("../../carousel-preview/CarouselPreview.js"),i=require("./EditWhatsAppCarouselTemplateV2.js"),o=require("../../template-preview/models/Channels.js"),s=require("../../../constants/Theme.js"),r=require("../context/templateModalContext.js"),n=require("../utils/getVariableNameEmail.js"),u=require("../utils/highlightFor.js"),d=require("./DesktopPreview.js"),p=require("./EditWhatsAppTemplateV2.js"),c=require("./MobilePreview.js"),h=require("./VariableConnectorsPanel.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=m(a);const v=f.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
// height: 100%;
|
|
4
|
-
`,
|
|
4
|
+
`,C=f.default.div`
|
|
5
5
|
padding: 16px 14px;
|
|
6
|
-
max-width:
|
|
6
|
+
max-width: 450px;
|
|
7
7
|
|
|
8
8
|
height: ${e=>e.channel===o.CHANNEL_TYPE.WHATSAPP?"500px":"475px"};
|
|
9
9
|
overflow-y: auto;
|
|
10
10
|
padding-bottom: 24px;
|
|
11
11
|
border-left: ${s.COLORS.stroke.primary} 1px solid;
|
|
12
12
|
border-top: ${e=>e.isWhatsappCarousel?`${s.COLORS.stroke.primary} 1px solid`:void 0};
|
|
13
|
-
|
|
14
|
-
`,P=f.default.div`
|
|
13
|
+
`,x=f.default.div`
|
|
15
14
|
padding: ${e=>e.isWhatsappCarousel?void 0:e.showOnlyContent?"16px 14px":"16px 32px"};
|
|
16
15
|
flex: 1;
|
|
17
|
-
height: ${e=>e.isWhatsappCarousel
|
|
16
|
+
height: ${e=>e.isWhatsappCarousel?"500px":"475px"};
|
|
18
17
|
overflow-y: auto;
|
|
19
|
-
|
|
20
|
-
display: ${e=>e.hideDeviceContainerInPreview&&e.channel===o.CHANNEL_TYPE.WHATSAPP?"flex":"initial"};
|
|
21
|
-
`;exports.default=i=>{const{showVariableMapping:d,showOnlyContent:v,whatsappSpecificPickerMeta:f,showVariableModal:g,variableList:E,discountCode:b,setDiscountCode:j,variableListForImage:A,showSampleValues:y,fileName:N,setFileName:T}=i,L=t.useRef(),S=t.useRef(),{device:_,display_content:M,channel:O,template:V,setTemplate:W,isWhatsappCarousel:I,isProductCarouselType:q,hideDeviceContainerInPreview:H}=r.useTemplateModalContext();const k=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(w,{children:[e.jsx(P,Object.assign({showOnlyContent:v,showVariableMapping:d,isWhatsappCarousel:I,hideDeviceContainerInPreview:H,channel:O},{children:"mobile"===_?e.jsx(m.default,{ref:S,display_content:null!=M?M:"",channel:O,template:V,showSampleValues:y}):O===o.CHANNEL_TYPE.WHATSAPP&&I?e.jsx(a.CarouselPreview,{ref:L,channel:O,template:V,showSampleValues:y,isPreview:!1}):O!==o.CHANNEL_TYPE.MESSAGE?e.jsx(c.default,{ref:L,channel:O,display_content:null!=M?M:"",showSampleValues:y}):e.jsx(e.Fragment,{})})),(q||d)&&e.jsx(x,Object.assign({channel:O,isWhatsappCarousel:I,showVariableMapping:!0},{children:O!==o.CHANNEL_TYPE.WHATSAPP?e.jsx(C.default,{onFocus:O===o.CHANNEL_TYPE.EMAIL?function(e){var t,i,a;const l=null===document||void 0===document?void 0:document.getElementById("mobile"===_?"template_html_mobile":"template_html_desktop"),n=p.getVariableNameForEmailByIndex(e+1),r=O===o.CHANNEL_TYPE.EMAIL?null===(t=null==l?void 0:l.contentWindow)||void 0===t?void 0:t.document.getElementById(n):document.getElementById(n),d=k(r),c=null==r?void 0:r.offsetLeft;"desktop"===_?d&&L.current&&(null===(i=null==l?void 0:l.contentWindow)||void 0===i||i.scrollTo(null!=c?c:0,d),u.highlightFor(n,s.COLORS.background.warning.light,2,O,_)):d&&S.current&&(null===(a=null==l?void 0:l.contentWindow)||void 0===a||a.scrollTo(null!=c?c:0,d),u.highlightFor(n,s.COLORS.background.warning.light,2,O,_))}:void 0,showVariableModal:g,variableList:E,discountCode:b,setDiscountCode:j}):O===o.CHANNEL_TYPE.WHATSAPP&&I?e.jsx(l.default,{whatsappSpecificPickerMeta:f,template:V,showVariableModal:g,variableList:E,variableListForImage:A,discountCode:b,setDiscountCode:j}):e.jsx(h.default,{whatsappSpecificPickerMeta:f,template:V,onTemplateChange:e=>{null==W||W(e)},showVariableModal:g,variableList:E,variableListForImage:A,discountCode:b,setDiscountCode:j,fileName:N,setFileName:T})})),!d&&!q&&e.jsx(x,{children:e.jsx(n.BodySecondary,Object.assign({color:s.COLORS.content.secondary,style:{fontStyle:"italic"}},{children:"Click on ‘Select template’ below to use it"}))})]})};
|
|
18
|
+
`;exports.default=a=>{const{showVariableMapping:m,showOnlyContent:f,whatsappSpecificPickerMeta:g,showVariableModal:w,variableList:b,discountCode:P,setDiscountCode:j,variableListForImage:E,showSampleValues:L,fileName:T,setFileName:A}=a,N=t.useRef(),y=t.useRef(),{device:S,display_content:M,channel:_,template:V,setTemplate:W,isWhatsappCarousel:q,isProductCarouselType:O}=r.useTemplateModalContext();const F=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(v,{children:[e.jsx(x,Object.assign({showOnlyContent:f,showVariableMapping:m,isWhatsappCarousel:q},{children:"mobile"===S?e.jsx(c.default,{ref:y,display_content:null!=M?M:"",channel:_,template:V,showSampleValues:L}):_===o.CHANNEL_TYPE.WHATSAPP&&q?e.jsx(l.CarouselPreview,{ref:N,channel:_,template:V,showSampleValues:L,isPreview:!1}):_!==o.CHANNEL_TYPE.MESSAGE?e.jsx(d.default,{ref:N,channel:_,display_content:null!=M?M:"",showSampleValues:L}):e.jsx(e.Fragment,{})})),(O||m)&&e.jsx(C,Object.assign({channel:_,isWhatsappCarousel:q},{children:_!==o.CHANNEL_TYPE.WHATSAPP?e.jsx(h.default,{onFocus:_===o.CHANNEL_TYPE.EMAIL?function(e){var t,a,l;const i=null===document||void 0===document?void 0:document.getElementById("mobile"===S?"template_html_mobile":"template_html_desktop"),r=n.getVariableNameForEmailByIndex(e+1),d=_===o.CHANNEL_TYPE.EMAIL?null===(t=null==i?void 0:i.contentWindow)||void 0===t?void 0:t.document.getElementById(r):document.getElementById(r),p=F(d),c=null==d?void 0:d.offsetLeft;"desktop"===S?p&&N.current&&(null===(a=null==i?void 0:i.contentWindow)||void 0===a||a.scrollTo(null!=c?c:0,p),u.highlightFor(r,s.COLORS.background.warning.light,2,_,S)):p&&y.current&&(null===(l=null==i?void 0:i.contentWindow)||void 0===l||l.scrollTo(null!=c?c:0,p),u.highlightFor(r,s.COLORS.background.warning.light,2,_,S))}:void 0,showVariableModal:w,variableList:b,discountCode:P,setDiscountCode:j}):_===o.CHANNEL_TYPE.WHATSAPP&&q?e.jsx(i.default,{whatsappSpecificPickerMeta:g,template:V,showVariableModal:w,variableList:b,variableListForImage:E,discountCode:P,setDiscountCode:j}):e.jsx(p.default,{whatsappSpecificPickerMeta:g,template:V,onTemplateChange:e=>{null==W||W(e)},showVariableModal:w,variableList:b,variableListForImage:E,discountCode:P,setDiscountCode:j,fileName:T,setFileName:A})}))]})};
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
height: 6px;
|
|
18
18
|
background: #d9d9d9;
|
|
19
19
|
border-radius: 3px;
|
|
20
|
-
`,h=d.default.forwardRef(((r,t)=>{let{display_content:s,showSampleValues:l}=r;return e.jsxs(n,Object.assign({ref:t},{children:[e.jsxs(u,{children:[e.jsx(m,{}),e.jsx(m,{}),e.jsx(m,{})]}),e.jsx("div",{children:s?e.jsx(a.TemplatePreview,{showSampleValues:l,channel:p.CHANNEL_TYPE.EMAIL,hideHeader:!0,emailSpecificMeta:{emailDisplayContent:s,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_desktop",containerStyle:{height:441},templateContainerStyles:{height:"100%"}}}):e.jsx("div",Object.assign({style:{padding:20}},{children:e.jsx(i.Spinner,{size:"small"})}))})]}))}));h.displayName="DesktopPreview",exports.default=h;
|
|
20
|
+
`,h=d.default.forwardRef(((r,t)=>{let{display_content:s,showSampleValues:l}=r;return e.jsxs(n,Object.assign({ref:t},{children:[e.jsxs(u,{children:[e.jsx(m,{}),e.jsx(m,{}),e.jsx(m,{})]}),e.jsx("div",{children:s?e.jsx(a.TemplatePreview,{showSampleValues:l,channel:p.CHANNEL_TYPE.EMAIL,hideHeader:!0,emailSpecificMeta:{emailDisplayContent:s,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_desktop",containerStyle:{width:584,height:441},templateContainerStyles:{height:"100%"}}}):e.jsx("div",Object.assign({style:{padding:20}},{children:e.jsx(i.Spinner,{size:"small"})}))})]}))}));h.displayName="DesktopPreview",exports.default=h;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { VariableListInterfaceV2 } from "../../add-variableV2";
|
|
3
3
|
import { HEADER_TYPES } from "../../template-preview";
|
|
4
|
-
import { UseEditWhatsappTemplateMediaResponse } from './useEditWhtasappTemplateMedia';
|
|
5
4
|
declare const EditMediaModal: React.FC<{
|
|
6
5
|
setOpenEditMedia: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
6
|
openEditMedia: boolean;
|
|
8
7
|
mediaComponentFormat: HEADER_TYPES;
|
|
9
8
|
variableListForImage: VariableListInterfaceV2[];
|
|
10
9
|
uploadMedia: (urlOrVariable?: string) => void;
|
|
11
|
-
editIconRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
12
|
-
fileRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
13
|
-
useEditWhatsappTemplateMediaResponse: UseEditWhatsappTemplateMediaResponse;
|
|
14
10
|
}>;
|
|
15
11
|
export default EditMediaModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../button/Button.js"),a=require("../../input-with-vars/InputWithVariables.js"),s=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");require("../../curtain/CurtainHelper.js");var r=require("../../template-preview/models/TemplateMeta.js"),l=require("../../template-preview/models/WhatsAppTemplate.js"),d=require("../../TypographyStyle.js"),o=require("../../../assets/icons/file.svg.js"),n=require("../../../assets/icons/filePdf.svg.js"),u=require("../../../assets/icons/image.svg.js"),c=require("../../../assets/icons/upload.svg.js"),p=require("../context/templateModalContext.js");exports.default=h=>{let{setOpenEditMedia:j,mediaComponentFormat:x,variableListForImage:g,openEditMedia:m,uploadMedia:E}=h;const{pod:b}=p.useTemplateModalContext();return e.jsx(s.StyledModal,Object.assign({open:m,zIndex:2e3,onClose:()=>j(!1),width:"440px"},{children:e.jsxs("div",Object.assign({style:{padding:24,borderRadius:4}},{children:[e.jsx(d.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:x===r.HEADER_TYPES.IMAGE?e.jsx(u.default,{width:40,height:40}):x===r.HEADER_TYPES.VIDEO?e.jsx(o.default,{width:40,height:40}):e.jsx(n.default,{width:40,height:40})})),e.jsx(d.TitleMedium,{children:x===r.HEADER_TYPES.IMAGE?"Upload an image":x===r.HEADER_TYPES.VIDEO?"Upload a video":"Upload a document"}),e.jsx(d.BodySecondary,{children:x===r.HEADER_TYPES.IMAGE?"JPEG/ PNG format • Max 5MB":x===r.HEADER_TYPES.VIDEO?"MP4 format video • Max 16MB":"PDF format a document • Max 100MB"})]})),e.jsxs("div",Object.assign({style:{marginBottom:16}},{children:[e.jsx(d.BodyRegular,{children:"Media"}),e.jsx(a.InputWithVariables,{noMaxCharCheck:!0,allowMix:!1,onChange:()=>{},prevVariable:{actualValue:"",variableType:"string"},variablesList:g,showSideVariablePanel:!0,placeHolder:"Enter URL or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&E(t.actualValue)},showAddButton:b!==l.POD.CAMPAIGN||x===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(d.BodyCaption,Object.assign({style:{flex:1}},{children:"Or upload media 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:c.default,onClick:()=>E()})}))]}))]}))}))};
|
|
@@ -8,6 +8,7 @@ export interface EditMediaV2Props {
|
|
|
8
8
|
isLoading?: boolean;
|
|
9
9
|
mediaType?: HEADER_TYPES;
|
|
10
10
|
handleImageChange?: () => void;
|
|
11
|
+
disableEditVariable?: boolean;
|
|
11
12
|
setOpenEditMedia?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
13
|
}
|
|
13
14
|
declare const EditMediaV2: (props: EditMediaV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,8 @@
|
|
|
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"),i=require("../../../assets/icons/document_pdf.svg.js"),t=require("../../../assets/icons/edit.svg.js"),s=require("../../../assets/icons/refresh.svg.js"),r=require("styled-components"),n=require("../../shimmer-image/ShimmerImage.js"),l=require("../../spinner/Spinner.js"),o=require("../../template-preview/models/TemplateMeta.js"),a=require("../../TypographyStyle.js"),d=require("../../../utils/StringUtils.js"),c=require("../../../constants/Theme.js"),u=require("./EditMediaV2.style.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const h=g(r).default.div`
|
|
2
2
|
padding-left: 14px;
|
|
3
3
|
padding-right: 6px;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
width: 44px;
|
|
5
|
+
height: 24px;
|
|
6
|
+
border-left: 1px solid ${c.COLORS.stroke.primary};
|
|
6
7
|
cursor: pointer;
|
|
7
|
-
|
|
8
|
-
align-items: center;
|
|
9
|
-
`;exports.default=n=>{const{imageName:j,error:m,isLoading:x,mediaType:y,selectedVariable:O,setOpenEditMedia:f}=n,v=null==j?void 0:j[0].split("/"),C=null==v?void 0:v[v.length-1],{disableEditVariable:b}=u.useTemplateModalContext();return e.jsxs(h.Container,{children:[e.jsx(h.ImageContainer,Object.assign({error:!!m,onClick:()=>null==f?void 0:f(!0)},{children:m?e.jsx(t.default,{width:56,height:56}):x?e.jsx(o.Spinner,{size:"small"}):y===a.HEADER_TYPES.IMAGE?e.jsx(l.ShimmerImage,{imageUrl:null==j?void 0:j[0],width:56,height:56}):y===a.HEADER_TYPES.VIDEO?e.jsx("video",Object.assign({src:j[0],style:{width:56,height:56}},{children:e.jsx("track",{default:!0,kind:"captions",srcLang:"en",src:j[0]})})):e.jsx(i.default,{width:18,height:22,color:g.COLORS.content.placeholder})})),e.jsxs(h.RightComponent,{children:[e.jsx("div",Object.assign({style:{flex:m?"unset":1}},{children:j&&m?e.jsx(e.Fragment,{}):x?e.jsx(d.BodyCaption,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):e.jsx(d.BodySecondary,Object.assign({style:{color:g.COLORS.content.primary,marginLeft:8}},{children:O||c.default.toCapitilize(null==y?void 0:y.toLowerCase())||C}))})),!!m&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8,gap:"2px"}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:g.COLORS.content.negative}},{children:["Error loading this ",null==y?void 0:y.toLowerCase(),". Retry"]})),e.jsx(d.Caption,Object.assign({style:{color:g.COLORS.content.secondary}},{children:m}))]}))]}),!b&&!x&&e.jsx(p,Object.assign({onClick:()=>null==f?void 0:f(!0),onKeyDown:()=>null==f?void 0:f(!0),role:"presentation"},{children:m?e.jsx(r.default,{color:g.COLORS.content.brand,width:24,height:24}):e.jsx(s.default,{width:24,height:24,color:g.COLORS.content.placeholder})}))]})};
|
|
8
|
+
`;exports.default=r=>{const{imageName:g,error:j,isLoading:p,mediaType:m,disableEditVariable:x,selectedVariable:y,setOpenEditMedia:O}=r,f=null==g?void 0:g[0].split("/"),v=null==f?void 0:f[f.length-1];return e.jsxs(u.Container,{children:[e.jsx(u.ImageContainer,Object.assign({error:!!j,onClick:()=>null==O?void 0:O(!0)},{children:j?e.jsx(s.default,{color:c.COLORS.content.brand,width:32,height:32}):p?e.jsx(l.Spinner,{size:"small"}):m===o.HEADER_TYPES.IMAGE?e.jsx(n.ShimmerImage,{imageUrl:null==g?void 0:g[0],width:56,height:56}):m===o.HEADER_TYPES.VIDEO?e.jsx("video",Object.assign({src:g[0],style:{width:56,height:56}},{children:e.jsx("track",{default:!0,kind:"captions",srcLang:"en",src:g[0]})})):e.jsx(i.default,{width:18,height:22,color:c.COLORS.content.placeholder})})),e.jsxs(u.RightComponent,{children:[e.jsx("div",Object.assign({style:{flex:j?"unset":1}},{children:g&&j?e.jsx(e.Fragment,{}):p?e.jsx(a.BodyCaption,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):e.jsx(a.BodySecondary,Object.assign({style:{color:c.COLORS.content.primary,marginLeft:8}},{children:y||d.default.toCapitilize(null==m?void 0:m.toLowerCase())||v}))})),!!j&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e.jsxs(a.BodySecondary,Object.assign({style:{color:c.COLORS.content.negative}},{children:["Error loading this ",null==m?void 0:m.toLowerCase(),". Retry"]})),e.jsx(a.Caption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:j}))]})),!x&&!j&&!p&&e.jsx(h,Object.assign({onClick:()=>null==O?void 0:O(!0),onKeyDown:()=>null==O?void 0:O(!0),role:"presentation"},{children:e.jsx(t.default,{width:24,height:24,color:c.COLORS.content.placeholder})}))]})]})};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../../constants/Theme.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../../constants/Theme.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(e);const i=o.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: 12px;
|
|
5
5
|
/* justify-content: center; */
|
|
6
6
|
flex: 1;
|
|
7
|
-
`,o
|
|
7
|
+
`,n=o.default.div`
|
|
8
8
|
width: 56px;
|
|
9
9
|
height: 56px;
|
|
10
10
|
display: flex;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
border: 1px solid ${t.COLORS.stroke.primary};
|
|
17
17
|
box-sizing: content-box;
|
|
18
18
|
cursor: ${e=>e.error?"pointer":"default"};
|
|
19
|
-
`,d=
|
|
19
|
+
`,d=o.default.div`
|
|
20
20
|
padding: 8px;
|
|
21
21
|
flex-direction: row;
|
|
22
22
|
display: flex;
|
|
@@ -25,9 +25,8 @@
|
|
|
25
25
|
border: 1px solid ${t.COLORS.stroke.primary};
|
|
26
26
|
border-radius: 4px;
|
|
27
27
|
margin-left: 8px;
|
|
28
|
-
|
|
29
|
-
`,a=i.default.div`
|
|
28
|
+
`,a=o.default.div`
|
|
30
29
|
padding-bottom: 0px;
|
|
31
30
|
min-width: 285px;
|
|
32
31
|
margin-bottom: 16px;
|
|
33
|
-
`;exports.Container=d,exports.EditTemplateMediaContainer=a,exports.ImageContainer=
|
|
32
|
+
`;exports.Container=d,exports.EditTemplateMediaContainer=a,exports.ImageContainer=n,exports.RightComponent=i;
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VariableListInterfaceV2 } from "../../add-variableV2";
|
|
3
|
+
import { WhatsAppPickerMeta, WhatsAppTemplate } from "../../template-preview/models/WhatsAppTemplate";
|
|
4
|
+
declare const EditMediaTemplateMediaV2: React.FC<{
|
|
5
|
+
mediaComponent: WhatsAppTemplate['components'][0];
|
|
6
|
+
template: WhatsAppTemplate;
|
|
7
|
+
whatsappSpecificPickerMeta: WhatsAppPickerMeta;
|
|
8
|
+
updateTemplateImageUrl(url: string, format: WhatsAppTemplate['components'][0]['format']): void;
|
|
9
|
+
variableListForImage?: VariableListInterfaceV2[];
|
|
10
|
+
}>;
|
|
11
|
+
export default EditMediaTemplateMediaV2;
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("lodash"),n=require("react"),o=require("../../helpers/FileUploaderHelper.js"),a=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 l=require("../../template-preview/models/TemplateMeta.js"),r=require("../context/templateModalContext.js"),s=require("./EditMediaModal.js"),d=require("./EditMediaV2.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(n);const p=e=>/^{{.*}}$/.test(e);exports.default=c=>{let{mediaComponent:m,template:v,updateTemplateImageUrl:f,whatsappSpecificPickerMeta:E,variableListForImage:g}=c;var h,j,b,_,M,x,y,A;const{disableEditVariable:C,selectedCarouselIndex:T}=r.useTemplateModalContext(),[S,D]=n.useState(void 0),[I,q]=n.useState(),[R,O]=n.useState(),[H,w]=n.useState(!1),k=u.default.createRef(),[P,U]=n.useState(!1),[F,Y]=n.useState(""),{template:L,setTemplate:N}=r.useTemplateModalContext(),{uploadMediaFiles:V,uploadMediaLink:G}=E;let z;function B(){var e;(null===(e=null==k?void 0:k.current)||void 0===e?void 0:e.click)&&k.current.click()}function W(i){var t;return e.__awaiter(this,void 0,void 0,(function*(){const e=new o.FileUploaderHelper;if(i instanceof Blob){const n=e.validate({file:i});if(n)Y(n),U(!1);else{const e=m.format===l.HEADER_TYPES.IMAGE,n=yield V({file:i,fileName:S,isImage:e});if(n.success){const[e]=i.type.split("/");f(null!==(t=n.url)&&void 0!==t?t:"","application"===e?l.HEADER_TYPES.DOCUMENT:l.HEADER_TYPES[e.toUpperCase()])}else Y("An unknown technical error occurred");U(!1)}}else Y("An unknown technical error occurred"),U(!1)}))}return z=m.format===l.HEADER_TYPES.IMAGE?"image/png, image/jpeg":m.format===l.HEADER_TYPES.VIDEO?"video/mp4":"application/pdf",n.useEffect((()=>{D(void 0),q(void 0),O(void 0),w(!1),U(!1),Y("")}),[T]),i.jsxs(i.Fragment,{children:[i.jsx(s.default,{mediaComponentFormat:null!==(h=m.format)&&void 0!==h?h:l.HEADER_TYPES.IMAGE,uploadMedia:function(i){var n,a,r,s,d,c;return e.__awaiter(this,void 0,void 0,(function*(){if(Y(""),O(""),w(!1),i)if(i.startsWith("https"))try{if(U(!0),G){const e=yield G(i),{type:t,size:a,success:r}=e;if(r){const i=(new o.FileUploaderHelper).validate({linkData:{type:t,size:a}});if(i)return Y(i),void U(!1);const[r]=t.split("/");f(null!==(n=e.url)&&void 0!==n?n:"",r.includes("application")?l.HEADER_TYPES.DOCUMENT:l.HEADER_TYPES[r.toUpperCase()])}else Y("An unknown technical error occurred");U(!1)}else{const e=yield fetch(i),t=yield e.blob();yield W(t)}}catch(e){Y("An unknown technical error occurred")}else if(p(i)){let e;if(O(i),e=null!=T&&T>-1?{components:null===(r=null===(a=L.components[1])||void 0===a?void 0:a.cards)||void 0===r?void 0:r[T].components,mapping:null===(d=null===(s=null==L?void 0:L.mapping)||void 0===s?void 0:s.cards)||void 0===d?void 0:d[T]}:Object.assign({},L),e.components){const t=null===(c=null==e?void 0:e.components)||void 0===c?void 0:c.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 n=Object.assign(Object.assign({},e.components[t]),{format:m.format,example:{header_handle:[i]}}),o=[...e.components];o[t]=n,e.components=o}}if(e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[i]})),U(!1),null!=T&&T>-1){const i=t.cloneDeep(L);i.components[1].cards[T].components=e.components,i.mapping.cards[T]=e.mapping,null==N||N(Object.assign({},i))}else null==N||N(Object.assign({},e))}else U(!1),Y("Invalid URL or variable");else B()}))},variableListForImage:g||[],setOpenEditMedia:w,openEditMedia:H}),!!I&&i.jsx(a.BikImageCropper,{aspectRatio:15/8,src:I,onCropComplete:function(i){return e.__awaiter(this,void 0,void 0,(function*(){U(!1),Y("");const e=yield fetch(i);W(yield e.blob()).then((()=>{q(void 0)}))}))},onCancel:()=>{U(!1),q(""),k.current&&(k.current.value="")}}),i.jsx("input",{ref:k,style:{display:"none"},type:"file",onChange:function(e){var i;Y(""),U(!0);const t=null===(i=e.target.files)||void 0===i?void 0:i[0];if(m.format===l.HEADER_TYPES.IMAGE){const e=new FileReader;q(""),D(""),e.onload=()=>{q(e.result),D(null==t?void 0:t.name)},t&&e.readAsDataURL(t)}else W(t)},accept:z}),i.jsx(d.default,{imageName:null!==(b=null===(j=null==m?void 0:m.example)||void 0===j?void 0:j.header_handle)&&void 0!==b?b:[],handleImageChange:B,mediaType:null==m?void 0:m.format,error:F,isLoading:P,setOpenEditMedia:w,selectedVariable:p(null!==(x=null===(M=null===(_=null==m?void 0:m.example)||void 0===_?void 0:_.header_handle)||void 0===M?void 0:M[0])&&void 0!==x?x:"")?null===(A=null===(y=null==m?void 0:m.example)||void 0===y?void 0:y.header_handle)||void 0===A?void 0:A[0]:R,disableEditVariable:C})]})};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("lodash"),t=require("react"),o=require("styled-components"),i=require("../../input/Input.js"),l=require("../../template-preview/models/TemplateMeta.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("lodash"),t=require("react"),o=require("styled-components"),i=require("../../input/Input.js"),l=require("../../template-preview/models/TemplateMeta.js"),s=require("../../template-preview/models/WhatsAppTemplate.js"),a=require("../context/templateModalContext.js"),d=require("../utils/getDataFromTemplateComponent.js"),r=require("../utils/validateName.js"),u=require("./BackTrackComponent.js"),p=require("./DiscountCodeComponent.js"),c=require("./EditMediaV2.style.js"),v=require("./EditWhatsAppTemplateMediaV2.js"),m=require("./VariableConnector.js"),b=require("./VariableConnectorsPanel.js"),g=require("./VariableConnectorWhatsApp.js"),f=require("./VariableEditorHeader.js"),j=require("./WhatsAppTemplateCardButtonV2.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const O=h(o).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,variableList:k,variableListForImage:M,discountCode:L,setDiscountCode:q,fileName:D,setFileName:I}=o;var R,U,P,A,w,N,S,_,F,H,Q,Y,K,W,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,re,ue,pe,ce;const ve=T.isCarouselType,{originalVariableList:me,pod:be,extras:ge,selectedCarouselIndex:fe,isProductCarouselType:je}=s.useTemplateModalContext(),{descriptionComponents:he,urlBtns:Ce,qrbBtns:Oe,imageComponent:xe,bodyVariables:Te,headerVariables:ye}=r.getAllDataFromTemplateComponent(T),Ee=t.useRef(null),Ve=d.useAdditionalVariables({variableList:k,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"}),[Be,ke]=t.useState(!1),[Me,Le]=t.useState(-1===fe?{descriptionComponents:he,urlBtns:Ce,qrbBtns:Oe,imageComponent:xe,bodyVariables:Te,headerVariables:ye}:{}),{uploadMediaLink:qe,uploadMediaFiles:De}=V,Ie=f.useEditWhatsappTemplateMedia({uploadMediaLink:qe,uploadMediaFiles:De,updateTemplateImageUrl:function(e,t){var o,i,l,a,s,d,r,u;let p;p=null!=fe&&fe>-1?{components:null===(i=null===(o=T.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[fe].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[fe]}: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!=fe&&fe>-1){const e=n.cloneDeep(T);e.components[1].cards[fe].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[fe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==E||E(Object.assign({},e)),Ue(!0)}else null==E||E(Object.assign({},p))},mediaComponent:ve?Me.imageComponent:xe,fileRef:Ee}),[Re,Ue]=t.useState(!1),[Pe,Ae]=t.useState(D),[we,Ne]=t.useState();function Se(e,t,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=fe&&fe>-1?{components:null===(i=Object.assign({},T).components[1].cards)||void 0===i?void 0:i[fe].components,mapping:null===(l=Object.assign({},T).mapping.cards)||void 0===l?void 0:l[fe]}: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!=fe&&fe>-1&&je){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===(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))?ke(!0):(ke(!1),null==q||q(""))}if(null!=fe&&fe>-1){const e=n.cloneDeep(T);e.components[1].cards[fe].components=b.components,e.mapping.cards[fe]=b.mapping,null==E||E(Object.assign({},e))}else null==E||E(b)}function _e(e,t,o){var i,l,a,s,d,r;const u=null!=fe&&fe>-1?{components:null===(i=Object.assign({},T).components[1].cards)||void 0===i?void 0:i[fe].components,mapping:null===(l=Object.assign({},T).mapping.cards)||void 0===l?void 0:l[fe]}:Object.assign({},T);if(null!=fe&&fe>-1&&je){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=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=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 p=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==p&&p>-1){const n=null===(a=null==u?void 0:u.components[p].buttons)||void 0===a?void 0:a.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===(d=null===(s=u.components)||void 0===s?void 0:s[p])||void 0===d?void 0:d.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({},u.components[p]),{buttons:i}),a=[...u.components];a[p]=l,u.components=a}}if(null!=fe&&fe>-1){const e=n.cloneDeep(T);e.components[1].cards[fe].components=u.components,null==E||E(Object.assign({},e))}else null==E||E(u)}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))))ke(!0);else{ke(!1);const e=null===(n=null==ge?void 0:ge.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[T]),t.useEffect((()=>{var e,n,t,o;if(null!=fe&&fe>-1){const i={components:null===(n=null===(e=T.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[fe].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[fe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:p}=r.getAllDataFromTemplateComponent(i);Le({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:p})}else if(null!=fe&&-1===fe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=r.getAllDataFromTemplateComponent(T);Le({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[fe]),t.useEffect((()=>{var e,n,t,o;if(null!=fe&&fe>-1&&Re){const i={components:null===(n=null===(e=T.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[fe].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[fe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:p}=r.getAllDataFromTemplateComponent(i);Le({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:p}),Ue(!1)}}),[Re]);const Fe=ve?Me.imageComponent:xe;return Ie.openEditMedia?e.jsx(h.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(m.default,{mediaComponentFormat:null!==(R=Fe.format)&&void 0!==R?R:l.HEADER_TYPES.IMAGE,uploadMedia:Ie.uploadMedia,variableListForImage:M||[],useEditWhatsappTemplateMediaResponse:Ie,setOpenEditMedia:Ie.setOpenEditMedia,openEditMedia:Ie.openEditMedia,editIconRef:Ie.editIconRef,fileRef:Ee})})):e.jsxs(h.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!Me.imageComponent&&!je&&e.jsxs(g.EditTemplateMediaContainer,{children:[e.jsx(b.default,{imageName:null!==(P=null===(U=null==Fe?void 0:Fe.example)||void 0===U?void 0:U.header_handle)&&void 0!==P?P:[],handleImageChange:Ie.handleImageChange,mediaType:null==Fe?void 0:Fe.format,error:Ie.error,isLoading:Ie.loading,setOpenEditMedia:Ie.setOpenEditMedia,selectedVariable:u.isVariable(null!==(N=null===(w=null===(A=null==Fe?void 0:Fe.example)||void 0===A?void 0:A.header_handle)||void 0===w?void 0:w[0])&&void 0!==N?N:"")?null===(_=null===(S=null==Fe?void 0:Fe.example)||void 0===S?void 0:S.header_handle)||void 0===_?void 0:_[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])?null===(Y=null===(Q=null==T?void 0:T.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:Ie.selectedVariable}),(null==xe?void 0:xe.format)==l.HEADER_TYPES.DOCUMENT?e.jsx(y,{children:e.jsx(i.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Pe,errorMessage:we||void 0,onBlur:()=>{if(!Pe)return null==I||I(""),void Ne("PDF name is Required");const e=p.validateInputName(Pe);null==I||I(Pe),Ne(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{Ne(""),Ae(e)}})}):e.jsx(e.Fragment,{})]}),Me.bodyVariables.length>0&&e.jsx(O.default,{containerStyle:{paddingTop:Me.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===(K=Me.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(C.default,{originalVariableList:null!=fe&&fe>-1?me.cards[fe]:me,type:n.type,descriptionComponent:n.component,showVariableModal:B,variableList:k},t))),(null===($=null===(W=null!=fe&&fe>-1?me.cards[fe].buttons:null==me?void 0:me.buttons)||void 0===W?void 0:W.filter((e=>"URL"===e.type)))||void 0===$?void 0:$.length)>0&&e.jsx(O.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(X=null===(G=null!=fe&&fe>-1?me.cards[fe].buttons:null==me?void 0:me.buttons)||void 0===G?void 0:G.filter((e=>be===a.POD.CHATBOT||"URL"===e.type)))||void 0===X?void 0:X.map(((n,t)=>{if("URL"===n.type)return e.jsx(x.default,{variableListIndex:t,CTAoptions:null==V?void 0:V.CTAoptions,button:n,currentVariableList:null!=fe&&fe>-1?Object.assign({},me.cards[fe]):Object.assign({},me),updateSelectedURLTemplateBtn:Se,variableList:k},`${t}_${fe}`)})),be===a.POD.CHATBOT&&(null===(J=null===(z=Oe[0])||void 0===z?void 0:z.component)||void 0===J?void 0:J.buttons)&&(null===(ne=null===(ee=null===(Z=Oe[0])||void 0===Z?void 0:Z.component)||void 0===ee?void 0:ee.buttons)||void 0===ne?void 0:ne.length)>0&&e.jsx(c.BackTrackComponent,{backTrackMessage:null===(te=null==ge?void 0:ge.backTrackExtra)||void 0===te?void 0:te[0],setBackTrackMessage:null===(oe=null==ge?void 0:ge.backTrackExtra)||void 0===oe?void 0:oe[1]}),(null===(le=null===(ie=null!=fe&&fe>-1?me.cards[fe].buttons:null==me?void 0:me.buttons)||void 0===ie?void 0:ie.filter((e=>"QUICK_REPLY"===e.type)))||void 0===le?void 0:le.length)>0&&(be!==a.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(c.BackTrackComponent,{backTrackMessage:null===(ae=null==ge?void 0:ge.backTrackExtra)||void 0===ae?void 0:ae[0],setBackTrackMessage:null===(se=null==ge?void 0:ge.backTrackExtra)||void 0===se?void 0:se[1]})),null===(re=null===(de=null!=fe&&fe>-1?me.cards[fe].buttons:null==me?void 0:me.buttons)||void 0===de?void 0:de.filter((e=>"QUICK_REPLY"===e.type)))||void 0===re?void 0:re.map(((n,t)=>{if("QUICK_REPLY"===n.type&&be!==a.POD.CHATBOT)return e.jsx(x.default,{variableListIndex:t,QRBoptions:null==V?void 0:V.QRBoptions,button:n,currentVariableList:null!=fe&&fe>-1?Object.assign({},me.cards[fe]):Object.assign({},me),updateSelectedQRBTemplateBtn:_e},`${t}_${fe}`)})),be===a.POD.CHATBOT&&Be&&e.jsx(v.DiscountCodeComponent,{discountCode:null===(ue=null==ge?void 0:ge.discountCodeExtra)||void 0===ue?void 0:ue[0],setDiscountCode:null===(pe=null==ge?void 0:ge.discountCodeExtra)||void 0===pe?void 0:pe[1],variableList:k}),null===(ce=null!=fe&&fe>-1?me.cards[fe].buttons:null==me?void 0:me.buttons)||void 0===ce?void 0:ce.map(((n,t)=>{var o,i,l;if("COPY_CODE"===n.type)return e.jsx(j.default,{index:t,variable:{variableName:null!==(o=n.text)&&void 0!==o?o:"Copy Code",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=n.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:Ve,componentType:"BUTTONS"},t)}))]}))};
|
|
7
|
+
`;exports.default=o=>{let{template:h,onTemplateChange:C,whatsappSpecificPickerMeta:T,showVariableModal:x,variableList:y,variableListForImage:B,discountCode:E,setDiscountCode:V,fileName:k,setFileName:L}=o;var q,D,U,I,P,R,w,A,M,N,S,_,F,H,Q,Y,K,W,$,X,z;const G=h.isCarouselType,{originalVariableList:J,pod:Z,extras:ee,selectedCarouselIndex:ne,isProductCarouselType:te}=a.useTemplateModalContext(),{descriptionComponents:oe,urlBtns:ie,qrbBtns:le,imageComponent:se,bodyVariables:ae,headerVariables:de}=d.getAllDataFromTemplateComponent(h),[re,ue]=t.useState(!1),[pe,ce]=t.useState(-1===ne?{descriptionComponents:oe,urlBtns:ie,qrbBtns:le,imageComponent:se,bodyVariables:ae,headerVariables:de}:{}),[ve,me]=t.useState(!1),[be,ge]=t.useState(k),[fe,je]=t.useState();function he(e,t,o){var i,l,s,a,d,r,u,p,c,v;const m=null!=ne&&ne>-1?{components:null===(i=Object.assign({},h).components[1].cards)||void 0===i?void 0:i[ne].components,mapping:null===(l=Object.assign({},h).mapping.cards)||void 0===l?void 0:l[ne]}:Object.assign({},h),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!=ne&&ne>-1&&te){const t=Object.assign({},h).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 s=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};s=Object.assign(Object.assign({},s),{url:"https://d.bik.ai/{{1}}",example:[f]});const a=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},e),{buttons:a})}return e}))})))}):e})),i=null===(a=null===(s=Object.assign({},h).mapping)||void 0===s?void 0:s.cards)||void 0===a?void 0:a.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(h);return l.components=t,l.mapping.cards=i,void(null==C||C(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 s=n[o];s=Object.assign(Object.assign({},s),{url:"https://d.bik.ai/{{1}}",example:[l]});const a=[...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==s?void 0:s.text)?s:e)),d=Object.assign(Object.assign({},b.components[j]),{buttons:a}),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))?ue(!0):(ue(!1),null==V||V(""))}if(null!=ne&&ne>-1){const e=n.cloneDeep(h);e.components[1].cards[ne].components=b.components,e.mapping.cards[ne]=b.mapping,null==C||C(Object.assign({},e))}else null==C||C(b)}function Oe(e,t,o){var i,l,s,a,d,r;const u=null!=ne&&ne>-1?{components:null===(i=Object.assign({},h).components[1].cards)||void 0===i?void 0:i[ne].components,mapping:null===(l=Object.assign({},h).mapping.cards)||void 0===l?void 0:l[ne]}:Object.assign({},h);if(null!=ne&&ne>-1&&te){const t=Object.assign({},h).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 s=null===(t=n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let a=null!==(i=null==s?void 0:s[o])&&void 0!==i?i:{};a=Object.assign(Object.assign({},a),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=n.cloneDeep(h);return i.components=t,void(null==C||C(Object.assign({},i)))}const p=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==p&&p>-1){const n=null===(s=null==u?void 0:u.components[p].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===(d=null===(a=u.components)||void 0===a?void 0:a[p])||void 0===d?void 0:d.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({},u.components[p]),{buttons:i}),s=[...u.components];s[p]=l,u.components=s}}if(null!=ne&&ne>-1){const e=n.cloneDeep(h);e.components[1].cards[ne].components=u.components,null==C||C(Object.assign({},e))}else null==C||C(u)}t.useEffect((()=>{var e,n;if(null===(e=h.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))ue(!0);else{ue(!1);const e=null===(n=null==ee?void 0:ee.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[h]),t.useEffect((()=>{var e,n,t,o;if(null!=ne&&ne>-1){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[ne].components,mapping:null===(o=null===(t=null==h?void 0:h.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[ne]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:u,headerVariables:p}=d.getAllDataFromTemplateComponent(i);ce({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:u,headerVariables:p})}else if(null!=ne&&-1===ne){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=d.getAllDataFromTemplateComponent(h);ce({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[ne]),t.useEffect((()=>{var e,n,t,o;if(null!=ne&&ne>-1&&ve){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[ne].components,mapping:null===(o=null===(t=null==h?void 0:h.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[ne]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:u,headerVariables:p}=d.getAllDataFromTemplateComponent(i);ce({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:u,headerVariables:p}),me(!1)}}),[ve]);return e.jsxs(b.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!pe.imageComponent&&!te&&e.jsxs(c.EditTemplateMediaContainer,{children:[e.jsx(v.default,{whatsappSpecificPickerMeta:T,mediaComponent:G?pe.imageComponent:se,updateTemplateImageUrl:function(e,t){var o,i,l,s,a,d,r,u;let p;p=null!=ne&&ne>-1?{components:null===(i=null===(o=h.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[ne].components,mapping:null===(s=null===(l=null==h?void 0:h.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[ne]}:Object.assign({},h);const c=null===(a=null==p?void 0:p.components)||void 0===a?void 0:a.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})}if(p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0})),null!=ne&&ne>-1){const e=n.cloneDeep(h);e.components[1].cards[ne].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[ne]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==C||C(Object.assign({},e)),me(!0)}else null==C||C(Object.assign({},p))},template:h,variableListForImage:B}),(null==se?void 0:se.format)==l.HEADER_TYPES.DOCUMENT?e.jsx(O,{children:e.jsx(i.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:be,errorMessage:fe||void 0,onBlur:()=>{if(!be)return null==L||L(""),void je("PDF name is Required");const e=r.validateInputName(be);null==L||L(be),je(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{je(""),ge(e)}})}):e.jsx(e.Fragment,{})]}),pe.bodyVariables.length>0&&e.jsx(f.default,{containerStyle:{paddingTop:pe.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===(q=pe.descriptionComponents)||void 0===q?void 0:q.map(((n,t)=>e.jsx(g.default,{originalVariableList:null!=ne&&ne>-1?J.cards[ne]:J,type:n.type,descriptionComponent:n.component,showVariableModal:x,variableList:y},t))),(null===(U=null===(D=null!=ne&&ne>-1?J.cards[ne].buttons:null==J?void 0:J.buttons)||void 0===D?void 0:D.filter((e=>"URL"===e.type)))||void 0===U?void 0:U.length)>0&&e.jsx(f.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(P=null===(I=null!=ne&&ne>-1?J.cards[ne].buttons:null==J?void 0:J.buttons)||void 0===I?void 0:I.filter((e=>Z===s.POD.CHATBOT||"URL"===e.type)))||void 0===P?void 0:P.map(((n,t)=>{if("URL"===n.type)return e.jsx(j.default,{variableListIndex:t,CTAoptions:null==T?void 0:T.CTAoptions,button:n,currentVariableList:null!=ne&&ne>-1?Object.assign({},J.cards[ne]):Object.assign({},J),updateSelectedURLTemplateBtn:he,variableList:y},`${t}_${ne}`)})),Z===s.POD.CHATBOT&&(null===(w=null===(R=le[0])||void 0===R?void 0:R.component)||void 0===w?void 0:w.buttons)&&(null===(N=null===(M=null===(A=le[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===N?void 0:N.length)>0&&e.jsx(u.BackTrackComponent,{backTrackMessage:null===(S=null==ee?void 0:ee.backTrackExtra)||void 0===S?void 0:S[0],setBackTrackMessage:null===(_=null==ee?void 0:ee.backTrackExtra)||void 0===_?void 0:_[1]}),(null===(H=null===(F=null!=ne&&ne>-1?J.cards[ne].buttons:null==J?void 0:J.buttons)||void 0===F?void 0:F.filter((e=>"QUICK_REPLY"===e.type)))||void 0===H?void 0:H.length)>0&&(Z!==s.POD.CHATBOT?e.jsx(f.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(u.BackTrackComponent,{backTrackMessage:null===(Q=null==ee?void 0:ee.backTrackExtra)||void 0===Q?void 0:Q[0],setBackTrackMessage:null===(Y=null==ee?void 0:ee.backTrackExtra)||void 0===Y?void 0:Y[1]})),null===(W=null===(K=null!=ne&&ne>-1?J.cards[ne].buttons:null==J?void 0:J.buttons)||void 0===K?void 0:K.filter((e=>"QUICK_REPLY"===e.type)))||void 0===W?void 0:W.map(((n,t)=>{if("QUICK_REPLY"===n.type&&Z!==s.POD.CHATBOT)return e.jsx(j.default,{variableListIndex:t,QRBoptions:null==T?void 0:T.QRBoptions,button:n,currentVariableList:null!=ne&&ne>-1?Object.assign({},J.cards[ne]):Object.assign({},J),updateSelectedQRBTemplateBtn:Oe},`${t}_${ne}`)})),Z===s.POD.CHATBOT&&re&&e.jsx(p.DiscountCodeComponent,{discountCode:null===($=null==ee?void 0:ee.discountCodeExtra)||void 0===$?void 0:$[0],setDiscountCode:null===(X=null==ee?void 0:ee.discountCodeExtra)||void 0===X?void 0:X[1],variableList:y}),null===(z=null!=ne&&ne>-1?J.cards[ne].buttons:null==J?void 0:J.buttons)||void 0===z?void 0:z.map(((n,t)=>{var o,i,l;if("COPY_CODE"===n.type)return e.jsx(m.default,{index:t,variable:{variableName:null!==(o=n.text)&&void 0!==o?o:"Copy Code",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=n.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:y,componentType:"BUTTONS"},t)}))]}))};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("styled-components"),a=require("../../template-preview/TemplatePreview.js");require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../../constants/Theme.js"),require("../../curtain/CurtainHelper.js"),require("../../template-preview/models/TemplateMeta.js");var r=require("../../template-preview/models/WhatsAppTemplate.js"),s=require("../context/templateModalContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("styled-components"),a=require("../../template-preview/TemplatePreview.js");require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../../constants/Theme.js"),require("../../curtain/CurtainHelper.js"),require("../../template-preview/models/TemplateMeta.js");var r=require("../../template-preview/models/WhatsAppTemplate.js"),s=require("../context/templateModalContext.js"),o=require("../utils/getPreviewDimension.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=l(t),n=l(i);const d=n.default.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
height: 100%;
|
|
4
4
|
border-radius: 31px;
|
|
5
|
-
width: ${e=>
|
|
5
|
+
width: ${e=>o.getPreviewWidth(e.channel)}px;
|
|
6
6
|
background-color: white;
|
|
7
7
|
margin: auto;
|
|
8
8
|
overflow-y: auto;
|
|
9
|
-
`,
|
|
9
|
+
`,c=n.default.div`
|
|
10
10
|
position: absolute;
|
|
11
11
|
flex: 1;
|
|
12
12
|
background-color: white;
|
|
@@ -17,9 +17,4 @@
|
|
|
17
17
|
height: calc(100% - 17px);
|
|
18
18
|
border-radius: 16px;
|
|
19
19
|
overflow-y: auto;
|
|
20
|
-
`,h=
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
flex: 1;
|
|
25
|
-
`;exports.default=h;
|
|
20
|
+
`,h=p.default.forwardRef(((t,i)=>{let{display_content:l,channel:p,template:n,showSampleValues:h}=t;const{pod:m}=s.useTemplateModalContext();return e.jsx("div",{children:e.jsxs(d,Object.assign({channel:p},{children:[e.jsx("img",{alt:"",src:"https://firebasestorage.googleapis.com/v0/b/staging-bikayi.appspot.com/o/bik%2FkNwEVoGlLpVjOsXoO1M8WgvWicP2%2F6f07b850-8b4b-4d58-96cc-8ba6df7b4e4a-Device___Frame.jpg?alt=media&token=253f1bfe-8481-4f54-bdef-3c0a73697d6a",style:{width:o.getPreviewWidth(p),height:443}}),e.jsx(c,Object.assign({ref:i},{children:e.jsx(a.TemplatePreview,{showSampleValues:h,template:n,channel:p,smsSpecificMeta:{smsDisplayContent:l},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:m!==r.POD.CHATBOT,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426,width:240}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:l,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%",width:"100%"},templateContainerStyles:{height:"100%"}},isPreview:!0})}))]}))})}));h.displayName="MobilePreview",exports.default=h;
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
background-color: rgba(0, 0, 0, 0.1);
|
|
14
14
|
z-index: 1000;
|
|
15
15
|
cursor: not-allowed;
|
|
16
|
-
`,f={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"};exports.Container=y,exports.default=i=>{let{onFocus:x,variable:h,index:N,showVariableModal:C,variableList:A,setShowDiscountCheckBox:S,componentType:P,CTAoptions:V}=i;var k,L,D,B,H;const[w,Y]=n.useState(!1),[U,q]=n.useState(""),[R,M]=n.useState([]),[I,W]=n.useState(),[$,z]=n.useState(!1),[Z,F]=n.useState(!1),{device:G,channel:K,isError:J,originalVariableList:Q,template:X,templateSelectionTriggered:ee,setTemplate:te,setDisplayContent:le,setOriginalVariableList:ae,globalNormalizedPlaceholders:ne,enabledCustomText:ie,pod:se,selectedCarouselIndex:oe,isProductCarouselType:ue,disableEditVariable:de,disableEditExpiry:ce,templateErrorIndexes:re}=O.useTemplateModalContext();function pe(){var e,t;const l=[];let a=[];if(K!==p.CHANNEL_TYPE.MESSAGE||ie){"link"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),W(f)):"date_time"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),W(T)):(l.push({label:"",options:[f,E,T]}),W(E));const e=null!=ne?ne:[];M([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ne?ne:[];M([{label:"",options:[E,f]},...e]),a=[{label:"",options:[E,f]},...e]}if((K===p.CHANNEL_TYPE.WHATSAPP||K===p.CHANNEL_TYPE.EMAIL||K===p.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(r.placeHolderNamePattern.test(h.updatedValue)&&K===p.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&K!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(se===m.POD.CHATBOT&&"BUTTONS"===P){const l=null==V?void 0:V.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}n={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(h,a,K);e.value&&W(e)}else"date_time"===h.type?(W(T),q(h.updatedValue),ge(null!==(e=h.index)&&void 0!==e?e:0,h.updatedValue)):(null===(t=h.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(W(f),q(h.updatedValue.split("https://")[1])):(W(E),q(h.updatedValue))}function me(e,t){var l,a,n;const i=e;q(""),W(i),K===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value&&"static_expiry"!==i.value?(be(null!==(l=i.value)&&void 0!==l?l:"","string"),null==ge||ge(null!==(a=h.index)&&void 0!==a?a:0,i.value,!0)):(null==ge||ge(null!==(n=h.index)&&void 0!==n?n:0,"",!0,i.value),be("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?be(i.value,"url"===i.bikPlaceholderType?"link":"string"):(q(""),be("",i.value))}function ve(e,t){var l;q(t);const a="custom_link"===(null==I?void 0:I.value)&&t?t.includes("https")?t:`https://${t}`:t;be(a,"static_expiry"===e?"string":e),K===p.CHANNEL_TYPE.WHATSAPP&&(null==ge||ge(null!==(l=h.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function be(e,t){var l,n,i,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(K!==p.CHANNEL_TYPE.WHATSAPP){const a=j.getVariableNameForEmailByIndex(N+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===G?"template_html_mobile":"template_html_desktop"),i=K===p.CHANNEL_TYPE.EMAIL?null===(l=null==n?void 0:n.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const s=Q.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==ae||ae(s)}if(K===p.CHANNEL_TYPE.WHATSAPP){if(null!=oe&&oe>-1&&ue){const l=Object.assign({},Q).cards.map(((l,a)=>{var n,i;return"BODY"===P?Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>N===l?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t))}):"BUTTONS"===P?Object.assign(Object.assign({},l),{buttons:null===(i=l.buttons)||void 0===i?void 0:i.map(((l,a)=>a===N?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==ae||ae((e=>Object.assign(Object.assign({},e),{cards:l}))))}const l=null!=oe&&oe>-1?Q.cards[oe]:Q;let u=l.body,d=l.header,c=l.buttons;if("BODY"===P?u=null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===P?d=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===P&&(c=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===N?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))),null!=oe&&oe>-1){const e=a.cloneDeep(Q.cards);e[oe]={header:d,body:u,buttons:c},null==ae||ae((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ae||ae((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:c})))}}function ge(e,t,l,n){var i,s,o,u,d,c,r;if(null!=oe&&oe>-1&&ue){const s=Object.assign({},X).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,n,i,s,o,u;if("BODY"===l.type&&"BODY"===P){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const a=[...null!==(o=null===(s=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const n=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:n})}return l}if("BUTTONS"===l.type&&"BUTTONS"===P){const a=null===(u=l.buttons)||void 0===u?void 0:u.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return a?Object.assign(Object.assign({},l),{buttons:a}):l}return l}))})))}):l})),o=a.cloneDeep(X);if(l){const l=null===(i=Object.assign({},X).mapping.cards)||void 0===i?void 0:i.map(((l,a)=>{var i,s,o;if("BODY"===P)return Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===P&&(null==l?void 0:l.buttons)){let i=-1,u=-1;return null===(s=X.components[1].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(i++,l===e&&"URL"==t.type&&(u=i))})))})),Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((e,l)=>l===u?"custom_link"===n?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==te||te(o))}const p=null!=oe&&oe>-1?{components:null===(s=Object.assign({},X).components[1].cards)||void 0===s?void 0:s[oe].components,mapping:null===(o=Object.assign({},X).mapping.cards)||void 0===o?void 0:o[oe]}:Object.assign({},X),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,n,i,s,o,u,d,c,r;const p=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const l=[...null!==(o=null===(s=null===(i=p.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{body_text:[l]});return Object.assign(Object.assign({},p),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(c=null===(d=p.example)||void 0===d?void 0:d.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{header_text:l});return Object.assign(Object.assign({},p),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===P){const a=null===(r=l.buttons)||void 0===r?void 0:r.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},p),{buttons:a}):p}if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},p),{example:Object.assign(Object.assign({},p.example),{limited_time_offer:t})})}return l}));if(p.components=m,l)if("BODY"===P&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===P&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===P&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,a=-1;m.forEach((t=>{var n;"BUTTONS"===t.type&&(null===(n=t.buttons)||void 0===n||n.forEach(((t,n)=>{"URL"===t.type&&(l++,n===e&&"URL"==t.type&&(a=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===a?"custom_link"===n?"((customPlaceholderName))":t:e))})}if(null!=oe&&oe>-1&&X){const e=a.cloneDeep(X);e.components[1].cards[oe].components=p.components,e.mapping.cards[oe]=p.mapping,null==te||te(e)}else null==te||te(Object.assign({},p))}return n.useEffect((()=>{w&&(null==x||x())}),[w]),n.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===G?"template_html_mobile":"template_html_desktop",s=document.getElementById(i),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(n=null==s?void 0:s.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);K===p.CHANNEL_TYPE.EMAIL&&(null==le||le(o))}()}),[ee]),n.useEffect((()=>{pe()}),[]),n.useEffect((()=>{pe()}),[oe]),n.useEffect((()=>{G&&I&&U&&setTimeout((()=>{be("custom_link"===(null==I?void 0:I.value)&&U?U.includes("https")?U:`https://${U}`:U,I.value)}),100)}),[G]),n.useEffect((()=>{!Z&&I&&h.updatedValue&&setTimeout((()=>{be("custom_link"===(null==I?void 0:I.value)&&h.updatedValue?h.updatedValue.includes("https")?h.updatedValue:`https://${h.updatedValue}`:h.updatedValue,I.value),F(!0)}),100)}),[I]),e.jsxs(y,Object.assign({channel:K,focused:w,onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:J&&!I?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(k=h.variableName)||void 0===k?void 0:k.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:C?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==I?void 0:I.label)?"space-between":"flex-end"}},{children:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:se===m.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(L=null==I?void 0:I.value)&&void 0!==L?L:"")?null==I?void 0:I.label:null==I?void 0:I.value:c.truncate(null!==(D=null==I?void 0:I.label)&&void 0!==D?D:"",20,!0)})),de||"date_time"===(null==h?void 0:h.type)&&ce?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{z(!$)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{disabled:de,options:R,isSearchable:!1,onSelect:me,defaultOptions:I?[Object.assign(Object.assign({},I),{selected:!0})]:[]})})),("custom_text"===(null==I?void 0:I.value)||"custom_link"===(null==I?void 0:I.value))&&e.jsx(d.Input,{state:de?"disabled":"none",labelText:"custom_text"===(null==I?void 0:I.value)?"Custom text value":"custom_link"===(null==I?void 0:I.value)?"Custom URL value":"",id:`variable-value-${null==I?void 0:I.value}-${N}`,value:U,errorMessage:J&&(null===(B=null==re?void 0:re.buttons)||void 0===B?void 0:B.includes(null!==(H=null==h?void 0:h.index)&&void 0!==H?H:-1))?U&&0!==U.trim().length?"custom_link"!==I.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${U.trim()}`)&&0!==U.trim().length?"custom_link"!==I.value&&U.length>30?"Length cannot be more than 30":"BUTTONS"===P&&"custom_link"!==I.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==I?void 0:I.value)?2e3:"BUTTONS"===P?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==I?void 0:I.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===I.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{ve(I.value,e)}}),"static_expiry"===(null==I?void 0:I.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[de&&e.jsx(_,{onClick:e=>e.preventDefault()}),e.jsx(o.CustomDateTime,{placement:"auto",time:U?l.format(new Date(U),"hh:mm a"):l.format(new Date,"hh:mm a"),date:U?new Date(U):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{ve("static_expiry",e.toISOString())}})]})),$&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:$,setShowVariable:z,placeholder:"Add a variable",customTrigger:e=>{null==S||S(!1),"{{custom.url}}"===e.actualValue?me({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?me({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?me({label:e.displayName,selected:!0,value:"static_expiry"}):me({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
|
|
16
|
+
`,f={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"};exports.Container=y,exports.default=i=>{let{onFocus:x,variable:h,index:N,showVariableModal:C,variableList:A,setShowDiscountCheckBox:S,componentType:P,CTAoptions:V}=i;var k,L,D;const[B,H]=n.useState(!1),[w,Y]=n.useState(""),[U,q]=n.useState([]),[R,M]=n.useState(),[I,W]=n.useState(!1),[$,z]=n.useState(!1),{device:Z,channel:F,isError:G,originalVariableList:K,template:J,templateSelectionTriggered:Q,setTemplate:X,setDisplayContent:ee,setOriginalVariableList:te,globalNormalizedPlaceholders:le,enabledCustomText:ae,pod:ne,selectedCarouselIndex:ie,isProductCarouselType:se,disableEditVariable:oe,disableEditExpiry:ue}=O.useTemplateModalContext();function de(){var e,t;const l=[];let a=[];if(F!==p.CHANNEL_TYPE.MESSAGE||ae){"link"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),M(f)):"date_time"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),M(T)):(l.push({label:"",options:[f,E,T]}),M(E));const e=null!=le?le:[];q([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=le?le:[];q([{label:"",options:[E,f]},...e]),a=[{label:"",options:[E,f]},...e]}if((F===p.CHANNEL_TYPE.WHATSAPP||F===p.CHANNEL_TYPE.EMAIL||F===p.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(r.placeHolderNamePattern.test(h.updatedValue)&&F===p.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&F!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(ne===m.POD.CHATBOT&&"BUTTONS"===P){const l=null==V?void 0:V.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}n={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(h,a,F);e.value&&M(e)}else"date_time"===h.type?(M(T),Y(h.updatedValue),me(null!==(e=h.index)&&void 0!==e?e:0,h.updatedValue)):(null===(t=h.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(M(f),Y(h.updatedValue.split("https://")[1])):(M(E),Y(h.updatedValue))}function ce(e,t){var l,a,n;const i=e;Y(""),M(i),F===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value&&"static_expiry"!==i.value?(pe(null!==(l=i.value)&&void 0!==l?l:"","string"),null==me||me(null!==(a=h.index)&&void 0!==a?a:0,i.value,!0)):(null==me||me(null!==(n=h.index)&&void 0!==n?n:0,w,!0,i.value),pe("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?pe(i.value,"url"===i.bikPlaceholderType?"link":"string"):(Y(""),pe("",i.value))}function re(e,t){var l;Y(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;pe(a,"static_expiry"===e?"string":e),F===p.CHANNEL_TYPE.WHATSAPP&&(null==me||me(null!==(l=h.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function pe(e,t){var l,n,i,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(F!==p.CHANNEL_TYPE.WHATSAPP){const a=j.getVariableNameForEmailByIndex(N+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===Z?"template_html_mobile":"template_html_desktop"),i=F===p.CHANNEL_TYPE.EMAIL?null===(l=null==n?void 0:n.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const s=K.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==te||te(s)}if(F===p.CHANNEL_TYPE.WHATSAPP){if(null!=ie&&ie>-1&&se){const l=Object.assign({},K).cards.map(((l,a)=>{var n,i;return"BODY"===P?Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>N===l?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t))}):"BUTTONS"===P?Object.assign(Object.assign({},l),{buttons:null===(i=l.buttons)||void 0===i?void 0:i.map(((l,a)=>a===N?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==te||te((e=>Object.assign(Object.assign({},e),{cards:l}))))}const l=null!=ie&&ie>-1?K.cards[ie]:K;let u=l.body,d=l.header,c=l.buttons;if("BODY"===P?u=null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===P?d=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===P&&(c=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===N?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))),null!=ie&&ie>-1){const e=a.cloneDeep(K.cards);e[ie]={header:d,body:u,buttons:c},null==te||te((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==te||te((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:c})))}}function me(e,t,l,n){var i,s,o,u,d,c,r;if(null!=ie&&ie>-1&&se){const s=Object.assign({},J).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,n,i,s,o,u;if("BODY"===l.type&&"BODY"===P){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const a=[...null!==(o=null===(s=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const n=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:n})}return l}if("BUTTONS"===l.type&&"BUTTONS"===P){const a=null===(u=l.buttons)||void 0===u?void 0:u.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return a?Object.assign(Object.assign({},l),{buttons:a}):l}return l}))})))}):l})),o=a.cloneDeep(J);if(l){const l=null===(i=Object.assign({},J).mapping.cards)||void 0===i?void 0:i.map(((l,a)=>{var i,s,o;if("BODY"===P)return Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===P&&(null==l?void 0:l.buttons)){let i=-1,u=-1;return null===(s=J.components[1].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(i++,l===e&&"URL"==t.type&&(u=i))})))})),Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((e,l)=>l===u?"custom_link"===n?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==X||X(o))}const p=null!=ie&&ie>-1?{components:null===(s=Object.assign({},J).components[1].cards)||void 0===s?void 0:s[ie].components,mapping:null===(o=Object.assign({},J).mapping.cards)||void 0===o?void 0:o[ie]}:Object.assign({},J),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,n,i,s,o,u,d,c,r;const p=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const l=[...null!==(o=null===(s=null===(i=p.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{body_text:[l]});return Object.assign(Object.assign({},p),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(c=null===(d=p.example)||void 0===d?void 0:d.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{header_text:l});return Object.assign(Object.assign({},p),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===P){const a=null===(r=l.buttons)||void 0===r?void 0:r.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},p),{buttons:a}):p}if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},p),{example:Object.assign(Object.assign({},p.example),{limited_time_offer:t})})}return l}));if(p.components=m,l)if("BODY"===P&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===P&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===P&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,a=-1;m.forEach((t=>{var n;"BUTTONS"===t.type&&(null===(n=t.buttons)||void 0===n||n.forEach(((t,n)=>{"URL"===t.type&&(l++,n===e&&"URL"==t.type&&(a=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===a?"custom_link"===n?"((customPlaceholderName))":t:e))})}if(null!=ie&&ie>-1&&J){const e=a.cloneDeep(J);e.components[1].cards[ie].components=p.components,e.mapping.cards[ie]=p.mapping,null==X||X(e)}else null==X||X(Object.assign({},p))}return n.useEffect((()=>{B&&(null==x||x())}),[B]),n.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===Z?"template_html_mobile":"template_html_desktop",s=document.getElementById(i),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(n=null==s?void 0:s.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);F===p.CHANNEL_TYPE.EMAIL&&(null==ee||ee(o))}()}),[Q]),n.useEffect((()=>{de()}),[]),n.useEffect((()=>{de()}),[ie]),n.useEffect((()=>{Z&&R&&w&&setTimeout((()=>{pe("custom_link"===(null==R?void 0:R.value)&&w?w.includes("https")?w:`https://${w}`:w,R.value)}),100)}),[Z]),n.useEffect((()=>{!$&&R&&h.updatedValue&&setTimeout((()=>{pe("custom_link"===(null==R?void 0:R.value)&&h.updatedValue?h.updatedValue.includes("https")?h.updatedValue:`https://${h.updatedValue}`:h.updatedValue,R.value),z(!0)}),100)}),[R]),e.jsxs(y,Object.assign({channel:F,focused:B,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:G&&!R?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(k=h.variableName)||void 0===k?void 0:k.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:C?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:ne===m.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(L=null==R?void 0:R.value)&&void 0!==L?L:"")?null==R?void 0:R.label:null==R?void 0:R.value:c.truncate(null!==(D=null==R?void 0:R.label)&&void 0!==D?D:"",20,!0)})),oe||"date_time"===(null==h?void 0:h.type)&&ue?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{W(!I)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{disabled:oe,options:U,isSearchable:!1,onSelect:ce,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&e.jsx(d.Input,{state:oe?"disabled":"none",labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${N}`,value:w,errorMessage:G?w&&0!==w.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${w.trim()}`)&&0!==w.trim().length?"custom_link"!==R.value&&w.length>30?"Length cannot be more than 30":"BUTTONS"===P&&"custom_link"!==R.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===P?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{re(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[oe&&e.jsx(_,{onClick:e=>e.preventDefault()}),e.jsx(o.CustomDateTime,{placement:"auto",time:w?l.format(new Date(w),"hh:mm a"):l.format(new Date,"hh:mm a"),date:w?new Date(w):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{re("static_expiry",e.toISOString())}})]})),I&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:I,setShowVariable:W,placeholder:"Add a variable",customTrigger:e=>{null==S||S(!1),"{{custom.url}}"===e.actualValue?ce({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ce({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ce({label:e.displayName,selected:!0,value:"static_expiry"}):ce({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.validateIsUrl=e=>new RegExp("^(https?://)?([a-z0-9-]+\\.)+[a-z]{2,}(\\.[a-z]{2,})?(\\:[0-9]+)?(/[\\w@.-]*)*$","i").test(e);
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("../../constants/Theme.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=t(e);const d=o.default.div`
|
|
2
2
|
padding: 16px;
|
|
3
3
|
padding-bottom: 12px;
|
|
4
4
|
border-top-left-radius: 4px;
|
|
5
5
|
border-top-right-radius: 4px;
|
|
6
|
-
border: 1px solid ${
|
|
6
|
+
border: 1px solid ${r.COLORS.stroke.primary};
|
|
7
7
|
`,i=o.default.div`
|
|
8
8
|
width: 100%;
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
11
|
justify-content: center;
|
|
12
|
-
border-left: 1px solid ${
|
|
13
|
-
border-right: 1px solid ${
|
|
14
|
-
border-top-color: ${
|
|
15
|
-
border-top-width: ${
|
|
12
|
+
border-left: 1px solid ${r.COLORS.stroke.primary};
|
|
13
|
+
border-right: 1px solid ${r.COLORS.stroke.primary};
|
|
14
|
+
border-top-color: ${r.COLORS.stroke.primary};
|
|
15
|
+
border-top-width: ${e=>e.hideHeader?"1px":"0px"};
|
|
16
16
|
overflow: scroll;
|
|
17
17
|
`,a=o.default.div`
|
|
18
18
|
width: 100%;
|
|
19
19
|
height: 100%;
|
|
20
|
-
background-color: ${
|
|
21
|
-
`,
|
|
20
|
+
background-color: ${r.BASE_COLORS.grayscale[100]};
|
|
21
|
+
`,n=o.default.div`
|
|
22
22
|
height: 100%;
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
@@ -26,20 +26,18 @@
|
|
|
26
26
|
justify-content: center;
|
|
27
27
|
flex-grow: 1;
|
|
28
28
|
min-height: 180px;
|
|
29
|
-
|
|
30
|
-
border-right: 1px solid ${e.COLORS.stroke.primary};
|
|
31
|
-
`,n=o.default.div`
|
|
29
|
+
`,s=o.default.div`
|
|
32
30
|
display: flex;
|
|
33
31
|
justify-content: center;
|
|
34
32
|
width: 100%;
|
|
35
|
-
background: ${
|
|
33
|
+
background: ${r.COLORS.surface.standard};
|
|
36
34
|
border-bottom-left-radius: 4px;
|
|
37
35
|
border-bottom-right-radius: 4px;
|
|
38
|
-
border: 1px solid ${
|
|
36
|
+
border: 1px solid ${r.COLORS.stroke.primary};
|
|
39
37
|
`,l=o.default.div`
|
|
40
38
|
border-radius: 4px;
|
|
41
|
-
background-color: ${
|
|
42
|
-
margin-top: ${
|
|
39
|
+
background-color: ${r.COLORS.surface.standard};
|
|
40
|
+
margin-top: ${e=>e.hideHeader?0:16};
|
|
43
41
|
display: flex;
|
|
44
42
|
flex-direction: column;
|
|
45
|
-
`;exports.CardLoadingContainer=a,exports.EmailContainer=l,exports.Header=d,exports.IframeContainer=
|
|
43
|
+
`;exports.CardLoadingContainer=a,exports.EmailContainer=l,exports.Header=d,exports.IframeContainer=n,exports.ImageContainer=i,exports.ViewButton=s;
|
|
@@ -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"),s=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/more_vertical.svg.js"),t=require("../../assets/icons/search.svg.js"),i=require("../../constants/Theme.js"),l=require("../TypographyStyle.js"),n=require("./helpers/SmsTemplateHelper.js"),a=require("./SMS/SMSBubble.js"),o=require("./SmsTemplatePreview.styled.js");exports.default=d=>{let{template:c,variableStore:u,hideHeader:j,display_content:h,onlyTemplateContent:x,size:g}=d;var p;const S=null==c?void 0:c.content;return e.jsxs(e.Fragment,{children:[!j&&!x&&e.jsx(o.SMSCardHeader,{children:e.jsx(l.TitleRegular,Object.assign({style:{maxWidth:"100%"}},{children:c.name}))}),!x&&e.jsx(o.SMSHeader,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:8}},{children:[e.jsx(s.default,{width:16,height:16,color:i.COLORS.content.secondary}),e.jsx(l.Caption,{children:null===(p=null==c?void 0:c.headers)||void 0===p?void 0:p[0]})]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:8}},{children:[e.jsx(t.default,{width:16,height:16,color:i.COLORS.content.secondary}),e.jsx(r.default,{width:16,height:16,color:i.COLORS.content.secondary})]}))]})}),e.jsx(o.SMSBubbleContainer,Object.assign({size:g},{children:e.jsx(a.default,{size:null!=g?g:"large",content:null!=h?h:n.renderVariableUIForPreview(S,null!=u?u:[])})}))]})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
height: 8px;
|
|
5
5
|
left: -8px;
|
|
6
6
|
top: -9px;
|
|
7
|
-
`;exports.default=a=>{const{bodyText:j,footerText:m,headerMediaType:y,headerText:
|
|
7
|
+
`;exports.default=a=>{const{bodyText:j,footerText:m,headerMediaType:y,headerText:S,headerAssetLink:g,headerAssetName:f,quickReplybtn:v,ctaBtn:q,actionTypes:E,textType:b,extras:w,showHeader:C,imagePreviewStyles:A,size:N,children:O,isPreview:F}=a,M=new l.WhatsAppFormatToHTML,P=i.useMemo((()=>({color:d.COLORS.content.primary,margin:12,fontSize:C?d.FONTS.caption.fontSize:d.FONTS.bodySecondary.fontSize,fontWeight:d.FONTS.bodySecondary.fontWeight,maxWidth:"100%",whiteSpace:"pre-wrap",marginBottom:0,marginTop:8,wordBreak:"break-word"})),[]);return e.jsxs(p.Container,Object.assign({isPreview:F},{children:[e.jsx(u,{children:e.jsx(t.default,{color:"white",height:8,width:8})}),y===c.HEADER_TYPES.TEXT?e.jsx(T.default,{bold:!0,text:S}):y!==c.HEADER_TYPES.NONE?e.jsx(x.MediaCard,{headerAssetLink:g,headerAssetName:f,mediaType:y,imagePreviewStyles:y===c.HEADER_TYPES.IMAGE?A:{}}):e.jsx(e.Fragment,{}),!!j&&e.jsx(e.Fragment,{children:O?e.jsx(e.Fragment,{children:O}):e.jsx(e.Fragment,{children:"html"===b?e.jsx("div",{className:"richTextEditor",style:P,dangerouslySetInnerHTML:{__html:M.convertToHTML(j)}}):e.jsx(n.BodySecondary,{children:j})})}),e.jsxs(p.FooterWrapper,{children:[e.jsx(o.Tooltip,Object.assign({body:null!=m?m:"",placement:"top"},{children:e.jsx(p.TimeStamp,Object.assign({style:{flex:1}},{children:m}))})),e.jsx(p.TimeStamp,{children:"16:48"})]}),E===c.ACTIONS_TYPES.QUICK_REPLY?e.jsx("div",{children:null==v?void 0:v.map(((t,r)=>e.jsx(h.ChatBtn,{text:t.text},r)))}):E===c.ACTIONS_TYPES.CTA_BTN?e.jsx("div",{children:null==q?void 0:q.map(((t,i)=>e.jsx(h.ChatBtn,{textTypography:C?n.Caption:n.BodySecondary,extraContent:w?t.extra:void 0,placeholder:t.placeholder,text:t.text,Icon:"phoneNumber"===t.type?r.default:s.default,size:N},i)))}):e.jsx(e.Fragment,{})]}))};
|
|
@@ -9,10 +9,6 @@ export declare const TimeStamp: import("styled-components").StyledComponent<"div
|
|
|
9
9
|
numberOfLines?: number | undefined;
|
|
10
10
|
color?: string | undefined;
|
|
11
11
|
}, never>;
|
|
12
|
-
export declare const FooterText: import("styled-components").StyledComponent<"div", any, {
|
|
13
|
-
numberOfLines?: number | undefined;
|
|
14
|
-
color?: string | undefined;
|
|
15
|
-
}, never>;
|
|
16
12
|
export declare const MediaContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
13
|
export declare const ChatBtnContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
18
14
|
export declare const FooterWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../TypographyStyle.js"),r=require("../../../constants/Theme.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e);const a=i.default.div`
|
|
2
2
|
background: ${r.COLORS.surface.standard};
|
|
3
|
+
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.12);
|
|
3
4
|
border-top-left-radius: ${e=>e.isCarouselCard?"12px":"0px"};
|
|
4
5
|
border-top-right-radius: 12px;
|
|
5
6
|
border-bottom-right-radius: 12px;
|
|
6
7
|
border-bottom-left-radius: 12px;
|
|
7
8
|
position: relative;
|
|
8
9
|
padding: 8px 0px;
|
|
9
|
-
border:
|
|
10
|
-
${e=>e.hasError?`${r.COLORS.content.negative}`:e.showBorder?`${r.COLORS.stroke.brand}`:`${r.COLORS.
|
|
10
|
+
border: 2px solid
|
|
11
|
+
${e=>e.hasError?`${r.COLORS.content.negative}`:e.showBorder?`${r.COLORS.stroke.brand}`:`${r.COLORS.text.white}`};
|
|
11
12
|
:hover {
|
|
12
13
|
border: 2px
|
|
13
14
|
${e=>e.isPreview?"unset":e.isWhatsappCarousel?e.hasError?"dashed":e.showBorder?"solid":"dashed":"solid"}
|
|
14
15
|
${r.COLORS.stroke.brand};
|
|
15
|
-
box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.25);
|
|
16
16
|
}
|
|
17
17
|
`,d=i.default(t.Caption)`
|
|
18
18
|
color: ${r.COLORS.content.secondary};
|
|
@@ -21,9 +21,7 @@
|
|
|
21
21
|
white-space: nowrap;
|
|
22
22
|
overflow: hidden;
|
|
23
23
|
text-wrap: wrap;
|
|
24
|
-
`,s=i.default
|
|
25
|
-
max-width: 200px;
|
|
26
|
-
`,p=i.default.div`
|
|
24
|
+
`,s=i.default.div`
|
|
27
25
|
border-radius: 8px;
|
|
28
26
|
display: flex;
|
|
29
27
|
flex-direction: column;
|
|
@@ -39,7 +37,7 @@
|
|
|
39
37
|
justify-content: center;
|
|
40
38
|
align-items: center;
|
|
41
39
|
border-top: 1px solid ${r.COLORS.stroke.primary};
|
|
42
|
-
`,
|
|
40
|
+
`,p=i.default.div`
|
|
43
41
|
display: flex;
|
|
44
42
|
flex-direction: row;
|
|
45
43
|
justify-content: space-between;
|
|
@@ -62,4 +60,4 @@
|
|
|
62
60
|
position: absolute;
|
|
63
61
|
top: 16px;
|
|
64
62
|
right: 16px;
|
|
65
|
-
`,exports.ChatBtnContainer=n,exports.Container=a,exports.
|
|
63
|
+
`,exports.ChatBtnContainer=n,exports.Container=a,exports.FooterWrapper=p,exports.MediaContainer=s,exports.TimeStamp=d;
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
`,g=f.default(C)`
|
|
17
17
|
font-weight: 600;
|
|
18
18
|
margin-bottom: 8px;
|
|
19
|
-
`,E=new u.VariableEditorHelper;exports.ChatUIV2=o=>{const{bodyText:p,footerText:u,headerMediaType:T,headerText:f,headerAssetLink:v,headerAssetName:b,quickReplybtn:q,ctaBtn:O,actionTypes:_,extras:w,showHeader:P,imagePreviewStyles:
|
|
19
|
+
`,E=new u.VariableEditorHelper;exports.ChatUIV2=o=>{const{bodyText:p,footerText:u,headerMediaType:T,headerText:f,headerAssetLink:v,headerAssetName:b,quickReplybtn:q,ctaBtn:O,actionTypes:_,extras:w,showHeader:P,imagePreviewStyles:S,size:I,bodyVariableList:L,headerVariableList:A,buttons:M,limitedTimeOfferComponent:N,carouselCardIndex:R,isWhatsappCarousel:B,isPreview:H}=o,Y=E.format(p,L),U=E.format(f,A),{selectedCarouselIndex:D,isProductCarouselType:F,errorIndexes:V}=n.useTemplateModalContext(),k={COPY_CODE:t.default,PHONE_NUMBER:s.default,URL:a.default,QUICK_REPLY:i.default};return e.jsxs(h.Container,Object.assign({isCarouselCard:null!=R&&R>-1,showBorder:null!=R&&R===D||F&&null!=R&&R>-1&&null!=D&&D>-1,hasError:null==V?void 0:V.includes(null!=R?R:-2),isWhatsappCarousel:B,isPreview:H},{children:[!B&&e.jsx(y,{children:e.jsx(r.default,{color:"white",height:8,width:8})}),T===x.HEADER_TYPES.TEXT?e.jsx(g,{dangerouslySetInnerHTML:{__html:U}}):T!==x.HEADER_TYPES.NONE?e.jsx(j.MediaCard,{headerAssetLink:v,headerAssetName:b,mediaType:T,imagePreviewStyles:T===x.HEADER_TYPES.IMAGE?S:{}}):e.jsx(e.Fragment,{}),(null==N?void 0:N.dateTime)?e.jsx(m.LimitedTimeOffer,{text:N.text,dateTime:N.dateTime,code:N.code}):e.jsx(e.Fragment,{}),!!p&&e.jsx(e.Fragment,{children:e.jsx(C,{dangerouslySetInnerHTML:{__html:Y}})}),e.jsxs(h.FooterWrapper,{children:[e.jsx(l.Tooltip,Object.assign({body:null!=u?u:"",placement:"top"},{children:e.jsx(h.TimeStamp,Object.assign({style:{flex:1}},{children:u}))})),e.jsx(h.TimeStamp,{children:"16:48"})]}),M&&M.length>0?M.map(((t,r)=>e.jsx(c.ChatBtn,{text:"COPY_CODE"===t.type?"Copy code":t.text,Icon:k[t.type],size:I},r))):_===x.ACTIONS_TYPES.QUICK_REPLY?e.jsx("div",{children:null==q?void 0:q.map(((t,r)=>e.jsx(c.ChatBtn,{text:t.text},r)))}):_===x.ACTIONS_TYPES.CTA_BTN?e.jsx("div",{children:null==O?void 0:O.map(((t,r)=>e.jsx(c.ChatBtn,{textTypography:P?d.Caption:d.BodySecondary,extraContent:w?t.extra:void 0,placeholder:t.placeholder,text:t.text,Icon:"phoneNumber"===t.type?s.default:a.default,size:I},r)))}):e.jsx(e.Fragment,{})]}))};
|