bj-web-components 0.2.13 → 0.2.15

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,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),b=require("react"),Kt=require("react-dom"),qt=require("../Pagination/Pagination.js"),me=require("../Icon/Icon.js");;/* empty css */const Bt=require("../Tooltip/ContentTooltip.js"),Tt=require("../Tooltip/TooltipWrapper.js"),zt=require("../CheckBox/index.js"),It=require("../Dropdown/BDropdown.js"),Vt=require("../OverlayScrollbar/BOverlayScrollbar.js"),wt=require("../SkuInputCard/spin_loading_red.gif.js"),Lt=require("../ProductField/no_data_light.png.js"),At=require("./Column.js"),Ht=require("./ColumnGroup.js"),_=require("./utils/sortFilter.js"),ve=require("./utils/columns.js");;/* empty css */const Wt=300;function E(...p){return p.filter(Boolean).join(" ")}function Ut(p,u){return u===void 0?void 0:(Array.isArray(u)?u:[u]).reduce((r,k)=>{if(!(r==null||typeof r!="object"))return r[k]},p)}function H(p,u,j){if(typeof j=="function")return j(p,u);if(j){const r=p[String(j)];if(typeof r=="string"||typeof r=="number")return r}return u}function Ze(p,u){return Math.max(1,Math.ceil(p/u))}function $t(p){return!!(p&&typeof p=="object"&&!b.isValidElement(p)&&"props"in p)}function Gt(p,u){return(typeof u.text=="string"||typeof u.text=="number"?String(u.text):String(u.value)).toLocaleLowerCase().includes(p.toLocaleLowerCase())}function Xe({checked:p,disabled:u,label:j,name:r,onChange:k,type:U="checkbox"}){return U==="checkbox"?i.jsx(zt.BCheckBox,{"aria-label":j,checked:p,className:"bj-table__selection-checkbox",disabled:u,name:r,onChange:k,skipGroup:!0}):i.jsxs("label",{className:E("bj-table__selection-control",p&&"bj-table__selection-control--checked",u&&"bj-table__selection-control--disabled"),children:[i.jsx("input",{"aria-label":j,checked:p,className:"bj-table__selection-input",disabled:u,name:r,onChange:k,type:U}),i.jsx("span",{"aria-hidden":"true",className:"bj-table__selection-box",children:p&&i.jsx(me,{className:"bj-table__selection-check-icon",type:"icon-a-dagouxi"})})]})}function Jt({columns:p,dataSource:u=[],rowKey:j,rowSelection:r,pagination:k=!1,loading:U=!1,bordered:Ye=!0,size:et="middle",showHeader:tt=!0,emptyText:ae,emptyImage:le=Lt,emptyHeight:st,t:$=Y=>Y,className:rt,style:at,rowClassName:ie,sortDirections:lt=["ascend","descend",null],onChange:ne,children:Ce,title:Fe,footer:De,summary:Re,tableLayout:Pe,components:v,onRow:de,onHeaderRow:ce,id:it,scroll:o,locale:W}){var Ue,$e,Ge;const Y=b.useRef(null),ke=b.useRef(null),ee=b.useMemo(()=>p??ve.convertChildrenToColumns(Ce),[Ce,p]),G=b.useMemo(()=>ve.flattenColumns(ee),[ee]),Oe=b.useMemo(()=>ve.buildHeaderRows(ee),[ee]),[nt,Ee]=b.useState((r==null?void 0:r.defaultSelectedRowKeys)??[]),[oe,te]=b.useState(k?k.defaultCurrent??1:1),[dt,ct]=b.useState(k?k.defaultPageSize??10:10),[ot,bt]=b.useState(()=>new Map(G.flatMap((e,t)=>e.defaultSortOrder?[[_.getColumnKey(e,t),e.defaultSortOrder]]:[]))),[ft,ut]=b.useState(()=>new Map(G.flatMap((e,t)=>e.defaultFilteredValue===void 0?[]:[[_.getColumnKey(e,t),e.defaultFilteredValue]]))),[M,L]=b.useState(null),[Me,J]=b.useState(new Map),[ht,se]=b.useState(null),pt=b.useRef(`btable-${Math.random().toString(36).slice(2,10)}`).current,[A,be]=b.useState(null),[fe,Se]=b.useState(null),[ue,Ke]=b.useState(""),[Q,qe]=b.useState(""),[_t,he]=b.useState(),pe=b.useRef(0),a=k||void 0,B=(a==null?void 0:a.pageSize)??dt,D=(r==null?void 0:r.selectedRowKeys)??nt,m=G,R=new Map(ot),O=new Map(ft);m.forEach((e,t)=>{if("children"in e)return;const s=_.getColumnKey(e,t);e.sortOrder!==void 0&&R.set(s,e.sortOrder),e.filteredValue!==void 0&&O.set(s,e.filteredValue)});const Be=b.useMemo(()=>_.filterRecords(u,m,O),[m,O,u]),T=b.useMemo(()=>_.sortRecords(Be,m,R),[m,Be,R]),_e=(a==null?void 0:a.total)??T.length,Te=Ze(_e,B),S=Math.min((a==null?void 0:a.current)??oe,Te);b.useEffect(()=>{S!==oe&&(a==null?void 0:a.current)===void 0&&te(S)},[S,a==null?void 0:a.current,oe]),b.useEffect(()=>{if(!A||M===null){Se(null);return}const e=()=>{const t=A.getBoundingClientRect();Se({left:t.left,top:t.bottom+8})};return e(),document.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{document.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[A,M]),b.useEffect(()=>{if(M===null)return;const e=t=>{const s=t.target;A!=null&&A.contains(s)||s.closest(".bj-table__filter-dropdown")||(L(null),be(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[A,M]),b.useEffect(()=>{const e=window.setTimeout(()=>qe(ue.trim()),Wt);return()=>window.clearTimeout(e)},[ue]),b.useEffect(()=>{if(M===null)return;const e=G.find((s,d)=>_.getColumnKey(s,d)===M);if(!e||"children"in e||!e.filterRequest)return;const t=++pe.current;Promise.resolve().then(()=>e.filterRequest(Q)).then(s=>{pe.current===t&&he(s)},()=>{pe.current===t&&he([])})},[Q,G,M]);const z=b.useMemo(()=>{if(!a)return T.map((t,s)=>({record:t,index:s}));const e=(S-1)*B;return T.slice(e,e+B).map((t,s)=>({record:t,index:e+s}))},[S,B,a,T]),ze=b.useMemo(()=>z.map(({record:e,index:t})=>H(e,t,j)),[j,z]),jt=D.map(String).join("|"),gt=ze.map(String).join("|");b.useEffect(()=>{var c;if(!r||D.length===0)return;const e=new Set(ze),t=D.filter(f=>e.has(f));if(t.length===D.length)return;r.selectedRowKeys===void 0&&Ee(t);const s=new Set(t),d=z.filter(({record:f,index:l})=>s.has(H(f,l,j))).map(({record:f})=>f);(c=r.onChange)==null||c.call(r,t,d,{type:"multiple"})},[r,j,jt,gt,z]);const je=(e,t=R,s=O,d=S)=>{const c=Object.fromEntries(s),f=_.filterRecords(u,m,s),l=_.sortRecords(f,m,t);ne==null||ne({...a,current:d,pageSize:B,total:(a==null?void 0:a.total)??l.length},c,_.getSorterResult(m,t),{action:e,currentDataSource:l})},yt=(e,t)=>{if(!e.sorter)return;const s=_.getColumnKey(e,t),d=_.getNextSortOrder(R.get(s)??null,e.sortDirections??lt),c=new Map;c.set(s,d),e.sortOrder===void 0&&bt(c),je("sort",c)},ge=(e,t,s)=>{const d=_.getColumnKey(e,t),c=new Map(O);c.set(d,s),e.filteredValue===void 0&&ut(c),L(null),(a==null?void 0:a.current)===void 0&&te(1),je("filter",R,c,1)},xt=(e,t)=>{const s=_.getColumnKey(e,t),d=e.filterResetToDefaultFilteredValue?e.defaultFilteredValue??[]:[];J(c=>new Map(c).set(s,d))},re=(e,t,s)=>{var c,f,l,C;const d=_.getColumnKey(e,t);if(M===d){L(null),be(null),(c=e.onFilterDropdownOpenChange)==null||c.call(e,!1),(f=e.onFilterDropdownVisibleChange)==null||f.call(e,!1);return}Ke(""),qe(""),he(void 0),J(g=>new Map(g).set(d,O.get(d)??[])),L(d),s&&be(s),(l=e.onFilterDropdownOpenChange)==null||l.call(e,!0),(C=e.onFilterDropdownVisibleChange)==null||C.call(e,!0)},vt=(e,t)=>{var w,Je;const s=_.getColumnKey(e,t),d=`bj-table-badge-${pt}-${String(s).replace(/[^a-zA-Z0-9_-]/g,"-")}`,c=R.get(s)??null,f=O.get(s)??[],l=Me.get(s)??f,C=e.filterDropdownOpen??e.filterDropdownVisible??M===s,g=e.filtered||f.length>0,h=c==="ascend"?"icon-a-zhengxumian":c==="descend"?"icon-a-daoxumian":"icon-a-weipaixumian",I=_.renderColumnTitle(e.title,{sortOrder:c,sortColumn:c?e:void 0,sortColumns:c?[{column:e,order:c}]:[],filters:Object.fromEntries(O)}),V=typeof e.filterDropdown=="function"?e.filterDropdown({prefixCls:"bj-table",selectedKeys:l.filter(n=>typeof n!="boolean"),setSelectedKeys:n=>J(y=>new Map(y).set(s,n)),confirm:n=>{ge(e,t,Me.get(s)??l),(n==null?void 0:n.closeDropdown)===!1&&L(s)},clearFilters:n=>{const y=e.filterResetToDefaultFilteredValue?e.defaultFilteredValue??[]:[];J(F=>new Map(F).set(s,y)),(n==null?void 0:n.confirm)===!0&&ge(e,t,y),((n==null?void 0:n.closeDropdown)===!1||(n==null?void 0:n.confirm)!==!0)&&L(s)},filters:e.filters,close:()=>L(null),visible:C}):e.filterDropdown,P=e.filterRequest?_t??[]:e.filters??[],x=Q&&!e.filterRequest?P.filter(n=>typeof e.filterSearch=="function"?e.filterSearch(Q,n):Gt(Q,n)):P,q=!!(e.filterSearch||e.filterRequest),N=i.jsxs("div",{className:E("bj-table__column-header",e.sorter&&"bj-table__column-header--sortable"),children:[e.badge!==void 0&&i.jsx("span",{"aria-label":"表头提示",className:"bj-table__column-badge-trigger",id:d,onBlur:()=>se(null),onClick:n=>n.stopPropagation(),onFocus:()=>se(s),onKeyDown:n=>n.stopPropagation(),onMouseEnter:()=>se(s),onMouseLeave:()=>se(null),role:"button",tabIndex:0,children:i.jsx("span",{"aria-hidden":"true",className:"bj-table__column-badge-shape"})}),i.jsxs("div",{className:"bj-table__column-title",children:[i.jsx("span",{className:"bj-table__column-title-content",children:I}),e.sorter&&i.jsx("span",{"aria-hidden":"true",className:"bj-table__column-sorter",children:i.jsx(me,{className:"bj-table__column-sorter-icon",type:h})})]}),(e.filters||e.filterDropdown)&&i.jsxs("div",{className:"bj-table__filter",children:[i.jsx("button",{"aria-expanded":C,"aria-label":"筛选",className:E("bj-table__filter-trigger",g&&"bj-table__filter-trigger--active"),onClick:n=>{n.stopPropagation(),re(e,t)},type:"button",children:typeof e.filterIcon=="function"?e.filterIcon(g):e.filterIcon??i.jsx(me,{className:"bj-table__filter-icon",type:"icon-a-shaixuanxi"})}),C&&fe&&typeof document<"u"&&Kt.createPortal(i.jsx("div",{className:"bj-table__filter-dropdown",onClick:n=>n.stopPropagation(),role:"dialog",style:{left:fe.left,top:fe.top},children:V??i.jsx(It.BDropdown,{...e.filterDropdownProps,emptyText:(W==null?void 0:W.filterEmptyText)??$("暂无筛选项"),multiple:e.filterMultiple!==!1,onChange:(n,y)=>{var F,Qe;J(St=>new Map(St).set(s,n)),(Qe=(F=e.filterDropdownProps)==null?void 0:F.onChange)==null||Qe.call(F,n,y)},onConfirm:n=>{var y,F;ge(e,t,n),(F=(y=e.filterDropdownProps)==null?void 0:y.onConfirm)==null||F.call(y,n)},onReset:()=>{var n,y;xt(e,t),(y=(n=e.filterDropdownProps)==null?void 0:n.onReset)==null||y.call(n)},onSearch:n=>{var y,F;Ke(n),(F=(y=e.filterDropdownProps)==null?void 0:y.onSearch)==null||F.call(y,n)},options:x.map(n=>({label:n.text,value:n.value})),searchable:((w=e.filterDropdownProps)==null?void 0:w.searchable)??q,searchPlaceholder:((Je=e.filterDropdownProps)==null?void 0:Je.searchPlaceholder)??(e.filterRequest?$("请输入搜索内容"):(W==null?void 0:W.filterSearchPlaceholder)??$("搜索")),searchValue:ue,value:l})}),document.body)]})]});return e.badge!==void 0?i.jsxs(Tt,{className:"bj-table__column-tooltip-wrapper",children:[i.jsx("div",{className:"bj-table__column-tooltip-trigger",children:N}),ht===s&&i.jsx(Bt,{className:"bj-table__column-tooltip",content:e.badge,getAnchorElement:()=>document.getElementById(d),getPopupContainer:()=>document.body,placement:"top"})]}):N},Ie=(e,t,s)=>{var f,l;t.selectedRowKeys===void 0&&Ee(e);const d=new Set(e),c=u.filter((C,g)=>d.has(H(C,g,j)));(f=t.onChange)==null||f.call(t,e,c),s&&((l=t.onSelect)==null||l.call(t,s,d.has(H(s,u.indexOf(s),j)),c))},mt=(e,t)=>{if(!r)return;const s=H(e,t,j),d=D.includes(s),c=r.type==="radio"?d?[]:[s]:d?D.filter(f=>f!==s):[...D,s];Ie(c,r,e)},Ve=z.filter(({record:e})=>{var t;return!((t=r==null?void 0:r.getCheckboxProps)!=null&&t.call(r,e).disabled)}),Z=Ve.map(({record:e,index:t})=>H(e,t,j)),ye=Z.length>0&&Z.every(e=>D.includes(e)),Nt=()=>{var s;if(!r||r.type==="radio")return;const e=new Set(Z),t=ye?D.filter(d=>!e.has(d)):Array.from(new Set([...D,...Z]));Ie(t,r),new Set(t),(s=r.onSelectAll)==null||s.call(r,!ye,Ve.map(({record:d})=>d))},Ct=e=>{var t;!a||e<1||e>Te||e===S||(a.current===void 0&&te(e),(t=a.onChange)==null||t.call(a,e,B),je("paginate",R,O,e))},Ft=e=>{var s,d;if(!a||e===B)return;const t=Math.min(S,Ze(_e,e));a.pageSize===void 0&&ct(e),a.current===void 0&&te(t),(s=a.onShowSizeChange)==null||s.call(a,t,e),(d=a.onChange)==null||d.call(a,t,e)},Dt=m.length+(r?1:0),X=(r==null?void 0:r.columnWidth)??48,we=e=>typeof e.width=="number"?e.width:0,Le=(e,t)=>{const s=e.fixed===!0?"left":e.fixed;return s==="left"?{position:"sticky",left:m.slice(0,t).reduce((c,f)=>c+we(f),r&&typeof X=="number"?X:0),zIndex:2}:s==="right"?{position:"sticky",right:m.slice(t+1).reduce((c,f)=>c+we(f),0),zIndex:2}:{}},Rt=o!=null&&o.x?{width:o.x===!0?"max-content":o.x,minWidth:"100%",tableLayout:Pe??"fixed"}:{tableLayout:Pe},Pt=(v==null?void 0:v.table)??"table",kt=((Ue=v==null?void 0:v.header)==null?void 0:Ue.wrapper)??"thead",Ot=(($e=v==null?void 0:v.header)==null?void 0:$e.row)??"tr",Ae=((Ge=v==null?void 0:v.header)==null?void 0:Ge.cell)??"th",K=typeof(v==null?void 0:v.body)=="object"?v.body:void 0,Et=(K==null?void 0:K.wrapper)??"tbody",He=(K==null?void 0:K.row)??"tr",xe=(K==null?void 0:K.cell)??"td",Mt=typeof ae=="function"?ae():ae??$("暂无数据"),We=typeof le=="string"?i.jsx("img",{alt:"",className:"bj-table__empty-image",src:le}):le;return i.jsxs("div",{id:it,ref:Y,className:E("bj-table",Ye&&"bj-table--bordered",`bj-table--${et}`,U&&"bj-table--loading",T.length===0&&"bj-table--empty",rt),style:at,children:[Fe&&i.jsx("div",{className:"bj-table__title",children:Fe(T)}),i.jsxs("div",{className:"bj-table__viewport",children:[i.jsx("div",{className:E("bj-table__scroll",!!(o!=null&&o.x||o!=null&&o.y)&&"bj-overlay-scrollbar-hidden"),ref:ke,style:{maxHeight:o==null?void 0:o.y},children:i.jsxs(Pt,{className:"bj-table__native-table",style:Rt,children:[m.some(e=>e.width)&&i.jsxs("colgroup",{children:[r&&i.jsx("col",{className:"bj-table__selection-col",style:{width:X}}),m.map((e,t)=>i.jsx("col",{style:{width:e.width}},e.key??t))]}),tt&&i.jsx(kt,{className:"bj-table__header",children:Oe.map((e,t)=>i.jsxs(Ot,{className:"bj-table__header-row",...ce==null?void 0:ce(m,t),children:[r&&t===0&&i.jsxs(Ae,{className:E("bj-table__header-cell","bj-table__selection-cell",!!(o!=null&&o.x)&&"bj-table__selection-cell--fixed"),rowSpan:Oe.length,scope:"col",style:{width:X},children:[r.type!=="radio"&&i.jsx(Xe,{checked:ye,disabled:Z.length===0,onChange:Nt,label:"选择当前页所有行"}),r.columnTitle]}),e.map(({column:s,colSpan:d,rowSpan:c},f)=>{var P;const l=s,C=m.indexOf(l),g=C>=0?C:f,h=!("children"in s)&&!!(l.filters||l.filterDropdown),I=!("children"in s)&&!!l.sorter,V=()=>{h?re(l,g):I&&yt(l,g)};return b.createElement(Ae,{...(P=l.onHeaderCell)==null?void 0:P.call(l,s,f),"aria-label":typeof l.title=="string"?l.title:void 0,"aria-sort":I?R.get(_.getColumnKey(l,g))==="ascend"?"ascending":R.get(_.getColumnKey(l,g))==="descend"?"descending":"none":void 0,className:E("bj-table__header-cell",l.fixed&&"bj-table__cell--fixed",(l.fixed==="left"||l.fixed===!0)&&"bj-table__cell--fixed-left",l.fixed==="right"&&"bj-table__cell--fixed-right",l.sorter&&"bj-table__header-cell--sortable",h&&"bj-table__header-cell--filterable",R.get(_.getColumnKey(l,g))&&"bj-table__header-cell--sorted",l.className),colSpan:d,key:l.key??String(l.dataIndex??f),onClick:x=>{var q,N,w;(w=(N=(q=l.onHeaderCell)==null?void 0:q.call(l,s,f))==null?void 0:N.onClick)==null||w.call(N,x),!x.target.closest(".bj-table__filter-dropdown")&&(h?re(l,g,x.currentTarget):V())},onKeyDown:x=>{var q,N,w;(w=(N=(q=l.onHeaderCell)==null?void 0:q.call(l,s,f))==null?void 0:N.onKeyDown)==null||w.call(N,x),!x.target.closest(".bj-table__filter-dropdown")&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),h?re(l,g,x.currentTarget):V())},rowSpan:c,scope:"col",style:{textAlign:l.align,...Le(l,g)},tabIndex:h||I?0:void 0},"children"in s?_.renderColumnTitle(s.title,{filters:Object.fromEntries(O)}):vt(l,g))})]},t))}),i.jsx(Et,{className:"bj-table__body",children:z.length>0?z.map(({record:e,index:t})=>{var l;const s=H(e,t,j),d=((l=r==null?void 0:r.getCheckboxProps)==null?void 0:l.call(r,e).disabled)??!1,c=D.includes(s),f=typeof ie=="function"?ie(e,t,0):ie;return b.createElement(He,{...de==null?void 0:de(e,t),className:E("bj-table__row",c&&"bj-table__row--selected",f),key:s},r&&i.jsx(xe,{className:E("bj-table__cell","bj-table__selection-cell",!!(o!=null&&o.x)&&"bj-table__selection-cell--fixed"),style:{width:X},children:i.jsx(Xe,{checked:c,disabled:d,label:`选择第 ${t+1} 行`,name:r.type==="radio"?"bj-table-row-selection":void 0,onChange:()=>mt(e,t),type:r.type??"checkbox"})}),m.map((C,g)=>{var N;const h=C,I=Ut(e,h.dataIndex),V=h.render?h.render(I,e,t):I,P=$t(V)?V:void 0,x={...(N=h.onCell)==null?void 0:N.call(h,e,t),...P==null?void 0:P.props},q=P?P.children:V;return x.colSpan===0||x.rowSpan===0?null:b.createElement(xe,{...x,className:E("bj-table__cell",h.fixed&&"bj-table__cell--fixed",(h.fixed==="left"||h.fixed===!0)&&"bj-table__cell--fixed-left",h.fixed==="right"&&"bj-table__cell--fixed-right",h.ellipsis&&"bj-table__cell--ellipsis",h.className,x.className),key:h.key??String(h.dataIndex??g),style:{textAlign:h.align,...Le(h,g),...x.style}},i.jsx("div",{className:"bj-table__cell-content",children:q??""}))}))}):i.jsx(He,{className:"bj-table__empty-row",children:i.jsx(xe,{className:"bj-table__empty-cell",colSpan:Math.max(Dt,1),style:{height:st}})})}),Re&&i.jsx("tfoot",{className:"bj-table__summary",children:Re(T)})]})}),z.length===0&&i.jsx("div",{className:"bj-table__empty-overlay",children:i.jsxs("div",{className:"bj-table__empty-content",children:[We&&i.jsx("div",{className:"bj-table__empty-image-wrap",children:We}),i.jsx("div",{className:"bj-table__empty-text",children:Mt})]})})]}),((o==null?void 0:o.x)||(o==null?void 0:o.y))&&i.jsx(Vt,{containerRef:Y,direction:o!=null&&o.x&&(o!=null&&o.y)?"both":o!=null&&o.x?"horizontal":"vertical",gap:2,horizontalInsetEnd:0,horizontalInsetStart:0,size:4,targetRef:ke}),De&&i.jsx("div",{className:"bj-table__footer",children:De(T)}),U&&i.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"bj-table__loading",role:"status",children:[i.jsx("img",{alt:"",className:"bj-table__loading-indicator",src:wt}),i.jsx("span",{className:"bj-table__loading-text",children:"加载中..."})]}),a&&i.jsx("div",{className:"bj-table__pagination",children:i.jsx(qt,{align:"end",disabled:a.disabled,current:S,defaultCurrent:a.defaultCurrent,defaultPageSize:a.defaultPageSize,dropdownClassName:a.dropdownClassName,hideOnSinglePage:a.hideOnSinglePage,onChange:Ct,onShowSizeChange:(e,t)=>Ft(t),pageSize:B,pageSizeOptions:a.pageSizeOptions,popupPlacement:a.popupPlacement,resolvePopupPlacement:a.resolvePopupPlacement,showQuickJumper:a.showQuickJumper,showSizeChanger:a.showSizeChanger,showTotal:a.showTotal,simple:a.simple,size:a.size,t:a.t??$,total:_e})})]})}const Ne=Jt;Ne.Column=At;Ne.ColumnGroup=Ht;exports.BTable=Ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),b=require("react"),Kt=require("react-dom"),qt=require("../Pagination/Pagination.js"),me=require("../Icon/Icon.js");;/* empty css */const Bt=require("../Tooltip/ContentTooltip.js"),Tt=require("../Tooltip/TooltipWrapper.js"),zt=require("../CheckBox/index.js"),It=require("../Dropdown/BDropdown.js"),Vt=require("../OverlayScrollbar/BOverlayScrollbar.js"),wt=require("../SkuInputCard/spin_loading_red.gif.js"),Lt=require("../ProductField/no_data_light.png.js"),At=require("./Column.js"),Ht=require("./ColumnGroup.js"),_=require("./utils/sortFilter.js"),ve=require("./utils/columns.js");;/* empty css */const Wt=300;function E(...p){return p.filter(Boolean).join(" ")}function Ut(p,u){return u===void 0?void 0:(Array.isArray(u)?u:[u]).reduce((r,k)=>{if(!(r==null||typeof r!="object"))return r[k]},p)}function H(p,u,j){if(typeof j=="function")return j(p,u);if(j){const r=p[String(j)];if(typeof r=="string"||typeof r=="number")return r}return u}function Ze(p,u){return Math.max(1,Math.ceil(p/u))}function $t(p){return!!(p&&typeof p=="object"&&!b.isValidElement(p)&&"props"in p)}function Gt(p,u){return(typeof u.text=="string"||typeof u.text=="number"?String(u.text):String(u.value)).toLocaleLowerCase().includes(p.toLocaleLowerCase())}function Xe({checked:p,disabled:u,label:j,name:r,onChange:k,type:W="checkbox"}){return W==="checkbox"?i.jsx(zt.BCheckBox,{"aria-label":j,checked:p,className:"bj-table__selection-checkbox",disabled:u,name:r,onChange:k,skipGroup:!0}):i.jsxs("label",{className:E("bj-table__selection-control",p&&"bj-table__selection-control--checked",u&&"bj-table__selection-control--disabled"),children:[i.jsx("input",{"aria-label":j,checked:p,className:"bj-table__selection-input",disabled:u,name:r,onChange:k,type:W}),i.jsx("span",{"aria-hidden":"true",className:"bj-table__selection-box",children:p&&i.jsx(me,{className:"bj-table__selection-check-icon",type:"icon-a-dagouxi"})})]})}function Jt({columns:p,dataSource:u=[],rowKey:j,rowSelection:r,pagination:k=!1,loading:W=!1,bordered:Ye=!0,size:et="middle",showHeader:tt=!0,emptyText:ae,emptyImage:le=Lt,emptyHeight:st,t:$=Y=>Y,className:rt,style:at,rowClassName:ie,sortDirections:lt=["ascend","descend",null],onChange:ne,children:Ce,title:Fe,footer:De,summary:Re,tableLayout:Pe,components:v,onRow:de,onHeaderRow:ce,id:it,scroll:o,locale:U}){var Ue,$e,Ge;const Y=b.useRef(null),ke=b.useRef(null),ee=b.useMemo(()=>p??ve.convertChildrenToColumns(Ce),[Ce,p]),G=b.useMemo(()=>ve.flattenColumns(ee),[ee]),Oe=b.useMemo(()=>ve.buildHeaderRows(ee),[ee]),[nt,Ee]=b.useState((r==null?void 0:r.defaultSelectedRowKeys)??[]),[oe,te]=b.useState(k?k.defaultCurrent??1:1),[dt,ct]=b.useState(k?k.defaultPageSize??10:10),[ot,bt]=b.useState(()=>new Map(G.flatMap((e,t)=>e.defaultSortOrder?[[_.getColumnKey(e,t),e.defaultSortOrder]]:[]))),[ft,ut]=b.useState(()=>new Map(G.flatMap((e,t)=>e.defaultFilteredValue===void 0?[]:[[_.getColumnKey(e,t),e.defaultFilteredValue]]))),[M,L]=b.useState(null),[Me,J]=b.useState(new Map),[ht,se]=b.useState(null),pt=b.useRef(`btable-${Math.random().toString(36).slice(2,10)}`).current,[A,be]=b.useState(null),[fe,Se]=b.useState(null),[ue,Ke]=b.useState(""),[Q,qe]=b.useState(""),[_t,he]=b.useState(),pe=b.useRef(0),a=k||void 0,T=(a==null?void 0:a.pageSize)??dt,D=(r==null?void 0:r.selectedRowKeys)??nt,m=G,R=new Map(ot),O=new Map(ft);m.forEach((e,t)=>{if("children"in e)return;const s=_.getColumnKey(e,t);e.sortOrder!==void 0&&R.set(s,e.sortOrder),e.filteredValue!==void 0&&O.set(s,e.filteredValue)});const Be=b.useMemo(()=>_.filterRecords(u,m,O),[m,O,u]),S=b.useMemo(()=>_.sortRecords(Be,m,R),[m,Be,R]),_e=(a==null?void 0:a.total)??S.length,Te=Ze(_e,T),K=Math.min((a==null?void 0:a.current)??oe,Te);b.useEffect(()=>{K!==oe&&(a==null?void 0:a.current)===void 0&&te(K)},[K,a==null?void 0:a.current,oe]),b.useEffect(()=>{if(!A||M===null){Se(null);return}const e=()=>{const t=A.getBoundingClientRect();Se({left:t.left,top:t.bottom+8})};return e(),document.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{document.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[A,M]),b.useEffect(()=>{if(M===null)return;const e=t=>{const s=t.target;A!=null&&A.contains(s)||s.closest(".bj-table__filter-dropdown")||(L(null),be(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[A,M]),b.useEffect(()=>{const e=window.setTimeout(()=>qe(ue.trim()),Wt);return()=>window.clearTimeout(e)},[ue]),b.useEffect(()=>{if(M===null)return;const e=G.find((s,d)=>_.getColumnKey(s,d)===M);if(!e||"children"in e||!e.filterRequest)return;const t=++pe.current;Promise.resolve().then(()=>e.filterRequest(Q)).then(s=>{pe.current===t&&he(s)},()=>{pe.current===t&&he([])})},[Q,G,M]);const z=b.useMemo(()=>{if(!a)return S.map((t,s)=>({record:t,index:s}));const e=(K-1)*T;return S.slice(e,e+T).map((t,s)=>({record:t,index:e+s}))},[K,T,a,S]),ze=b.useMemo(()=>z.map(({record:e,index:t})=>H(e,t,j)),[j,z]),jt=D.map(String).join("|"),gt=ze.map(String).join("|");b.useEffect(()=>{var c;if(!r||D.length===0)return;const e=new Set(ze),t=D.filter(f=>e.has(f));if(t.length===D.length)return;r.selectedRowKeys===void 0&&Ee(t);const s=new Set(t),d=z.filter(({record:f,index:l})=>s.has(H(f,l,j))).map(({record:f})=>f);(c=r.onChange)==null||c.call(r,t,d,{type:"multiple"})},[r,j,jt,gt,z]);const je=(e,t=R,s=O,d=K)=>{const c=Object.fromEntries(s),f=_.filterRecords(u,m,s),l=_.sortRecords(f,m,t);ne==null||ne({...a,current:d,pageSize:T,total:(a==null?void 0:a.total)??l.length},c,_.getSorterResult(m,t),{action:e,currentDataSource:l})},yt=(e,t)=>{if(!e.sorter)return;const s=_.getColumnKey(e,t),d=_.getNextSortOrder(R.get(s)??null,e.sortDirections??lt),c=new Map;c.set(s,d),e.sortOrder===void 0&&bt(c),je("sort",c)},ge=(e,t,s)=>{const d=_.getColumnKey(e,t),c=new Map(O);c.set(d,s),e.filteredValue===void 0&&ut(c),L(null),(a==null?void 0:a.current)===void 0&&te(1),je("filter",R,c,1)},xt=(e,t)=>{const s=_.getColumnKey(e,t),d=e.filterResetToDefaultFilteredValue?e.defaultFilteredValue??[]:[];J(c=>new Map(c).set(s,d))},re=(e,t,s)=>{var c,f,l,C;const d=_.getColumnKey(e,t);if(M===d){L(null),be(null),(c=e.onFilterDropdownOpenChange)==null||c.call(e,!1),(f=e.onFilterDropdownVisibleChange)==null||f.call(e,!1);return}Ke(""),qe(""),he(void 0),J(g=>new Map(g).set(d,O.get(d)??[])),L(d),s&&be(s),(l=e.onFilterDropdownOpenChange)==null||l.call(e,!0),(C=e.onFilterDropdownVisibleChange)==null||C.call(e,!0)},vt=(e,t)=>{var w,Je;const s=_.getColumnKey(e,t),d=`bj-table-badge-${pt}-${String(s).replace(/[^a-zA-Z0-9_-]/g,"-")}`,c=R.get(s)??null,f=O.get(s)??[],l=Me.get(s)??f,C=e.filterDropdownOpen??e.filterDropdownVisible??M===s,g=e.filtered||f.length>0,h=c==="ascend"?"icon-a-zhengxumian":c==="descend"?"icon-a-daoxumian":"icon-a-weipaixumian",I=_.renderColumnTitle(e.title,{sortOrder:c,sortColumn:c?e:void 0,sortColumns:c?[{column:e,order:c}]:[],filters:Object.fromEntries(O)}),V=typeof e.filterDropdown=="function"?e.filterDropdown({prefixCls:"bj-table",selectedKeys:l.filter(n=>typeof n!="boolean"),setSelectedKeys:n=>J(y=>new Map(y).set(s,n)),confirm:n=>{ge(e,t,Me.get(s)??l),(n==null?void 0:n.closeDropdown)===!1&&L(s)},clearFilters:n=>{const y=e.filterResetToDefaultFilteredValue?e.defaultFilteredValue??[]:[];J(F=>new Map(F).set(s,y)),(n==null?void 0:n.confirm)===!0&&ge(e,t,y),((n==null?void 0:n.closeDropdown)===!1||(n==null?void 0:n.confirm)!==!0)&&L(s)},filters:e.filters,close:()=>L(null),visible:C}):e.filterDropdown,P=e.filterRequest?_t??[]:e.filters??[],x=Q&&!e.filterRequest?P.filter(n=>typeof e.filterSearch=="function"?e.filterSearch(Q,n):Gt(Q,n)):P,B=!!(e.filterSearch||e.filterRequest),N=i.jsxs("div",{className:E("bj-table__column-header",e.sorter&&"bj-table__column-header--sortable"),children:[e.badge!==void 0&&i.jsx("span",{"aria-label":"表头提示",className:"bj-table__column-badge-trigger",id:d,onBlur:()=>se(null),onClick:n=>n.stopPropagation(),onFocus:()=>se(s),onKeyDown:n=>n.stopPropagation(),onMouseEnter:()=>se(s),onMouseLeave:()=>se(null),role:"button",tabIndex:0,children:i.jsx("span",{"aria-hidden":"true",className:"bj-table__column-badge-shape"})}),i.jsxs("div",{className:"bj-table__column-title",children:[i.jsx("span",{className:"bj-table__column-title-content",children:I}),e.sorter&&i.jsx("span",{"aria-hidden":"true",className:"bj-table__column-sorter",children:i.jsx(me,{className:"bj-table__column-sorter-icon",type:h})})]}),(e.filters||e.filterDropdown)&&i.jsxs("div",{className:"bj-table__filter",children:[i.jsx("button",{"aria-expanded":C,"aria-label":"筛选",className:E("bj-table__filter-trigger",g&&"bj-table__filter-trigger--active"),onClick:n=>{n.stopPropagation(),re(e,t)},type:"button",children:typeof e.filterIcon=="function"?e.filterIcon(g):e.filterIcon??i.jsx(me,{className:"bj-table__filter-icon",type:"icon-a-shaixuanxi"})}),C&&fe&&typeof document<"u"&&Kt.createPortal(i.jsx("div",{className:"bj-table__filter-dropdown",onClick:n=>n.stopPropagation(),role:"dialog",style:{left:fe.left,top:fe.top},children:V??i.jsx(It.BDropdown,{...e.filterDropdownProps,emptyText:(U==null?void 0:U.filterEmptyText)??$("暂无筛选项"),multiple:e.filterMultiple!==!1,onChange:(n,y)=>{var F,Qe;J(St=>new Map(St).set(s,n)),(Qe=(F=e.filterDropdownProps)==null?void 0:F.onChange)==null||Qe.call(F,n,y)},onConfirm:n=>{var y,F;ge(e,t,n),(F=(y=e.filterDropdownProps)==null?void 0:y.onConfirm)==null||F.call(y,n)},onReset:()=>{var n,y;xt(e,t),(y=(n=e.filterDropdownProps)==null?void 0:n.onReset)==null||y.call(n)},onSearch:n=>{var y,F;Ke(n),(F=(y=e.filterDropdownProps)==null?void 0:y.onSearch)==null||F.call(y,n)},options:x.map(n=>({label:n.text,description:n.description,value:n.value})),searchable:((w=e.filterDropdownProps)==null?void 0:w.searchable)??B,searchPlaceholder:((Je=e.filterDropdownProps)==null?void 0:Je.searchPlaceholder)??(e.filterRequest?$("请输入搜索内容"):(U==null?void 0:U.filterSearchPlaceholder)??$("搜索")),searchValue:ue,value:l})}),document.body)]})]});return e.badge!==void 0?i.jsxs(Tt,{className:"bj-table__column-tooltip-wrapper",children:[i.jsx("div",{className:"bj-table__column-tooltip-trigger",children:N}),ht===s&&i.jsx(Bt,{className:"bj-table__column-tooltip",content:e.badge,getAnchorElement:()=>document.getElementById(d),getPopupContainer:()=>document.body,placement:"top"})]}):N},Ie=(e,t,s)=>{var f,l;t.selectedRowKeys===void 0&&Ee(e);const d=new Set(e),c=u.filter((C,g)=>d.has(H(C,g,j)));(f=t.onChange)==null||f.call(t,e,c),s&&((l=t.onSelect)==null||l.call(t,s,d.has(H(s,u.indexOf(s),j)),c))},mt=(e,t)=>{if(!r)return;const s=H(e,t,j),d=D.includes(s),c=r.type==="radio"?d?[]:[s]:d?D.filter(f=>f!==s):[...D,s];Ie(c,r,e)},Ve=z.filter(({record:e})=>{var t;return!((t=r==null?void 0:r.getCheckboxProps)!=null&&t.call(r,e).disabled)}),Z=Ve.map(({record:e,index:t})=>H(e,t,j)),ye=Z.length>0&&Z.every(e=>D.includes(e)),Nt=()=>{var s;if(!r||r.type==="radio")return;const e=new Set(Z),t=ye?D.filter(d=>!e.has(d)):Array.from(new Set([...D,...Z]));Ie(t,r),new Set(t),(s=r.onSelectAll)==null||s.call(r,!ye,Ve.map(({record:d})=>d))},Ct=e=>{var t;!a||e<1||e>Te||e===K||(a.current===void 0&&te(e),(t=a.onChange)==null||t.call(a,e,T),je("paginate",R,O,e))},Ft=e=>{var s,d;if(!a||e===T)return;const t=Math.min(K,Ze(_e,e));a.pageSize===void 0&&ct(e),a.current===void 0&&te(t),(s=a.onShowSizeChange)==null||s.call(a,t,e),(d=a.onChange)==null||d.call(a,t,e)},Dt=m.length+(r?1:0),X=(r==null?void 0:r.columnWidth)??48,we=e=>typeof e.width=="number"?e.width:0,Le=(e,t)=>{const s=e.fixed===!0?"left":e.fixed;return s==="left"?{position:"sticky",left:m.slice(0,t).reduce((c,f)=>c+we(f),r&&typeof X=="number"?X:0),zIndex:2}:s==="right"?{position:"sticky",right:m.slice(t+1).reduce((c,f)=>c+we(f),0),zIndex:2}:{}},Rt=o!=null&&o.x?{width:o.x===!0?"max-content":o.x,minWidth:"100%",tableLayout:Pe??"fixed"}:{tableLayout:Pe},Pt=(v==null?void 0:v.table)??"table",kt=((Ue=v==null?void 0:v.header)==null?void 0:Ue.wrapper)??"thead",Ot=(($e=v==null?void 0:v.header)==null?void 0:$e.row)??"tr",Ae=((Ge=v==null?void 0:v.header)==null?void 0:Ge.cell)??"th",q=typeof(v==null?void 0:v.body)=="object"?v.body:void 0,Et=(q==null?void 0:q.wrapper)??"tbody",He=(q==null?void 0:q.row)??"tr",xe=(q==null?void 0:q.cell)??"td",Mt=typeof ae=="function"?ae():ae??$("暂无数据"),We=typeof le=="string"?i.jsx("img",{alt:"",className:"bj-table__empty-image",src:le}):le;return i.jsxs("div",{id:it,ref:Y,className:E("bj-table",Ye&&"bj-table--bordered",`bj-table--${et}`,W&&"bj-table--loading",S.length===0&&"bj-table--empty",rt),style:at,children:[Fe&&i.jsx("div",{className:"bj-table__title",children:Fe(S)}),i.jsxs("div",{className:"bj-table__viewport",children:[i.jsx("div",{className:E("bj-table__scroll",!!(o!=null&&o.x||o!=null&&o.y)&&"bj-overlay-scrollbar-hidden"),ref:ke,style:{maxHeight:o==null?void 0:o.y},children:i.jsxs(Pt,{className:"bj-table__native-table",style:Rt,children:[m.some(e=>e.width)&&i.jsxs("colgroup",{children:[r&&i.jsx("col",{className:"bj-table__selection-col",style:{width:X}}),m.map((e,t)=>i.jsx("col",{style:{width:e.width}},e.key??t))]}),tt&&i.jsx(kt,{className:"bj-table__header",children:Oe.map((e,t)=>i.jsxs(Ot,{className:"bj-table__header-row",...ce==null?void 0:ce(m,t),children:[r&&t===0&&i.jsxs(Ae,{className:E("bj-table__header-cell","bj-table__selection-cell",!!(o!=null&&o.x)&&"bj-table__selection-cell--fixed"),rowSpan:Oe.length,scope:"col",style:{width:X},children:[r.type!=="radio"&&i.jsx(Xe,{checked:ye,disabled:Z.length===0,onChange:Nt,label:"选择当前页所有行"}),r.columnTitle]}),e.map(({column:s,colSpan:d,rowSpan:c},f)=>{var P;const l=s,C=m.indexOf(l),g=C>=0?C:f,h=!("children"in s)&&!!(l.filters||l.filterDropdown),I=!("children"in s)&&!!l.sorter,V=()=>{h?re(l,g):I&&yt(l,g)};return b.createElement(Ae,{...(P=l.onHeaderCell)==null?void 0:P.call(l,s,f),"aria-label":typeof l.title=="string"?l.title:void 0,"aria-sort":I?R.get(_.getColumnKey(l,g))==="ascend"?"ascending":R.get(_.getColumnKey(l,g))==="descend"?"descending":"none":void 0,className:E("bj-table__header-cell",l.fixed&&"bj-table__cell--fixed",(l.fixed==="left"||l.fixed===!0)&&"bj-table__cell--fixed-left",l.fixed==="right"&&"bj-table__cell--fixed-right",l.sorter&&"bj-table__header-cell--sortable",h&&"bj-table__header-cell--filterable",R.get(_.getColumnKey(l,g))&&"bj-table__header-cell--sorted",l.className),colSpan:d,key:l.key??String(l.dataIndex??f),onClick:x=>{var B,N,w;(w=(N=(B=l.onHeaderCell)==null?void 0:B.call(l,s,f))==null?void 0:N.onClick)==null||w.call(N,x),!x.target.closest(".bj-table__filter-dropdown")&&(h?re(l,g,x.currentTarget):V())},onKeyDown:x=>{var B,N,w;(w=(N=(B=l.onHeaderCell)==null?void 0:B.call(l,s,f))==null?void 0:N.onKeyDown)==null||w.call(N,x),!x.target.closest(".bj-table__filter-dropdown")&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),h?re(l,g,x.currentTarget):V())},rowSpan:c,scope:"col",style:{textAlign:l.align,...Le(l,g)},tabIndex:h||I?0:void 0},"children"in s?_.renderColumnTitle(s.title,{filters:Object.fromEntries(O)}):vt(l,g))})]},t))}),i.jsx(Et,{className:"bj-table__body",children:z.length>0?z.map(({record:e,index:t})=>{var l;const s=H(e,t,j),d=((l=r==null?void 0:r.getCheckboxProps)==null?void 0:l.call(r,e).disabled)??!1,c=D.includes(s),f=typeof ie=="function"?ie(e,t,0):ie;return b.createElement(He,{...de==null?void 0:de(e,t),className:E("bj-table__row",c&&"bj-table__row--selected",f),key:s},r&&i.jsx(xe,{className:E("bj-table__cell","bj-table__selection-cell",!!(o!=null&&o.x)&&"bj-table__selection-cell--fixed"),style:{width:X},children:i.jsx(Xe,{checked:c,disabled:d,label:`选择第 ${t+1} 行`,name:r.type==="radio"?"bj-table-row-selection":void 0,onChange:()=>mt(e,t),type:r.type??"checkbox"})}),m.map((C,g)=>{var N;const h=C,I=Ut(e,h.dataIndex),V=h.render?h.render(I,e,t):I,P=$t(V)?V:void 0,x={...(N=h.onCell)==null?void 0:N.call(h,e,t),...P==null?void 0:P.props},B=P?P.children:V;return x.colSpan===0||x.rowSpan===0?null:b.createElement(xe,{...x,className:E("bj-table__cell",h.fixed&&"bj-table__cell--fixed",(h.fixed==="left"||h.fixed===!0)&&"bj-table__cell--fixed-left",h.fixed==="right"&&"bj-table__cell--fixed-right",h.ellipsis&&"bj-table__cell--ellipsis",h.className,x.className),key:h.key??String(h.dataIndex??g),style:{textAlign:h.align,...Le(h,g),...x.style}},i.jsx("div",{className:"bj-table__cell-content",children:B??""}))}))}):i.jsx(He,{className:"bj-table__empty-row",children:i.jsx(xe,{className:"bj-table__empty-cell",colSpan:Math.max(Dt,1),style:{height:st}})})}),Re&&i.jsx("tfoot",{className:"bj-table__summary",children:Re(S)})]})}),z.length===0&&i.jsx("div",{className:"bj-table__empty-overlay",children:i.jsxs("div",{className:"bj-table__empty-content",children:[We&&i.jsx("div",{className:"bj-table__empty-image-wrap",children:We}),i.jsx("div",{className:"bj-table__empty-text",children:Mt})]})})]}),((o==null?void 0:o.x)||(o==null?void 0:o.y))&&i.jsx(Vt,{containerRef:Y,direction:o!=null&&o.x&&(o!=null&&o.y)?"both":o!=null&&o.x?"horizontal":"vertical",gap:2,horizontalInsetEnd:0,horizontalInsetStart:0,size:4,targetRef:ke}),De&&i.jsx("div",{className:"bj-table__footer",children:De(S)}),W&&i.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"bj-table__loading",role:"status",children:[i.jsx("img",{alt:"",className:"bj-table__loading-indicator",src:wt}),i.jsx("span",{className:"bj-table__loading-text",children:"加载中..."})]}),a&&S.length>0&&i.jsx("div",{className:"bj-table__pagination",children:i.jsx(qt,{align:"end",disabled:W||a.disabled,current:K,defaultCurrent:a.defaultCurrent,defaultPageSize:a.defaultPageSize,dropdownClassName:a.dropdownClassName,hideOnSinglePage:a.hideOnSinglePage,onChange:Ct,onShowSizeChange:(e,t)=>Ft(t),pageSize:T,pageSizeOptions:a.pageSizeOptions,popupPlacement:a.popupPlacement,resolvePopupPlacement:a.resolvePopupPlacement,showQuickJumper:a.showQuickJumper,showSizeChanger:a.showSizeChanger,showTotal:a.showTotal,simple:a.simple,size:a.size,t:a.t??$,total:_e})})]})}const Ne=Jt;Ne.Column=At;Ne.ColumnGroup=Ht;exports.BTable=Ne;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as F, jsx as o } from "react/jsx-runtime";
2
- import { useRef as ne, useMemo as W, useState as x, useEffect as G, createElement as De, isValidElement as wt } from "react";
2
+ import { useRef as ne, useMemo as W, useState as x, useEffect as J, createElement as De, isValidElement as wt } from "react";
3
3
  import { createPortal as At } from "react-dom";
4
4
  import qt from "../Pagination/Pagination.mjs";
5
5
  import Ce from "../Icon/Icon.mjs";
@@ -51,9 +51,9 @@ function lt({
51
51
  label: p,
52
52
  name: a,
53
53
  onChange: R,
54
- type: J = "checkbox"
54
+ type: $ = "checkbox"
55
55
  }) {
56
- return J === "checkbox" ? /* @__PURE__ */ o(
56
+ return $ === "checkbox" ? /* @__PURE__ */ o(
57
57
  Ut,
58
58
  {
59
59
  "aria-label": p,
@@ -74,7 +74,7 @@ function lt({
74
74
  disabled: f,
75
75
  name: a,
76
76
  onChange: R,
77
- type: J
77
+ type: $
78
78
  }
79
79
  ),
80
80
  /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "bj-table__selection-box", children: u && /* @__PURE__ */ o(Ce, { className: "bj-table__selection-check-icon", type: "icon-a-dagouxi" }) })
@@ -86,7 +86,7 @@ function dr({
86
86
  rowKey: p,
87
87
  rowSelection: a,
88
88
  pagination: R = !1,
89
- loading: J = !1,
89
+ loading: $ = !1,
90
90
  bordered: it = !0,
91
91
  size: nt = "middle",
92
92
  showHeader: dt = !0,
@@ -109,7 +109,7 @@ function dr({
109
109
  onHeaderRow: he,
110
110
  id: ht,
111
111
  scroll: c,
112
- locale: $
112
+ locale: G
113
113
  }) {
114
114
  var Je, Qe, Ze;
115
115
  const re = ne(null), Ee = ne(null), ae = W(
@@ -125,7 +125,7 @@ function dr({
125
125
  () => new Map(Z.flatMap((e, t) => e.defaultSortOrder ? [[C(e, t), e.defaultSortOrder]] : []))
126
126
  ), [jt, mt] = x(
127
127
  () => new Map(Z.flatMap((e, t) => e.defaultFilteredValue === void 0 ? [] : [[C(e, t), e.defaultFilteredValue]]))
128
- ), [M, q] = x(null), [ze, X] = x(/* @__PURE__ */ new Map()), [vt, se] = x(null), Nt = ne(`btable-${Math.random().toString(36).slice(2, 10)}`).current, [H, pe] = x(null), [_e, Te] = x(null), [ge, Ke] = x(""), [Y, Se] = x(""), [xt, ye] = x(), je = ne(0), l = R || void 0, K = (l == null ? void 0 : l.pageSize) ?? pt, k = (a == null ? void 0 : a.selectedRowKeys) ?? ut, m = Z, P = new Map(gt), B = new Map(jt);
128
+ ), [M, q] = x(null), [ze, X] = x(/* @__PURE__ */ new Map()), [vt, se] = x(null), Nt = ne(`btable-${Math.random().toString(36).slice(2, 10)}`).current, [H, pe] = x(null), [_e, Te] = x(null), [ge, Ke] = x(""), [Y, Se] = x(""), [xt, ye] = x(), je = ne(0), l = R || void 0, S = (l == null ? void 0 : l.pageSize) ?? pt, k = (a == null ? void 0 : a.selectedRowKeys) ?? ut, m = Z, P = new Map(gt), B = new Map(jt);
129
129
  m.forEach((e, t) => {
130
130
  if ("children" in e) return;
131
131
  const r = C(e, t);
@@ -134,13 +134,13 @@ function dr({
134
134
  const Ve = W(
135
135
  () => et(f, m, B),
136
136
  [m, B, f]
137
- ), S = W(
137
+ ), I = W(
138
138
  () => tt(Ve, m, P),
139
139
  [m, Ve, P]
140
- ), me = (l == null ? void 0 : l.total) ?? S.length, Le = at(me, K), I = Math.min((l == null ? void 0 : l.current) ?? ue, Le);
141
- G(() => {
142
- I !== ue && (l == null ? void 0 : l.current) === void 0 && le(I);
143
- }, [I, l == null ? void 0 : l.current, ue]), G(() => {
140
+ ), me = (l == null ? void 0 : l.total) ?? I.length, Le = at(me, S), z = Math.min((l == null ? void 0 : l.current) ?? ue, Le);
141
+ J(() => {
142
+ z !== ue && (l == null ? void 0 : l.current) === void 0 && le(z);
143
+ }, [z, l == null ? void 0 : l.current, ue]), J(() => {
144
144
  if (!H || M === null) {
145
145
  Te(null);
146
146
  return;
@@ -152,20 +152,20 @@ function dr({
152
152
  return e(), document.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
153
153
  document.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
154
154
  };
155
- }, [H, M]), G(() => {
155
+ }, [H, M]), J(() => {
156
156
  if (M === null) return;
157
157
  const e = (t) => {
158
158
  const r = t.target;
159
159
  H != null && H.contains(r) || r.closest(".bj-table__filter-dropdown") || (q(null), pe(null));
160
160
  };
161
161
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
162
- }, [H, M]), G(() => {
162
+ }, [H, M]), J(() => {
163
163
  const e = window.setTimeout(
164
164
  () => Se(ge.trim()),
165
165
  lr
166
166
  );
167
167
  return () => window.clearTimeout(e);
168
- }, [ge]), G(() => {
168
+ }, [ge]), J(() => {
169
169
  if (M === null) return;
170
170
  const e = Z.find((r, n) => C(r, n) === M);
171
171
  if (!e || "children" in e || !e.filterRequest) return;
@@ -181,17 +181,17 @@ function dr({
181
181
  }, [Y, Z, M]);
182
182
  const V = W(() => {
183
183
  if (!l)
184
- return S.map((t, r) => ({ record: t, index: r }));
185
- const e = (I - 1) * K;
186
- return S.slice(e, e + K).map((t, r) => ({
184
+ return I.map((t, r) => ({ record: t, index: r }));
185
+ const e = (z - 1) * S;
186
+ return I.slice(e, e + S).map((t, r) => ({
187
187
  record: t,
188
188
  index: e + r
189
189
  }));
190
- }, [I, K, l, S]), we = W(
190
+ }, [z, S, l, I]), we = W(
191
191
  () => V.map(({ record: e, index: t }) => U(e, t, p)),
192
192
  [p, V]
193
193
  ), Ft = k.map(String).join("|"), Dt = we.map(String).join("|");
194
- G(() => {
194
+ J(() => {
195
195
  var d;
196
196
  if (!a || k.length === 0) return;
197
197
  const e = new Set(we), t = k.filter((b) => e.has(b));
@@ -200,10 +200,10 @@ function dr({
200
200
  const r = new Set(t), n = V.filter(({ record: b, index: s }) => r.has(U(b, s, p))).map(({ record: b }) => b);
201
201
  (d = a.onChange) == null || d.call(a, t, n, { type: "multiple" });
202
202
  }, [a, p, Ft, Dt, V]);
203
- const ve = (e, t = P, r = B, n = I) => {
203
+ const ve = (e, t = P, r = B, n = z) => {
204
204
  const d = Object.fromEntries(r), b = et(f, m, r), s = tt(b, m, t);
205
205
  be == null || be(
206
- { ...l, current: n, pageSize: K, total: (l == null ? void 0 : l.total) ?? s.length },
206
+ { ...l, current: n, pageSize: S, total: (l == null ? void 0 : l.total) ?? s.length },
207
207
  d,
208
208
  er(m, t),
209
209
  { action: e, currentDataSource: s }
@@ -247,7 +247,7 @@ function dr({
247
247
  filters: e.filters,
248
248
  close: () => q(null),
249
249
  visible: N
250
- }) : e.filterDropdown, O = e.filterRequest ? xt ?? [] : e.filters ?? [], y = Y && !e.filterRequest ? O.filter((i) => typeof e.filterSearch == "function" ? e.filterSearch(Y, i) : nr(Y, i)) : O, T = !!(e.filterSearch || e.filterRequest), v = /* @__PURE__ */ F("div", { className: E("bj-table__column-header", e.sorter && "bj-table__column-header--sortable"), children: [
250
+ }) : e.filterDropdown, O = e.filterRequest ? xt ?? [] : e.filters ?? [], y = Y && !e.filterRequest ? O.filter((i) => typeof e.filterSearch == "function" ? e.filterSearch(Y, i) : nr(Y, i)) : O, K = !!(e.filterSearch || e.filterRequest), v = /* @__PURE__ */ F("div", { className: E("bj-table__column-header", e.sorter && "bj-table__column-header--sortable"), children: [
251
251
  e.badge !== void 0 && /* @__PURE__ */ o(
252
252
  "span",
253
253
  {
@@ -295,7 +295,7 @@ function dr({
295
295
  $t,
296
296
  {
297
297
  ...e.filterDropdownProps,
298
- emptyText: ($ == null ? void 0 : $.filterEmptyText) ?? Q("暂无筛选项"),
298
+ emptyText: (G == null ? void 0 : G.filterEmptyText) ?? Q("暂无筛选项"),
299
299
  multiple: e.filterMultiple !== !1,
300
300
  onChange: (i, g) => {
301
301
  var D, Ye;
@@ -313,9 +313,13 @@ function dr({
313
313
  var g, D;
314
314
  Ke(i), (D = (g = e.filterDropdownProps) == null ? void 0 : g.onSearch) == null || D.call(g, i);
315
315
  },
316
- options: y.map((i) => ({ label: i.text, value: i.value })),
317
- searchable: ((A = e.filterDropdownProps) == null ? void 0 : A.searchable) ?? T,
318
- searchPlaceholder: ((Xe = e.filterDropdownProps) == null ? void 0 : Xe.searchPlaceholder) ?? (e.filterRequest ? Q("请输入搜索内容") : ($ == null ? void 0 : $.filterSearchPlaceholder) ?? Q("搜索")),
316
+ options: y.map((i) => ({
317
+ label: i.text,
318
+ description: i.description,
319
+ value: i.value
320
+ })),
321
+ searchable: ((A = e.filterDropdownProps) == null ? void 0 : A.searchable) ?? K,
322
+ searchPlaceholder: ((Xe = e.filterDropdownProps) == null ? void 0 : Xe.searchPlaceholder) ?? (e.filterRequest ? Q("请输入搜索内容") : (G == null ? void 0 : G.filterSearchPlaceholder) ?? Q("搜索")),
319
323
  searchValue: ge,
320
324
  value: s
321
325
  }
@@ -381,12 +385,12 @@ function dr({
381
385
  );
382
386
  }, Bt = (e) => {
383
387
  var t;
384
- !l || e < 1 || e > Le || e === I || (l.current === void 0 && le(e), (t = l.onChange) == null || t.call(l, e, K), ve("paginate", P, B, e));
388
+ !l || e < 1 || e > Le || e === z || (l.current === void 0 && le(e), (t = l.onChange) == null || t.call(l, e, S), ve("paginate", P, B, e));
385
389
  }, Et = (e) => {
386
390
  var r, n;
387
- if (!l || e === K)
391
+ if (!l || e === S)
388
392
  return;
389
- const t = Math.min(I, at(me, e));
393
+ const t = Math.min(z, at(me, e));
390
394
  l.pageSize === void 0 && _t(e), l.current === void 0 && le(t), (r = l.onShowSizeChange) == null || r.call(l, t, e), (n = l.onChange) == null || n.call(l, t, e);
391
395
  }, Mt = m.length + (a ? 1 : 0), te = (a == null ? void 0 : a.columnWidth) ?? 48, He = (e) => typeof e.width == "number" ? e.width : 0, We = (e, t) => {
392
396
  const r = e.fixed === !0 ? "left" : e.fixed;
@@ -395,7 +399,7 @@ function dr({
395
399
  width: c.x === !0 ? "max-content" : c.x,
396
400
  minWidth: "100%",
397
401
  tableLayout: Be ?? "fixed"
398
- } : { tableLayout: Be }, zt = (j == null ? void 0 : j.table) ?? "table", Tt = ((Je = j == null ? void 0 : j.header) == null ? void 0 : Je.wrapper) ?? "thead", Kt = ((Qe = j == null ? void 0 : j.header) == null ? void 0 : Qe.row) ?? "tr", Ue = ((Ze = j == null ? void 0 : j.header) == null ? void 0 : Ze.cell) ?? "th", z = typeof (j == null ? void 0 : j.body) == "object" ? j.body : void 0, St = (z == null ? void 0 : z.wrapper) ?? "tbody", $e = (z == null ? void 0 : z.row) ?? "tr", Fe = (z == null ? void 0 : z.cell) ?? "td", Vt = typeof de == "function" ? de() : de ?? Q("暂无数据"), Ge = typeof oe == "string" ? /* @__PURE__ */ o("img", { alt: "", className: "bj-table__empty-image", src: oe }) : oe;
402
+ } : { tableLayout: Be }, zt = (j == null ? void 0 : j.table) ?? "table", Tt = ((Je = j == null ? void 0 : j.header) == null ? void 0 : Je.wrapper) ?? "thead", Kt = ((Qe = j == null ? void 0 : j.header) == null ? void 0 : Qe.row) ?? "tr", Ue = ((Ze = j == null ? void 0 : j.header) == null ? void 0 : Ze.cell) ?? "th", T = typeof (j == null ? void 0 : j.body) == "object" ? j.body : void 0, St = (T == null ? void 0 : T.wrapper) ?? "tbody", $e = (T == null ? void 0 : T.row) ?? "tr", Fe = (T == null ? void 0 : T.cell) ?? "td", Vt = typeof de == "function" ? de() : de ?? Q("暂无数据"), Ge = typeof oe == "string" ? /* @__PURE__ */ o("img", { alt: "", className: "bj-table__empty-image", src: oe }) : oe;
399
403
  return /* @__PURE__ */ F(
400
404
  "div",
401
405
  {
@@ -405,13 +409,13 @@ function dr({
405
409
  "bj-table",
406
410
  it && "bj-table--bordered",
407
411
  `bj-table--${nt}`,
408
- J && "bj-table--loading",
409
- S.length === 0 && "bj-table--empty",
412
+ $ && "bj-table--loading",
413
+ I.length === 0 && "bj-table--empty",
410
414
  ct
411
415
  ),
412
416
  style: bt,
413
417
  children: [
414
- Pe && /* @__PURE__ */ o("div", { className: "bj-table__title", children: Pe(S) }),
418
+ Pe && /* @__PURE__ */ o("div", { className: "bj-table__title", children: Pe(I) }),
415
419
  /* @__PURE__ */ F("div", { className: "bj-table__viewport", children: [
416
420
  /* @__PURE__ */ o(
417
421
  "div",
@@ -470,12 +474,12 @@ function dr({
470
474
  colSpan: n,
471
475
  key: s.key ?? String(s.dataIndex ?? b),
472
476
  onClick: (y) => {
473
- var T, v, A;
474
- (A = (v = (T = s.onHeaderCell) == null ? void 0 : T.call(s, r, b)) == null ? void 0 : v.onClick) == null || A.call(v, y), !y.target.closest(".bj-table__filter-dropdown") && (h ? ie(s, _, y.currentTarget) : w());
477
+ var K, v, A;
478
+ (A = (v = (K = s.onHeaderCell) == null ? void 0 : K.call(s, r, b)) == null ? void 0 : v.onClick) == null || A.call(v, y), !y.target.closest(".bj-table__filter-dropdown") && (h ? ie(s, _, y.currentTarget) : w());
475
479
  },
476
480
  onKeyDown: (y) => {
477
- var T, v, A;
478
- (A = (v = (T = s.onHeaderCell) == null ? void 0 : T.call(s, r, b)) == null ? void 0 : v.onKeyDown) == null || A.call(v, y), !y.target.closest(".bj-table__filter-dropdown") && (y.key === "Enter" || y.key === " ") && (y.preventDefault(), h ? ie(s, _, y.currentTarget) : w());
481
+ var K, v, A;
482
+ (A = (v = (K = s.onHeaderCell) == null ? void 0 : K.call(s, r, b)) == null ? void 0 : v.onKeyDown) == null || A.call(v, y), !y.target.closest(".bj-table__filter-dropdown") && (y.key === "Enter" || y.key === " ") && (y.preventDefault(), h ? ie(s, _, y.currentTarget) : w());
479
483
  },
480
484
  rowSpan: d,
481
485
  scope: "col",
@@ -516,7 +520,7 @@ function dr({
516
520
  ),
517
521
  m.map((N, _) => {
518
522
  var v;
519
- const h = N, L = sr(e, h.dataIndex), w = h.render ? h.render(L, e, t) : L, O = ir(w) ? w : void 0, y = { ...(v = h.onCell) == null ? void 0 : v.call(h, e, t), ...O == null ? void 0 : O.props }, T = O ? O.children : w;
523
+ const h = N, L = sr(e, h.dataIndex), w = h.render ? h.render(L, e, t) : L, O = ir(w) ? w : void 0, y = { ...(v = h.onCell) == null ? void 0 : v.call(h, e, t), ...O == null ? void 0 : O.props }, K = O ? O.children : w;
520
524
  return y.colSpan === 0 || y.rowSpan === 0 ? null : /* @__PURE__ */ De(
521
525
  Fe,
522
526
  {
@@ -533,7 +537,7 @@ function dr({
533
537
  key: h.key ?? String(h.dataIndex ?? _),
534
538
  style: { textAlign: h.align, ...We(h, _), ...y.style }
535
539
  },
536
- /* @__PURE__ */ o("div", { className: "bj-table__cell-content", children: T ?? "" })
540
+ /* @__PURE__ */ o("div", { className: "bj-table__cell-content", children: K ?? "" })
537
541
  );
538
542
  })
539
543
  );
@@ -545,7 +549,7 @@ function dr({
545
549
  style: { height: ot }
546
550
  }
547
551
  ) }) }),
548
- Re && /* @__PURE__ */ o("tfoot", { className: "bj-table__summary", children: Re(S) })
552
+ Re && /* @__PURE__ */ o("tfoot", { className: "bj-table__summary", children: Re(I) })
549
553
  ] })
550
554
  }
551
555
  ),
@@ -566,24 +570,24 @@ function dr({
566
570
  targetRef: Ee
567
571
  }
568
572
  ),
569
- Oe && /* @__PURE__ */ o("div", { className: "bj-table__footer", children: Oe(S) }),
570
- J && /* @__PURE__ */ F("div", { "aria-live": "polite", "aria-busy": "true", className: "bj-table__loading", role: "status", children: [
573
+ Oe && /* @__PURE__ */ o("div", { className: "bj-table__footer", children: Oe(I) }),
574
+ $ && /* @__PURE__ */ F("div", { "aria-live": "polite", "aria-busy": "true", className: "bj-table__loading", role: "status", children: [
571
575
  /* @__PURE__ */ o("img", { alt: "", className: "bj-table__loading-indicator", src: Jt }),
572
576
  /* @__PURE__ */ o("span", { className: "bj-table__loading-text", children: "加载中..." })
573
577
  ] }),
574
- l && /* @__PURE__ */ o("div", { className: "bj-table__pagination", children: /* @__PURE__ */ o(
578
+ l && I.length > 0 && /* @__PURE__ */ o("div", { className: "bj-table__pagination", children: /* @__PURE__ */ o(
575
579
  qt,
576
580
  {
577
581
  align: "end",
578
- disabled: l.disabled,
579
- current: I,
582
+ disabled: $ || l.disabled,
583
+ current: z,
580
584
  defaultCurrent: l.defaultCurrent,
581
585
  defaultPageSize: l.defaultPageSize,
582
586
  dropdownClassName: l.dropdownClassName,
583
587
  hideOnSinglePage: l.hideOnSinglePage,
584
588
  onChange: Bt,
585
589
  onShowSizeChange: (e, t) => Et(t),
586
- pageSize: K,
590
+ pageSize: S,
587
591
  pageSizeOptions: l.pageSizeOptions,
588
592
  popupPlacement: l.popupPlacement,
589
593
  resolvePopupPlacement: l.resolvePopupPlacement,