realgrid-react 0.9.5 → 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 +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +77 -77
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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=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);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 F 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 M 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 x 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=x;exports.RGFooter=F;exports.RGFooters=M;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;
|
|
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
|
@@ -135,6 +135,7 @@ declare interface IRealGridBaseProps<G> extends Omit<IComponentBase, '$grid'> {
|
|
|
135
135
|
onLayoutExpanded?: (grid: GridType<G>, layout: RealGrid.CellLayoutGroupItem) => void;
|
|
136
136
|
onLayoutCollapsing?: (grid: GridType<G>, layout: RealGrid.CellLayoutGroupItem) => boolean;
|
|
137
137
|
onLayoutCollapsed?: (grid: GridType<G>, layout: RealGrid.CellLayoutGroupItem) => void;
|
|
138
|
+
onGridFocusChanged?: (grid: GridType<G>, focused: boolean, event: Event) => void;
|
|
138
139
|
dataProps?: RealGrid.DataOptions;
|
|
139
140
|
}
|
|
140
141
|
|
package/dist/index.es.js
CHANGED
|
@@ -4,32 +4,32 @@ var o = (n, r, t) => (C(n, typeof r != "symbol" ? r + "" : r, t), t);
|
|
|
4
4
|
import p from "react";
|
|
5
5
|
import * as u from "realgrid";
|
|
6
6
|
const m = (n, ...r) => (r.forEach((t) => {
|
|
7
|
-
for (const
|
|
8
|
-
if (
|
|
7
|
+
for (const s in t) {
|
|
8
|
+
if (s === "children")
|
|
9
9
|
continue;
|
|
10
|
-
const e = t[
|
|
11
|
-
e === null ? n[
|
|
10
|
+
const e = t[s];
|
|
11
|
+
e === null ? n[s] = null : e === void 0 ? delete n[s] : Array.isArray(e) ? n[s] = [...e] : typeof e == "object" ? e instanceof Date ? n[s] = new Date(e) : n[s] = m(n[s] == null ? {} : n[s], e) : n[s] = e;
|
|
12
12
|
}
|
|
13
13
|
}), n), c = (n, r = {}, t = {}) => {
|
|
14
14
|
n = n || {};
|
|
15
|
-
const
|
|
16
|
-
for (const [e,
|
|
17
|
-
if (!
|
|
15
|
+
const s = ["children", "rows", "$grid"];
|
|
16
|
+
for (const [e, i] of Object.entries(r))
|
|
17
|
+
if (!s.includes(e))
|
|
18
18
|
if (!t.hasOwnProperty(e))
|
|
19
19
|
n[e] = null;
|
|
20
|
-
else if (Array.isArray(
|
|
21
|
-
(!t[e] || JSON.stringify(
|
|
22
|
-
else if (
|
|
20
|
+
else if (Array.isArray(i))
|
|
21
|
+
(!t[e] || JSON.stringify(i) != JSON.stringify(t[e])) && (n[e] = t[e]);
|
|
22
|
+
else if (i instanceof Object && !(i instanceof Date || Array.isArray(i) || typeof i == "function"))
|
|
23
23
|
if (!(t[e] instanceof Object))
|
|
24
24
|
n[e] = t[e];
|
|
25
25
|
else {
|
|
26
|
-
const d = c({},
|
|
26
|
+
const d = c({}, i, t[e]);
|
|
27
27
|
Object.keys(d).length && (n[e] = d);
|
|
28
28
|
}
|
|
29
29
|
else
|
|
30
|
-
typeof
|
|
31
|
-
for (const [e,
|
|
32
|
-
|
|
30
|
+
typeof i == "function" ? i.toString() !== t[e].toString() && (n[e] = t[e]) : i !== t[e] && (n[e] = t[e]);
|
|
31
|
+
for (const [e, i] of Object.entries(t))
|
|
32
|
+
s.includes(e) || r.hasOwnProperty(e) || (n[e] = i);
|
|
33
33
|
return n;
|
|
34
34
|
};
|
|
35
35
|
class w extends p.Component {
|
|
@@ -49,9 +49,9 @@ class w extends p.Component {
|
|
|
49
49
|
return t || {};
|
|
50
50
|
}
|
|
51
51
|
// private methods
|
|
52
|
-
$_connectEvents(t,
|
|
53
|
-
for (let
|
|
54
|
-
|
|
52
|
+
$_connectEvents(t, s, e) {
|
|
53
|
+
for (let i in e)
|
|
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]));
|
|
55
55
|
}
|
|
56
56
|
$_executeCallback() {
|
|
57
57
|
var t;
|
|
@@ -61,8 +61,8 @@ class w extends p.Component {
|
|
|
61
61
|
this.dataProvider.beginUpdate();
|
|
62
62
|
try {
|
|
63
63
|
for (; this._mountCBs && this._mountCBs.length; ) {
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
const s = this._mountCBs.shift();
|
|
65
|
+
s == null || s.call(this);
|
|
66
66
|
}
|
|
67
67
|
} finally {
|
|
68
68
|
this.dataProvider.endUpdate();
|
|
@@ -73,50 +73,50 @@ class w extends p.Component {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
// public Method
|
|
76
|
-
addCallback(t,
|
|
77
|
-
this._mountCBs.push(t), clearTimeout(this._mountTimer), this._columnsChanged =
|
|
76
|
+
addCallback(t, s) {
|
|
77
|
+
this._mountCBs.push(t), clearTimeout(this._mountTimer), this._columnsChanged = s === "column", this._mountTimer = setTimeout(() => {
|
|
78
78
|
this.$_executeCallback();
|
|
79
79
|
}, 20);
|
|
80
80
|
}
|
|
81
81
|
removeCallback(t) {
|
|
82
82
|
if (this._mountCBs) {
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const s = this._mountCBs.indexOf(t);
|
|
84
|
+
s >= 0 && this._mountCBs.splice(s, 1);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
componentDidMount() {
|
|
88
|
-
const { grid: t, dataProvider:
|
|
89
|
-
if (this._gridView = t, this._dataProvider =
|
|
90
|
-
const
|
|
91
|
-
|
|
88
|
+
const { grid: t, dataProvider: s, props: e } = this.createObject();
|
|
89
|
+
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) {
|
|
90
|
+
const i = e.onInitialized.constructor.name;
|
|
91
|
+
i === "Function" ? e.onInitialized(t) : i === "AsyncFunction" && Promise.resolve(e.onInitialized(t));
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
componentWillUnmount() {
|
|
95
95
|
this.beforeDestroy(), this._gridView = this._gridView && this._gridView.destroy(), this._dataProvider = this._dataProvider && this._dataProvider.destroy();
|
|
96
96
|
}
|
|
97
|
-
componentDidUpdate(t,
|
|
97
|
+
componentDidUpdate(t, s, e) {
|
|
98
98
|
this.$_executeCallback();
|
|
99
|
-
const
|
|
100
|
-
this.$_connectEvents(d, h,
|
|
101
|
-
let l = c({}, t.dataProps,
|
|
102
|
-
h.setOptions(l), l = c({}, t.gridProps,
|
|
99
|
+
const i = this.getProps(this.props) || {}, d = this.gridView, h = this.dataProvider;
|
|
100
|
+
this.$_connectEvents(d, h, i);
|
|
101
|
+
let l = c({}, t.dataProps, i.dataProps);
|
|
102
|
+
h.setOptions(l), l = c({}, t.gridProps, i.gridProps), d.setOptions(l), l = c([], t.layout || [], i.layout || []), l && l.length > 0 && d.setColumnLayout(i.layout);
|
|
103
103
|
}
|
|
104
104
|
render() {
|
|
105
105
|
const t = {};
|
|
106
106
|
t.$grid = this;
|
|
107
|
-
let
|
|
108
|
-
const e = p.Children.map(this.props.children, (
|
|
109
|
-
return p.createElement("div", { style: { width: "100%", height: "100%" }, ref: (
|
|
107
|
+
let s = 0;
|
|
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)));
|
|
109
|
+
return p.createElement("div", { style: { width: "100%", height: "100%" }, ref: (i) => this.gridContainer = i }, e);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
class D extends w {
|
|
113
113
|
constructor() {
|
|
114
114
|
super(...arguments);
|
|
115
115
|
o(this, "createObject", () => {
|
|
116
|
-
var
|
|
117
|
-
const t = m({}, this.getProps(this.props)),
|
|
118
|
-
return
|
|
119
|
-
grid:
|
|
116
|
+
var i;
|
|
117
|
+
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);
|
|
118
|
+
return s.setDataSource(e), {
|
|
119
|
+
grid: s,
|
|
120
120
|
dataProvider: e,
|
|
121
121
|
props: t
|
|
122
122
|
};
|
|
@@ -133,23 +133,23 @@ class D extends w {
|
|
|
133
133
|
return this._dataProvider;
|
|
134
134
|
}
|
|
135
135
|
componentDidMount() {
|
|
136
|
-
var
|
|
136
|
+
var s;
|
|
137
137
|
super.componentDidMount();
|
|
138
138
|
const t = this.props.rows;
|
|
139
|
-
t && Array.isArray(t) && t.length > 0 && ((
|
|
139
|
+
t && Array.isArray(t) && t.length > 0 && ((s = this.dataProvider) == null || s.setRows(t));
|
|
140
140
|
}
|
|
141
|
-
componentDidUpdate(t,
|
|
142
|
-
super.componentDidUpdate(t,
|
|
141
|
+
componentDidUpdate(t, s, e) {
|
|
142
|
+
super.componentDidUpdate(t, s, e), t.rows != this.props.rows && this.dataProvider.setRows(this.props.rows);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
class P extends w {
|
|
146
146
|
constructor() {
|
|
147
147
|
super(...arguments);
|
|
148
148
|
o(this, "createObject", () => {
|
|
149
|
-
var
|
|
150
|
-
const t = m({}, this.getProps(this.props)),
|
|
151
|
-
return
|
|
152
|
-
grid:
|
|
149
|
+
var i;
|
|
150
|
+
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);
|
|
151
|
+
return s.setTreeOptions(t.treeOptions || {}), s.setDataSource(e), {
|
|
152
|
+
grid: s,
|
|
153
153
|
dataProvider: e,
|
|
154
154
|
props: t
|
|
155
155
|
};
|
|
@@ -166,15 +166,15 @@ class P extends w {
|
|
|
166
166
|
return this._dataProvider;
|
|
167
167
|
}
|
|
168
168
|
componentDidMount() {
|
|
169
|
-
var
|
|
169
|
+
var s, e;
|
|
170
170
|
super.componentDidMount();
|
|
171
171
|
const t = this.props.rows;
|
|
172
|
-
Array.isArray(t) ? (
|
|
172
|
+
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);
|
|
173
173
|
}
|
|
174
|
-
componentDidUpdate(t,
|
|
174
|
+
componentDidUpdate(t, s, e) {
|
|
175
175
|
var d, h;
|
|
176
|
-
const
|
|
177
|
-
(this.props.treeField || this.props.rowsProp) && t.rows !==
|
|
176
|
+
const i = this.props.rows;
|
|
177
|
+
(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) : (h = this.dataProvider) == null || h.setObjectRows(this.props.json, this.props.rowsProp, this.props.childrenProp, this.props.iconProp)), super.componentDidUpdate(t, s, e);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
class a extends p.Component {
|
|
@@ -196,9 +196,9 @@ class a extends p.Component {
|
|
|
196
196
|
const t = this.$parent;
|
|
197
197
|
t && (t.removeCallback(this.mountCB), this.unMountCB()), this.$model = null;
|
|
198
198
|
}
|
|
199
|
-
componentDidUpdate(t,
|
|
200
|
-
let
|
|
201
|
-
this.$model && this.$model.assignFrom && this.$model.assignFrom(
|
|
199
|
+
componentDidUpdate(t, s, e) {
|
|
200
|
+
let i = c({}, this.props, t);
|
|
201
|
+
!(Object.keys(i).length === 0) && this.$model && this.$model.assignFrom && this.$model.assignFrom(i), this._doUpdate();
|
|
202
202
|
}
|
|
203
203
|
render() {
|
|
204
204
|
return p.createElement(p.Fragment);
|
|
@@ -223,10 +223,10 @@ class g extends a {
|
|
|
223
223
|
componentWillUnmount() {
|
|
224
224
|
super.componentWillUnmount();
|
|
225
225
|
}
|
|
226
|
-
componentDidUpdate(t,
|
|
227
|
-
if (super.componentDidUpdate(t,
|
|
228
|
-
const
|
|
229
|
-
|
|
226
|
+
componentDidUpdate(t, s, e) {
|
|
227
|
+
if (super.componentDidUpdate(t, s, e), t.width !== this.props.width) {
|
|
228
|
+
const i = this.$model.layout;
|
|
229
|
+
i && (i.cellWidth = this.props.width);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
}
|
|
@@ -343,13 +343,13 @@ class G extends a {
|
|
|
343
343
|
super(...arguments);
|
|
344
344
|
o(this, "_field");
|
|
345
345
|
o(this, "mountCB", () => {
|
|
346
|
-
const t = this.$parent.gridView,
|
|
347
|
-
|
|
346
|
+
const t = this.$parent.gridView, s = t == null ? void 0 : t.getDataSource();
|
|
347
|
+
s && !s.fieldByName(this.props.fieldName) && (this._field = s.addField(this.props));
|
|
348
348
|
});
|
|
349
349
|
o(this, "unMountCB", () => {
|
|
350
350
|
if (this._field) {
|
|
351
|
-
const t = this.$parent.gridView,
|
|
352
|
-
|
|
351
|
+
const t = this.$parent.gridView, s = t == null ? void 0 : t.getDataSource();
|
|
352
|
+
s && s.removeField(this._field.fieldName);
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
}
|
|
@@ -361,17 +361,17 @@ class y extends a {
|
|
|
361
361
|
o(this, "mounted");
|
|
362
362
|
o(this, "_column");
|
|
363
363
|
o(this, "mountCB", () => {
|
|
364
|
-
const t = this.$parent.gridView,
|
|
365
|
-
let
|
|
366
|
-
|
|
364
|
+
const t = this.$parent.gridView, s = this.$parent.props.autoGenerateField, e = t == null ? void 0 : t.getDataSource();
|
|
365
|
+
let i = this.props.fieldName;
|
|
366
|
+
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));
|
|
367
367
|
});
|
|
368
368
|
o(this, "unMountCB", () => {
|
|
369
369
|
const t = this.$parent.gridView;
|
|
370
370
|
if (this._column && t && !t._view.disposing) {
|
|
371
|
-
let
|
|
371
|
+
let s = this._column.fieldName;
|
|
372
372
|
t.removeColumn(this._column.name);
|
|
373
|
-
const e = this.$parent.props.autoGenerateField,
|
|
374
|
-
e &&
|
|
373
|
+
const e = this.$parent.props.autoGenerateField, i = t == null ? void 0 : t.getDataSource();
|
|
374
|
+
e && s && i && (t.columnByField(s) || i.removeField(s));
|
|
375
375
|
}
|
|
376
376
|
});
|
|
377
377
|
}
|
|
@@ -381,10 +381,10 @@ class y extends a {
|
|
|
381
381
|
componentWillUnmount() {
|
|
382
382
|
super.componentWillUnmount();
|
|
383
383
|
}
|
|
384
|
-
componentDidUpdate(t,
|
|
385
|
-
if (super.componentDidUpdate(t,
|
|
386
|
-
const
|
|
387
|
-
|
|
384
|
+
componentDidUpdate(t, s, e) {
|
|
385
|
+
if (super.componentDidUpdate(t, s, e), t.width !== this.props.width) {
|
|
386
|
+
const i = this.$model.layout;
|
|
387
|
+
i && (i.cellWidth = this.props.width);
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
}
|
|
@@ -419,10 +419,10 @@ class $ extends a {
|
|
|
419
419
|
componentWillUnmount() {
|
|
420
420
|
super.componentWillUnmount();
|
|
421
421
|
}
|
|
422
|
-
componentDidUpdate(t,
|
|
423
|
-
if (super.componentDidUpdate(t,
|
|
424
|
-
const
|
|
425
|
-
|
|
422
|
+
componentDidUpdate(t, s, e) {
|
|
423
|
+
if (super.componentDidUpdate(t, s, e), t.width !== this.props.width) {
|
|
424
|
+
const i = this.$model.layout;
|
|
425
|
+
i && (i.cellWidth = this.props.width);
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
}
|