@hzab/edit-table 0.1.12 → 0.1.13-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hzab/edit-table
2
2
 
3
+ ## 0.1.13-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 单元格自动撑开行高,整个table动态高度
8
+
9
+ ## 0.1.13
10
+
11
+ ### Patch Changes
12
+
13
+ feat:行高随单元格高度自适应撑开
14
+
3
15
  ## 0.1.12
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- let e=require("react"),t=require("antd"),n=require("@silevis/reactgrid"),r=require("@hzab/form-render"),i=require("@ant-design/icons"),a=require("react/jsx-runtime"),o=require("react/compiler-runtime"),s=require("@hzab/utils/src/formily/field");require("@silevis/reactgrid/styles.css");var c={"DatePicker.MonthPicker":t.DatePicker.MonthPicker,"DatePicker.QuarterPicker":t.DatePicker.QuarterPicker,"DatePicker.RangePicker":t.DatePicker.RangePicker,"DatePicker.TimePicker":t.DatePicker.TimePicker,"DatePicker.WeekPicker":t.DatePicker.WeekPicker,"DatePicker.YearPicker":t.DatePicker.YearPicker,"Input.Password":t.Input.Password,"Input.Search":t.Input.Search,"Input.TextArea":t.Input.TextArea,"TimePicker.RangePicker":t.TimePicker.RangePicker},l=[`DatePicker`,`DatePicker.MonthPicker`,`DatePicker.QuarterPicker`,`DatePicker.RangePicker`,`DatePicker.TimePicker`,`DatePicker.WeekPicker`,`DatePicker.YearPicker`,`TimePicker.RangePicker`],u=(r,o={})=>{class s{getCompatibleCell(e){let t;try{t=(0,n.getCellProperty)(e,`values`,`object`)}catch(e){t=[]}let r=e.selectedValue?parseFloat(e.selectedValue):NaN,i=!0;try{i=(0,n.getCellProperty)(e,`isDisabled`,`boolean`)}catch(e){i=!1}let a=e.selectedValue,o=a||``;return{...e,selectedValue:a,text:o,value:r,values:t,isDisabled:i}}update(e,t){let n=e.values.some(e=>e.value==t.text)?t.text:(t==null?void 0:t.text)||void 0;return this.getCompatibleCell({...e,selectedValue:n})}getClassName(e,t){return``}handleCompositionEnd(e,t){return{cell:{...e},enableEditMode:!1}}render(s,c,u){var d;let[f,p]=(0,e.useState)(!1),[m,h]=(0,e.useState)(!1),g=(s==null?void 0:s.columnId)+(s==null?void 0:s.rowId),[_,v]=(0,e.useState)(s==null?void 0:s.text),[y,b]=(0,e.useState)(!1),x=(0,e.useRef)(s==null?void 0:s.text),S=(0,e.useRef)();(0,e.useEffect)(()=>{v(s==null?void 0:s.text),x.current=s==null?void 0:s.text},[s==null?void 0:s.text]),(0,e.useEffect)(()=>{function e(e){window.gridEditId!=g&&p(!1)}return document.addEventListener(`click`,e),()=>{document.removeEventListener(`click`,e)}},[]);let C=e=>{var t;let n=!1,r=!1;for(let t of(s==null?void 0:s.validatorList)||[]){var i;t!=null&&(i=t.pattern)!=null&&i.test(e)&&(n=!0);break}r=!n&&Array.isArray(s==null?void 0:s.validatorList)&&(s==null||(t=s.validatorList)==null?void 0:t.length)>0,b(r)};(0,e.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>{let e=document.querySelector(`.ant-picker-dropdown`);if(!e)return;let t=e=>{e.stopPropagation()};return e.addEventListener(`pointerdown`,t,!0),()=>{e.removeEventListener(`pointerdown`,t,!0)}},0);return()=>clearTimeout(e)},[m]);let w=()=>{let e=x.current;u(this.getCompatibleCell({...s,text:e,selectedValue:e}),!0)},T=(0,e.useMemo)(()=>l!=null&&l.includes(s==null?void 0:s.type)?{open:m,onOpenChange:e=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{h(e)},80)}}:{},[s]);return(0,e.useEffect)(()=>{!f&&s.type==`Upload`&&window.uploadEdit&&window.uploadEdit==g&&(window.uploadEdit=null,w())},[f,_]),(0,a.jsxs)(`div`,{className:`base-hoc ${f?`base-hoc-edit`:``}`,onDoubleClick:e=>{s!=null&&s.nonEditable||(s.type===`Upload`&&(window.uploadEdit=g),p(!0))},children:[(0,a.jsx)(r,{...o,onPointerDown:e=>e.stopPropagation(),componentProps:{style:{width:`100%`,display:`flex`,alignItems:`center`},value:_,options:s.values,onChange:e=>{var t,n;let r=(t=e==null||(n=e.target)==null?void 0:n.value)==null?e:t;v(r),x.current=r,C(r)},onBlur:e=>{w(),l!=null&&l.includes(s==null?void 0:s.type)||p(!1)},onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{((0,n.isAlphaNumericKey)(e.keyCode)||(0,n.isNavigationKey)(e.keyCode))&&e.stopPropagation()},...T,...(s==null?void 0:s.getField)&&(s==null?void 0:s.getField()[`x-component-props`])||{}},pattern:f?``:`readPretty`,cell:s}),y&&(0,a.jsx)(t.Popover,{content:(d=s==null?void 0:s.validatorMessage)==null?`该字段不合法`:d,children:(0,a.jsx)(i.InfoCircleOutlined,{className:`validator-icon`})})]})}}return new s},d=t=>{let{pattern:n,cell:r,componentProps:i,Com:o,cellRender:c}=t,l=(0,e.useMemo)(()=>{var e;if(r!=null&&r.getField)return(0,s.getVal)({...(r==null?void 0:r.getField)&&(r==null?void 0:r.getField()),enum:(r==null||(e=r.getField())==null?void 0:e.enum)||(r==null?void 0:r.values)},{[(r==null?void 0:r.getField)&&(r==null?void 0:r.getField().name)]:r.text})},[r]);return c&&c(t)?(0,a.jsx)(c,{...t}):(0,a.jsx)(`div`,{className:`base-hoc`,children:n==`readPretty`?(0,a.jsx)(`div`,{children:l}):(0,a.jsx)(o,{className:`rg-input`,ref:e=>{e&&e.focus()},...i})})},f=e=>{let n=(0,o.c)(5),r=e==null?void 0:e.componentProps,i;n[0]===r?i=n[1]:(i={...r,type:`number`},n[0]=r,n[1]=i);let s;return n[2]!==e||n[3]!==i?(s=(0,a.jsx)(d,{...e,componentProps:i,Com:t.Input}),n[2]=e,n[3]=i,n[4]=s):s=n[4],s},p=t=>{let n=(0,o.c)(21),{cell:r}=t,{setExpandKeys:s,expandKeys:c,rowKey:l,setNewDataSource:u,record:d}=r,[f,p]=(0,e.useState)(!1),m;n[0]!==d||n[1]!==l||n[2]!==u?(m=e=>{u(t=>{var n;let r=[...t],i=d==null||(n=d.children)==null?void 0:n.map(e=>e==null?void 0:e[l]);if(e){let e=t==null?void 0:t.findIndex(e=>(e==null?void 0:e[l])==(d==null?void 0:d[l])),n=(t==null?void 0:t.filter(e=>i==null?void 0:i.includes(e==null?void 0:e[l])))||[];return(n==null?void 0:n.length)==0&&r.splice(e+1,0,...(d==null?void 0:d.children)||[]),[...r]}return t==null?void 0:t.filter(e=>!(i!=null&&i.includes(e==null?void 0:e[l])))})},n[0]=d,n[1]=l,n[2]=u,n[3]=m):m=n[3];let h=m,g;n[4]!==c||n[5]!==h||n[6]!==d||n[7]!==l?(g=()=>{c!=null&&c.includes(d==null?void 0:d[l])&&(p(!0),h(!0))},n[4]=c,n[5]=h,n[6]=d,n[7]=l,n[8]=g):g=n[8];let _=r==null?void 0:r.record,v;n[9]===_?v=n[10]:(v=[_],n[9]=_,n[10]=v),(0,e.useEffect)(g,v);let y;n[11]!==f||n[12]!==h||n[13]!==d||n[14]!==l||n[15]!==s?(y=()=>{s(e=>e!=null&&e.includes(d==null?void 0:d[l])?e==null?void 0:e.filter(e=>e!=(d==null?void 0:d[l])):[...e,d==null?void 0:d[l]]),p(!f),h(!f)},n[11]=f,n[12]=h,n[13]=d,n[14]=l,n[15]=s,n[16]=y):y=n[16];let b=y,x;return n[17]!==f||n[18]!==b||n[19]!==(d==null?void 0:d.children)?(x=(0,a.jsx)(`div`,{className:`expandList-template`,children:d!=null&&d.children?(0,a.jsx)(a.Fragment,{children:f?(0,a.jsx)(i.MinusCircleOutlined,{className:`expandList-template-icon`,onClick:b}):(0,a.jsx)(i.PlusCircleOutlined,{className:`expandList-template-icon`,onClick:b})}):(0,a.jsx)(`div`,{style:{width:14}})}),n[17]=f,n[18]=b,n[19]=d==null?void 0:d.children,n[20]=x):x=n[20],x};function m(e){return typeof e==`object`&&!!e}var h=e=>{var t;return typeof(e==null?void 0:e.title)==`function`?m(e==null?void 0:e.title())?e==null||(t=e.title())==null?void 0:t.props.children:String(e==null?void 0:e.title())||``:String(e==null?void 0:e.title)||``};function g(e,t=40){let n=e=>e.reduce((e,t)=>{var r;return(r=t.children)!=null&&r.length?[...e,...n(t.children)]:[...e,t]},[]),r=(e,t=1)=>e.reduce((e,n)=>{var i;return(i=n.children)!=null&&i.length?Math.max(e,r(n.children,t+1)):Math.max(e,t)},t),i=n(e),a=r(e),o=i.length,s=(e,t=0)=>e.map(e=>{var r;if(!(((r=e.children)==null?void 0:r.length)>0))return{...e,rowspan:a-t,colspan:1,_depth:t,_isLeaf:!0};let i=n(e.children).length;return{...e,rowspan:1,colspan:i,_depth:t,_isLeaf:!1,children:s(e.children,t+1)}}),c=s(e,0),l=Array.from({length:a},(e,n)=>({rowId:`header-${n}`,height:t,cells:[]})),u=e=>{var t;return(t=[`rowSelection`,`ExpandListTemplate`])!=null&&t.includes(e==null?void 0:e.type)?e==null?void 0:e.type:m(typeof(e==null?void 0:e.title)==`function`?e==null?void 0:e.title():null)?`${e==null?void 0:e.dataIndex}`:`header`},d=(e,t=0)=>{e.forEach(e=>{if(e._isLeaf){let n={...e,type:u(e),text:h(e),dataIndex:e.dataIndex,width:e.width,rowspan:e.rowspan,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}};e.sorter&&(n.sorter=e.sorter),e.key&&(n.key=e.key),l[t].cells.push(n)}else l[t].cells.push({...e,type:u(e),text:h(e),colspan:e.colspan,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}}),e.children&&d(e.children,t+1)})};d(c,0),l.forEach((e,t)=>{let n=[],r=0,s=0;for(;r<o;){let o=e.cells[s];if(!o){let e=i[r];n.push({...e,type:u(e),text:h(e),dataIndex:e.dataIndex,width:e.width,rowspan:t===a-1?1:void 0,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}}),r++,s++;continue}let c=o.colspan||1;if((o.rowspan||1)>1&&t>0){r+=c,s++;continue}n.push(o),r+=c,s++;for(let e=1;e<c;e++)n.push({type:`header`,text:``})}e.cells=n});let f=l[a-1],p=[];return i.forEach((e,t)=>{let n=f.cells.find(t=>t.dataIndex===e.dataIndex&&t.text===e.title);n?p.push(n):p.push({...e,type:u(e),text:h(e),dataIndex:e.dataIndex,width:e.width,rowspan:1,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}})}),f.cells=p,l.forEach(e=>{for(;e.cells.length<o;)e.cells.push({type:`header`,text:``})}),l}function _(e){let t=[];function n(e){e.forEach(e=>{if(e.children&&e.children.length>0)n(e.children);else{let{title:n,dataIndex:r,key:i,width:a,sorter:o,k:s,...c}=e;t.push({type:`Input`,dataIndex:r,title:n,...i&&{key:i},...a&&{width:a},...o&&{sorter:o},...s&&{k:s},...c})}})}return n(e),t}function v(i,o){var s;let{columns:l,dataSource:h,formulaConfig:v,onChange:y,reactGridProps:b={},onEditSubmit:x,headerRowHeight:S=44,rowHeight:C=44,reactGridStyle:w,className:T,Slots:E,rowSelection:D,rowKey:O=`id`,query:k,loading:A,isExpand:j=!1,getList:M,onRow:N}=i,[P,F]=(0,e.useState)([]),[I,L]=(0,e.useState)([]),R=(0,e.useRef)([]),[z,B]=(0,e.useState)([]),[V,H]=(0,e.useState)([]),[U,W]=(0,e.useState)([]),[G,K]=(0,e.useState)([]),[ee,te]=(0,e.useState)([]),[ne,q]=(0,e.useState)([]),J=(0,e.useRef)(),re=(0,e.useRef)(),Y=(0,e.useRef)();(0,e.useImperativeHandle)(o,()=>({rows:I}));let X=(e,t=0)=>{e==null||e.forEach(e=>{e.level=t+1,e!=null&&e.children&&X(e==null?void 0:e.children,e.level)})};(0,e.useEffect)(()=>{X(h),W(h)},[h]),(0,e.useEffect)(()=>{let e=I.map(e=>e.rowId);e!=null&&e.includes(J.current)||q([])},[I]);let ie=e=>{var t,n;let r=e==null||(t=e.cells)==null||(t=t[0])==null?void 0:t.record,i=[`_$actions`,`rowSelection`],a={id:e==null?void 0:e.rowId};return e==null||(n=e.cells)==null||n.forEach(e=>{e!=null&&e.columnId&&!(i!=null&&i.includes(e==null?void 0:e.columnId))&&(a[e==null?void 0:e.columnId]=(e==null?void 0:e.text)||(e==null?void 0:e.value)||(e==null?void 0:e.selectedValue)||``,(e==null?void 0:e.type)==`Number`&&(a[e==null?void 0:e.columnId]=e==null?void 0:e.value))}),{...r,...a}};(0,e.useEffect)(()=>{if(Array.isArray(l)&&(l==null?void 0:l.length)>0){j&&l.unshift({type:`ExpandListTemplate`,width:14,key:`ExpandListTemplate`,nonEditable:!0,style:(D==null?void 0:D.style)||{background:`rgba(128, 128, 128, 0.1)`}}),D&&l.unshift({type:`rowSelection`,nonEditable:!0,width:(D==null?void 0:D.width)||30,key:`rowSelection`,style:(D==null?void 0:D.style)||{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}}),F(g(l,S));let e=_(l);B(e==null?void 0:e.map((e,t)=>({...e,columnId:(e==null?void 0:e.dataIndex)||(e==null?void 0:e.key)||(e==null?void 0:e.name)||``})))}},[l,D]);let Z={},Q=e=>{e==null||e.forEach(e=>{if(m(typeof(e==null?void 0:e.title)==`function`?e==null?void 0:e.title():null)){let t=e==null?void 0:e.title;Z[e==null?void 0:e.dataIndex]=u(t)}e!=null&&e.children&&Q(e==null?void 0:e.children)})};(0,e.useEffect)(()=>{Q(l),te(Z)},[l]),(0,e.useEffect)(()=>{let e=z==null?void 0:z.map(e=>e==null?void 0:e.columnId),t=U==null?void 0:U.map((t,n)=>({rowId:t[O],height:C,cells:e==null?void 0:e.map((e,r)=>{var i;let a={},o=z[r],s=t[e],c=(i=o==null?void 0:o.type)==null?`text`:i;if(v){for(let n in v)if(n==e){let e=v[n];a={text:(e==null?void 0:e.setCellData)&&(e==null?void 0:e.setCellData(t)),value:(e==null?void 0:e.setCellData)&&(e==null?void 0:e.setCellData(t)),style:(e==null?void 0:e.setCellStyle)&&(e==null?void 0:e.setCellStyle((e==null?void 0:e.setCellData)&&(e==null?void 0:e.setCellData(t))||t))}}}return{...o,record:t,rowId:t[O]||(o==null?void 0:o.type),type:c,nonEditable:(o==null?void 0:o.pattern)==`readPretty`?!0:o==null?void 0:o.nonEditable,text:String(s||``),value:s,selectedValue:s||``,style:(o==null?void 0:o.type)==`rowSelection`?{display:`flex`,justifyContent:`center`}:{},...N&&N(t,n,r)||{},...(o==null?void 0:o.onCell)&&(o==null?void 0:o.onCell(t,n,r))||{},...(o==null?void 0:o.cellProps)||{},setNewDataSource:W,setExpandKeys:K,rowKey:O,expandKeys:G,Slots:E,...a}})})),n=[...P,...t];L(n)},[U,z,P]),(0,e.useEffect)(()=>{if(A){var e;let t=I==null?void 0:I.find(e=>{var t;return(e==null?void 0:e.rowId)==((t=Y.current)==null?void 0:t.rowId)});t==null||(e=t.cells)==null||e.find(e=>{var t;return(e==null?void 0:e.columnId)==((t=Y.current)==null?void 0:t.columnId)}),{...Y.current},R.current=I}},[A,I]);let ae=async e=>{let t=[];if(!Array.isArray(e)||e.length===0)return;let n=!1;if((e==null?void 0:e.length)>1&&(n=!0),L(r=>(e.forEach(async e=>{let i=r.findIndex(t=>t.rowId==e.rowId),a=z.findIndex(t=>t.columnId==e.columnId);if(r[i].cells[a]={...e.newCell},Y.current={...e.newCell},t.push(ie(r[i])),v)for(let e in v){let t=v[e],n=z.findIndex(t=>t.columnId==e),a={...r[i].cells[n],text:(t==null?void 0:t.setCellData)&&(t==null?void 0:t.setCellData(r[i])),value:(t==null?void 0:t.setCellData)&&(t==null?void 0:t.setCellData(r[i])),style:(t==null?void 0:t.setCellStyle)&&(t==null?void 0:t.setCellStyle((t==null?void 0:t.setCellData)&&(t==null?void 0:t.setCellData(r[i]))||r[i]))};r[i].cells[n]=a}if(x&&!n)try{await x(t)}catch(e){M&&M()}y&&y(r[i])}),[...r])),n)try{x&&await x(t)}catch(e){M&&M()}},oe=(0,e.useMemo)(()=>{let e={...r.antdComponents||{},...r.customComponents||{},...c},t={};for(let n in e)t[n]=u(t=>(0,a.jsx)(d,{...t,...i,Com:e[n]}));return t},[r.antdComponents,r.customComponents]),se=e=>{let t=I==null?void 0:I.find(t=>{var n;return(t==null?void 0:t.rowId)==(e==null||(n=e.cell)==null?void 0:n.rowId)});return(0,a.jsxs)(`div`,{onPointerDown:e=>e.stopPropagation(),children:[(E==null?void 0:E.tableActionsSlot)&&(0,a.jsx)(E.tableActionsSlot,{...e==null?void 0:e.cell,rowData:t}),(E==null?void 0:E.actionPrefixSlot)&&(0,a.jsx)(E.actionPrefixSlot,{...e==null?void 0:e.cell,rowData:t}),(E==null?void 0:E.actionCenterSlot)&&(0,a.jsx)(E.actionCenterSlot,{...e==null?void 0:e.cell,rowData:t}),(E==null?void 0:E.actionSuffixSlot)&&(0,a.jsx)(E.actionSuffixSlot,{...e==null?void 0:e.cell,rowData:t})]})};function $(e){let t=[];function n(e){for(let r of e)t.push(r),r.children&&r.children.length&&n(r.children)}return n(e),t}let ce=e=>{var n,r,i,o,s,c;let{record:l,rowId:u}=e==null?void 0:e.cell,d=(n=$(h))==null?void 0:n.filter(e=>{var t;return!(D!=null&&(t=D.getCheckboxProps)!=null&&(t=t.call(D,e))!=null&&t.disabled)}),f=typeof(D==null?void 0:D.getCheckboxProps)==`function`?D==null||(r=D.getCheckboxProps)==null?void 0:r.call(D,l):{};return(0,a.jsx)(t.Checkbox,{...e==null?void 0:e.componentProps,checked:(D==null||(i=D.selectedRowKeys)==null?void 0:i.includes(l&&l[O]||``))||!u&&(D==null||(o=D.selectedRowKeys)==null?void 0:o.length)==(d==null?void 0:d.length)&&(d==null?void 0:d.length)>0,indeterminate:!u&&(D==null||(s=D.selectedRowKeys)==null?void 0:s.length)>0&&(D==null||(c=D.selectedRowKeys)==null?void 0:c.length)<(d==null?void 0:d.length),onChange:e=>{if(e.target.checked&&u){let e=[...D==null?void 0:D.selectedRowKeys,l[O]],t=d==null?void 0:d.filter(t=>e==null?void 0:e.includes(t[O]));D==null||D.onChange(e,t)}else if(!e.target.checked&&u){var t,n;let e=D==null||(t=D.selectedRowKeys)==null?void 0:t.filter(e=>e!=l[O]),r=d==null?void 0:d.filter(t=>e==null?void 0:e.includes(t[O]));D==null||D.onChange(D==null||(n=D.selectedRowKeys)==null?void 0:n.filter(e=>e!=l[O]),r)}else if(e.target.checked&&!u){let e=d==null?void 0:d.map(e=>e[O]),t=d==null?void 0:d.filter(t=>e==null?void 0:e.includes(t[O]));D==null||D.onChange(d==null?void 0:d.map(e=>e[O]),t)}else!e.target.checked&&!u&&(D==null||D.onChange([],[]))},...f})};(0,e.useEffect)(()=>{if(D){var e;let t=(e=$(h))==null?void 0:e.filter(e=>{var t;return!(D!=null&&(t=D.getCheckboxProps)!=null&&(t=t.call(D,e))!=null&&t.disabled)}),n=t==null?void 0:t.filter(e=>V==null?void 0:V.includes(e[O]));D==null||D.onChange(V,n)}},[V,h]),(0,e.useEffect)(()=>{H([])},[k==null?void 0:k.pageNum]);let le=(0,e.useMemo)(()=>{let e={};for(let t in b==null?void 0:b.customCellTemplates)e[t]=u(b==null?void 0:b.customCellTemplates[t]);return e},[b==null?void 0:b.customCellTemplates]),ue=(e,t)=>{var n;let r=t==null||(n=t.find(t=>(t==null?void 0:t.rowId)==(e==null?void 0:e.rowId)))==null||(n=n.cells)==null?void 0:n.map(t=>({columnId:t==null?void 0:t.columnId,rowId:e==null?void 0:e.rowId,className:`custom-highlights-row`,borderColor:`transparent`}));J.current=e==null?void 0:e.rowId,q(r)};return(0,a.jsx)(t.Spin,{spinning:A,children:(0,a.jsxs)(`div`,{className:`grid-container ${T}`,style:w,children:[(0,a.jsx)(n.ReactGrid,{ref:re,rows:A?R.current:I,columns:z,onCellsChanged:ae,enableFillHandle:!0,enableRangeSelection:!0,horizontalStickyBreakpoint:120,...b,highlights:(s=b==null?void 0:b.highlights)==null?ne:s,onFocusLocationChanging:e=>{var t,n;let r=(e==null?void 0:e.columnId)+(e==null?void 0:e.rowId);return window.gridEditId=r,typeof(e==null?void 0:e.rowId)==`string`&&(e==null||(t=e.rowId)==null?void 0:t.indexOf(`header-`))>-1||(b!=null&&b.isRowHighlights&&e!=null&&e.columnId&&ue(e,I),(n=[`_$actions`,`rowSelection`,`ExpandListTemplate`])!=null&&n.includes(e==null?void 0:e.columnId))?!1:b!=null&&b.onFocusLocationChanging?b==null?void 0:b.onFocusLocationChanging(e,I):e},customCellTemplates:{ExpandListTemplate:u(p),...oe,...le,...ee,_$actions:u(se),rowSelection:u(ce),Number:u(f,i)}},(h==null?void 0:h.length)==0?0:1),(h==null?void 0:h.length)<=0&&(0,a.jsx)(`div`,{className:`grid-container-empty`,children:(0,a.jsx)(t.Empty,{image:t.Empty.PRESENTED_IMAGE_SIMPLE})})]})})}var y=(0,e.forwardRef)(v);module.exports=y;
1
+ let e=require("react"),t=require("antd"),n=require("@silevis/reactgrid"),r=require("@hzab/form-render"),i=require("@ant-design/icons"),a=require("react/jsx-runtime"),o=require("react/compiler-runtime"),s=require("@hzab/utils/src/formily/field");require("@silevis/reactgrid/styles.css");var c={"DatePicker.MonthPicker":t.DatePicker.MonthPicker,"DatePicker.QuarterPicker":t.DatePicker.QuarterPicker,"DatePicker.RangePicker":t.DatePicker.RangePicker,"DatePicker.TimePicker":t.DatePicker.TimePicker,"DatePicker.WeekPicker":t.DatePicker.WeekPicker,"DatePicker.YearPicker":t.DatePicker.YearPicker,"Input.Password":t.Input.Password,"Input.Search":t.Input.Search,"Input.TextArea":t.Input.TextArea,"TimePicker.RangePicker":t.TimePicker.RangePicker},l=[`DatePicker`,`DatePicker.MonthPicker`,`DatePicker.QuarterPicker`,`DatePicker.RangePicker`,`DatePicker.TimePicker`,`DatePicker.WeekPicker`,`DatePicker.YearPicker`,`TimePicker.RangePicker`],u=(r,o={})=>{class s{getCompatibleCell(e){let t;try{t=(0,n.getCellProperty)(e,`values`,`object`)}catch(e){t=[]}let r=e.selectedValue?parseFloat(e.selectedValue):NaN,i=!0;try{i=(0,n.getCellProperty)(e,`isDisabled`,`boolean`)}catch(e){i=!1}let a=e.selectedValue,o=a||``;return{...e,selectedValue:a,text:o,value:r,values:t,isDisabled:i}}update(e,t){let n=e.values.some(e=>e.value==t.text)?t.text:(t==null?void 0:t.text)||void 0;return this.getCompatibleCell({...e,selectedValue:n})}getClassName(e,t){return``}handleCompositionEnd(e,t){return{cell:{...e},enableEditMode:!1}}render(s,c,u){var d;let[f,p]=(0,e.useState)(!1),[m,h]=(0,e.useState)(!1),g=(s==null?void 0:s.columnId)+(s==null?void 0:s.rowId),[_,v]=(0,e.useState)(s==null?void 0:s.text),[y,b]=(0,e.useState)(!1),x=(0,e.useRef)(s==null?void 0:s.text),S=(0,e.useRef)(),C=(0,e.useRef)(null),w=(0,e.useRef)(null);(0,e.useEffect)(()=>{let e=C.current,t=s==null?void 0:s.onRowHeightChange;if(!e||!t||(s==null?void 0:s.rowId)==null||typeof(s==null?void 0:s.rowId)==`string`&&s.rowId.indexOf(`header-`)===0)return;let n=e.firstElementChild,r=n||e;if(w.current===null){let t=getComputedStyle(e);w.current=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}let i=n?w.current:0,a=()=>t(s==null?void 0:s.rowId,r.scrollHeight+i,s==null?void 0:s.columnId);a();let o=new ResizeObserver(a);return o.observe(r),()=>o.disconnect()},[s==null?void 0:s.rowId,s==null?void 0:s.columnId,s==null?void 0:s.onRowHeightChange,f,_]),(0,e.useEffect)(()=>{v(s==null?void 0:s.text),x.current=s==null?void 0:s.text},[s==null?void 0:s.text]),(0,e.useEffect)(()=>{function e(e){window.gridEditId!=g&&p(!1)}return document.addEventListener(`click`,e),()=>{document.removeEventListener(`click`,e)}},[]);let T=e=>{var t;let n=!1,r=!1;for(let t of(s==null?void 0:s.validatorList)||[]){var i;t!=null&&(i=t.pattern)!=null&&i.test(e)&&(n=!0);break}r=!n&&Array.isArray(s==null?void 0:s.validatorList)&&(s==null||(t=s.validatorList)==null?void 0:t.length)>0,b(r)};(0,e.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>{let e=document.querySelector(`.ant-picker-dropdown`);if(!e)return;let t=e=>{e.stopPropagation()};return e.addEventListener(`pointerdown`,t,!0),()=>{e.removeEventListener(`pointerdown`,t,!0)}},0);return()=>clearTimeout(e)},[m]);let E=()=>{let e=x.current;u(this.getCompatibleCell({...s,text:e,selectedValue:e}),!0)},D=(0,e.useMemo)(()=>l!=null&&l.includes(s==null?void 0:s.type)?{open:m,onOpenChange:e=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{h(e)},80)}}:{},[s]);return(0,e.useEffect)(()=>{!f&&s.type==`Upload`&&window.uploadEdit&&window.uploadEdit==g&&(window.uploadEdit=null,E())},[f,_]),(0,a.jsxs)(`div`,{ref:C,className:`base-hoc ${f?`base-hoc-edit`:``}`,onDoubleClick:e=>{s!=null&&s.nonEditable||(s.type===`Upload`&&(window.uploadEdit=g),p(!0))},children:[(0,a.jsx)(r,{...o,onPointerDown:e=>e.stopPropagation(),componentProps:{style:{width:`100%`,display:`flex`,alignItems:`center`},value:_,options:s.values,onChange:e=>{var t,n;let r=(t=e==null||(n=e.target)==null?void 0:n.value)==null?e:t;v(r),x.current=r,T(r)},onBlur:e=>{E(),l!=null&&l.includes(s==null?void 0:s.type)||p(!1)},onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{((0,n.isAlphaNumericKey)(e.keyCode)||(0,n.isNavigationKey)(e.keyCode))&&e.stopPropagation()},...D,...(s==null?void 0:s.getField)&&(s==null?void 0:s.getField()[`x-component-props`])||{}},pattern:f?``:`readPretty`,cell:s}),y&&(0,a.jsx)(t.Popover,{content:(d=s==null?void 0:s.validatorMessage)==null?`该字段不合法`:d,children:(0,a.jsx)(i.InfoCircleOutlined,{className:`validator-icon`})})]})}}return new s},d=t=>{let{pattern:n,cell:r,componentProps:i,Com:o,cellRender:c}=t,l=(0,e.useMemo)(()=>{var e;if(r!=null&&r.getField)return(0,s.getVal)({...(r==null?void 0:r.getField)&&(r==null?void 0:r.getField()),enum:(r==null||(e=r.getField())==null?void 0:e.enum)||(r==null?void 0:r.values)},{[(r==null?void 0:r.getField)&&(r==null?void 0:r.getField().name)]:r.text})},[r]);return c&&c(t)?(0,a.jsx)(c,{...t}):(0,a.jsx)(`div`,{className:`base-hoc-inner`,children:n==`readPretty`?(0,a.jsx)(`div`,{children:l}):(0,a.jsx)(o,{className:`rg-input`,ref:e=>{e&&e.focus()},...i})})},f=e=>{let n=(0,o.c)(5),r=e==null?void 0:e.componentProps,i;n[0]===r?i=n[1]:(i={...r,type:`number`},n[0]=r,n[1]=i);let s;return n[2]!==e||n[3]!==i?(s=(0,a.jsx)(d,{...e,componentProps:i,Com:t.Input}),n[2]=e,n[3]=i,n[4]=s):s=n[4],s},p=t=>{let n=(0,o.c)(21),{cell:r}=t,{setExpandKeys:s,expandKeys:c,rowKey:l,setNewDataSource:u,record:d}=r,[f,p]=(0,e.useState)(!1),m;n[0]!==d||n[1]!==l||n[2]!==u?(m=e=>{u(t=>{var n;let r=[...t],i=d==null||(n=d.children)==null?void 0:n.map(e=>e==null?void 0:e[l]);if(e){let e=t==null?void 0:t.findIndex(e=>(e==null?void 0:e[l])==(d==null?void 0:d[l])),n=(t==null?void 0:t.filter(e=>i==null?void 0:i.includes(e==null?void 0:e[l])))||[];return(n==null?void 0:n.length)==0&&r.splice(e+1,0,...(d==null?void 0:d.children)||[]),[...r]}return t==null?void 0:t.filter(e=>!(i!=null&&i.includes(e==null?void 0:e[l])))})},n[0]=d,n[1]=l,n[2]=u,n[3]=m):m=n[3];let h=m,g;n[4]!==c||n[5]!==h||n[6]!==d||n[7]!==l?(g=()=>{c!=null&&c.includes(d==null?void 0:d[l])&&(p(!0),h(!0))},n[4]=c,n[5]=h,n[6]=d,n[7]=l,n[8]=g):g=n[8];let _=r==null?void 0:r.record,v;n[9]===_?v=n[10]:(v=[_],n[9]=_,n[10]=v),(0,e.useEffect)(g,v);let y;n[11]!==f||n[12]!==h||n[13]!==d||n[14]!==l||n[15]!==s?(y=()=>{s(e=>e!=null&&e.includes(d==null?void 0:d[l])?e==null?void 0:e.filter(e=>e!=(d==null?void 0:d[l])):[...e,d==null?void 0:d[l]]),p(!f),h(!f)},n[11]=f,n[12]=h,n[13]=d,n[14]=l,n[15]=s,n[16]=y):y=n[16];let b=y,x;return n[17]!==f||n[18]!==b||n[19]!==(d==null?void 0:d.children)?(x=(0,a.jsx)(`div`,{className:`expandList-template`,children:d!=null&&d.children?(0,a.jsx)(a.Fragment,{children:f?(0,a.jsx)(i.MinusCircleOutlined,{className:`expandList-template-icon`,onClick:b}):(0,a.jsx)(i.PlusCircleOutlined,{className:`expandList-template-icon`,onClick:b})}):(0,a.jsx)(`div`,{style:{width:14}})}),n[17]=f,n[18]=b,n[19]=d==null?void 0:d.children,n[20]=x):x=n[20],x};function m(e){return typeof e==`object`&&!!e}var h=e=>{var t;return typeof(e==null?void 0:e.title)==`function`?m(e==null?void 0:e.title())?e==null||(t=e.title())==null?void 0:t.props.children:String(e==null?void 0:e.title())||``:String(e==null?void 0:e.title)||``};function g(e,t=40){let n=e=>e.reduce((e,t)=>{var r;return(r=t.children)!=null&&r.length?[...e,...n(t.children)]:[...e,t]},[]),r=(e,t=1)=>e.reduce((e,n)=>{var i;return(i=n.children)!=null&&i.length?Math.max(e,r(n.children,t+1)):Math.max(e,t)},t),i=n(e),a=r(e),o=i.length,s=(e,t=0)=>e.map(e=>{var r;if(!(((r=e.children)==null?void 0:r.length)>0))return{...e,rowspan:a-t,colspan:1,_depth:t,_isLeaf:!0};let i=n(e.children).length;return{...e,rowspan:1,colspan:i,_depth:t,_isLeaf:!1,children:s(e.children,t+1)}}),c=s(e,0),l=Array.from({length:a},(e,n)=>({rowId:`header-${n}`,height:t,cells:[]})),u=e=>{var t;return(t=[`rowSelection`,`ExpandListTemplate`])!=null&&t.includes(e==null?void 0:e.type)?e==null?void 0:e.type:m(typeof(e==null?void 0:e.title)==`function`?e==null?void 0:e.title():null)?`${e==null?void 0:e.dataIndex}`:`header`},d=(e,t=0)=>{e.forEach(e=>{if(e._isLeaf){let n={...e,type:u(e),text:h(e),dataIndex:e.dataIndex,width:e.width,rowspan:e.rowspan,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}};e.sorter&&(n.sorter=e.sorter),e.key&&(n.key=e.key),l[t].cells.push(n)}else l[t].cells.push({...e,type:u(e),text:h(e),colspan:e.colspan,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}}),e.children&&d(e.children,t+1)})};d(c,0),l.forEach((e,t)=>{let n=[],r=0,s=0;for(;r<o;){let o=e.cells[s];if(!o){let e=i[r];n.push({...e,type:u(e),text:h(e),dataIndex:e.dataIndex,width:e.width,rowspan:t===a-1?1:void 0,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}}),r++,s++;continue}let c=o.colspan||1;if((o.rowspan||1)>1&&t>0){r+=c,s++;continue}n.push(o),r+=c,s++;for(let e=1;e<c;e++)n.push({type:`header`,text:``})}e.cells=n});let f=l[a-1],p=[];return i.forEach((e,t)=>{let n=f.cells.find(t=>t.dataIndex===e.dataIndex&&t.text===e.title);n?p.push(n):p.push({...e,type:u(e),text:h(e),dataIndex:e.dataIndex,width:e.width,rowspan:1,style:e!=null&&e.style?e==null?void 0:e.style:{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}})}),f.cells=p,l.forEach(e=>{for(;e.cells.length<o;)e.cells.push({type:`header`,text:``})}),l}function _(e){let t=[];function n(e){e.forEach(e=>{if(e.children&&e.children.length>0)n(e.children);else{let{title:n,dataIndex:r,key:i,width:a,sorter:o,k:s,...c}=e;t.push({type:`Input`,dataIndex:r,title:n,...i&&{key:i},...a&&{width:a},...o&&{sorter:o},...s&&{k:s},...c})}})}return n(e),t}function v(i,o){var s;let{columns:l,dataSource:h,formulaConfig:v,onChange:y,reactGridProps:b={},onEditSubmit:x,headerRowHeight:S=44,rowHeight:C=44,reactGridStyle:w,className:T,Slots:E,rowSelection:D,rowKey:O=`id`,query:k,loading:A,isExpand:ee=!1,getList:j,onRow:M}=i,[N,te]=(0,e.useState)([]),[P,F]=(0,e.useState)([]),I=(0,e.useRef)([]),[L,R]=(0,e.useState)([]),[z,B]=(0,e.useState)([]),[V,H]=(0,e.useState)([]),[ne,re]=(0,e.useState)([]),[ie,ae]=(0,e.useState)([]),[oe,U]=(0,e.useState)([]),W=(0,e.useRef)(),[G,se]=(0,e.useState)({}),K=(0,e.useRef)({}),q=(0,e.useRef)(),ce=(0,e.useRef)(),J=(0,e.useRef)(),Y=(0,e.useCallback)(()=>{q.current=void 0;let e=K.current;Object.keys(e).length!==0&&(K.current={},se(t=>{let n=t;for(let r in e){let i={...n[r]||{}},a=!1;for(let t in e[r]){let n=e[r][t];i[t]!==n&&(i[t]=n,a=!0)}a&&(n===t&&(n={...t}),n[r]=i)}return n===t?t:n}))},[]),le=(0,e.useCallback)((e,t,n)=>{let r=Math.max(Number(t)||0,C),i=String(e),a=n||`_`,o=K.current[i]=K.current[i]||{};o[a]!==r&&(o[a]=r,q.current||(q.current=requestAnimationFrame(Y)))},[C,Y]);(0,e.useEffect)(()=>()=>{q.current&&cancelAnimationFrame(q.current)},[]),(0,e.useEffect)(()=>{F(e=>{if(!Array.isArray(e)||e.length===0)return e;let t=!1,n=e.map(e=>{if(typeof(e==null?void 0:e.rowId)==`string`&&e.rowId.indexOf(`header-`)===0)return e;let n=G[e.rowId],r=n&&Object.keys(n).length>0?Math.max(C,...Object.values(n).map(Number)):C;return e.height===r?e:(t=!0,{...e,height:r})});return t?n:e})},[G,C]),(0,e.useImperativeHandle)(o,()=>({rows:P}));let X=(e,t=0)=>{e==null||e.forEach(e=>{e.level=t+1,e!=null&&e.children&&X(e==null?void 0:e.children,e.level)})};(0,e.useEffect)(()=>{X(h),H(h)},[h]),(0,e.useEffect)(()=>{let e=P.map(e=>e.rowId);e!=null&&e.includes(W.current)||U([])},[P]);let ue=e=>{var t,n;let r=e==null||(t=e.cells)==null||(t=t[0])==null?void 0:t.record,i=[`_$actions`,`rowSelection`],a={id:e==null?void 0:e.rowId};return e==null||(n=e.cells)==null||n.forEach(e=>{e!=null&&e.columnId&&!(i!=null&&i.includes(e==null?void 0:e.columnId))&&(a[e==null?void 0:e.columnId]=(e==null?void 0:e.text)||(e==null?void 0:e.value)||(e==null?void 0:e.selectedValue)||``,(e==null?void 0:e.type)==`Number`&&(a[e==null?void 0:e.columnId]=e==null?void 0:e.value))}),{...r,...a}};(0,e.useEffect)(()=>{if(Array.isArray(l)&&(l==null?void 0:l.length)>0){ee&&l.unshift({type:`ExpandListTemplate`,width:14,key:`ExpandListTemplate`,nonEditable:!0,style:(D==null?void 0:D.style)||{background:`rgba(128, 128, 128, 0.1)`}}),D&&l.unshift({type:`rowSelection`,nonEditable:!0,width:(D==null?void 0:D.width)||30,key:`rowSelection`,style:(D==null?void 0:D.style)||{background:`rgba(128, 128, 128, 0.1)`,display:`flex`,justifyContent:`center`}}),te(g(l,S));let e=_(l);R(e==null?void 0:e.map((e,t)=>({...e,columnId:(e==null?void 0:e.dataIndex)||(e==null?void 0:e.key)||(e==null?void 0:e.name)||``})))}},[l,D]);let Z={},Q=e=>{e==null||e.forEach(e=>{if(m(typeof(e==null?void 0:e.title)==`function`?e==null?void 0:e.title():null)){let t=e==null?void 0:e.title;Z[e==null?void 0:e.dataIndex]=u(t)}e!=null&&e.children&&Q(e==null?void 0:e.children)})};(0,e.useEffect)(()=>{Q(l),ae(Z)},[l]),(0,e.useEffect)(()=>{let e=L==null?void 0:L.map(e=>e==null?void 0:e.columnId),t=V==null?void 0:V.map((t,n)=>{let r=G[t[O]],i=r&&Object.keys(r).length>0?Math.max(C,...Object.values(r).map(Number)):C;return{rowId:t[O],height:i,cells:e==null?void 0:e.map((e,r)=>{var i;let a={},o=L[r],s=t[e],c=(i=o==null?void 0:o.type)==null?`text`:i;if(v){for(let n in v)if(n==e){let e=v[n];a={text:(e==null?void 0:e.setCellData)&&(e==null?void 0:e.setCellData(t)),value:(e==null?void 0:e.setCellData)&&(e==null?void 0:e.setCellData(t)),style:(e==null?void 0:e.setCellStyle)&&(e==null?void 0:e.setCellStyle((e==null?void 0:e.setCellData)&&(e==null?void 0:e.setCellData(t))||t))}}}return{...o,record:t,rowId:t[O]||(o==null?void 0:o.type),type:c,nonEditable:(o==null?void 0:o.pattern)==`readPretty`?!0:o==null?void 0:o.nonEditable,text:String(s||``),value:s,selectedValue:s||``,style:(o==null?void 0:o.type)==`rowSelection`?{display:`flex`,justifyContent:`center`}:{},...M&&M(t,n,r)||{},...(o==null?void 0:o.onCell)&&(o==null?void 0:o.onCell(t,n,r))||{},...(o==null?void 0:o.cellProps)||{},setNewDataSource:H,setExpandKeys:re,rowKey:O,expandKeys:ne,Slots:E,onRowHeightChange:le,...a}})}}),n=[...N,...t];F(n)},[V,L,N]),(0,e.useEffect)(()=>{if(A){var e;let t=P==null?void 0:P.find(e=>{var t;return(e==null?void 0:e.rowId)==((t=J.current)==null?void 0:t.rowId)});t==null||(e=t.cells)==null||e.find(e=>{var t;return(e==null?void 0:e.columnId)==((t=J.current)==null?void 0:t.columnId)}),{...J.current},I.current=P}},[A,P]);let de=async e=>{let t=[];if(!Array.isArray(e)||e.length===0)return;let n=!1;if((e==null?void 0:e.length)>1&&(n=!0),F(r=>(e.forEach(async e=>{let i=r.findIndex(t=>t.rowId==e.rowId),a=L.findIndex(t=>t.columnId==e.columnId);if(r[i].cells[a]={...e.newCell},J.current={...e.newCell},t.push(ue(r[i])),v)for(let e in v){let t=v[e],n=L.findIndex(t=>t.columnId==e),a={...r[i].cells[n],text:(t==null?void 0:t.setCellData)&&(t==null?void 0:t.setCellData(r[i])),value:(t==null?void 0:t.setCellData)&&(t==null?void 0:t.setCellData(r[i])),style:(t==null?void 0:t.setCellStyle)&&(t==null?void 0:t.setCellStyle((t==null?void 0:t.setCellData)&&(t==null?void 0:t.setCellData(r[i]))||r[i]))};r[i].cells[n]=a}if(x&&!n)try{await x(t)}catch(e){j&&j()}y&&y(r[i])}),[...r])),n)try{x&&await x(t)}catch(e){j&&j()}},fe=(0,e.useMemo)(()=>{let e={...r.antdComponents||{},...r.customComponents||{},...c},t={};for(let n in e)t[n]=u(t=>(0,a.jsx)(d,{...t,...i,Com:e[n]}));return t},[r.antdComponents,r.customComponents]),pe=e=>{let t=P==null?void 0:P.find(t=>{var n;return(t==null?void 0:t.rowId)==(e==null||(n=e.cell)==null?void 0:n.rowId)});return(0,a.jsxs)(`div`,{onPointerDown:e=>e.stopPropagation(),children:[(E==null?void 0:E.tableActionsSlot)&&(0,a.jsx)(E.tableActionsSlot,{...e==null?void 0:e.cell,rowData:t}),(E==null?void 0:E.actionPrefixSlot)&&(0,a.jsx)(E.actionPrefixSlot,{...e==null?void 0:e.cell,rowData:t}),(E==null?void 0:E.actionCenterSlot)&&(0,a.jsx)(E.actionCenterSlot,{...e==null?void 0:e.cell,rowData:t}),(E==null?void 0:E.actionSuffixSlot)&&(0,a.jsx)(E.actionSuffixSlot,{...e==null?void 0:e.cell,rowData:t})]})};function $(e){let t=[];function n(e){for(let r of e)t.push(r),r.children&&r.children.length&&n(r.children)}return n(e),t}let me=e=>{var n,r,i,o,s,c;let{record:l,rowId:u}=e==null?void 0:e.cell,d=(n=$(h))==null?void 0:n.filter(e=>{var t;return!(D!=null&&(t=D.getCheckboxProps)!=null&&(t=t.call(D,e))!=null&&t.disabled)}),f=typeof(D==null?void 0:D.getCheckboxProps)==`function`?D==null||(r=D.getCheckboxProps)==null?void 0:r.call(D,l):{};return(0,a.jsx)(t.Checkbox,{...e==null?void 0:e.componentProps,checked:(D==null||(i=D.selectedRowKeys)==null?void 0:i.includes(l&&l[O]||``))||!u&&(D==null||(o=D.selectedRowKeys)==null?void 0:o.length)==(d==null?void 0:d.length)&&(d==null?void 0:d.length)>0,indeterminate:!u&&(D==null||(s=D.selectedRowKeys)==null?void 0:s.length)>0&&(D==null||(c=D.selectedRowKeys)==null?void 0:c.length)<(d==null?void 0:d.length),onChange:e=>{if(e.target.checked&&u){let e=[...D==null?void 0:D.selectedRowKeys,l[O]],t=d==null?void 0:d.filter(t=>e==null?void 0:e.includes(t[O]));D==null||D.onChange(e,t)}else if(!e.target.checked&&u){var t,n;let e=D==null||(t=D.selectedRowKeys)==null?void 0:t.filter(e=>e!=l[O]),r=d==null?void 0:d.filter(t=>e==null?void 0:e.includes(t[O]));D==null||D.onChange(D==null||(n=D.selectedRowKeys)==null?void 0:n.filter(e=>e!=l[O]),r)}else if(e.target.checked&&!u){let e=d==null?void 0:d.map(e=>e[O]),t=d==null?void 0:d.filter(t=>e==null?void 0:e.includes(t[O]));D==null||D.onChange(d==null?void 0:d.map(e=>e[O]),t)}else!e.target.checked&&!u&&(D==null||D.onChange([],[]))},...f})};(0,e.useEffect)(()=>{if(D){var e;let t=(e=$(h))==null?void 0:e.filter(e=>{var t;return!(D!=null&&(t=D.getCheckboxProps)!=null&&(t=t.call(D,e))!=null&&t.disabled)}),n=t==null?void 0:t.filter(e=>z==null?void 0:z.includes(e[O]));D==null||D.onChange(z,n)}},[z,h]),(0,e.useEffect)(()=>{B([])},[k==null?void 0:k.pageNum]);let he=(0,e.useMemo)(()=>{let e={};for(let t in b==null?void 0:b.customCellTemplates)e[t]=u(b==null?void 0:b.customCellTemplates[t]);return e},[b==null?void 0:b.customCellTemplates]),ge=(e,t)=>{var n;let r=t==null||(n=t.find(t=>(t==null?void 0:t.rowId)==(e==null?void 0:e.rowId)))==null||(n=n.cells)==null?void 0:n.map(t=>({columnId:t==null?void 0:t.columnId,rowId:e==null?void 0:e.rowId,className:`custom-highlights-row`,borderColor:`transparent`}));W.current=e==null?void 0:e.rowId,U(r)};return(0,a.jsx)(t.Spin,{spinning:A,children:(0,a.jsxs)(`div`,{className:`grid-container ${T}`,style:w,children:[(0,a.jsx)(n.ReactGrid,{ref:ce,rows:A?I.current:P,columns:L,onCellsChanged:de,enableFillHandle:!0,enableRangeSelection:!0,horizontalStickyBreakpoint:120,...b,highlights:(s=b==null?void 0:b.highlights)==null?oe:s,onFocusLocationChanging:e=>{var t,n;let r=(e==null?void 0:e.columnId)+(e==null?void 0:e.rowId);return window.gridEditId=r,typeof(e==null?void 0:e.rowId)==`string`&&(e==null||(t=e.rowId)==null?void 0:t.indexOf(`header-`))>-1||(b!=null&&b.isRowHighlights&&e!=null&&e.columnId&&ge(e,P),(n=[`_$actions`,`rowSelection`,`ExpandListTemplate`])!=null&&n.includes(e==null?void 0:e.columnId))?!1:b!=null&&b.onFocusLocationChanging?b==null?void 0:b.onFocusLocationChanging(e,P):e},customCellTemplates:{ExpandListTemplate:u(p),...fe,...he,...ie,_$actions:u(pe),rowSelection:u(me),Number:u(f,i)}},(h==null?void 0:h.length)==0?0:1),(h==null?void 0:h.length)<=0&&(0,a.jsx)(`div`,{className:`grid-container-empty`,children:(0,a.jsx)(t.Empty,{image:t.Empty.PRESENTED_IMAGE_SIMPLE})})]})})}var y=(0,e.forwardRef)(v);module.exports=y;
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- .number-cell-template .rg-input{border:none}.expandList-template{align-items:center;display:flex}.expandList-template .expandList-template-icon{cursor:pointer}.expandList-template .expandList-template-name{margin-left:8px}.expandList-template .expandList-template-indent{margin-left:32px}.grid-container{max-height:100vh;padding-bottom:16px;position:relative;overflow:auto}.grid-container .ant-input-affix-wrapper-focused,.grid-container .ant-input-affix-wrapper:focus{box-shadow:none}.grid-container .rg-input{border:none}.grid-container .ant-select{width:100%!important}.grid-container .rg-header-cell,.grid-container .rg-cell{z-index:2;justify-content:center;align-items:center;display:flex}.grid-container .rg-partial-area{z-index:3}.grid-container .rg-cell{padding:0!important}.grid-container .rg-cell-focus,.grid-container .rg-fill-handle{z-index:2}.base-hoc{z-index:1;justify-content:center;align-items:center;width:100%;height:100%;padding:4px;display:flex}.base-hoc-edit{background-color:#fff}.validator-icon{cursor:pointer;background:#fff;position:relative}.rg-rowSelection-cell label{justify-content:center}.grid-container-empty{justify-content:center;align-items:center;height:100%;display:flex}.rg-pane-left,.rg-pane-right{z-index:10!important}.custom-highlights-row{background:#e9f8ff}.rg-pane-top{z-index:9!important}.shadow-top-left-corner,.shadow-top-right-corner{z-index:11!important}
1
+ .number-cell-template .rg-input{border:none}.expandList-template{align-items:center;display:flex}.expandList-template .expandList-template-icon{cursor:pointer}.expandList-template .expandList-template-name{margin-left:8px}.expandList-template .expandList-template-indent{margin-left:32px}.grid-container{max-height:100vh;padding-bottom:16px;position:relative;overflow:auto}.grid-container .ant-input-affix-wrapper-focused,.grid-container .ant-input-affix-wrapper:focus{box-shadow:none}.grid-container .rg-input{border:none}.grid-container .ant-select{width:100%!important}.grid-container .rg-header-cell,.grid-container .rg-cell{z-index:2;justify-content:center;align-items:center;display:flex}.grid-container .rg-partial-area{z-index:3}.grid-container .rg-cell{padding:0!important}.grid-container .rg-cell-focus,.grid-container .rg-fill-handle{z-index:2}.base-hoc{box-sizing:border-box;z-index:1;justify-content:center;align-items:center;width:100%;height:auto;min-height:100%;padding:4px;display:flex}.base-hoc-edit{background-color:#fff}.base-hoc-inner{justify-content:center;align-items:center;width:100%;display:flex}.validator-icon{cursor:pointer;background:#fff;position:relative}.rg-rowSelection-cell label{justify-content:center}.grid-container-empty{justify-content:center;align-items:center;height:100%;display:flex}.rg-pane-left,.rg-pane-right{z-index:10!important}.custom-highlights-row{background:#e9f8ff}.rg-pane-top{z-index:9!important}.shadow-top-left-corner,.shadow-top-right-corner{z-index:11!important}
2
2
  /*$vite$:1*/