| 1 |
import{t as X,k as w,l as Y,r as g,a as Z,u as tt,_ as d,j as t,M as et,I as st,p as r,aU as x,d0 as nt,c_ as lt,d1 as at,aa as it,aq as ot,au as ct,cs as dt,c$ as rt}from"./main-162.js";import{F as o,A as ut}from"./bf-4-157.js";import{a as bt}from"./bf-562-110.js";import{F as pt}from"./bf-382-322.js";import{F as mt,b as xt,H as ft,c as gt}from"./bf-947-93.js";import{a as b,F as P,I as ht}from"./bf-630-188.js";import{S as h}from"./bf-243-83.js";import"./bf-442-111.js";import"./bf-917-73.js";import"./bf-432-112.js";import"./bf-746-113.js";/* empty css */import"./bf-40-156.js";import"./bf-644-69.js";import"./bf-174-145.js";import"./bf-553-107.js";import"./bf-424-108.js";import"./bf-974-109.js";import"./bf-207-114.js";import"./bf-734-115.js";import"./bf-379-125.js";import"./bf-217-124.js";import"./bf-741-81.js";import"./bf-819-116.js";import"./bf-76-117.js";import"./bf-608-71.js";function Vt(){const{fieldKey:e}=X(),[c,p]=w(it),n=Y(c[e]),[v,j]=g.useState({}),[M,y]=g.useState(!1),[R,E]=g.useState(""),{txt:H,align:W,txtAlign:K,fulW:L,btnTyp:$}=n,[O,z]=g.useState(W),{css:i}=Z(),[D,f]=w(ot),V=tt(ct),T=[{name:d("Left"),value:"start"},{name:d("Center"),value:"center"},{name:d("Right"),value:"end"}],S=[{name:"Reset",value:"reset",disabled:!1},{name:"Button",value:"button",disabled:!1}];st&&S.push({name:"Save Draft",value:"save-draft",disabled:!1});function q(s){n.txt=s.target.value;const l=r(c,a=>{a[e]=n});p(l),x({event:`Button text updated : ${n.txt}`,type:"change_btn_txt",state:{fields:l,fldKey:e}})}function U(s){const{value:l}=s.target;if(n.btnTyp=l,n.btnTyp==="submit"&&F()){j({btnTyp:d("Already have a submit button")}),setTimeout(()=>{j({btnTyp:""})},3e3);return}v.btnTyp&&j({btnTyp:""});let a="var(--btn-bg)",u="var(--btn-c)",_="var(--btn-bdr-clr)",N="var(--btn-bdr)",k="var(--btn-bdr-width)";l==="reset"&&(a="hsla(240, 12%, 94%, 100)",u="hsla(208, 46%, 25%, 100)"),l==="save-default"&&(a="hsla(0, 0%, 100%, 100)",u="var(--btn-bgc)",_="var(--btn-bgc)",N="solid",k="1px"),f(I=>r(I,m=>{m.fields[e].classes[`.${e}-btn`].background=a,m.fields[e].classes[`.${e}-btn`].color=u,l!=="save-draft"&&(m.fields[e].classes[`.${e}-btn`]["border-color"]=_,m.fields[e].classes[`.${e}-btn`]["border-style"]=N,m.fields[e].classes[`.${e}-btn`]["border-width"]=k,m.fields[e].classes[`.${e}-btn:hover`].color="var(--btn-c)")}));const C=r(c,I=>{I[e]=n});p(C),x({event:`Button Type updated to ${l}: ${n.txt}`,type:"set_btn_typ",state:{fields:C,fldKey:e}})}function G(s){const{value:l}=s.target;f(a=>r(a,u=>{u.fields[e].classes[`.${e}-inp-fld-wrp`]["justify-content"]=l})),n.align=l,p(r(c,a=>{a[e]=n})),z(l),x({event:`Button Alignment changed to ${l}: ${n.txt}`,type:"set_btn_align",state:{fields:c,fldKey:e}})}function J(s){const{value:l}=s.target;f(a=>r(a,u=>{u.fields[e].classes[`.${e}-btn`]["justify-content"]=l})),n.txtAlign=l,p(r(c,a=>{a[e]=n})),x({event:`Button Text Alignment changed to ${l}: ${n.txt}`,type:"set_btn_text_align",state:{fields:c,fldKey:e}})}const F=()=>Object.values(c).filter(l=>l.typ==="button"&&l.btnTyp==="submit").length>=1;(!F()||$==="submit")&&S.push({name:"Submit",value:"submit",disabled:!0});function Q(s){f(a=>r(a,u=>{u.fields[e].classes[`.${e}-btn`].width=s.target.checked?"100%":"auto"})),n.fulW=s.target.checked;const l=r(c,a=>{a[e]=n});p(l),x({event:`Button Full width ${s.target.checked?"on":"off"}`,type:"set_btn_full",state:{fields:l,fldKey:e}})}const B=s=>{nt(D,e,dt[s])||lt(V,s),at(s,e),E(s),y(!0)},A=s=>{if(n[s]){delete n[s];const l=r(c,a=>{a[e]=n});p(l),x({event:`${rt[s]} Icon Deleted`,type:`delete_${s}`,state:{fldKey:e,fields:l}})}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"",children:[t.jsx(mt,{title:"Field Settings",subtitle:n.typ,fieldKey:e}),t.jsx(xt,{}),t.jsx(b,{}),t.jsxs(h,{id:"btn-txt-stng",title:d("Button Text"),className:i(o.fieldSection),open:!0,children:[t.jsx("div",{className:i(o.placeholder),children:t.jsx(ut,{id:"btn-txt","aria-label":"Button text",placeholder:"Type text here...",value:H,changeAction:q})}),t.jsx(P,{label:"Leading Icon",iconSrc:n==null?void 0:n.btnPreIcn,styleRoute:"btn-pre-i",setIcon:()=>B("btnPreIcn"),removeIcon:()=>A("btnPreIcn"),isPro:!0}),t.jsx(P,{label:"Trailing Icon",iconSrc:n==null?void 0:n.btnSufIcn,styleRoute:"btn-suf-i",setIcon:()=>B("btnSufIcn"),removeIcon:()=>A("btnSufIcn"),isPro:!0})]}),t.jsx(b,{}),t.jsx(ft,{}),t.jsx(b,{}),t.jsx(pt,{}),t.jsx(b,{}),t.jsx(h,{id:"btn-algn",title:d("Button Align"),className:i(o.fieldSection),open:!0,children:t.jsx("div",{className:i(o.placeholder),children:t.jsx("select",{"data-testid":"btn-algn-slct",className:i(o.input),name:"",id:"",value:O,onChange:G,children:T.map(s=>t.jsx("option",{value:s.value,children:s.name},`btcd-k-${s.name}`))})})}),t.jsx(b,{}),t.jsx(h,{id:"txt-algn",title:d("Text Align"),className:i(o.fieldSection),open:!0,children:t.jsx("div",{className:i(o.placeholder),children:t.jsx("select",{"data-testid":"txt-algn-slct",className:i(o.input),name:"",id:"",value:K||"center",onChange:J,children:T.map(s=>t.jsx("option",{value:s.value,children:s.name},`btcd-k-${s.name}`))})})}),t.jsx(b,{}),t.jsxs(h,{id:"btn-typ",title:d("Button Type"),className:i(o.fieldSection),open:!0,children:[t.jsx("div",{className:i(o.placeholder),children:t.jsx("select",{"data-testid":"btn-typ-slct",className:i(o.input),name:"",id:"",value:$,onChange:U,children:S.map(s=>t.jsx("option",{value:s.value,children:s.name},`btcd-k-${s.name}`))})}),v.btnTyp&&t.jsx("span",{className:i({cr:"red",ml:10}),children:v.btnTyp})]}),t.jsx(b,{}),t.jsx("div",{className:i(o.fieldSection,{pr:"36px"}),children:t.jsx(bt,{id:"ful-wid-btn",tip:"By disabling this option, the button full width will be remove",title:d("Full Width"),action:Q,isChecked:L||""})}),t.jsx(b,{}),t.jsx(gt,{})]}),t.jsxs(et,{md:!0,autoHeight:!0,show:M,setModal:y,className:"o-v",title:d("Icons"),children:[t.jsx("div",{className:"pos-rel"}),t.jsx(ht,{iconType:R,addPaddingOnSelect:!1,setModal:y})]})]})}export{Vt as default}; |