@bikdotai/bik-component-library 0.0.564-beta.picker.12 → 0.0.564-beta.picker.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/template-context-mapper/modalElements/Body.js +4 -4
- package/dist/cjs/components/variable-picker-v3/Content.js +1 -1
- package/dist/cjs/components/variable-picker-v3/model.d.ts +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/Body.js +1 -1
- package/dist/esm/components/variable-picker-v3/Content.js +1 -1
- package/dist/esm/components/variable-picker-v3/model.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../curtain/CurtainHelper.js");var t=require("../../variable-picker-v3/model.js"),a=require("lodash"),i=require("react"),l=require("styled-components"),o=require("../../carousel-preview/CarouselPreview.js"),r=require("./EditWhatsAppCarouselTemplateV2.js"),n=require("../../template-preview/models/Channels.js"),s=require("../../TypographyStyle.js"),d=require("../../variable-picker-v3/VariablePicker.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../curtain/CurtainHelper.js");var t=require("../../variable-picker-v3/model.js"),a=require("lodash"),i=require("react"),l=require("styled-components"),o=require("../../carousel-preview/CarouselPreview.js"),r=require("./EditWhatsAppCarouselTemplateV2.js"),n=require("../../template-preview/models/Channels.js"),s=require("../../TypographyStyle.js"),d=require("../../variable-picker-v3/VariablePicker.js"),c=require("../../../constants/Theme.js"),p=require("../context/templateModalContext.js"),u=require("../utils/constants.js"),h=require("../utils/getVariableNameEmail.js"),m=require("../utils/highlightFor.js"),C=require("./DesktopPreview.js"),v=require("./EditWhatsAppTemplateV2.js"),w=require("./MobilePreview.js"),P=require("./VariableConnectorsPanel.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=b(l);const g=x.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
// height: 100%;
|
|
4
4
|
`,E=x.default.div`
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
height: ${e=>e.channel===n.CHANNEL_TYPE.WHATSAPP?"500px":"475px"};
|
|
9
9
|
overflow-y: auto;
|
|
10
10
|
padding-bottom: 24px;
|
|
11
|
-
border-left: ${
|
|
12
|
-
border-top: ${e=>e.isWhatsappCarousel?`${
|
|
11
|
+
border-left: ${c.COLORS.stroke.primary} 1px solid;
|
|
12
|
+
border-top: ${e=>e.isWhatsappCarousel?`${c.COLORS.stroke.primary} 1px solid`:void 0};
|
|
13
13
|
${e=>!e.showVariableMapping&&"width: 340px; height: 500px"};
|
|
14
14
|
`,f=x.default.div`
|
|
15
15
|
padding: ${e=>e.isWhatsappCarousel?void 0:e.showOnlyContent?"16px 14px":"16px 32px"};
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
background-image: ${e=>e.hideDeviceContainerInPreview&&e.channel===n.CHANNEL_TYPE.WHATSAPP?`url(${u.BACKGROUND_PREVIEW_IMAGE});`:"none"};
|
|
20
20
|
display: ${e=>e.hideDeviceContainerInPreview&&e.channel===n.CHANNEL_TYPE.WHATSAPP?"flex":"initial"};
|
|
21
21
|
align-items: flex-start;
|
|
22
|
-
`;exports.default=l=>{const{showVariableMapping:u,showOnlyContent:b,whatsappSpecificPickerMeta:x,showVariableModal:j,discountCode:A,setDiscountCode:y,variableListForImage:
|
|
22
|
+
`;exports.default=l=>{const{showVariableMapping:u,showOnlyContent:b,whatsappSpecificPickerMeta:x,showVariableModal:j,discountCode:A,setDiscountCode:y,variableListForImage:S,showSampleValues:T,variableListFromProps:L}=l,N=i.useRef(),k=i.useRef(),{variableList:V,setVariableList:M,variableCallback:_,showVariablePicker:H,setShowVariablePicker:q,device:O,display_content:W,channel:D,template:I,setTemplate:Y,isWhatsappCarousel:B,isProductCarouselType:$,hideDeviceContainerInPreview:F,onDefaultVariableSelect:R}=p.useTemplateModalContext();const G=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(g,{children:[e.jsx(f,Object.assign({showOnlyContent:b,showVariableMapping:u,isWhatsappCarousel:B,hideDeviceContainerInPreview:F,channel:D},{children:"mobile"===O?e.jsx(w.default,{ref:k,display_content:null!=W?W:"",channel:D,template:I,showSampleValues:T}):D===n.CHANNEL_TYPE.WHATSAPP&&B?e.jsx(o.CarouselPreview,{ref:N,channel:D,template:I,showSampleValues:T,isPreview:!1,showArrows:!0}):D!==n.CHANNEL_TYPE.MESSAGE?e.jsx(C.default,{ref:N,channel:D,display_content:null!=W?W:"",showSampleValues:T}):e.jsx(e.Fragment,{})})),($||u)&&e.jsxs(E,Object.assign({channel:D,isWhatsappCarousel:B,showVariableMapping:!0},{children:[e.jsx("div",Object.assign({style:{height:"100%",width:"whatsapp"===D?428:400,display:H?"block":"none"}},{children:e.jsx(d.VariablePicker,{hideHeaderCross:!0,showHeader:!0,showBackButton:!0,onBackButtonClick:()=>{M(a.cloneDeep(L)),q(!1)},onSelect:e=>{_(e),M(a.cloneDeep(L)),q(!1)},type:t.PickerType.EMBEDDED,data:null!=V?V:[],onDefaultVariableSelect:R},Math.random())})),e.jsx("div",Object.assign({style:{padding:"16px 14px",width:"whatsapp"===D?428:400,display:H?"none":"block"}},{children:D!==n.CHANNEL_TYPE.WHATSAPP?e.jsx(P.default,{onFocus:D===n.CHANNEL_TYPE.EMAIL?function(e){var t,a,i;const l=null===document||void 0===document?void 0:document.getElementById("mobile"===O?"template_html_mobile":"template_html_desktop"),o=h.getVariableNameForEmailByIndex(e+1),r=D===n.CHANNEL_TYPE.EMAIL?null===(t=null==l?void 0:l.contentWindow)||void 0===t?void 0:t.document.getElementById(o):document.getElementById(o),s=G(r),d=null==r?void 0:r.offsetLeft;"desktop"===O?s&&N.current&&(null===(a=null==l?void 0:l.contentWindow)||void 0===a||a.scrollTo(null!=d?d:0,s),m.highlightFor(o,c.COLORS.background.warning.light,2,D,O)):s&&k.current&&(null===(i=null==l?void 0:l.contentWindow)||void 0===i||i.scrollTo(null!=d?d:0,s),m.highlightFor(o,c.COLORS.background.warning.light,2,D,O))}:void 0,showVariableModal:j,discountCode:A,setDiscountCode:y}):D===n.CHANNEL_TYPE.WHATSAPP&&B?e.jsx(r.default,{whatsappSpecificPickerMeta:x,template:I,showVariableModal:j,variableListForImage:S,discountCode:A,setDiscountCode:y}):e.jsx(v.default,{whatsappSpecificPickerMeta:x,template:I,onTemplateChange:e=>{null==Y||Y(e)},showVariableModal:j,variableListForImage:S,discountCode:A,setDiscountCode:y})}))]})),[n.CHANNEL_TYPE.WHATSAPP,n.CHANNEL_TYPE.SMS].includes(D)&&!u&&!$&&e.jsx(E,{children:e.jsx(s.BodySecondary,Object.assign({color:c.COLORS.content.secondary,style:{fontStyle:"italic"}},{children:"Click on ‘Select template’ below to use it"}))})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_back.svg.js"),a=require("../../assets/icons/cross.svg.js"),i=require("../../assets/icons/plus.svg.js"),l=require("../../assets/icons/triangle_error.svg.js"),r=require("react"),n=require("../../constants/Theme.js"),o=require("../accordion/Accordion.js"),c=require("../icon-button/IconButton.js"),d=require("../input/Input.js"),u=require("../list-item/ListItem.js"),h=require("../switch/Switch.js"),b=require("../tooltips/Tooltip.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_back.svg.js"),a=require("../../assets/icons/cross.svg.js"),i=require("../../assets/icons/plus.svg.js"),l=require("../../assets/icons/triangle_error.svg.js"),r=require("react"),n=require("../../constants/Theme.js"),o=require("../accordion/Accordion.js"),c=require("../icon-button/IconButton.js"),d=require("../input/Input.js"),u=require("../list-item/ListItem.js"),h=require("../switch/Switch.js"),b=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),p=require("./context.js"),g=require("./DefaultVariableContent.js"),x=require("./model.js"),y=require("./NoResult.js"),m=require("./recommendVaribles.js"),f=require("./searchVariables.js"),v=require("./styles.js"),O=require("./SubHeaderItems.js");const S=(e,t)=>{if(0===t.length)return e;const a=e.toLowerCase().indexOf(t.toLowerCase());if(-1===a)return e;const i=e.slice(0,a),l=e.slice(a,a+t.length),r=e.slice(a+t.length);return s.jsxs("span",{children:[i,s.jsx("b",Object.assign({style:{color:n.COLORS.content.primary}},{children:l})),r]})},C=/.*\..*/;exports.VariablePickerContent=V=>{const{data:w,onSelect:R,showHeader:k,showBackButton:q,hideHeaderCross:T,onBackButtonClick:B,isEvaluationList:I,autoOpenFirst:L,headerText:N,contentHeight:D,onDefaultVariableSelect:_}=V,[E,H]=r.useState(w),[P,$]=r.useState(""),[F,A]=r.useState([]),[M,W]=r.useState(""),[z,K]=r.useState(!1),[G,J]=r.useState([]),[Q,U]=r.useState(!1),[X,Y]=r.useState(),Z=Q&&V.type===x.PickerType.EMBEDDED&&!T;r.useEffect((()=>{ee(!0)}),[]),r.useEffect((()=>{F.length>0?J([F[F.length-1]]):J(w)}),[F]);const ee=s=>e.__awaiter(void 0,void 0,void 0,(function*(){if(K(s),s){const e=m.showOnlyRecommendedVariables(E,F);H(e)}else if(F.length>0){const e=M==F[F.length-1].displayName;if(P.length>0&&e){const e=f.searchVariables(P,G,F);H(e)}else H([F[F.length-1].variables])}else if(P.length>0){const e=f.searchVariables(P,G,F);H(e)}else H(w)})),se=()=>{if(D)return D;let e=131;return F.length>0&&(e+=32),(V.showHeader||V.showBackButton)&&(e+=40),`calc(100% - ${e}px)`},te=e=>{if(!V.disabled)if(I){const s=(e=>{if(e.actualValue.match(C)){const s=e.actualValue.replace("{{","").replace("}}","").split(".");let t=s[0];return s.forEach(((e,s)=>{if(0===s)return;const a=(e=>/\w+\[\d+\]/g.test(e))(e);if(a){const s=e.match(/(\w+)\[(\d+)\]/);if(s){const e=s[1],a=s[2];t+=`['${e}'][${a}]`}}else t+=`['${e}']`})),t}return e.actualValueEval?e.actualValueEval:e.actualValue})(e);R(Object.assign(Object.assign({},e),{actualValue:s}))}else{if(e.isDefaultValueSupported)return Y(e),void U(!0);R(e)}};return s.jsx(p.VariablePickerContext.Provider,Object.assign({value:{variables:E,searchText:P,subHeaderStack:F,showRecommended:z,setSubHeaderStack:A,setSearchText:$,setVariables:H,setShowRecommended:K}},{children:s.jsxs("div",Object.assign({tabIndex:-1,id:"variable-picker-v3",style:{backgroundColor:"white",borderRadius:4,height:"100%",outline:"none"},onClick:e=>e.stopPropagation()},{children:[(k||q||Q)&&s.jsxs(v.HeaderWrapper,Object.assign({openDefault:Q},{children:[s.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[(q||Q)&&s.jsx(c.IconButton,{Icon:()=>s.jsx(t.default,{width:16,height:16,style:{display:"flex",color:n.COLORS.content.primary}}),onClick:()=>{Q?Q&&U(!1):B&&B()}}),(k||Q)&&s.jsx(j.TitleRegular,{children:Q?"Set up":null!=N?N:"Select Variable"})]})),Z&&s.jsx(c.IconButton,{style:{color:"#212121"},Icon:a.default,onClick:()=>V.onClose&&V.onClose()})]})),Q&&X?s.jsx(g.DefaultVariableContent,{variable:X,onInsertVariable:e=>{R(e),null==_||_(e),console.log("insert",e)}}):s.jsxs(s.Fragment,{children:[s.jsx("div",Object.assign({style:{padding:"0 16px",paddingTop:12,backgroundColor:n.COLORS.surface.subdued,borderTopLeftRadius:4,borderTopRightRadius:4}},{children:s.jsx(d.Input,{id:"search-bar-v3-picker",onBlur:e=>{V.onSearchBlur&&V.onSearchBlur(e)},value:P,noKeyDownChange:!0,placeholder:"Search",onChangeText:e=>{e||W("");const s=f.searchVariables(e,G,F);if(z){const e=m.showOnlyRecommendedVariables(s,F);H(e)}else H(s);$(e);const t=F.length>0?F[F.length-1].displayName:"home";W(t)}})})),s.jsxs(v.RecommendWrapper,{children:[s.jsx(j.BodySecondary,Object.assign({style:{color:n.COLORS.content.secondary}},{children:"Only Recommended"})),s.jsx(h.Switch,{value:z,onValueChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield ee(s)}))})]}),F.length>0&&s.jsxs(v.BackHeader,{children:[s.jsx("div",Object.assign({style:{position:"absolute",left:16}},{children:s.jsx(c.IconButton,{id:"back-btn-v3",style:{display:"flex"},Icon:()=>s.jsx(t.default,{width:12,height:12,style:{color:n.COLORS.content.secondary}}),onClick:e=>{e.stopPropagation();let s=P;const t=[...F],a=t.pop();if(A(t),a.displayName===M&&($(""),s=""),s.length>0){const e=t.length>0?[t[t.length-1]]:w,a=f.searchVariables(s,e,t);if(z){const e=m.showOnlyRecommendedVariables(a,t);H(e)}else H(a)}else if(t.length>0)if(z){const e=m.showOnlyRecommendedVariables([t[t.length-1].variables],t);H(e)}else H([t[t.length-1].variables]);else if(z){const e=m.showOnlyRecommendedVariables(w,F);H(e)}else H(w)}})})),s.jsx(j.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:F[F.length-1].displayName}))]}),s.jsx(s.Fragment,{children:E.length>0?s.jsx(v.Container,Object.assign({height:se()},{children:E.map(((e,t)=>{var a,r;return e.displayName&&void 0!==e.variables?s.jsx("div",Object.assign({style:{borderBottom:`1px solid ${n.COLORS.stroke.primary}`}},{children:s.jsx(o.BikAccordion,Object.assign({autoOpen:L&&0===t,headerPadding:"12px 16px",header:s.jsx(j.TitleSmall,Object.assign({style:{color:n.COLORS.content.secondary}},{children:S(e.displayName,P)}))},{children:s.jsx(O.default,{parentVariable:e,disabled:null!==(a=V.disabled)&&void 0!==a&&a,searchText:P,variable:e.variables,onSelect:e=>{if(e.isDefaultValueSupported)return Y(e),void U(!0);R(e)}})}))}),e.displayName+z):e.displayName?s.jsx(b.Tooltip,Object.assign({body:O.renderTooltipBody(e),placement:"bottom"},{children:s.jsx(u.ListItem,{variant:V.disabled?"readonly":(null==e?void 0:e.selected)?"selected":"default",version:"2.0",leadingIcon:(null==e?void 0:e.selected)||V.disabled?s.jsx(s.Fragment,{}):s.jsx(i.default,{width:14,height:14}),customListItemLabel:s.jsxs("div",Object.assign({style:{display:"flex",gap:4}},{children:[s.jsx(j.BodySecondary,Object.assign({style:{fontSize:"14px",color:n.COLORS.text.primary}},{children:S(e.displayName,P)})),!e.isAvailable&&s.jsx(b.Tooltip,Object.assign({body:"Not Recommended"},{children:s.jsx("div",Object.assign({style:{display:"flex",marginTop:2}},{children:s.jsx(l.default,{width:16,height:16,color:n.COLORS.content.secondary})}))}))]})),listItem:{label:e.displayName,value:e.displayName},subText:e.description||"",onClick:()=>te(e)},t)}),t):s.jsx(O.default,{disabled:null!==(r=V.disabled)&&void 0!==r&&r,searchText:P,variable:e,onSelect:e=>te(e)},t)}))})):s.jsx(y.default,{height:se(),searchText:P})})]})]}))}))},exports.highlightSearchText=S;
|
|
@@ -19,4 +19,4 @@ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import"../../cur
|
|
|
19
19
|
background-image: ${e=>e.hideDeviceContainerInPreview&&e.channel===p.WHATSAPP?`url(${u});`:"none"};
|
|
20
20
|
display: ${e=>e.hideDeviceContainerInPreview&&e.channel===p.WHATSAPP?"flex":"initial"};
|
|
21
21
|
align-items: flex-start;
|
|
22
|
-
`,S=n=>{const{showVariableMapping:u,showOnlyContent:S,whatsappSpecificPickerMeta:k,showVariableModal:j,discountCode:
|
|
22
|
+
`,S=n=>{const{showVariableMapping:u,showOnlyContent:S,whatsappSpecificPickerMeta:k,showVariableModal:j,discountCode:V,setDiscountCode:A,variableListForImage:M,showSampleValues:W,variableListFromProps:T}=n,D=l(),E=l(),{variableList:I,setVariableList:$,variableCallback:H,showVariablePicker:L,setShowVariablePicker:B,device:O,display_content:_,channel:F,template:G,setTemplate:N,isWhatsappCarousel:q,isProductCarouselType:z,hideDeviceContainerInPreview:J,onDefaultVariableSelect:K}=h();const Q=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e(P,{children:[t(y,Object.assign({showOnlyContent:S,showVariableMapping:u,isWhatsappCarousel:q,hideDeviceContainerInPreview:J,channel:F},{children:"mobile"===O?t(g,{ref:E,display_content:null!=_?_:"",channel:F,template:G,showSampleValues:W}):F===p.WHATSAPP&&q?t(r,{ref:D,channel:F,template:G,showSampleValues:W,isPreview:!1,showArrows:!0}):F!==p.MESSAGE?t(f,{ref:D,channel:F,display_content:null!=_?_:"",showSampleValues:W}):t(o,{})})),(z||u)&&e(x,Object.assign({channel:F,isWhatsappCarousel:q,showVariableMapping:!0},{children:[t("div",Object.assign({style:{height:"100%",width:"whatsapp"===F?428:400,display:L?"block":"none"}},{children:t(c,{hideHeaderCross:!0,showHeader:!0,showBackButton:!0,onBackButtonClick:()=>{$(a(T)),B(!1)},onSelect:e=>{H(e),$(a(T)),B(!1)},type:i.EMBEDDED,data:null!=I?I:[],onDefaultVariableSelect:K},Math.random())})),t("div",Object.assign({style:{padding:"16px 14px",width:"whatsapp"===F?428:400,display:L?"none":"block"}},{children:F!==p.WHATSAPP?t(C,{onFocus:F===p.EMAIL?function(e){var t,o,i;const a=null===document||void 0===document?void 0:document.getElementById("mobile"===O?"template_html_mobile":"template_html_desktop"),l=w(e+1),n=F===p.EMAIL?null===(t=null==a?void 0:a.contentWindow)||void 0===t?void 0:t.document.getElementById(l):document.getElementById(l),r=Q(n),s=null==n?void 0:n.offsetLeft;"desktop"===O?r&&D.current&&(null===(o=null==a?void 0:a.contentWindow)||void 0===o||o.scrollTo(null!=s?s:0,r),v(l,m.background.warning.light,2,F,O)):r&&E.current&&(null===(i=null==a?void 0:a.contentWindow)||void 0===i||i.scrollTo(null!=s?s:0,r),v(l,m.background.warning.light,2,F,O))}:void 0,showVariableModal:j,discountCode:V,setDiscountCode:A}):F===p.WHATSAPP&&q?t(s,{whatsappSpecificPickerMeta:k,template:G,showVariableModal:j,variableListForImage:M,discountCode:V,setDiscountCode:A}):t(b,{whatsappSpecificPickerMeta:k,template:G,onTemplateChange:e=>{null==N||N(e)},showVariableModal:j,variableListForImage:M,discountCode:V,setDiscountCode:A})}))]})),[p.WHATSAPP,p.SMS].includes(F)&&!u&&!z&&t(x,{children:t(d,Object.assign({color:m.content.secondary,style:{fontStyle:"italic"}},{children:"Click on ‘Select template’ below to use it"}))})]})};export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t,jsxs as s,Fragment as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t,jsxs as s,Fragment as i}from"react/jsx-runtime";import o from"../../assets/icons/arrow_back.svg.js";import l from"../../assets/icons/cross.svg.js";import a from"../../assets/icons/plus.svg.js";import n from"../../assets/icons/triangle_error.svg.js";import{useState as r,useEffect as c}from"react";import{COLORS as d}from"../../constants/Theme.js";import{BikAccordion as h}from"../accordion/Accordion.js";import{IconButton as p}from"../icon-button/IconButton.js";import{Input as m}from"../input/Input.js";import{ListItem as u}from"../list-item/ListItem.js";import{Switch as g}from"../switch/Switch.js";import{Tooltip as b}from"../tooltips/Tooltip.js";import{TitleRegular as f,BodySecondary as y,BodyCaption as v,TitleSmall as j}from"../TypographyStyle.js";import{VariablePickerContext as x}from"./context.js";import{DefaultVariableContent as O}from"./DefaultVariableContent.js";import{PickerType as S}from"./model.js";import w from"./NoResult.js";import{showOnlyRecommendedVariables as k}from"./recommendVaribles.js";import{searchVariables as C}from"./searchVariables.js";import{HeaderWrapper as V,RecommendWrapper as T,BackHeader as I,Container as N}from"./styles.js";import B,{renderTooltipBody as D}from"./SubHeaderItems.js";const R=(e,i)=>{if(0===i.length)return e;const o=e.toLowerCase().indexOf(i.toLowerCase());if(-1===o)return e;const l=e.slice(0,o),a=e.slice(o,o+i.length),n=e.slice(o+i.length);return s("span",{children:[l,t("b",Object.assign({style:{color:d.content.primary}},{children:a})),n]})},E=/.*\..*/,H=H=>{const{data:L,onSelect:$,showHeader:P,showBackButton:_,hideHeaderCross:A,onBackButtonClick:z,isEvaluationList:F,autoOpenFirst:K,headerText:M,contentHeight:q,onDefaultVariableSelect:G}=H,[J,Q]=r(L),[U,W]=r(""),[X,Y]=r([]),[Z,ee]=r(""),[te,se]=r(!1),[ie,oe]=r([]),[le,ae]=r(!1),[ne,re]=r(),ce=le&&H.type===S.EMBEDDED&&!A;c((()=>{de(!0)}),[]),c((()=>{X.length>0?oe([X[X.length-1]]):oe(L)}),[X]);const de=t=>e(void 0,void 0,void 0,(function*(){if(se(t),t){const e=k(J,X);Q(e)}else if(X.length>0){const e=Z==X[X.length-1].displayName;if(U.length>0&&e){const e=C(U,ie,X);Q(e)}else Q([X[X.length-1].variables])}else if(U.length>0){const e=C(U,ie,X);Q(e)}else Q(L)})),he=()=>{if(q)return q;let e=131;return X.length>0&&(e+=32),(H.showHeader||H.showBackButton)&&(e+=40),`calc(100% - ${e}px)`},pe=e=>{if(!H.disabled)if(F){const t=(e=>{if(e.actualValue.match(E)){const t=e.actualValue.replace("{{","").replace("}}","").split(".");let s=t[0];return t.forEach(((e,t)=>{if(0===t)return;const i=(e=>/\w+\[\d+\]/g.test(e))(e);if(i){const t=e.match(/(\w+)\[(\d+)\]/);if(t){const e=t[1],i=t[2];s+=`['${e}'][${i}]`}}else s+=`['${e}']`})),s}return e.actualValueEval?e.actualValueEval:e.actualValue})(e);$(Object.assign(Object.assign({},e),{actualValue:t}))}else{if(e.isDefaultValueSupported)return re(e),void ae(!0);$(e)}};return t(x.Provider,Object.assign({value:{variables:J,searchText:U,subHeaderStack:X,showRecommended:te,setSubHeaderStack:Y,setSearchText:W,setVariables:Q,setShowRecommended:se}},{children:s("div",Object.assign({tabIndex:-1,id:"variable-picker-v3",style:{backgroundColor:"white",borderRadius:4,height:"100%",outline:"none"},onClick:e=>e.stopPropagation()},{children:[(P||_||le)&&s(V,Object.assign({openDefault:le},{children:[s("div",Object.assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[(_||le)&&t(p,{Icon:()=>t(o,{width:16,height:16,style:{display:"flex",color:d.content.primary}}),onClick:()=>{le?le&&ae(!1):z&&z()}}),(P||le)&&t(f,{children:le?"Set up":null!=M?M:"Select Variable"})]})),ce&&t(p,{style:{color:"#212121"},Icon:l,onClick:()=>H.onClose&&H.onClose()})]})),le&&ne?t(O,{variable:ne,onInsertVariable:e=>{$(e),null==G||G(e),console.log("insert",e)}}):s(i,{children:[t("div",Object.assign({style:{padding:"0 16px",paddingTop:12,backgroundColor:d.surface.subdued,borderTopLeftRadius:4,borderTopRightRadius:4}},{children:t(m,{id:"search-bar-v3-picker",onBlur:e=>{H.onSearchBlur&&H.onSearchBlur(e)},value:U,noKeyDownChange:!0,placeholder:"Search",onChangeText:e=>{e||ee("");const t=C(e,ie,X);if(te){const e=k(t,X);Q(e)}else Q(t);W(e);const s=X.length>0?X[X.length-1].displayName:"home";ee(s)}})})),s(T,{children:[t(y,Object.assign({style:{color:d.content.secondary}},{children:"Only Recommended"})),t(g,{value:te,onValueChange:t=>e(void 0,void 0,void 0,(function*(){yield de(t)}))})]}),X.length>0&&s(I,{children:[t("div",Object.assign({style:{position:"absolute",left:16}},{children:t(p,{id:"back-btn-v3",style:{display:"flex"},Icon:()=>t(o,{width:12,height:12,style:{color:d.content.secondary}}),onClick:e=>{e.stopPropagation();let t=U;const s=[...X],i=s.pop();if(Y(s),i.displayName===Z&&(W(""),t=""),t.length>0){const e=s.length>0?[s[s.length-1]]:L,i=C(t,e,s);if(te){const e=k(i,s);Q(e)}else Q(i)}else if(s.length>0)if(te){const e=k([s[s.length-1].variables],s);Q(e)}else Q([s[s.length-1].variables]);else if(te){const e=k(L,X);Q(e)}else Q(L)}})})),t(v,Object.assign({style:{color:d.content.secondary}},{children:X[X.length-1].displayName}))]}),t(i,{children:J.length>0?t(N,Object.assign({height:he()},{children:J.map(((e,o)=>{var l,r;return e.displayName&&void 0!==e.variables?t("div",Object.assign({style:{borderBottom:`1px solid ${d.stroke.primary}`}},{children:t(h,Object.assign({autoOpen:K&&0===o,headerPadding:"12px 16px",header:t(j,Object.assign({style:{color:d.content.secondary}},{children:R(e.displayName,U)}))},{children:t(B,{parentVariable:e,disabled:null!==(l=H.disabled)&&void 0!==l&&l,searchText:U,variable:e.variables,onSelect:e=>{if(e.isDefaultValueSupported)return re(e),void ae(!0);$(e)}})}))}),e.displayName+te):e.displayName?t(b,Object.assign({body:D(e),placement:"bottom"},{children:t(u,{variant:H.disabled?"readonly":(null==e?void 0:e.selected)?"selected":"default",version:"2.0",leadingIcon:(null==e?void 0:e.selected)||H.disabled?t(i,{}):t(a,{width:14,height:14}),customListItemLabel:s("div",Object.assign({style:{display:"flex",gap:4}},{children:[t(y,Object.assign({style:{fontSize:"14px",color:d.text.primary}},{children:R(e.displayName,U)})),!e.isAvailable&&t(b,Object.assign({body:"Not Recommended"},{children:t("div",Object.assign({style:{display:"flex",marginTop:2}},{children:t(n,{width:16,height:16,color:d.content.secondary})}))}))]})),listItem:{label:e.displayName,value:e.displayName},subText:e.description||"",onClick:()=>pe(e)},o)}),o):t(B,{disabled:null!==(r=H.disabled)&&void 0!==r&&r,searchText:U,variable:e,onSelect:e=>pe(e)},o)}))})):t(w,{height:he(),searchText:U})})]})]}))}))};export{H as VariablePickerContent,R as highlightSearchText};
|