import{DownOutlined as e,UpOutlined as t}from"@ant-design/icons";import{Form as o,Row as n,Col as r,Button as l}from"antd";import{useState as s,useRef as i,useEffect as a}from"react";import c from"../FormBuilder/FormItemsRenderer.js";import m from"../Icon/ResetIcon/index.js";import u from"../Icon/SearchIcon/index.js";import{jsx as d,jsxs as h}from"react/jsx-runtime";const p=p=>{const{labelCol:f={span:6},options:y=[],values:b={},onFinish:g,onSubmit:x,onReset:C,searchText:F="搜索",resetText:I="重置",showSearchButton:w=!0,showResetButton:j=!0,extraButtons:k,form:R,...S}=p,[V,v]=s(!0),[B,A]=s(6),[N,T]=s(!1),$=i(`search-${Date.now()}`);return a(()=>{y&&0!==y.length&&setTimeout(()=>{const e=document.querySelectorAll(`.${$.current}>.${window.process.env.app.antd["ant-prefix"]}-col`).length-(k?2:1);A({0:24,1:18,2:12,3:6}[e%4]||6),T(e>3)},0)},[y,k]),d("div",{className:"search-layout card-layout",children:d(o,{form:R,labelCol:f,initialValues:b,...S,children:h(n,{className:$.current,children:[d(c,{options:y,labelCol:f,span:6,collapse:V,useAutoGenerateRequired:!1,initialValues:b}),d(r,{span:N&&V?6:B,children:h(o.Item,{label:" ",labelCol:{span:2},colon:!1,style:{textAlign:"right"},children:[w&&d(l,{type:"primary",icon:d(u,{}),onClick:()=>{const e=R.getFieldsValue();g?.(e,"submit"),x?.(e)},children:F}),j&&d(l,{style:{marginLeft:8},icon:d(m,{}),onClick:()=>{const e=R.getFieldsValue(),t={};Object.keys(e).forEach(e=>{t[e]=b.hasOwnProperty(e)?b[e]:void 0}),R.setFieldsValue(t),g?.(b,"reset"),C?.(b)},children:I}),N&&d(l,{type:"link",icon:d(V?e:t,{}),onClick:()=>{v(!V)},style:{marginLeft:8},children:V?"展开":"收起"})]})}),k&&d(r,{span:24,children:d(o.Item,{label:" ",colon:!1,labelCol:{span:0},children:k})})]})})})};p.displayName="Search",p.useForm=o.useForm,p.useWatch=o.useWatch;export{p as default};
