@noraent/nora-datagrid 0.0.240 → 0.0.241

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.240",
3
+ "version": "0.0.241",
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
- `,gn=n=>{const r=k(),[t,e]=i.useState(!1),u=i.useRef(null);return i.useEffect((()=>{u.current=n,r.current.setInitialStore(n),r.current.initHeightCache(),e(!0)}),[]),t?v.jsx(bn,{props:n,prevProps:u}):v.jsxs(dn,{children:[v.jsx(wn,{}),v.jsx(hn,{style:{marginTop:"8px",fontSize:"14px"},children:"로딩중"})]})},bn=({props:n,prevProps:r})=>{const t=k();return v.jsx(M,{value:t,children:v.jsx(xn,{props:n,prevProps:r})})},xn=i.memo((({props:n,prevProps:r})=>{const t=k(),e=I();return i.useEffect((()=>{r.current&&Object.keys(n).forEach((u=>{var i;const o=u;if(r.current&&(null==(i=r.current)?void 0:i[o])!==n[o]){const r=t.current.setBasicStore(n);if(t.current.setStoreState(o,r[o]),e.setState(["state",o],r[o]),"dataSource"===u){const n=t.current.initHeightCache();t.current.reloadRange(),e.setState(["cumulativeHeights"],n),e.setState(["__reloadRangeRandomKey"],window.crypto.randomUUID())}}})),r.current=n}),[n]),v.jsx(vn,{})})),_n=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.j.includes(n.k)))),[]),u=n.useCallback((()=>{const n=r.current.store.state.cellFocus[0]?Math.max(r.current.store.state.cellFocus[0]-1,0):void 0,t=r.current.store.state.cellFocus[1]?Math.max(r.current.store.state.cellFocus[1]-1,0):void 0;if(void 0===n||void 0===t)return;const e=r.current.store.state.columns[t],u=r.current.store.state.dataSource[n];return e?{id:u.id,field:e.fieldId,fieldName:e.fieldName,value:u[e.fieldId],row:u,startRowIndex:n,endRowIndex:t}:void 0}),[]),i=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${b.body.scroll.root}`);if(t){const e=r.current.getScrollTop(n);t.scrollTop=e}}}),[]),o=n.useCallback((n=>{const t=structuredClone(r.current.store.H);t.push(n),r.current={...r.current,store:{...r.current.store,H:t}}}),[]),f=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.B=`${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()}),10)}),[]),c=n.useCallback((n=>{const t=r.current.store.state.dataSource.filter(((r,t)=>n.includes(t))).flatMap((n=>n.k)),e=r.current.store.state.dataSource.filter(((r,t)=>n.includes(t)));r.current.store.j=t,r.current.store.updateKeyTemp.add("__selectionList"),setTimeout((()=>{var n;null==(n=r.current.getPublicApi())||n.forceUpdate(),r.current.store.state.onSelectionRowChange&&r.current.store.state.onSelectionRowChange(e)}),10)}),[]);d(r,{addCellRange:o,getData:t,scrollToRowIndex:i,setRowHeight:f,getSelectedRow:e,setSelection:c,getSelectedCell:u},"public")}(t),function(r){const t=n.useCallback((()=>{}),[]),e=n.useCallback((()=>{r.current={...r.current,store:{...r.current.store,O:window.crypto.randomUUID()}}}),[]),u=n.useCallback(((n,t)=>{r.current={...r.current,store:{...r.current.store,state:{...r.current.store.state,[n]:t}}}}),[]),i=n.useCallback((n=>{r.current={...r.current,store:{...r.current.store,gridContainer:n}}}),[]),o=n.useCallback((n=>{const t=f(n),e=["__selectionMode","__checkboxSelection"].reduce(((r,t)=>("__selectionMode"===t&&(r[t]=n.selectionMode??"single"),"__checkboxSelection"===t&&(r[t]=n.checkboxSelection??!0),r)),{});return r.current={...r.current,store:{...r.current.store,original:t,state:{...t},H:[],P:{},D:0,cumulativeHeights:[],j:[],updateKeyTemp:new Set,B:"",F:"single",M:!1,I:!0,O:window.crypto.randomUUID(),W:"function"==typeof(null==n?void 0:n.loader)?n.loader():void 0,...e}},r.current}),[]),f=n.useCallback((n=>["columns","dataSource","cellFocus","editStatus","readOnly","onSelectionRowChange","onCellClick"].reduce(((r,t)=>{if(t in n)if("dataSource"===t)r[t]=n[t].map((({height:n=32,...r},t)=>({height:n,...r,k:window.crypto.randomUUID(),U:t,L: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,k:window.crypto.randomUUID(),T:t,$: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,selectionMode:"multiple",checkboxSelection:!0,onSelectionRowChange:()=>{},onCellClick:()=>{},loader:()=>{}}[n]}(t);return r}),{})),[]),c=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${b.body.scroll.root}`);if(t){const r=w(n);t.scrollTop=r}}}),[]),a=n.useCallback((n=>{const t=Object.assign(r.current.store.P,n);r.current={...r.current,store:{...r.current.store,P:t}}}),[]),l=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}),[]),s=n.useCallback((()=>{const{store:n}=r.current;return n.state.cellFocus}),[]),v=n.useCallback((async n=>{const{store:t}=r.current;return t.state.editStatus=n,t.state.editStatus}),[]),h=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}),[]),p=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}),[]),w=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:i,setInitialStore:o,scrollToRowIndex:c,addCellRangeTemp:a,setCellFocus:l,getCellFocus:s,setEditStatus:v,cellByRowIndex:h,setBasicStore:f,initHeightCache:p,getScrollTop:w,setStoreState:u,reloadRange:e},"private")}(t),t}(e),o=i.useRef(null);return i.useEffect((()=>{u.current.setGridContainer(o)}),[]),v.jsx(v.Fragment,{children:v.jsx($.Provider,{value:u,children:v.jsxs(T,{ref:o,children:[v.jsx(T.Title,{}),v.jsx(T.Body,{children:v.jsx(gn,{...r})})]})})})})),mn=i.memo(_n);exports.DataGrid=mn,exports.classes=x,exports.useGridApiRef=()=>n.useRef({});
5
+ `,gn=n=>{const r=k(),[t,e]=i.useState(!1),u=i.useRef(null);return i.useEffect((()=>{u.current=n,r.current.setInitialStore(n),r.current.initHeightCache(),e(!0)}),[]),t?v.jsx(bn,{props:n,prevProps:u}):v.jsxs(dn,{children:[v.jsx(wn,{}),v.jsx(hn,{style:{marginTop:"8px",fontSize:"14px"},children:"로딩중"})]})},bn=({props:n,prevProps:r})=>{const t=k();return v.jsx(M,{value:t,children:v.jsx(xn,{props:n,prevProps:r})})},xn=i.memo((({props:n,prevProps:r})=>{const t=k(),e=I();return i.useEffect((()=>{r.current&&Object.keys(n).forEach((u=>{var i;const o=u;if(r.current&&(null==(i=r.current)?void 0:i[o])!==n[o]){const r=t.current.setBasicStore(n);if(t.current.setStoreState(o,r[o]),e.setState(["state",o],r[o]),"dataSource"===u){t.current.store.j=[];const n=t.current.initHeightCache();t.current.reloadRange(),e.setState(["cumulativeHeights"],n),e.setState(["__reloadRangeRandomKey"],window.crypto.randomUUID())}}})),r.current=n}),[n]),v.jsx(vn,{})})),_n=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.j.includes(n.k)))),[]),u=n.useCallback((()=>{const n=r.current.store.state.cellFocus[0]?Math.max(r.current.store.state.cellFocus[0]-1,0):void 0,t=r.current.store.state.cellFocus[1]?Math.max(r.current.store.state.cellFocus[1]-1,0):void 0;if(void 0===n||void 0===t)return;const e=r.current.store.state.columns[t],u=r.current.store.state.dataSource[n];return e?{id:u.id,field:e.fieldId,fieldName:e.fieldName,value:u[e.fieldId],row:u,startRowIndex:n,endRowIndex:t}:void 0}),[]),i=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${b.body.scroll.root}`);if(t){const e=r.current.getScrollTop(n);t.scrollTop=e}}}),[]),o=n.useCallback((n=>{const t=structuredClone(r.current.store.H);t.push(n),r.current={...r.current,store:{...r.current.store,H:t}}}),[]),f=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.B=`${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()}),10)}),[]),c=n.useCallback((n=>{const t=r.current.store.state.dataSource.filter(((r,t)=>n.includes(t))).flatMap((n=>n.k)),e=r.current.store.state.dataSource.filter(((r,t)=>n.includes(t)));r.current.store.j=t,r.current.store.updateKeyTemp.add("__selectionList"),setTimeout((()=>{var n;null==(n=r.current.getPublicApi())||n.forceUpdate(),r.current.store.state.onSelectionRowChange&&r.current.store.state.onSelectionRowChange(e)}),10)}),[]);d(r,{addCellRange:o,getData:t,scrollToRowIndex:i,setRowHeight:f,getSelectedRow:e,setSelection:c,getSelectedCell:u},"public")}(t),function(r){const t=n.useCallback((()=>{}),[]),e=n.useCallback((()=>{r.current={...r.current,store:{...r.current.store,O:window.crypto.randomUUID()}}}),[]),u=n.useCallback(((n,t)=>{r.current={...r.current,store:{...r.current.store,state:{...r.current.store.state,[n]:t}}}}),[]),i=n.useCallback((n=>{r.current={...r.current,store:{...r.current.store,gridContainer:n}}}),[]),o=n.useCallback((n=>{const t=f(n),e=["__selectionMode","__checkboxSelection"].reduce(((r,t)=>("__selectionMode"===t&&(r[t]=n.selectionMode??"single"),"__checkboxSelection"===t&&(r[t]=n.checkboxSelection??!0),r)),{});return r.current={...r.current,store:{...r.current.store,original:t,state:{...t},H:[],P:{},D:0,cumulativeHeights:[],j:[],updateKeyTemp:new Set,B:"",F:"single",M:!1,I:!0,O:window.crypto.randomUUID(),W:"function"==typeof(null==n?void 0:n.loader)?n.loader():void 0,...e}},r.current}),[]),f=n.useCallback((n=>["columns","dataSource","cellFocus","editStatus","readOnly","onSelectionRowChange","onCellClick"].reduce(((r,t)=>{if(t in n)if("dataSource"===t)r[t]=n[t].map((({height:n=32,...r},t)=>({height:n,...r,k:window.crypto.randomUUID(),U:t,L: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,k:window.crypto.randomUUID(),T:t,$: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,selectionMode:"multiple",checkboxSelection:!0,onSelectionRowChange:()=>{},onCellClick:()=>{},loader:()=>{}}[n]}(t);return r}),{})),[]),c=n.useCallback((n=>{if(r.current.initHeightCache(),r.current.store.gridContainer.current){const t=r.current.store.gridContainer.current.querySelector(`.${b.body.scroll.root}`);if(t){const r=w(n);t.scrollTop=r}}}),[]),a=n.useCallback((n=>{const t=Object.assign(r.current.store.P,n);r.current={...r.current,store:{...r.current.store,P:t}}}),[]),l=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}),[]),s=n.useCallback((()=>{const{store:n}=r.current;return n.state.cellFocus}),[]),v=n.useCallback((async n=>{const{store:t}=r.current;return t.state.editStatus=n,t.state.editStatus}),[]),h=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}),[]),p=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}),[]),w=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:i,setInitialStore:o,scrollToRowIndex:c,addCellRangeTemp:a,setCellFocus:l,getCellFocus:s,setEditStatus:v,cellByRowIndex:h,setBasicStore:f,initHeightCache:p,getScrollTop:w,setStoreState:u,reloadRange:e},"private")}(t),t}(e),o=i.useRef(null);return i.useEffect((()=>{u.current.setGridContainer(o)}),[]),v.jsx(v.Fragment,{children:v.jsx($.Provider,{value:u,children:v.jsxs(T,{ref:o,children:[v.jsx(T.Title,{}),v.jsx(T.Body,{children:v.jsx(gn,{...r})})]})})})})),mn=i.memo(_n);exports.DataGrid=mn,exports.classes=x,exports.useGridApiRef=()=>n.useRef({});
@@ -504,7 +504,6 @@ function usePublicTest(apiRef) {
504
504
  return apiRef.current.store.state.dataSource;
505
505
  }, []);
506
506
  const getSelectedRow = React__default.useCallback(() => {
507
- console.log("getSelectedRow", apiRef.current.store.__selectionList);
508
507
  return apiRef.current.store.state.dataSource.filter((v) => apiRef.current.store.__selectionList.includes(v.__uuid));
509
508
  }, []);
510
509
  const getSelectedCell = React__default.useCallback(() => {
@@ -7540,6 +7539,7 @@ const DataGridMain3 = React.memo(({ props, prevProps }) => {
7540
7539
  gridRef.current.setStoreState(typedKey, basicStore[typedKey]);
7541
7540
  store.setState(["state", typedKey], basicStore[typedKey]);
7542
7541
  if (key === "dataSource") {
7542
+ gridRef.current.store.__selectionList = [];
7543
7543
  const heightCache = gridRef.current.initHeightCache();
7544
7544
  gridRef.current.reloadRange();
7545
7545
  store.setState(["cumulativeHeights"], heightCache);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noraent/nora-datagrid",
3
- "version": "0.0.240",
3
+ "version": "0.0.241",
4
4
  "module": "./dist/nora_datagrid.es.js",
5
5
  "main": "./dist/nora_datagrid.cjs.js",
6
6
  "private": false,