2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
|
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[6388],{50727:function(ye,oe,r){var b=r(4942),ie=r(97685),W=r(91),Q=r(55850),Y=r(15861),f=r(1413),ce=r(24969),se=r(97462),k=r(952),q=r(6376),ee=r(48171),de=r(53914),ne=r(22270),F=r(60249),ue=r(83622),p=r(77569),z=r(21770),U=r(88306),te=r(8880),y=r(67294),ve=r(54048),h=r(85893),fe=["onTableChange","maxLength","formItemProps","recordCreatorProps","rowKey","controlled","defaultValue","onChange","editableFormRef"],ge=["record","position","creatorButtonText","newRecordType","parentKey","style"],re=y.createContext(void 0);function A(n){var x=n.children,j=n.record,e=n.position,o=n.newRecordType,s=n.parentKey,t=(0,y.useContext)(re);return y.cloneElement(x,(0,f.Z)((0,f.Z)({},x.props),{},{onClick:function(){var a=(0,Y.Z)((0,Q.Z)().mark(function O(Z){var _,D,I,T;return(0,Q.Z)().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,(_=(D=x.props).onClick)===null||_===void 0?void 0:_.call(D,Z);case 2:if(T=m.sent,T!==!1){m.next=5;break}return m.abrupt("return");case 5:t==null||(I=t.current)===null||I===void 0||I.addEditRecord(j,{position:e,newRecordType:o,parentKey:s});case 6:case"end":return m.stop()}},O)}));function C(O){return a.apply(this,arguments)}return C}()}))}function le(n){var x,j,e=(0,q.YB)(),o=n.onTableChange,s=n.maxLength,t=n.formItemProps,a=n.recordCreatorProps,C=n.rowKey,O=n.controlled,Z=n.defaultValue,_=n.onChange,D=n.editableFormRef,I=(0,W.Z)(n,fe),T=(0,y.useRef)(void 0),E=(0,y.useRef)(),m=(0,y.useRef)();(0,y.useImperativeHandle)(I.actionRef,function(){return E.current},[E.current]);var K=(0,z.Z)(function(){return n.value||Z||[]},{value:n.value,onChange:n.onChange}),M=(0,ie.Z)(K,2),u=M[0],N=M[1],S=y.useMemo(function(){return typeof C=="function"?C:function(i,v){return i[C]||v}},[C]),L=(0,ee.J)(function(i){if(typeof i=="number"&&!n.name){if(i>=u.length)return i;var v=u&&u[i];return S==null?void 0:S(v,i)}if((typeof i=="string"||i>=u.length)&&n.name){var c=u.findIndex(function(l,d){var g;return(S==null||(g=S(l,d))===null||g===void 0?void 0:g.toString())===(i==null?void 0:i.toString())});if(c!==-1)return c}return i});(0,y.useImperativeHandle)(D,function(){var i=function(l){var d,g;if(l==null)throw new Error("rowIndex is required");var P=L(l),B=[n.name,(d=P==null?void 0:P.toString())!==null&&d!==void 0?d:""].flat(1).filter(Boolean);return(g=m.current)===null||g===void 0?void 0:g.getFieldValue(B)},v=function(){var l,d=[n.name].flat(1).filter(Boolean);if(Array.isArray(d)&&d.length===0){var g,P=(g=m.current)===null||g===void 0?void 0:g.getFieldsValue();return Array.isArray(P)?P:Object.keys(P).map(function(B){return P[B]})}return(l=m.current)===null||l===void 0?void 0:l.getFieldValue(d)};return(0,f.Z)((0,f.Z)({},m.current),{},{getRowData:i,getRowsData:v,setRowData:function(l,d){var g,P;if(l==null)throw new Error("rowIndex is required");var B=L(l),G=[n.name,(g=B==null?void 0:B.toString())!==null&&g!==void 0?g:""].flat(1).filter(Boolean),Oe=Object.assign({},(0,f.Z)((0,f.Z)({},i(l)),d||{})),Pe=(0,te.Z)({},G,Oe);return(P=m.current)===null||P===void 0||P.setFieldsValue(Pe),!0}})},[L,n.name,m.current]),(0,y.useEffect)(function(){n.controlled&&(u||[]).forEach(function(i,v){var c;(c=m.current)===null||c===void 0||c.setFieldsValue((0,b.Z)({},"".concat(S(i,v)),i))},{})},[(0,de.ZP)(u),n.controlled]),(0,y.useEffect)(function(){if(n.name){var i;m.current=n==null||(i=n.editable)===null||i===void 0?void 0:i.form}},[(x=n.editable)===null||x===void 0?void 0:x.form,n.name]);var $=a||{},H=$.record,J=$.position,R=$.creatorButtonText,me=$.newRecordType,he=$.parentKey,Ce=$.style,be=(0,W.Z)($,ge),X=J==="top",V=(0,y.useMemo)(function(){return typeof s=="number"&&s<=(u==null?void 0:u.length)?!1:a!==!1&&(0,h.jsx)(A,{record:(0,ne.h)(H,u==null?void 0:u.length,u)||{},position:J,parentKey:(0,ne.h)(he,u==null?void 0:u.length,u),newRecordType:me,children:(0,h.jsx)(ue.ZP,(0,f.Z)((0,f.Z)({type:"dashed",style:(0,f.Z)({display:"block",margin:"10px 0",width:"100%"},Ce),icon:(0,h.jsx)(ce.Z,{})},be),{},{children:R||e.getMessage("editableTable.action.add","\u6DFB
|