ll-package
Version:
2 lines (1 loc) • 3.42 kB
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("../../../../@babel/runtime/helpers/esm/extends.js"),d=require("vue"),c=require("../../vc-util/warning.js"),k=require("../utils/legacyUtil.js"),a=require("../constant.js"),K=require("../../table/context.js"),$=require("../../_util/vnode.js");var B=function(l,o){var t={};for(var e in l)Object.prototype.hasOwnProperty.call(l,e)&&o.indexOf(e)<0&&(t[e]=l[e]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(l);n<e.length;n++)o.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(l,e[n])&&(t[e[n]]=l[e[n]]);return t};function m(l){return l.reduce((o,t)=>{const{fixed:e}=t,n=e===!0?"left":e,u=t.children;return u&&u.length>0?[...o,...m(u).map(N=>v.default({fixed:n},N))]:[...o,v.default(v.default({},t),{fixed:n})]},[])}function W(l){let o=!0;for(let e=0;e<l.length;e+=1){const n=l[e];if(o&&n.fixed!=="left")o=!1;else if(!o&&n.fixed==="left"){c.warning(!1,`Index ${e-1} of \`columns\` missing \`fixed='left'\` prop.`);break}}let t=!0;for(let e=l.length-1;e>=0;e-=1){const n=l[e];if(t&&n.fixed!=="right")t=!1;else if(!t&&n.fixed==="right"){c.warning(!1,`Index ${e+1} of \`columns\` missing \`fixed='right'\` prop.`);break}}}function z(l){return l.map(o=>{const{fixed:t}=o,e=B(o,["fixed"]);let n=t;return t==="left"?n="right":t==="right"&&(n="left"),v.default({fixed:n},e)})}function G(l,o){let{prefixCls:t,columns:e,expandable:n,expandedKeys:u,getRowKey:N,onTriggerExpand:b,expandIcon:w,rowExpandable:P,expandIconColumnIndex:f,direction:y,expandRowByClick:D,expandColumnWidth:L,expandFixed:p}=l;const I=K.useInjectSlots(),M=d.computed(()=>{if(n.value){let r=e.value.slice();if(process.env.NODE_ENV!=="production"&&f.value>=0&&c.warning(!1,"`expandIconColumnIndex` is deprecated. Please use `Table.EXPAND_COLUMN` in `columns` instead."),!r.includes(a.EXPAND_COLUMN)){const i=f.value||0;i>=0&&r.splice(i,0,a.EXPAND_COLUMN)}process.env.NODE_ENV!=="production"&&r.filter(i=>i===a.EXPAND_COLUMN).length>1&&c.warning(!1,"There exist more than one `EXPAND_COLUMN` in `columns`.");const E=r.indexOf(a.EXPAND_COLUMN);r=r.filter((i,s)=>i!==a.EXPAND_COLUMN||s===E);const O=e.value[E];let x;(p.value==="left"||p.value)&&!f.value?x="left":(p.value==="right"||p.value)&&f.value===e.value.length?x="right":x=O?O.fixed:null;const A=u.value,h=P.value,U=w.value,X=t.value,V=D.value,R={[k.INTERNAL_COL_DEFINE]:{class:`${t.value}-expand-icon-col`,columnType:"EXPAND_COLUMN"},title:$.customRenderSlot(I.value,"expandColumnTitle",{},()=>[""]),fixed:x,class:`${t.value}-row-expand-icon-cell`,width:L.value,customRender:i=>{let{record:s,index:F}=i;const T=N.value(s,F),q=A.has(T),S=h?h(s):!0,_=U({prefixCls:X,expanded:q,expandable:S,record:s,onExpand:b});return V?d.createVNode("span",{onClick:j=>j.stopPropagation()},[_]):_}};return r.map(i=>i===a.EXPAND_COLUMN?R:i)}return process.env.NODE_ENV!=="production"&&e.value.includes(a.EXPAND_COLUMN)&&c.warning(!1,"`expandable` is not config but there exist `EXPAND_COLUMN` in `columns`."),e.value.filter(r=>r!==a.EXPAND_COLUMN)}),g=d.computed(()=>{let r=M.value;return o.value&&(r=o.value(r)),r.length||(r=[{customRender:()=>null}]),r}),C=d.computed(()=>y.value==="rtl"?z(m(g.value)):m(g.value));return process.env.NODE_ENV!=="production"&&d.watchEffect(()=>{setTimeout(()=>{W(C.value)})}),[g,C]}exports.default=G;
;