@bikdotai/bik-component-library 0.0.581-beta-01 → 0.0.581-beta-02

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),s=require("../../dropdown/Dropdown.js"),a=require("../../input/Input.js"),n=require("../../template-preview/constants/regexPatterns.js"),i=require("../../template-preview/models/TemplateMeta.js"),o=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js"),c=require("../context/templateModalContext.js"),d=require("../utils/validateIsUrl.js"),b=require("./VariableConnector.js");exports.default=p=>{let{variableListIndex:j,button:g,updateSelectedURLTemplateBtn:m,updateSelectedQRBTemplateBtn:O,currentVariableList:v,CTAoptions:x,QRBoptions:f}=p;var y,L,h,R,U;const[V,C]=l.useState(""),[T,w]=l.useState(),{isError:q,disableEditVariable:I,pod:P,selectedCarouselIndex:E,originalVariableList:N,setOriginalVariableList:S,isProductCarouselType:_,ctaOptionsErrors:B,setCtaOptionsErrors:H}=c.useTemplateModalContext();function M(e){if(C(e),null!=E&&E>-1&&_){const l=t.cloneDeep(N);if("URL"===g.type){const t=l.cards.map((t=>{let l=t.buttons.filter((e=>"URL"===e.type))[j];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=t.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},t),{buttons:s})}));null==S||S((e=>Object.assign(Object.assign({},e),{cards:t}))),null==m||m(`https://${e}`,"custom",j)}return}let l=v.buttons.filter((e=>"URL"===e.type))[j];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=v.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),a=Object.assign({},null!=E&&E>-1?N.cards[E]:N);if(a.buttons=s,null!=E&&E>-1){const e=[...N.cards];e[E]=a,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((e=>Object.assign(Object.assign({},e),{buttons:[...s]})));null==m||m(`https://${e}`,"custom",j)}return l.useEffect((()=>{var e;if(g.buttonVariable&&n.editableVarPattern.test(g.buttonVariable))w(i.CUSTOM_URL_NAME),C((null===(e=g.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===g.type?x:f;e="URL"===g.type?t.findIndex((e=>e.placeHolder===g.buttonVariable)):t.findIndex((e=>e.label===g.flowName)),e>-1?w(t[e]):null==H||H((e=>Object.assign(Object.assign({},e),{[j]:"Required field!"})))}}),[]),P!==o.POD.CHATBOT?e.jsxs(b.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:u.COLORS.content.primary}},{children:[g.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(s.Dropdown,{disabled:I,options:"URL"===g.type?x:f,isSearchable:!0,onSelect:function(e,l){var s;null==H||H((e=>(delete e[j],Object.assign({},e))));const a=e;w(a);const n=("URL"===g.type?x:f).find((e=>e.placeHolder===a.placeHolder));if(n)if("custom_link"!==n.value){if(null!=E&&E>-1&&_){const e=t.cloneDeep(N);if("URL"===g.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:a.placeHolder});const l=e.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==m||m({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",j),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}else if("QUICK_REPLY"===g.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value});const l=e.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==O||O({flowName:a.label,flowId:a.value},"placeholder",j),console.log("newList",t),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}return}let e;if(console.log("singleOption?.value",a),console.log("buttonbuttonbutton",g),"URL"===g.type){let t=v.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:a.placeHolder,example:[null!==(s=null==a?void 0:a.value)&&void 0!==s?s:"https://d.bik.ai/"]}),e=v.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),console.log("updatedVariablesupdatedVariablesupdatedVariables",e),null==m||m({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",j)}else{let t=v.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value}),e=v.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==O||O({flowName:a.label,flowId:a.value},"placeholder",j)}const l=Object.assign({},null!=E&&E>-1?N.cards[E]:N);if(l.buttons=e,console.log("newList",l,e),null!=E&&E>-1){const e=[...N.cards];e[E]=l,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else M("")},defaultOptions:T?[Object.assign(Object.assign({},T),{selected:!0})]:[],error:q?null==B?void 0:B[j]:void 0})})),"custom_link"===(null==T?void 0:T.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(a.Input,{state:I?"disabled":"none",errorMessage:q?V?d.validateIsUrl(V)?"":"Enter valid URL":"Required field":"",value:V,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:M,maxCharLimit:2e3})}))]}):e.jsx(b.default,{index:j,variable:{variableName:null!==(y=g.text)&&void 0!==y?y:"",updatedValue:"((customPlaceholderName))"===g.buttonVariable?`${null===(L=g.example)||void 0===L?void 0:L[0]}`:null!==(h=g.buttonVariable)&&void 0!==h?h:"",type:"link",isEditableVariable:!0,index:null!==(R=g.index)&&void 0!==R?R:0,queryParams:null!==(U=g.queryParams)&&void 0!==U?U:[]},showVariableModal:!0,componentType:"BUTTONS",buttonType:g.type,CTAoptions:x})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),s=require("../../dropdown/Dropdown.js"),a=require("../../input/Input.js"),n=require("../../template-preview/constants/regexPatterns.js"),o=require("../../template-preview/models/TemplateMeta.js"),i=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js"),c=require("../context/templateModalContext.js"),d=require("../utils/validateIsUrl.js"),b=require("./VariableConnector.js");exports.default=p=>{let{variableListIndex:j,button:g,updateSelectedURLTemplateBtn:m,updateSelectedQRBTemplateBtn:O,currentVariableList:v,CTAoptions:f,QRBoptions:x}=p;var y,L,h,R,U;const[V,C]=l.useState(""),[T,w]=l.useState(),{isError:q,disableEditVariable:I,pod:P,selectedCarouselIndex:E,originalVariableList:N,setOriginalVariableList:S,isProductCarouselType:_,ctaOptionsErrors:B,setCtaOptionsErrors:H}=c.useTemplateModalContext();function M(e){if(C(e),null!=E&&E>-1&&_){const l=t.cloneDeep(N);if("URL"===g.type){const t=l.cards.map((t=>{let l=t.buttons.filter((e=>"URL"===e.type))[j];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=t.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},t),{buttons:s})}));null==S||S((e=>Object.assign(Object.assign({},e),{cards:t}))),null==m||m(`https://${e}`,"custom",j)}return}let l=v.buttons.filter((e=>"URL"===e.type))[j];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=v.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),a=Object.assign({},null!=E&&E>-1?N.cards[E]:N);if(a.buttons=s,null!=E&&E>-1){const e=[...N.cards];e[E]=a,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((e=>Object.assign(Object.assign({},e),{buttons:[...s]})));null==m||m(`https://${e}`,"custom",j)}return l.useEffect((()=>{var e;if(g.buttonVariable&&n.editableVarPattern.test(g.buttonVariable))w(o.CUSTOM_URL_NAME),C((null===(e=g.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===g.type?f:x;e="URL"===g.type?t.findIndex((e=>e.placeHolder===g.buttonVariable)):t.findIndex((e=>e.label===g.flowName)),e>-1?w(t[e]):null==H||H((e=>Object.assign(Object.assign({},e),{[j]:"Required field!"})))}}),[]),P!==i.POD.CHATBOT?e.jsxs(b.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:u.COLORS.content.primary}},{children:[g.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(s.Dropdown,{disabled:I,options:"URL"===g.type?f:x,isSearchable:!0,onSelect:function(e,l){var s;null==H||H((e=>(delete e[j],Object.assign({},e))));const a=e;w(a);const n=("URL"===g.type?f:x).find((e=>e.placeHolder===a.placeHolder));if(n)if("custom_link"!==n.value){if(null!=E&&E>-1&&_){const e=t.cloneDeep(N);if("URL"===g.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:a.placeHolder});const l=e.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==m||m({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",j),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}else if("QUICK_REPLY"===g.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value});const l=e.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==O||O({flowName:a.label,flowId:a.value},"placeholder",j),console.log("newList",t),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}return}let e;if(console.log("singleOption?.value",a),console.log("buttonbuttonbutton",g),"URL"===g.type){const t=v.buttons.filter((e=>"URL"===e.type));console.log("urlVariables first found",t);let l=t[j];l=Object.assign(Object.assign({},l),{buttonVariable:a.placeHolder,example:[null!==(s=null==a?void 0:a.value)&&void 0!==s?s:"https://d.bik.ai/"]}),console.log("after updatimg",l),console.log("currentVariableList",v),e=v.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),console.log("updatedVariablesupdatedVariablesupdatedVariables",e),null==m||m({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",j)}else{let t=v.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value}),e=v.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==O||O({flowName:a.label,flowId:a.value},"placeholder",j)}const l=Object.assign({},null!=E&&E>-1?N.cards[E]:N);if(l.buttons=e,console.log("newList",l,e),null!=E&&E>-1){const e=[...N.cards];e[E]=l,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else M("")},defaultOptions:T?[Object.assign(Object.assign({},T),{selected:!0})]:[],error:q?null==B?void 0:B[j]:void 0})})),"custom_link"===(null==T?void 0:T.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(a.Input,{state:I?"disabled":"none",errorMessage:q?V?d.validateIsUrl(V)?"":"Enter valid URL":"Required field":"",value:V,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:M,maxCharLimit:2e3})}))]}):e.jsx(b.default,{index:j,variable:{variableName:null!==(y=g.text)&&void 0!==y?y:"",updatedValue:"((customPlaceholderName))"===g.buttonVariable?`${null===(L=g.example)||void 0===L?void 0:L[0]}`:null!==(h=g.buttonVariable)&&void 0!==h?h:"",type:"link",isEditableVariable:!0,index:null!==(R=g.index)&&void 0!==R?R:0,queryParams:null!==(U=g.queryParams)&&void 0!==U?U:[]},showVariableModal:!0,componentType:"BUTTONS",buttonType:g.type,CTAoptions:f})};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{cloneDeep as l}from"lodash";import{useState as s,useEffect as a}from"react";import{Dropdown as n}from"../../dropdown/Dropdown.js";import{Input as o}from"../../input/Input.js";import{editableVarPattern as i}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as r}from"../../template-preview/models/TemplateMeta.js";import{POD as u}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as c}from"../../TypographyStyle.js";import{COLORS as d}from"../../../constants/Theme.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import{validateIsUrl as b}from"../utils/validateIsUrl.js";import m,{Container as g}from"./VariableConnector.js";const j=j=>{let{variableListIndex:f,button:v,updateSelectedURLTemplateBtn:O,updateSelectedQRBTemplateBtn:x,currentVariableList:y,CTAoptions:L,QRBoptions:h}=j;var R,U,V,w,T;const[C,I]=s(""),[E,P]=s(),{isError:H,disableEditVariable:N,pod:B,selectedCarouselIndex:Q,originalVariableList:_,setOriginalVariableList:S,isProductCarouselType:K,ctaOptionsErrors:Y,setCtaOptionsErrors:$}=p();function k(e){if(I(e),null!=Q&&Q>-1&&K){const t=l(_);if("URL"===v.type){const l=t.cards.map((t=>{let l=t.buttons.filter((e=>"URL"===e.type))[f];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=t.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},t),{buttons:s})}));null==S||S((e=>Object.assign(Object.assign({},e),{cards:l}))),null==O||O(`https://${e}`,"custom",f)}return}let t=y.buttons.filter((e=>"URL"===e.type))[f];t=Object.assign(Object.assign({},t),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=y.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),a=Object.assign({},null!=Q&&Q>-1?_.cards[Q]:_);if(a.buttons=s,null!=Q&&Q>-1){const e=[..._.cards];e[Q]=a,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((e=>Object.assign(Object.assign({},e),{buttons:[...s]})));null==O||O(`https://${e}`,"custom",f)}return a((()=>{var e;if(v.buttonVariable&&i.test(v.buttonVariable))P(r),I((null===(e=v.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===v.type?L:h;e="URL"===v.type?t.findIndex((e=>e.placeHolder===v.buttonVariable)):t.findIndex((e=>e.label===v.flowName)),e>-1?P(t[e]):null==$||$((e=>Object.assign(Object.assign({},e),{[f]:"Required field!"})))}}),[]),B!==u.CHATBOT?e(g,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(c,Object.assign({style:{color:d.content.primary}},{children:[v.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(n,{disabled:N,options:"URL"===v.type?L:h,isSearchable:!0,onSelect:function(e,t){var s;null==$||$((e=>(delete e[f],Object.assign({},e))));const a=e;P(a);const n=("URL"===v.type?L:h).find((e=>e.placeHolder===a.placeHolder));if(n)if("custom_link"!==n.value){if(null!=Q&&Q>-1&&K){const e=l(_);if("URL"===v.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"URL"===e.type))[f];t=Object.assign(Object.assign({},t),{buttonVariable:a.placeHolder});const l=e.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==O||O({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",f),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}else if("QUICK_REPLY"===v.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"QUICK_REPLY"===e.type))[f];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value});const l=e.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==x||x({flowName:a.label,flowId:a.value},"placeholder",f),console.log("newList",t),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}return}let e;if(console.log("singleOption?.value",a),console.log("buttonbuttonbutton",v),"URL"===v.type){let t=y.buttons.filter((e=>"URL"===e.type))[f];t=Object.assign(Object.assign({},t),{buttonVariable:a.placeHolder,example:[null!==(s=null==a?void 0:a.value)&&void 0!==s?s:"https://d.bik.ai/"]}),e=y.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),console.log("updatedVariablesupdatedVariablesupdatedVariables",e),null==O||O({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",f)}else{let t=y.buttons.filter((e=>"QUICK_REPLY"===e.type))[f];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value}),e=y.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==x||x({flowName:a.label,flowId:a.value},"placeholder",f)}const t=Object.assign({},null!=Q&&Q>-1?_.cards[Q]:_);if(t.buttons=e,console.log("newList",t,e),null!=Q&&Q>-1){const e=[..._.cards];e[Q]=t,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else k("")},defaultOptions:E?[Object.assign(Object.assign({},E),{selected:!0})]:[],error:H?null==Y?void 0:Y[f]:void 0})})),"custom_link"===(null==E?void 0:E.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(o,{state:N?"disabled":"none",errorMessage:H?C?b(C)?"":"Enter valid URL":"Required field":"",value:C,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:k,maxCharLimit:2e3})}))]}):t(m,{index:f,variable:{variableName:null!==(R=v.text)&&void 0!==R?R:"",updatedValue:"((customPlaceholderName))"===v.buttonVariable?`${null===(U=v.example)||void 0===U?void 0:U[0]}`:null!==(V=v.buttonVariable)&&void 0!==V?V:"",type:"link",isEditableVariable:!0,index:null!==(w=v.index)&&void 0!==w?w:0,queryParams:null!==(T=v.queryParams)&&void 0!==T?T:[]},showVariableModal:!0,componentType:"BUTTONS",buttonType:v.type,CTAoptions:L})};export{j as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{cloneDeep as l}from"lodash";import{useState as s,useEffect as a}from"react";import{Dropdown as n}from"../../dropdown/Dropdown.js";import{Input as o}from"../../input/Input.js";import{editableVarPattern as i}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as r}from"../../template-preview/models/TemplateMeta.js";import{POD as u}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as c}from"../../TypographyStyle.js";import{COLORS as d}from"../../../constants/Theme.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import{validateIsUrl as b}from"../utils/validateIsUrl.js";import m,{Container as g}from"./VariableConnector.js";const f=f=>{let{variableListIndex:j,button:v,updateSelectedURLTemplateBtn:O,updateSelectedQRBTemplateBtn:x,currentVariableList:y,CTAoptions:L,QRBoptions:h}=f;var R,U,V,w,T;const[C,I]=s(""),[E,P]=s(),{isError:H,disableEditVariable:N,pod:B,selectedCarouselIndex:Q,originalVariableList:_,setOriginalVariableList:S,isProductCarouselType:K,ctaOptionsErrors:Y,setCtaOptionsErrors:$}=p();function k(e){if(I(e),null!=Q&&Q>-1&&K){const t=l(_);if("URL"===v.type){const l=t.cards.map((t=>{let l=t.buttons.filter((e=>"URL"===e.type))[j];l=Object.assign(Object.assign({},l),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=t.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},t),{buttons:s})}));null==S||S((e=>Object.assign(Object.assign({},e),{cards:l}))),null==O||O(`https://${e}`,"custom",j)}return}let t=y.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const s=y.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),a=Object.assign({},null!=Q&&Q>-1?_.cards[Q]:_);if(a.buttons=s,null!=Q&&Q>-1){const e=[..._.cards];e[Q]=a,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((e=>Object.assign(Object.assign({},e),{buttons:[...s]})));null==O||O(`https://${e}`,"custom",j)}return a((()=>{var e;if(v.buttonVariable&&i.test(v.buttonVariable))P(r),I((null===(e=v.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===v.type?L:h;e="URL"===v.type?t.findIndex((e=>e.placeHolder===v.buttonVariable)):t.findIndex((e=>e.label===v.flowName)),e>-1?P(t[e]):null==$||$((e=>Object.assign(Object.assign({},e),{[j]:"Required field!"})))}}),[]),B!==u.CHATBOT?e(g,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(c,Object.assign({style:{color:d.content.primary}},{children:[v.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(n,{disabled:N,options:"URL"===v.type?L:h,isSearchable:!0,onSelect:function(e,t){var s;null==$||$((e=>(delete e[j],Object.assign({},e))));const a=e;P(a);const n=("URL"===v.type?L:h).find((e=>e.placeHolder===a.placeHolder));if(n)if("custom_link"!==n.value){if(null!=Q&&Q>-1&&K){const e=l(_);if("URL"===v.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:a.placeHolder});const l=e.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==O||O({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",j),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}else if("QUICK_REPLY"===v.type){const t=e.cards.map((e=>{let t=e.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value});const l=e.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e));return Object.assign(Object.assign({},e),{buttons:l})}));null==x||x({flowName:a.label,flowId:a.value},"placeholder",j),console.log("newList",t),null==S||S((e=>Object.assign(Object.assign({},e),{cards:t})))}return}let e;if(console.log("singleOption?.value",a),console.log("buttonbuttonbutton",v),"URL"===v.type){const t=y.buttons.filter((e=>"URL"===e.type));console.log("urlVariables first found",t);let l=t[j];l=Object.assign(Object.assign({},l),{buttonVariable:a.placeHolder,example:[null!==(s=null==a?void 0:a.value)&&void 0!==s?s:"https://d.bik.ai/"]}),console.log("after updatimg",l),console.log("currentVariableList",y),e=y.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),console.log("updatedVariablesupdatedVariablesupdatedVariables",e),null==O||O({defaultValue:n.value,placeHolder:n.placeHolder},"placeholder",j)}else{let t=y.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:a.label,flowId:a.value}),e=y.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==x||x({flowName:a.label,flowId:a.value},"placeholder",j)}const t=Object.assign({},null!=Q&&Q>-1?_.cards[Q]:_);if(t.buttons=e,console.log("newList",t,e),null!=Q&&Q>-1){const e=[..._.cards];e[Q]=t,null==S||S((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==S||S((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else k("")},defaultOptions:E?[Object.assign(Object.assign({},E),{selected:!0})]:[],error:H?null==Y?void 0:Y[j]:void 0})})),"custom_link"===(null==E?void 0:E.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(o,{state:N?"disabled":"none",errorMessage:H?C?b(C)?"":"Enter valid URL":"Required field":"",value:C,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:k,maxCharLimit:2e3})}))]}):t(m,{index:j,variable:{variableName:null!==(R=v.text)&&void 0!==R?R:"",updatedValue:"((customPlaceholderName))"===v.buttonVariable?`${null===(U=v.example)||void 0===U?void 0:U[0]}`:null!==(V=v.buttonVariable)&&void 0!==V?V:"",type:"link",isEditableVariable:!0,index:null!==(w=v.index)&&void 0!==w?w:0,queryParams:null!==(T=v.queryParams)&&void 0!==T?T:[]},showVariableModal:!0,componentType:"BUTTONS",buttonType:v.type,CTAoptions:L})};export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.581-beta-01",
3
+ "version": "0.0.581-beta-02",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",