realgrid-react 0.9.4 → 0.9.6

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.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var $=(o,r,t)=>r in o?C(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t;var n=(o,r,t)=>($(o,typeof r!="symbol"?r+"":r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),_=require("realgrid");function B(o){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:()=>o[t]})}}return r.default=o,Object.freeze(r)}const u=B(_),m=(o,...r)=>(r.forEach(t=>{for(const s in t){if(s==="children")continue;const e=t[s];e===null?o[s]=null:e===void 0?delete o[s]:Array.isArray(e)?o[s]=[...e]:typeof e=="object"?e instanceof Date?o[s]=new Date(e):o[s]=m(o[s]==null?{}:o[s],e):o[s]=e}}),o),h=(o,r={},t={})=>{o=o||{};const s=["children","rows","$grid"];for(const[e,i]of Object.entries(r))if(!s.includes(e))if(!t.hasOwnProperty(e))o[e]=null;else if(Array.isArray(i))(!t[e]||JSON.stringify(i)!=JSON.stringify(t[e]))&&(o[e]=t[e]);else if(i instanceof Object&&!(i instanceof Date||Array.isArray(i)||typeof i=="function"))if(!(t[e]instanceof Object))o[e]=t[e];else{const d=h({},i,t[e]);Object.keys(d).length&&(o[e]=d)}else typeof i=="function"?i.toString()!==t[e].toString()&&(o[e]=t[e]):i!==t[e]&&(o[e]=t[e]);for(const[e,i]of Object.entries(t))s.includes(e)||r.hasOwnProperty(e)||(o[e]=i);return o};class w extends l.Component{constructor(t){super(t);n(this,"_gridView",null);n(this,"_dataProvider",null);n(this,"_mountCBs",[]);n(this,"_mountTimer");n(this,"gridContainer");this.gridContainer=l.createRef()}getProps(t){return t||{}}$_connectEvents(t,s,e){for(let i in e)i&&typeof i=="string"&&i.startsWith("on")&&(t.hasOwnProperty(i)&&(t[i]=e[i]),s.hasOwnProperty(i)&&(s[i]=e[i]),i==="onDataRowInserting"&&(s.onRowInserting=e[i]))}$_executeCallback(){if(this.gridView&&(clearTimeout(this._mountTimer),!(!this._mountCBs||!this._mountCBs.length))){this.gridView.beginUpdate();try{this.dataProvider.beginUpdate();try{for(;this._mountCBs&&this._mountCBs.length;){const t=this._mountCBs.shift();t==null||t.call(this)}}finally{this.dataProvider.endUpdate()}}finally{this.gridView.endUpdate(!0),this._mountTimer=null,this._mountCBs=[]}}}addCallback(t){this._mountCBs.push(t),clearTimeout(this._mountTimer),this._mountTimer=setTimeout(()=>{this.$_executeCallback()},20)}removeCallback(t){if(this._mountCBs){const s=this._mountCBs.indexOf(t);s>=0&&this._mountCBs.splice(s,1)}}componentDidMount(){const{grid:t,dataProvider:s,props:e}=this.createObject();if(this._gridView=t,this._dataProvider=s,this.$_executeCallback(),this.$_connectEvents(t,s,e),t.setOptions(e.gridProps||{}),s.setOptions(e.dataProps||{}),e.rowStyleCallback&&t.setRowStyleCallback(e.rowStyleCallback),e.cellStyleCallback&&t.setCellStyleCallback(e.cellStyleCallback),e.layout&&t.setColumnLayout(e.layout),e.onInitialized){const i=e.onInitialized.constructor.name;i==="Function"?e.onInitialized(t):i==="AsyncFunction"&&Promise.resolve(e.onInitialized(t))}}componentWillUnmount(){this.beforeDestroy(),this._gridView=this._gridView&&this._gridView.destroy(),this._dataProvider=this._dataProvider&&this._dataProvider.destroy()}componentDidUpdate(t,s,e){this.$_executeCallback();const i=this.getProps(this.props)||{},d=this.gridView,c=this.dataProvider;this.$_connectEvents(d,c,i);let p=h({},t.dataProps,i.dataProps);c.setOptions(p),p=h({},t.gridProps,i.gridProps),d.setOptions(p),p=h([],t.layout||[],i.layout||[]),p&&p.length>0&&d.setColumnLayout(i.layout)}render(){const t={};t.$grid=this;let s=0;const e=l.Children.map(this.props.children,i=>(i&&i.type.CType==="$$RGColumn$$"?t.displayIndex=s++:delete t.displayIndex,i&&l.cloneElement(i,t)));return l.createElement("div",{style:{width:"100%",height:"100%"},ref:i=>this.gridContainer=i},e)}}class R extends w{constructor(){super(...arguments);n(this,"createObject",()=>{var i;const t=m({},this.getProps(this.props)),s=new u.GridView(this.gridContainer,t.accessibility,t.waiOptions),e=new u.LocalDataProvider((i=t.dataProps)==null?void 0:i.undoable);return s.setDataSource(e),{grid:s,dataProvider:e,props:t}});n(this,"beforeDestroy",()=>{const t=m({},this.getProps(this.props));return t.onDestroy&&t.onDestroy.call(this,this.gridView),{props:t}})}get gridView(){return this._gridView}get dataProvider(){return this._dataProvider}componentDidMount(){var s;super.componentDidMount();const t=this.props.rows;t&&Array.isArray(t)&&t.length>0&&((s=this.dataProvider)==null||s.setRows(t))}componentDidUpdate(t,s,e){super.componentDidUpdate(t,s,e),t.rows!=this.props.rows&&this.dataProvider.setRows(this.props.rows)}}class P extends w{constructor(){super(...arguments);n(this,"createObject",()=>{var i;const t=m({},this.getProps(this.props)),s=new u.TreeView(this.gridContainer),e=new u.LocalTreeDataProvider((i=t.dataProps)==null?void 0:i.undoable);return s.setTreeOptions(t.treeOptions||{}),s.setDataSource(e),{grid:s,dataProvider:e,props:t}});n(this,"beforeDestroy",()=>{const t=m({},this.getProps(this.props));return t.onDestroy&&t.onDestroy.call(this,this.gridView),{props:t}})}get gridView(){return this._gridView}get dataProvider(){return this._dataProvider}componentDidMount(){var s,e;super.componentDidMount();const t=this.props.rows;Array.isArray(t)?(s=this.dataProvider)==null||s.setRows(t,this.props.treeField,this.props.needSorting,this.props.childrenField,this.props.iconField):(e=this.dataProvider)==null||e.setObjectRows(this.props.json,this.props.rowsProp,this.props.childrenProp,this.props.iconProp)}componentDidUpdate(t,s,e){var d,c;const i=this.props.rows;(this.props.treeField||this.props.rowsProp)&&t.rows!==i&&(Array.isArray(i)?(d=this.dataProvider)==null||d.setRows(i,this.props.treeField,this.props.needSorting,this.props.childrenField,this.props.iconField):(c=this.dataProvider)==null||c.setObjectRows(this.props.json,this.props.rowsProp,this.props.childrenProp,this.props.iconProp)),super.componentDidUpdate(t,s,e)}}class a extends l.Component{constructor(t){super(t);n(this,"$parent");n(this,"$model");this.$parent=t.$grid}_doUpdate(){}componentDidMount(){const t=this.$parent;t&&t.addCallback(this.mountCB)}componentWillUnmount(){const t=this.$parent;t&&(t.removeCallback(this.mountCB),this.unMountCB()),this.$model=null}componentDidUpdate(t,s,e){let i=h({},this.props,t);this.$model&&this.$model.assignFrom&&this.$model.assignFrom(i),this._doUpdate()}render(){return l.createElement(l.Fragment)}}class f extends a{constructor(){super(...arguments);n(this,"_column");n(this,"mountCB",()=>{const t=this.$parent.gridView;t&&(this._column=this.$model=t.addColumn({...this.props,type:"series"},this.props.displayIndex??-1))});n(this,"unMountCB",()=>{const t=this.$parent.gridView;this._column&&t&&!t._view.disposing&&t.removeColumn(this._column.name)})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}componentDidUpdate(t,s,e){if(super.componentDidUpdate(t,s,e),t.width!==this.props.width){const i=this.$model.layout;i&&(i.cellWidth=this.props.width)}}}n(f,"CType","$$RGColumn$$");class D extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setStateBar({...this.props}),this.$model=this.$parent.gridView.stateBar});n(this,"unMountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setStateBar({})})}}class V extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setRowIndicator({...this.props}),this.$model=this.$parent.gridView.rowIndicator});n(this,"unMountCB",()=>{})}}class b extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setHeaderSummaries({...this.props}),this.$model=this.$parent.gridView.headerSummaries});n(this,"unMountCB",()=>{})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}}class G extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setHeaderSummary({...this.props}),this.$model=this.$parent.gridView.headerSummary});n(this,"unMountCB",()=>{})}}class v extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setHeader({...this.props}),this.$model=this.$parent.gridView.header});n(this,"unMountCB",()=>{})}}class S extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;this.$parent.gridView instanceof u.GridView&&((t=this.$parent.gridView)==null||t.setGroupPanel({visible:!0,...this.props}),this.$model=this.$parent.gridView.groupPanel)});n(this,"unMountCB",()=>{})}}class F extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setFooter({...this.props}),this.$model=this.$parent.gridView.footer});n(this,"unMountCB",()=>{})}}class M extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setFooters({...this.props}),this.$model=this.$parent.gridView.footers});n(this,"unMountCB",()=>{})}}class x extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setFilterPanel({...this.props}),this.$model=this.$parent.gridView.filterPanel});n(this,"unMountCB",()=>{})}}class O extends a{constructor(){super(...arguments);n(this,"_field");n(this,"mountCB",()=>{const t=this.$parent.gridView,s=t==null?void 0:t.getDataSource();s&&!s.fieldByName(this.props.fieldName)&&(this._field=s.addField(this.props))});n(this,"unMountCB",()=>{if(this._field){const t=this.$parent.gridView,s=t==null?void 0:t.getDataSource();s&&s.removeField(this._field.fieldName)}})}}class g extends a{constructor(){super(...arguments);n(this,"fieldName");n(this,"mounted");n(this,"_column");n(this,"mountCB",()=>{const t=this.$parent.gridView,s=this.$parent.props.autoGenerateField,e=t==null?void 0:t.getDataSource();let i=this.props.fieldName;s&&(!i&&this.props.field&&(i=this.props.field.fieldName),e&&!e.fieldByName(i)&&e.addField(this.props.field||i)),t&&(this._column=this.$model=t.addColumn({...this.props,fieldName:i},this.props.displayIndex??-1))});n(this,"unMountCB",()=>{const t=this.$parent.gridView;if(this._column&&t&&!t._view.disposing){let s=this._column.fieldName;t.removeColumn(this._column.name);const e=this.$parent.props.autoGenerateField,i=t==null?void 0:t.getDataSource();e&&s&&i&&(t.columnByField(s)||i.removeField(s))}})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}componentDidUpdate(t,s,e){if(super.componentDidUpdate(t,s,e),t.width!==this.props.width){const i=this.$model.layout;i&&(i.cellWidth=this.props.width)}}}n(g,"CType","$$RGColumn$$");class U extends a{constructor(){super(...arguments);n(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setCheckBar({...this.props}),this.$model=this.$parent.gridView.checkBar});n(this,"unMountCB",()=>{})}}class y extends a{constructor(){super(...arguments);n(this,"_column");n(this,"mountCB",()=>{const t=this.$parent.gridView;t&&(this._column=this.$model=t.addColumn({...this.props,type:"literal"},this.props.displayIndex??-1))});n(this,"unMountCB",()=>{const t=this.$parent.gridView;this._column&&t&&!t._view.disposing&&t.removeColumn(this._column.name)})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}componentDidUpdate(t,s,e){if(super.componentDidUpdate(t,s,e),t.width!==this.props.width){const i=this.$model.layout;i&&(i.cellWidth=this.props.width)}}}n(y,"CType","$$RGColumn$$");exports.RGCheckBar=U;exports.RGDataColumn=g;exports.RGDataField=O;exports.RGFilterPanel=x;exports.RGFooter=F;exports.RGFooters=M;exports.RGGroupPanel=S;exports.RGHeader=v;exports.RGHeaderSummaries=b;exports.RGHeaderSummary=G;exports.RGLiteralColumn=y;exports.RGRowIndicator=V;exports.RGSeriesColumn=f;exports.RGStateBar=D;exports.RealGridReact=R;exports.RealTreeReact=P;
1
+ "use strict";var y=Object.defineProperty;var $=(n,r,t)=>r in n?y(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t;var o=(n,r,t)=>($(n,typeof r!="symbol"?r+"":r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),_=require("realgrid");function R(n){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return r.default=n,Object.freeze(r)}const u=R(_),m=(n,...r)=>(r.forEach(t=>{for(const i in t){if(i==="children")continue;const e=t[i];e===null?n[i]=null:e===void 0?delete n[i]:Array.isArray(e)?n[i]=[...e]:typeof e=="object"?e instanceof Date?n[i]=new Date(e):n[i]=m(n[i]==null?{}:n[i],e):n[i]=e}}),n),h=(n,r={},t={})=>{n=n||{};const i=["children","rows","$grid"];for(const[e,s]of Object.entries(r))if(!i.includes(e))if(!t.hasOwnProperty(e))n[e]=null;else if(Array.isArray(s))(!t[e]||JSON.stringify(s)!=JSON.stringify(t[e]))&&(n[e]=t[e]);else if(s instanceof Object&&!(s instanceof Date||Array.isArray(s)||typeof s=="function"))if(!(t[e]instanceof Object))n[e]=t[e];else{const d=h({},s,t[e]);Object.keys(d).length&&(n[e]=d)}else typeof s=="function"?s.toString()!==t[e].toString()&&(n[e]=t[e]):s!==t[e]&&(n[e]=t[e]);for(const[e,s]of Object.entries(t))i.includes(e)||r.hasOwnProperty(e)||(n[e]=s);return n};class w extends l.Component{constructor(t){super(t);o(this,"_gridView",null);o(this,"_dataProvider",null);o(this,"_mountCBs",[]);o(this,"_mountTimer");o(this,"_columnsChanged");o(this,"gridContainer");this.gridContainer=l.createRef()}getProps(t){return t||{}}$_connectEvents(t,i,e){for(let s in e)s&&typeof s=="string"&&s.startsWith("on")&&(t.hasOwnProperty(s)&&(t[s]=e[s]),i.hasOwnProperty(s)&&(i[s]=e[s]),s==="onDataRowInserting"&&(i.onRowInserting=e[s]))}$_executeCallback(){var t;if(this.gridView&&(clearTimeout(this._mountTimer),!(!this._mountCBs||!this._mountCBs.length))){this.gridView.beginUpdate();try{this.dataProvider.beginUpdate();try{for(;this._mountCBs&&this._mountCBs.length;){const i=this._mountCBs.shift();i==null||i.call(this)}}finally{this.dataProvider.endUpdate()}}finally{this._columnsChanged&&this.props.onRGDataColumnsChanged&&((t=this.props)==null||t.onRGDataColumnsChanged(this.gridView),this._columnsChanged=!1),this.gridView.endUpdate(!0),this._mountTimer=null,this._mountCBs=[]}}}addCallback(t,i){this._mountCBs.push(t),clearTimeout(this._mountTimer),this._columnsChanged=i==="column",this._mountTimer=setTimeout(()=>{this.$_executeCallback()},20)}removeCallback(t){if(this._mountCBs){const i=this._mountCBs.indexOf(t);i>=0&&this._mountCBs.splice(i,1)}}componentDidMount(){const{grid:t,dataProvider:i,props:e}=this.createObject();if(this._gridView=t,this._dataProvider=i,this.$_executeCallback(),this.$_connectEvents(t,i,e),t.setOptions(e.gridProps||{}),i.setOptions(e.dataProps||{}),e.rowStyleCallback&&t.setRowStyleCallback(e.rowStyleCallback),e.cellStyleCallback&&t.setCellStyleCallback(e.cellStyleCallback),e.layout&&t.setColumnLayout(e.layout),e.onInitialized){const s=e.onInitialized.constructor.name;s==="Function"?e.onInitialized(t):s==="AsyncFunction"&&Promise.resolve(e.onInitialized(t))}}componentWillUnmount(){this.beforeDestroy(),this._gridView=this._gridView&&this._gridView.destroy(),this._dataProvider=this._dataProvider&&this._dataProvider.destroy()}componentDidUpdate(t,i,e){this.$_executeCallback();const s=this.getProps(this.props)||{},d=this.gridView,c=this.dataProvider;this.$_connectEvents(d,c,s);let p=h({},t.dataProps,s.dataProps);c.setOptions(p),p=h({},t.gridProps,s.gridProps),d.setOptions(p),p=h([],t.layout||[],s.layout||[]),p&&p.length>0&&d.setColumnLayout(s.layout)}render(){const t={};t.$grid=this;let i=0;const e=l.Children.map(this.props.children,s=>(s&&s.type.CType==="$$RGColumn$$"?t.displayIndex=s.props.displayIndex??i++:delete t.displayIndex,s&&l.cloneElement(s,t)));return l.createElement("div",{style:{width:"100%",height:"100%"},ref:s=>this.gridContainer=s},e)}}class B extends w{constructor(){super(...arguments);o(this,"createObject",()=>{var s;const t=m({},this.getProps(this.props)),i=new u.GridView(this.gridContainer,t.accessibility,t.waiOptions),e=new u.LocalDataProvider((s=t.dataProps)==null?void 0:s.undoable);return i.setDataSource(e),{grid:i,dataProvider:e,props:t}});o(this,"beforeDestroy",()=>{const t=m({},this.getProps(this.props));return t.onDestroy&&t.onDestroy.call(this,this.gridView),{props:t}})}get gridView(){return this._gridView}get dataProvider(){return this._dataProvider}componentDidMount(){var i;super.componentDidMount();const t=this.props.rows;t&&Array.isArray(t)&&t.length>0&&((i=this.dataProvider)==null||i.setRows(t))}componentDidUpdate(t,i,e){super.componentDidUpdate(t,i,e),t.rows!=this.props.rows&&this.dataProvider.setRows(this.props.rows)}}class P extends w{constructor(){super(...arguments);o(this,"createObject",()=>{var s;const t=m({},this.getProps(this.props)),i=new u.TreeView(this.gridContainer),e=new u.LocalTreeDataProvider((s=t.dataProps)==null?void 0:s.undoable);return i.setTreeOptions(t.treeOptions||{}),i.setDataSource(e),{grid:i,dataProvider:e,props:t}});o(this,"beforeDestroy",()=>{const t=m({},this.getProps(this.props));return t.onDestroy&&t.onDestroy.call(this,this.gridView),{props:t}})}get gridView(){return this._gridView}get dataProvider(){return this._dataProvider}componentDidMount(){var i,e;super.componentDidMount();const t=this.props.rows;Array.isArray(t)?(i=this.dataProvider)==null||i.setRows(t,this.props.treeField,this.props.needSorting,this.props.childrenField,this.props.iconField):(e=this.dataProvider)==null||e.setObjectRows(this.props.json,this.props.rowsProp,this.props.childrenProp,this.props.iconProp)}componentDidUpdate(t,i,e){var d,c;const s=this.props.rows;(this.props.treeField||this.props.rowsProp)&&t.rows!==s&&(Array.isArray(s)?(d=this.dataProvider)==null||d.setRows(s,this.props.treeField,this.props.needSorting,this.props.childrenField,this.props.iconField):(c=this.dataProvider)==null||c.setObjectRows(this.props.json,this.props.rowsProp,this.props.childrenProp,this.props.iconProp)),super.componentDidUpdate(t,i,e)}}class a extends l.Component{constructor(t){super(t);o(this,"$parent");o(this,"$model");o(this,"_type");this.$parent=t.$grid}_doUpdate(){}componentDidMount(){const t=this.$parent;t&&t.addCallback(this.mountCB,this._type)}componentWillUnmount(){const t=this.$parent;t&&(t.removeCallback(this.mountCB),this.unMountCB()),this.$model=null}componentDidUpdate(t,i,e){let s=h({},this.props,t);!(Object.keys(s).length===0)&&this.$model&&this.$model.assignFrom&&this.$model.assignFrom(s),this._doUpdate()}render(){return l.createElement(l.Fragment)}}class f extends a{constructor(){super(...arguments);o(this,"_column");o(this,"mountCB",()=>{const t=this.$parent.gridView;t&&(this._column=this.$model=t.addColumn({...this.props,type:"series"},this.props.displayIndex??-1))});o(this,"unMountCB",()=>{const t=this.$parent.gridView;this._column&&t&&!t._view.disposing&&t.removeColumn(this._column.name)})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}componentDidUpdate(t,i,e){if(super.componentDidUpdate(t,i,e),t.width!==this.props.width){const s=this.$model.layout;s&&(s.cellWidth=this.props.width)}}}o(f,"CType","$$RGColumn$$");class D extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setStateBar({...this.props}),this.$model=this.$parent.gridView.stateBar});o(this,"unMountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setStateBar({})})}}class V extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setRowIndicator({...this.props}),this.$model=this.$parent.gridView.rowIndicator});o(this,"unMountCB",()=>{})}}class b extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setHeaderSummaries({...this.props}),this.$model=this.$parent.gridView.headerSummaries});o(this,"unMountCB",()=>{})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}}class G extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setHeaderSummary({...this.props}),this.$model=this.$parent.gridView.headerSummary});o(this,"unMountCB",()=>{})}}class v extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setHeader({...this.props}),this.$model=this.$parent.gridView.header});o(this,"unMountCB",()=>{})}}class S extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;this.$parent.gridView instanceof u.GridView&&((t=this.$parent.gridView)==null||t.setGroupPanel({visible:!0,...this.props}),this.$model=this.$parent.gridView.groupPanel)});o(this,"unMountCB",()=>{})}}class x extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setFooter({...this.props}),this.$model=this.$parent.gridView.footer});o(this,"unMountCB",()=>{})}}class F extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setFooters({...this.props}),this.$model=this.$parent.gridView.footers});o(this,"unMountCB",()=>{})}}class M extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setFilterPanel({...this.props}),this.$model=this.$parent.gridView.filterPanel});o(this,"unMountCB",()=>{})}}class O extends a{constructor(){super(...arguments);o(this,"_field");o(this,"mountCB",()=>{const t=this.$parent.gridView,i=t==null?void 0:t.getDataSource();i&&!i.fieldByName(this.props.fieldName)&&(this._field=i.addField(this.props))});o(this,"unMountCB",()=>{if(this._field){const t=this.$parent.gridView,i=t==null?void 0:t.getDataSource();i&&i.removeField(this._field.fieldName)}})}}class g extends a{constructor(){super(...arguments);o(this,"fieldName");o(this,"mounted");o(this,"_column");o(this,"mountCB",()=>{const t=this.$parent.gridView,i=this.$parent.props.autoGenerateField,e=t==null?void 0:t.getDataSource();let s=this.props.fieldName;i&&(!s&&this.props.field&&(s=this.props.field.fieldName),e&&!e.fieldByName(s)&&e.addField(this.props.field||s)),t&&(this._column=this.$model=t.addColumn({...this.props,fieldName:s},this.props.displayIndex??-1))});o(this,"unMountCB",()=>{const t=this.$parent.gridView;if(this._column&&t&&!t._view.disposing){let i=this._column.fieldName;t.removeColumn(this._column.name);const e=this.$parent.props.autoGenerateField,s=t==null?void 0:t.getDataSource();e&&i&&s&&(t.columnByField(i)||s.removeField(i))}})}componentDidMount(){this._type="column",super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}componentDidUpdate(t,i,e){if(super.componentDidUpdate(t,i,e),t.width!==this.props.width){const s=this.$model.layout;s&&(s.cellWidth=this.props.width)}}}o(g,"CType","$$RGColumn$$");class U extends a{constructor(){super(...arguments);o(this,"mountCB",()=>{var t;(t=this.$parent.gridView)==null||t.setCheckBar({...this.props}),this.$model=this.$parent.gridView.checkBar});o(this,"unMountCB",()=>{})}}class C extends a{constructor(){super(...arguments);o(this,"_column");o(this,"mountCB",()=>{const t=this.$parent.gridView;t&&(this._column=this.$model=t.addColumn({...this.props,type:"literal"},this.props.displayIndex??-1))});o(this,"unMountCB",()=>{const t=this.$parent.gridView;this._column&&t&&!t._view.disposing&&t.removeColumn(this._column.name)})}componentDidMount(){super.componentDidMount()}componentWillUnmount(){super.componentWillUnmount()}componentDidUpdate(t,i,e){if(super.componentDidUpdate(t,i,e),t.width!==this.props.width){const s=this.$model.layout;s&&(s.cellWidth=this.props.width)}}}o(C,"CType","$$RGColumn$$");exports.RGCheckBar=U;exports.RGDataColumn=g;exports.RGDataField=O;exports.RGFilterPanel=M;exports.RGFooter=x;exports.RGFooters=F;exports.RGGroupPanel=S;exports.RGHeader=v;exports.RGHeaderSummaries=b;exports.RGHeaderSummary=G;exports.RGLiteralColumn=C;exports.RGRowIndicator=V;exports.RGSeriesColumn=f;exports.RGStateBar=D;exports.RealGridReact=B;exports.RealTreeReact=P;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ declare abstract class ComponentBase<T extends IComponentBase> extends default_2
8
8
  constructor(props: T);
9
9
  protected abstract mountCB: () => void;
10
10
  protected abstract unMountCB: () => void;
11
+ protected _type: string;
11
12
  protected _doUpdate(): void;
12
13
  componentDidMount(): void;
13
14
  componentWillUnmount(): void;
@@ -61,6 +62,10 @@ declare interface IRealGridBaseProps<G> extends Omit<IComponentBase, '$grid'> {
61
62
  * 셀 스타일 변경을 위한 콜백
62
63
  */
63
64
  cellStyleCallback?: RealGrid.CellStyleCallback;
65
+ /**
66
+ * RGDataColumn이 변경되었을때 호출되는 콜백
67
+ */
68
+ onRGDataColumnsChanged?: (grid: GridType<G>) => void;
64
69
  gridProps?: RealGrid.GridOptions;
65
70
  layout?: (string | Exclude<RealGrid.CellLayoutGroupItem, Function> | RealGrid.CellLayoutColumnItem)[];
66
71
  onCurrentChanging?: (grid: GridType<G>, oldIndex: RealGrid.CellIndex, newIndex: RealGrid.CellIndex) => boolean;
@@ -130,6 +135,7 @@ declare interface IRealGridBaseProps<G> extends Omit<IComponentBase, '$grid'> {
130
135
  onLayoutExpanded?: (grid: GridType<G>, layout: RealGrid.CellLayoutGroupItem) => void;
131
136
  onLayoutCollapsing?: (grid: GridType<G>, layout: RealGrid.CellLayoutGroupItem) => boolean;
132
137
  onLayoutCollapsed?: (grid: GridType<G>, layout: RealGrid.CellLayoutGroupItem) => void;
138
+ onGridFocusChanged?: (grid: GridType<G>, focused: boolean, event: Event) => void;
133
139
  dataProps?: RealGrid.DataOptions;
134
140
  }
135
141
 
@@ -257,6 +263,7 @@ declare abstract class RealBaseReact<G, T = {}> extends default_2.Component<T &
257
263
  protected _dataProvider: RealGrid.DataProviderBase | null;
258
264
  private _mountCBs;
259
265
  private _mountTimer;
266
+ protected _columnsChanged: boolean;
260
267
  protected gridContainer: default_2.LegacyRef<HTMLDivElement>;
261
268
  constructor(props: T);
262
269
  abstract get gridView(): GridType<G>;
@@ -272,7 +279,7 @@ declare abstract class RealBaseReact<G, T = {}> extends default_2.Component<T &
272
279
  protected getProps(props: T): T;
273
280
  private $_connectEvents;
274
281
  private $_executeCallback;
275
- addCallback(callback: Function): void;
282
+ addCallback(callback: Function, type: string): void;
276
283
  removeCallback(callback: Function): void;
277
284
  componentDidMount(): void;
278
285
  componentWillUnmount(): void;
package/dist/index.es.js CHANGED
@@ -41,6 +41,7 @@ class w extends p.Component {
41
41
  // field
42
42
  o(this, "_mountCBs", []);
43
43
  o(this, "_mountTimer");
44
+ o(this, "_columnsChanged");
44
45
  o(this, "gridContainer");
45
46
  this.gridContainer = p.createRef();
46
47
  }
@@ -53,26 +54,27 @@ class w extends p.Component {
53
54
  i && typeof i == "string" && i.startsWith("on") && (t.hasOwnProperty(i) && (t[i] = e[i]), s.hasOwnProperty(i) && (s[i] = e[i]), i === "onDataRowInserting" && (s.onRowInserting = e[i]));
54
55
  }
55
56
  $_executeCallback() {
57
+ var t;
56
58
  if (this.gridView && (clearTimeout(this._mountTimer), !(!this._mountCBs || !this._mountCBs.length))) {
57
59
  this.gridView.beginUpdate();
58
60
  try {
59
61
  this.dataProvider.beginUpdate();
60
62
  try {
61
63
  for (; this._mountCBs && this._mountCBs.length; ) {
62
- const t = this._mountCBs.shift();
63
- t == null || t.call(this);
64
+ const s = this._mountCBs.shift();
65
+ s == null || s.call(this);
64
66
  }
65
67
  } finally {
66
68
  this.dataProvider.endUpdate();
67
69
  }
68
70
  } finally {
69
- this.gridView.endUpdate(!0), this._mountTimer = null, this._mountCBs = [];
71
+ this._columnsChanged && this.props.onRGDataColumnsChanged && ((t = this.props) == null || t.onRGDataColumnsChanged(this.gridView), this._columnsChanged = !1), this.gridView.endUpdate(!0), this._mountTimer = null, this._mountCBs = [];
70
72
  }
71
73
  }
72
74
  }
73
75
  // public Method
74
- addCallback(t) {
75
- this._mountCBs.push(t), clearTimeout(this._mountTimer), this._mountTimer = setTimeout(() => {
76
+ addCallback(t, s) {
77
+ this._mountCBs.push(t), clearTimeout(this._mountTimer), this._columnsChanged = s === "column", this._mountTimer = setTimeout(() => {
76
78
  this.$_executeCallback();
77
79
  }, 20);
78
80
  }
@@ -103,11 +105,11 @@ class w extends p.Component {
103
105
  const t = {};
104
106
  t.$grid = this;
105
107
  let s = 0;
106
- const e = p.Children.map(this.props.children, (i) => (i && i.type.CType === "$$RGColumn$$" ? t.displayIndex = s++ : delete t.displayIndex, i && p.cloneElement(i, t)));
108
+ const e = p.Children.map(this.props.children, (i) => (i && i.type.CType === "$$RGColumn$$" ? t.displayIndex = i.props.displayIndex ?? s++ : delete t.displayIndex, i && p.cloneElement(i, t)));
107
109
  return p.createElement("div", { style: { width: "100%", height: "100%" }, ref: (i) => this.gridContainer = i }, e);
108
110
  }
109
111
  }
110
- class P extends w {
112
+ class D extends w {
111
113
  constructor() {
112
114
  super(...arguments);
113
115
  o(this, "createObject", () => {
@@ -140,7 +142,7 @@ class P extends w {
140
142
  super.componentDidUpdate(t, s, e), t.rows != this.props.rows && this.dataProvider.setRows(this.props.rows);
141
143
  }
142
144
  }
143
- class V extends w {
145
+ class P extends w {
144
146
  constructor() {
145
147
  super(...arguments);
146
148
  o(this, "createObject", () => {
@@ -181,13 +183,14 @@ class a extends p.Component {
181
183
  super(t);
182
184
  o(this, "$parent");
183
185
  o(this, "$model");
186
+ o(this, "_type");
184
187
  this.$parent = t.$grid;
185
188
  }
186
189
  _doUpdate() {
187
190
  }
188
191
  componentDidMount() {
189
192
  const t = this.$parent;
190
- t && t.addCallback(this.mountCB);
193
+ t && t.addCallback(this.mountCB, this._type);
191
194
  }
192
195
  componentWillUnmount() {
193
196
  const t = this.$parent;
@@ -195,13 +198,13 @@ class a extends p.Component {
195
198
  }
196
199
  componentDidUpdate(t, s, e) {
197
200
  let i = c({}, this.props, t);
198
- this.$model && this.$model.assignFrom && this.$model.assignFrom(i), this._doUpdate();
201
+ !(Object.keys(i).length === 0) && this.$model && this.$model.assignFrom && this.$model.assignFrom(i), this._doUpdate();
199
202
  }
200
203
  render() {
201
204
  return p.createElement(p.Fragment);
202
205
  }
203
206
  }
204
- class $ extends a {
207
+ class g extends a {
205
208
  constructor() {
206
209
  super(...arguments);
207
210
  o(this, "_column");
@@ -227,8 +230,8 @@ class $ extends a {
227
230
  }
228
231
  }
229
232
  }
230
- o($, "CType", "$$RGColumn$$");
231
- class D extends a {
233
+ o(g, "CType", "$$RGColumn$$");
234
+ class V extends a {
232
235
  constructor() {
233
236
  super(...arguments);
234
237
  o(this, "mountCB", () => {
@@ -252,7 +255,7 @@ class v extends a {
252
255
  });
253
256
  }
254
257
  }
255
- class b extends a {
258
+ class R extends a {
256
259
  constructor() {
257
260
  super(...arguments);
258
261
  o(this, "mountCB", () => {
@@ -269,7 +272,7 @@ class b extends a {
269
272
  super.componentWillUnmount();
270
273
  }
271
274
  }
272
- class R extends a {
275
+ class b extends a {
273
276
  constructor() {
274
277
  super(...arguments);
275
278
  o(this, "mountCB", () => {
@@ -335,7 +338,7 @@ class U extends a {
335
338
  });
336
339
  }
337
340
  }
338
- class O extends a {
341
+ class G extends a {
339
342
  constructor() {
340
343
  super(...arguments);
341
344
  o(this, "_field");
@@ -351,7 +354,7 @@ class O extends a {
351
354
  });
352
355
  }
353
356
  }
354
- class g extends a {
357
+ class y extends a {
355
358
  constructor() {
356
359
  super(...arguments);
357
360
  o(this, "fieldName");
@@ -373,7 +376,7 @@ class g extends a {
373
376
  });
374
377
  }
375
378
  componentDidMount() {
376
- super.componentDidMount();
379
+ this._type = "column", super.componentDidMount();
377
380
  }
378
381
  componentWillUnmount() {
379
382
  super.componentWillUnmount();
@@ -385,8 +388,8 @@ class g extends a {
385
388
  }
386
389
  }
387
390
  }
388
- o(g, "CType", "$$RGColumn$$");
389
- class G extends a {
391
+ o(y, "CType", "$$RGColumn$$");
392
+ class O extends a {
390
393
  constructor() {
391
394
  super(...arguments);
392
395
  o(this, "mountCB", () => {
@@ -397,7 +400,7 @@ class G extends a {
397
400
  });
398
401
  }
399
402
  }
400
- class y extends a {
403
+ class $ extends a {
401
404
  constructor() {
402
405
  super(...arguments);
403
406
  o(this, "_column");
@@ -423,22 +426,22 @@ class y extends a {
423
426
  }
424
427
  }
425
428
  }
426
- o(y, "CType", "$$RGColumn$$");
429
+ o($, "CType", "$$RGColumn$$");
427
430
  export {
428
- G as RGCheckBar,
429
- g as RGDataColumn,
430
- O as RGDataField,
431
+ O as RGCheckBar,
432
+ y as RGDataColumn,
433
+ G as RGDataField,
431
434
  U as RGFilterPanel,
432
435
  S as RGFooter,
433
436
  F as RGFooters,
434
437
  M as RGGroupPanel,
435
438
  x as RGHeader,
436
- b as RGHeaderSummaries,
437
- R as RGHeaderSummary,
438
- y as RGLiteralColumn,
439
+ R as RGHeaderSummaries,
440
+ b as RGHeaderSummary,
441
+ $ as RGLiteralColumn,
439
442
  v as RGRowIndicator,
440
- $ as RGSeriesColumn,
441
- D as RGStateBar,
442
- P as RealGridReact,
443
- V as RealTreeReact
443
+ g as RGSeriesColumn,
444
+ V as RGStateBar,
445
+ D as RealGridReact,
446
+ P as RealTreeReact
444
447
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "realgrid-react",
3
3
  "private": false,
4
- "version": "0.9.4",
4
+ "version": "0.9.6",
5
5
  "description": "RealGrid2 wrapping Component for React",
6
6
  "author": {
7
7
  "name": "WooriTech",