@noraent/nora-datagrid 0.0.104 → 0.0.105

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@noraent/nora-datagrid",
3
- "version": "0.0.104",
3
+ "version": "0.0.105",
4
4
  "module": "./dist/nora_datagrid.es.js",
5
5
  "main": "./dist/nora_datagrid.cjs.js",
6
6
  "private": false,
@@ -2,4 +2,4 @@
2
2
  to {
3
3
  transform: rotate(360deg);
4
4
  }
5
- `,jn=i.forwardRef(((r,t)=>{const{gridRef:e}=r,u=function(r){const t=function(r){const t=n.useRef(null),e=n.useRef(null);return t.current||(t.current={}),e.current||(e.current=function(n){const r={getPublicApi:()=>n,register:(t,e)=>{Object.keys(e).forEach((u=>{"public"===t?n[u]=e[u]:r[u]=e[u]}))}};return new Proxy(r,{get:(n,t)=>t in n?n[t]:r[t],set:(n,r,t)=>(n[r]=t,!0)})}(t.current)),n.useImperativeHandle(r,(()=>t.current),[]),e}(r);return function(r){const t=n.useCallback((()=>r.current.store.state.dataSource),[]),e=n.useCallback((()=>r.current.store.state.dataSource.filter((n=>r.current.store.u.includes(n.o)))),[]),u=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${j}`);if(t){const e=r.current.getScrollTop(n);t.scrollTop=e}}}),[]),i=n.useCallback((n=>{const t=structuredClone(r.current.store.U);t.push(n),r.current={...r.current,store:{...r.current.store,U:t}}}),[]),o=n.useCallback(((n,t=32)=>{r.current.store.state.dataSource[n]={...r.current.store.state.dataSource[n],height:t},r.current.initHeightCache(),r.current.store.L=`${Math.random()}`,r.current.store.updateKeyTemp.add("state, dataSource"),r.current.store.updateKeyTemp.add("__randomDataSourceKey"),r.current.store.updateKeyTemp.add("cumulativeHeights"),setTimeout((()=>{r.current.getPublicApi().forceUpdate()}),0)}),[]);d(r,{addCellRange:i,getData:t,scrollToRowIndex:u,setRowHeight:o,getSelectedRow:e},"public")}(t),function(r){const t=n.useCallback((()=>{}),[]),e=n.useCallback((n=>{r.current={...r.current,store:{...r.current.store,gridContainer:n}}}),[]),u=n.useCallback((n=>{const t=i(n);return r.current={...r.current,store:{...r.current.store,original:t,state:{...t},U:[],W:{},cumulativeHeights:[],u:[],updateKeyTemp:new Set,L:"",v:"single",l:!1}},r.current}),[]),i=n.useCallback((n=>["columns","dataSource","cellFocus","editStatus","readOnly"].reduce(((r,t)=>{if(t in n)if("dataSource"===t)r[t]=n[t].map((({height:n=32,...r},t)=>({height:n,...r,o:window.crypto.randomUUID(),N:t,O:t+1})));else if("columns"===t){const e=/[^0-9]/g;r[t]=n[t].map((({width:n=20,...r},t)=>({width:Number(`${n}`.replace(e,"")),...r,o:window.crypto.randomUUID(),m:t,i:t+1})))}else r[t]=n[t];else r[t]=function(n){return{cellFocus:[],columns:void 0,dataSource:void 0,gridRef:void 0,renderedRowStartEnd:void 0,editStatus:void 0,readOnly:!1}[n]}(t);return r}),{})),[]),o=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${j}`);if(t){const r=h(n);t.scrollTop=r}}}),[]),f=n.useCallback((n=>{const t=Object.assign(r.current.store.W,n);r.current={...r.current,store:{...r.current.store,W:t}}}),[]),c=n.useCallback((async(n,t)=>{const{store:e}=r.current,{dataSource:u,columns:i}=e.state,o=[n?Math.max(1,Math.min(n,u.length)):void 0,t?Math.max(1,Math.min(t,i.length)):void 0];return e.state.cellFocus=o,o}),[]),a=n.useCallback((()=>{const{store:n}=r.current;return n.state.cellFocus}),[]),l=n.useCallback((async n=>{const{store:t}=r.current;return t.state.editStatus=n,t.state.editStatus}),[]),s=n.useCallback((async(n,t,e)=>{const{store:u}=r.current;return u.state.dataSource[n]={...u.state.dataSource[n],[t]:e},u.state.dataSource}),[]),v=n.useCallback((()=>{let n=0;const t=r.current.store.state.dataSource.map((r=>(n+=r.height??32,n)));return t[0]=0,r.current.store.cumulativeHeights=t,t}),[]),h=n.useCallback((n=>{let t=0,e=r.current.store.cumulativeHeights.length-1,u=0;for(;e>=t;){const i=Math.floor((t+e)/2);i>n?e=i-1:(u=r.current.store.cumulativeHeights[i],t=i+1)}return u}),[]);d(r,{setText:t,setGridContainer:e,setInitialStore:u,scrollToRowIndex:o,addCellRangeTemp:f,setCellFocus:c,getCellFocus:a,setEditStatus:l,cellByRowIndex:s,setBasicStore:i,initHeightCache:v,getScrollTop:h},"private")}(t),t}(e),o=i.useRef(null),[f,c]=i.useTransition();i.useEffect((()=>{c((()=>{u.current.setGridContainer(o),u.current.setInitialStore(r),u.current.initHeightCache()}))}),[]);const a=i.useRef(null);return function(t,e){const i=n.useRef(!1);n.useEffect((()=>{i.current?c((()=>{a.current?Object.keys(r).forEach((n=>{var t;const e=n;if(a.current&&(null==(t=a.current)?void 0:t[e])!==r[e]){const t=u.current.setBasicStore(r);u.current.store.original[e]=t[e],u.current.store.state[e]=t[e],"dataSource"===n&&u.current.initHeightCache()}})):Object.keys(r).forEach((n=>{const t=n,e=u.current.setBasicStore(r);u.current.store.original[t]=e[t],u.current.store.state[t]=e[t],"dataSource"===n&&u.current.initHeightCache()})),a.current=r})):i.current=!0}),e)}(0,[r]),v.jsx(v.Fragment,{children:v.jsx(T.Provider,{value:u,children:v.jsx(k,{value:u,children:v.jsxs(L,{ref:o,children:[v.jsx(L.Title,{}),v.jsxs(L.Body,{children:[f&&v.jsxs(xn,{children:[v.jsx(An,{}),v.jsx(mn,{style:{marginTop:"8px",fontSize:"14px"},children:"로딩중"})]}),!f&&u.current.store&&v.jsx(gn,{})]})]})})})})})),Cn=i.memo(jn);exports.DataGrid=Cn,exports.useGridApiRef=()=>n.useRef({});
5
+ `,jn=i.forwardRef(((r,t)=>{const{gridRef:e}=r,u=function(r){const t=function(r){const t=n.useRef(null),e=n.useRef(null);return t.current||(t.current={}),e.current||(e.current=function(n){const r={getPublicApi:()=>n,register:(t,e)=>{Object.keys(e).forEach((u=>{"public"===t?n[u]=e[u]:r[u]=e[u]}))}};return new Proxy(r,{get:(n,t)=>t in n?n[t]:r[t],set:(n,r,t)=>(n[r]=t,!0)})}(t.current)),n.useImperativeHandle(r,(()=>t.current),[]),e}(r);return function(r){const t=n.useCallback((()=>r.current.store.state.dataSource),[]),e=n.useCallback((()=>r.current.store.state.dataSource.filter((n=>r.current.store.u.includes(n.o)))),[]),u=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${j}`);if(t){const e=r.current.getScrollTop(n);t.scrollTop=e}}}),[]),i=n.useCallback((n=>{const t=structuredClone(r.current.store.U);t.push(n),r.current={...r.current,store:{...r.current.store,U:t}}}),[]),o=n.useCallback(((n,t=32)=>{r.current.store.state.dataSource[n]={...r.current.store.state.dataSource[n],height:t},r.current.initHeightCache(),r.current.store.L=`${Math.random()}`,r.current.store.updateKeyTemp.add("state, dataSource"),r.current.store.updateKeyTemp.add("__randomDataSourceKey"),r.current.store.updateKeyTemp.add("cumulativeHeights"),setTimeout((()=>{r.current.getPublicApi().forceUpdate()}),0)}),[]);d(r,{addCellRange:i,getData:t,scrollToRowIndex:u,setRowHeight:o,getSelectedRow:e},"public")}(t),function(r){const t=n.useCallback((()=>{}),[]),e=n.useCallback((n=>{r.current={...r.current,store:{...r.current.store,gridContainer:n}}}),[]),u=n.useCallback((n=>{const t=i(n);return r.current={...r.current,store:{...r.current.store,original:t,state:{...t},U:[],W:{},cumulativeHeights:[],u:[],updateKeyTemp:new Set,L:"",v:"single",l:!1}},r.current}),[]),i=n.useCallback((n=>["columns","dataSource","cellFocus","editStatus","readOnly"].reduce(((r,t)=>{if(t in n)if("dataSource"===t)r[t]=n[t].map((({height:n=32,...r},t)=>({height:n,...r,o:window.crypto.randomUUID(),N:t,O:t+1})));else if("columns"===t){const e=/[^0-9]/g;r[t]=n[t].map((({width:n=20,...r},t)=>({width:Number(`${n}`.replace(e,"")),...r,o:window.crypto.randomUUID(),m:t,i:t+1})))}else r[t]=n[t];else r[t]=function(n){return{cellFocus:[],columns:void 0,dataSource:void 0,gridRef:void 0,renderedRowStartEnd:void 0,editStatus:void 0,readOnly:!1}[n]}(t);return r}),{})),[]),o=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${j}`);if(t){const r=h(n);t.scrollTop=r}}}),[]),f=n.useCallback((n=>{const t=Object.assign(r.current.store.W,n);r.current={...r.current,store:{...r.current.store,W:t}}}),[]),c=n.useCallback((async(n,t)=>{const{store:e}=r.current,{dataSource:u,columns:i}=e.state,o=[n?Math.max(1,Math.min(n,u.length)):void 0,t?Math.max(1,Math.min(t,i.length)):void 0];return e.state.cellFocus=o,o}),[]),a=n.useCallback((()=>{const{store:n}=r.current;return n.state.cellFocus}),[]),l=n.useCallback((async n=>{const{store:t}=r.current;return t.state.editStatus=n,t.state.editStatus}),[]),s=n.useCallback((async(n,t,e)=>{const{store:u}=r.current;return u.state.dataSource[n]={...u.state.dataSource[n],[t]:e},u.state.dataSource}),[]),v=n.useCallback((()=>{let n=0;const t=r.current.store.state.dataSource.length-1,e=r.current.store.state.dataSource.map(((r,e)=>(n+=r.height??32,t===e?n+40:n)));return e[0]=0,r.current.store.cumulativeHeights=e,e}),[]),h=n.useCallback((n=>{let t=0,e=r.current.store.cumulativeHeights.length-1,u=0;for(;e>=t;){const i=Math.floor((t+e)/2);i>n?e=i-1:(u=r.current.store.cumulativeHeights[i],t=i+1)}return u}),[]);d(r,{setText:t,setGridContainer:e,setInitialStore:u,scrollToRowIndex:o,addCellRangeTemp:f,setCellFocus:c,getCellFocus:a,setEditStatus:l,cellByRowIndex:s,setBasicStore:i,initHeightCache:v,getScrollTop:h},"private")}(t),t}(e),o=i.useRef(null),[f,c]=i.useTransition();i.useEffect((()=>{c((()=>{u.current.setGridContainer(o),u.current.setInitialStore(r),u.current.initHeightCache()}))}),[]);const a=i.useRef(null);return function(t,e){const i=n.useRef(!1);n.useEffect((()=>{i.current?c((()=>{a.current?Object.keys(r).forEach((n=>{var t;const e=n;if(a.current&&(null==(t=a.current)?void 0:t[e])!==r[e]){const t=u.current.setBasicStore(r);u.current.store.original[e]=t[e],u.current.store.state[e]=t[e],"dataSource"===n&&u.current.initHeightCache()}})):Object.keys(r).forEach((n=>{const t=n,e=u.current.setBasicStore(r);u.current.store.original[t]=e[t],u.current.store.state[t]=e[t],"dataSource"===n&&u.current.initHeightCache()})),a.current=r})):i.current=!0}),e)}(0,[r]),v.jsx(v.Fragment,{children:v.jsx(T.Provider,{value:u,children:v.jsx(k,{value:u,children:v.jsxs(L,{ref:o,children:[v.jsx(L.Title,{}),v.jsxs(L.Body,{children:[f&&v.jsxs(xn,{children:[v.jsx(An,{}),v.jsx(mn,{style:{marginTop:"8px",fontSize:"14px"},children:"로딩중"})]}),!f&&u.current.store&&v.jsx(gn,{})]})]})})})})})),Cn=i.memo(jn);exports.DataGrid=Cn,exports.useGridApiRef=()=>n.useRef({});
@@ -377,8 +377,12 @@ function useInternalPrivateApi(apiRef) {
377
377
  }, []);
378
378
  const initHeightCache = React__default.useCallback(() => {
379
379
  let sum = 0;
380
- const heightCache = apiRef.current.store.state.dataSource.map((row) => {
380
+ const totalSize = apiRef.current.store.state.dataSource.length - 1;
381
+ const heightCache = apiRef.current.store.state.dataSource.map((row, i) => {
381
382
  sum += row.height ?? 32;
383
+ if (totalSize === i) {
384
+ return sum + 40;
385
+ }
382
386
  return sum;
383
387
  });
384
388
  heightCache[0] = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noraent/nora-datagrid",
3
- "version": "0.0.104",
3
+ "version": "0.0.105",
4
4
  "module": "./dist/nora_datagrid.es.js",
5
5
  "main": "./dist/nora_datagrid.cjs.js",
6
6
  "private": false,