cnhis-design-vue 3.1.42-beta.7 → 3.1.42-beta.8
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
|
-
import{defineComponent as e,inject as t,ref as o,computed as l,provide as
|
|
1
|
+
import{defineComponent as e,inject as t,ref as o,computed as l,provide as a,watch as r,onMounted as n,createVNode as s,h as i,nextTick as u,onBeforeUnmount as d,reactive as c,unref as m}from"vue";import{traverse as p}from"../../../../../shared/utils/index.js";import{useThrottleFn as f}from"@vueuse/core";import{promiseTimeout as h}from"@vueuse/shared";import{isFunction as g,isNumber as x,omit as I,isString as v,range as y,last as H}from"lodash-es";import"../../../index.js";import{InjectionIhoTableUUID as b,WIDGET_TYPE as D}from"../../constants/index.js";import{useUUIDMap as R}from"../../utils/index.js";import{defineTablePlugin as U}from"../../hooks/useTablePlugin.js";class w{constructor(){this.records={},this.maxRecords=c({})}set(e,t,o){this.records[e]||(this.records[e]={}),this.records[e][t]=o,this.maxRecords[e]=Math.max(...Object.values(this.records[e]),0)}getMax(e){var t;return null!=(t=this.maxRecords[e])?t:0}}const{getItemFromUUID:E,removeItemFromUUID:M}=R((()=>new w),!0),{getItemFromUUID:T,removeItemFromUUID:j,setItemFromUUID:F}=R((()=>null)),{getItemFromUUID:A,removeItemFromUUID:S,setItemFromUUID:$}=R((()=>{})),L=e({props:{payload:{type:Object,required:!0}},setup(e){const d=t(b),c=t("$xetable"),m=o(),p=E(d),f=l((()=>e.payload.row[e.payload.column.field]));async function h(){await u();const{rowIndex:t,column:o}=e.payload;p&&x(t)&&m.value&&p.set(t,o.field,m.value.clientHeight)}a("updateCellHeight",h),r([()=>e.payload.rowIndex,()=>e.payload.column.field,f],h,{immediate:!0}),n((()=>{c&&!T(d)&&F(d,c)}));const I=l((()=>{var t,o,l,a;const r=null!=(o=null==(t=e.payload.column.editRender)?void 0:t.props)?o:{},n=null!=(a=null==(l=r.slots)?void 0:l.default)?a:r.slotFn;return g(n)?n:()=>f.value}));return()=>s("div",{ref:m,style:"padding:7px 0"},[i(I.value,e.payload)])}});function Y(e,t,{scrollTop:o=0}){var l,a;const{uuid:r,rowConfig:n={}}=t;if(!r)return;const s=E(r),{oSize:i=0,gt:u=100}=null!=(l=A(r))?l:{},{internalData:d,reactData:c}=e,{scrollYStore:p,elemStore:f,afterFullData:h,fullDataRowIdData:g}=d;if(u>h.length)return;const x=null!=(a=n.height)?a:36,I=f["main-body-wrapper"],v=I?m(I):null,b=v?Math.max(8,Math.ceil(v.clientHeight/x)+2+2*i):8,D=[0];let R=0;o&&y(0,h.length).find((e=>{const t=(H(D)||0)+Math.max(x,s.getMax(e));if(D.push(t),t>o)return R=Math.max(0,e-i),!0})),Object.assign(p,{startIndex:R,endIndex:R+b});const U=`${D[R]}px`,w=`${y(0,h.length).reduce(((e,t)=>e+Math.max(x,s.getMax(t))),0)}px`;["main","left","right"].forEach((e=>{const t=f[`${e}-body-table`],o=t?m(t):null;o&&(o.style.marginTop=U),["header","body","footer"].forEach((t=>{const o=f[`${e}-${t}-ySpace`],l=o?m(o):null;l&&(l.style.height=w)}))}));const M=h.slice(p.startIndex,p.endIndex);M.forEach(((t,o)=>{const l=e.getRowid(t),a=g[l];a&&(a.$index=o)})),c.tableData=M}function k(){const e="variableHeightRendererPlugin";return U({name:e,vxe(e){e.renderer.add(D.VARIABLE_HEIGHT,{renderCell:(e,t)=>s(L,{payload:t},null)})},apply(t){t.dataHooks.dataStart.tap(e,(e=>{if(!e.uuid)return;const t=A(e.uuid);t&&(e.scrollY=t),setTimeout((()=>{const t=T(e.uuid);t&&(e.scrollY={enabled:!1},t.reactData.scrollYLoad=!1,Y(t,e,{scrollTop:0}))}),300)})),t.fieldHooks.field.tap(e,(e=>{if(Reflect.get(e,"variableHeight")){const t=e.slots;e.slots=I(t,["default"]),e.editRender={...e.editRender,name:D.VARIABLE_HEIGHT}}return e})),t.fieldHooks.fieldList.tap(e,((e,t)=>(t.uuid&&p(e,((e,o)=>{var l,a,r;if((null==(l=e.editRender)?void 0:l.name)===D.VARIABLE_HEIGHT){$(t.uuid,t.scrollY),t.scrollY={enabled:!1};const e=null!=(r=null==(a=t.rowConfig)?void 0:a.height)?r:36,l=E(t.uuid),n=t.cellStyle;t.cellStyle=function(t){const o={};if(t.column.fixed){const a=Math.max(e,l.getMax(t.rowIndex));a&&(o.height=`${a}px`)}return Object.assign(o,n?g(n)?n(t):n:null)};const s=t.cellClassName;t.cellClassName=function(e){var t;const o=g(s)?s(e):s,l=o?v(o)?{[o]:!0}:o:{};return Object.assign({"virtual-height":(null==(t=e.column.editRender)?void 0:t.name)===D.VARIABLE_HEIGHT},l)},setTimeout((()=>{const e=T(t.uuid);e&&(e.reactData.scrollYLoad=!1,Y(e,t,{scrollTop:0}))}),300),o()}})),e))),t.setupHooks.setup.tap(e,(e=>{d((()=>{e.value.uuid&&(M(e.value.uuid),j(e.value.uuid),S(e.value.uuid))}))})),t.eventHooks.onScroll.tap(e,f((async(e,t)=>{const{uuid:o}=t;if(!o)return;const l=T(o);l&&(await h(0),Y(l,t,e))}),200))}})}export{k as variableHeightRendererPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cnhis-design-vue",
|
|
3
|
-
"version": "3.1.42-beta.
|
|
3
|
+
"version": "3.1.42-beta.8",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"module": "./es/components/index.js",
|
|
6
6
|
"main": "./es/components/index.js",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"iOS 7",
|
|
62
62
|
"last 3 iOS versions"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "d4b1fea0bc621fbcb042f755dda5fa87044b5898"
|
|
65
65
|
}
|