Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-bootstrap-table2-editor

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bootstrap-table2-editor - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

4

dist/react-bootstrap-table2-editor.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactBootstrapTable=t(require("react")):e.ReactBootstrapTable=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=42)}({0:function(t,n){t.exports=e},1:function(e,t,n){e.exports=n(4)()},14:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.TIME_TO_CLOSE_MESSAGE=3e3,t.DELAY_FOR_DBCLICK=200,t.CLICK_TO_CELL_EDIT="click",t.DBCLICK_TO_CELL_EDIT="dbclick"},4:function(e,t,n){"use strict";var r=n(5),o=n(6),i=n(7);e.exports=function(){function e(e,t,n,r,a,l){l!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},42:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(43),i=r(o),a=n(44),l=r(a),u=n(14);t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{wrapperFactory:i.default,editingCellFactory:l.default,CLICK_TO_CELL_EDIT:u.CLICK_TO_CELL_EDIT,DBCLICK_TO_CELL_EDIT:u.DBCLICK_TO_CELL_EDIT,DELAY_FOR_DBCLICK:u.DELAY_FOR_DBCLICK,options:e}}},43:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),f=r(c),d=n(1),p=r(d),h=n(14);t.default=function(e,t){var n,r,d=t._,y=t.remoteResolver,v=void 0;return r=n=function(t){function n(e){i(this,n);var t=a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return v=e.cellEdit.editingCellFactory(d),t.startEditing=t.startEditing.bind(t),t.escapeEditing=t.escapeEditing.bind(t),t.completeEditing=t.completeEditing.bind(t),t.handleCellUpdate=t.handleCellUpdate.bind(t),t.state={ridx:null,cidx:null,message:null,isDataChanged:!1},t}return l(n,t),s(n,[{key:"componentWillReceiveProps",value:function(e){e.cellEdit&&this.isRemoteCellEdit()?e.cellEdit.options.errorMessage?this.setState(function(){return{isDataChanged:!1,message:e.cellEdit.options.errorMessage}}):(this.setState(function(){return{isDataChanged:!0}}),this.escapeEditing()):this.setState(function(){return{isDataChanged:!1}})}},{key:"handleCellUpdate",value:function(e,t,n){var r=this.props,o=r.keyField,i=r.cellEdit,a=r.store,l=i.options,u=l.beforeSaveCell,s=l.afterSaveCell,c=d.get(e,t.dataField),f=d.get(e,o);d.isFunction(u)&&u(c,n,e,t),this.isRemoteCellEdit()?this.handleCellChange(f,t.dataField,n):(a.edit(f,t.dataField,n),d.isFunction(s)&&s(c,n,e,t),this.completeEditing())}},{key:"completeEditing",value:function(){this.setState(function(){return{ridx:null,cidx:null,message:null,isDataChanged:!0}})}},{key:"startEditing",value:function(e,t){var n=this,r=this.props.selectRow;r&&!r.clickToEdit&&r.clickToSelect||function(){n.setState(function(){return{ridx:e,cidx:t,isDataChanged:!1}})}()}},{key:"escapeEditing",value:function(){this.setState(function(){return{ridx:null,cidx:null}})}},{key:"render",value:function(){var t=this.state,n=t.isDataChanged,r=o(t,["isDataChanged"]),i=this.props.cellEdit,a=i.options,l=a.nonEditableRows,s=(a.errorMessage,o(a,["nonEditableRows","errorMessage"])),c=(i.editingCellFactory,o(i,["options","editingCellFactory"])),p=u({},s,c,r,{EditingCell:v,nonEditableRows:d.isDefined(l)?l():[],onStart:this.startEditing,onEscape:this.escapeEditing,onUpdate:this.handleCellUpdate});return f.default.createElement(e,u({},this.props,{data:this.props.store.data,isDataChanged:n,cellEdit:p}))}}]),n}(y(c.Component)),n.propTypes={options:p.default.shape({mode:p.default.oneOf([h.CLICK_TO_CELL_EDIT,h.DBCLICK_TO_CELL_EDIT]).isRequired,onErrorMessageDisappear:p.default.func,blurToSave:p.default.bool,beforeSaveCell:p.default.func,afterSaveCell:p.default.func,nonEditableRows:p.default.func,timeToCloseMessage:p.default.number,errorMessage:p.default.string})},r}},44:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(0),c=r(s),f=n(8),d=r(f),p=n(1),h=r(p),y=n(45),v=r(y),b=n(46),m=r(b),g=n(14);t.default=function(e){var t,n;return n=t=function(t){function n(e){o(this,n);var t=i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.indicatorTimer=null,t.clearTimer=t.clearTimer.bind(t),t.handleBlur=t.handleBlur.bind(t),t.handleClick=t.handleClick.bind(t),t.handleKeyDown=t.handleKeyDown.bind(t),t.beforeComplete=t.beforeComplete.bind(t),t.state={invalidMessage:null},t}return a(n,t),u(n,[{key:"componentWillReceiveProps",value:function(t){var n=t.message;e.isDefined(n)&&(this.createTimer(),this.setState(function(){return{invalidMessage:n}}))}},{key:"componentWillUnmount",value:function(){this.clearTimer()}},{key:"clearTimer",value:function(){this.indicatorTimer&&clearTimeout(this.indicatorTimer)}},{key:"createTimer",value:function(){var t=this;this.clearTimer();var n=this.props,r=n.timeToCloseMessage,o=n.onErrorMessageDisappear;this.indicatorTimer=e.sleep(function(){t.setState(function(){return{invalidMessage:null}}),e.isFunction(o)&&o()},r)}},{key:"beforeComplete",value:function(t,n,r){var o=this.props.onUpdate;if(e.isFunction(n.validator)){var i=n.validator(r,t,n);if(e.isObject(i)&&!i.valid)return this.setState(function(){return{invalidMessage:i.message}}),void this.createTimer()}o(t,n,r)}},{key:"handleBlur",value:function(){var t=this.props,n=t.onEscape,r=t.blurToSave,o=t.row,i=t.column;if(r){var a=this.editor.text.value;e.isDefined(a),this.beforeComplete(o,i,a)}else n()}},{key:"handleKeyDown",value:function(t){var n=this.props,r=n.onEscape,o=n.row,i=n.column;if(27===t.keyCode)r();else if(13===t.keyCode){var a=t.currentTarget.value;e.isDefined(a),this.beforeComplete(o,i,a)}}},{key:"handleClick",value:function(e){"TD"!==e.target.tagName&&e.stopPropagation()}},{key:"render",value:function(){var t=this,n=this.state.invalidMessage,r=this.props,o=r.row,i=r.column,a=r.className,u=r.style,s=r.rowIndex,f=r.columnIndex,p=i.dataField,h=e.get(o,p),y={onKeyDown:this.handleKeyDown,onBlur:this.handleBlur},b=e.isDefined(n),g=i.editorClasses||"";e.isFunction(i.editorClasses)&&(g=i.editorClasses(h,o,s,f));var _=i.editorStyle||{};e.isFunction(i.editorStyle)&&(_=i.editorStyle(h,o,s,f));var C=(0,d.default)({animated:b,shake:b},g);return c.default.createElement("td",{className:(0,d.default)("react-bootstrap-table-editing-cell",a),style:u,onClick:this.handleClick},c.default.createElement(v.default,l({ref:function(e){return t.editor=e},defaultValue:h,style:_,className:C},y)),b?c.default.createElement(m.default,{invalidMessage:n}):null)}}]),n}(s.Component),t.propTypes={row:h.default.object.isRequired,rowIndex:h.default.number.isRequired,column:h.default.object.isRequired,columnIndex:h.default.number.isRequired,onUpdate:h.default.func.isRequired,onEscape:h.default.func.isRequired,timeToCloseMessage:h.default.number,className:h.default.string,style:h.default.object},t.defaultProps={timeToCloseMessage:g.TIME_TO_CLOSE_MESSAGE,className:null,style:{}},n}},45:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),f=r(c),d=n(8),p=r(d),h=n(1),y=r(h),v=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return l(t,e),s(t,[{key:"componentDidMount",value:function(){var e=this.props.defaultValue;this.text.value=e,this.text.focus()}},{key:"render",value:function(){var e=this,t=this.props,n=(t.defaultValue,t.className),r=o(t,["defaultValue","className"]),i=(0,p.default)("form-control editor edit-text",n);return f.default.createElement("input",u({ref:function(t){return e.text=t},type:"text",className:i},r))}}]),t}(c.Component);v.propTypes={className:y.default.oneOfType([y.default.string,y.default.object]),defaultValue:y.default.oneOfType([y.default.string,y.default.number])},v.defaultProps={className:null,defaultValue:""},t.default=v},46:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=r(o),a=n(1),l=r(a),u=function(e){var t=e.invalidMessage;return i.default.createElement("div",{className:"alert alert-danger fade in"},i.default.createElement("strong",null,t))};u.propTypes={invalidMessage:l.default.string},u.defaultProps={invalidMessage:null},t.default=u},5:function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},6:function(e,t,n){"use strict";function r(e,t,n,r,i,a,l,u){if(o(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,a,l,u],f=0;s=new Error(t.replace(/%s/g,function(){return c[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}var o=function(e){};e.exports=r},7:function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},8:function(e,t,n){var r,o;/*!
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactBootstrapTable2Editor=t(require("react")):e.ReactBootstrapTable2Editor=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(t,n){t.exports=e},function(e,t,n){e.exports=n(6)()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.TIME_TO_CLOSE_MESSAGE=3e3,t.DELAY_FOR_DBCLICK=200,t.CLICK_TO_CELL_EDIT="click",t.DBCLICK_TO_CELL_EDIT="dbclick"},function(e,t,n){var r,o;/*!
Copyright (c) 2016 Jed Watson.

@@ -6,2 +6,2 @@ Licensed under the MIT License (MIT), see

*/
!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r))e.push(n.apply(null,r));else if("object"===o)for(var a in r)i.call(r,a)&&r[a]&&e.push(a)}}return e.join(" ")}var i={}.hasOwnProperty;void 0!==e&&e.exports?e.exports=n:(r=[],void 0!==(o=function(){return n}.apply(t,r))&&(e.exports=o))}()}})});
!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r))e.push(n.apply(null,r));else if("object"===o)for(var a in r)i.call(r,a)&&r[a]&&e.push(a)}}return e.join(" ")}var i={}.hasOwnProperty;void 0!==e&&e.exports?e.exports=n:(r=[],void 0!==(o=function(){return n}.apply(t,r))&&(e.exports=o))}()},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),i=r(o),a=n(10),l=r(a),u=n(2);t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{wrapperFactory:i.default,editingCellFactory:l.default,CLICK_TO_CELL_EDIT:u.CLICK_TO_CELL_EDIT,DBCLICK_TO_CELL_EDIT:u.DBCLICK_TO_CELL_EDIT,DELAY_FOR_DBCLICK:u.DELAY_FOR_DBCLICK,options:e}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),f=r(c),d=n(1),p=r(d),h=n(2);t.default=function(e,t){var n,r,d=t._,y=t.remoteResolver,v=void 0;return r=n=function(t){function n(e){i(this,n);var t=a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return v=e.cellEdit.editingCellFactory(d),t.startEditing=t.startEditing.bind(t),t.escapeEditing=t.escapeEditing.bind(t),t.completeEditing=t.completeEditing.bind(t),t.handleCellUpdate=t.handleCellUpdate.bind(t),t.state={ridx:null,cidx:null,message:null,isDataChanged:!1},t}return l(n,t),s(n,[{key:"componentWillReceiveProps",value:function(e){e.cellEdit&&this.isRemoteCellEdit()?e.cellEdit.options.errorMessage?this.setState(function(){return{isDataChanged:!1,message:e.cellEdit.options.errorMessage}}):(this.setState(function(){return{isDataChanged:!0}}),this.escapeEditing()):this.setState(function(){return{isDataChanged:!1}})}},{key:"handleCellUpdate",value:function(e,t,n){var r=this.props,o=r.keyField,i=r.cellEdit,a=r.store,l=i.options,u=l.beforeSaveCell,s=l.afterSaveCell,c=d.get(e,t.dataField),f=d.get(e,o);d.isFunction(u)&&u(c,n,e,t),this.isRemoteCellEdit()?this.handleCellChange(f,t.dataField,n):(a.edit(f,t.dataField,n),d.isFunction(s)&&s(c,n,e,t),this.completeEditing())}},{key:"completeEditing",value:function(){this.setState(function(){return{ridx:null,cidx:null,message:null,isDataChanged:!0}})}},{key:"startEditing",value:function(e,t){var n=this,r=this.props.selectRow;r&&!r.clickToEdit&&r.clickToSelect||function(){n.setState(function(){return{ridx:e,cidx:t,isDataChanged:!1}})}()}},{key:"escapeEditing",value:function(){this.setState(function(){return{ridx:null,cidx:null}})}},{key:"render",value:function(){var t=this.state,n=t.isDataChanged,r=o(t,["isDataChanged"]),i=this.props.cellEdit,a=i.options,l=a.nonEditableRows,s=(a.errorMessage,o(a,["nonEditableRows","errorMessage"])),c=(i.editingCellFactory,o(i,["options","editingCellFactory"])),p=u({},s,c,r,{EditingCell:v,nonEditableRows:d.isDefined(l)?l():[],onStart:this.startEditing,onEscape:this.escapeEditing,onUpdate:this.handleCellUpdate});return f.default.createElement(e,u({},this.props,{data:this.props.store.data,isDataChanged:n,cellEdit:p}))}}]),n}(y(c.Component)),n.propTypes={options:p.default.shape({mode:p.default.oneOf([h.CLICK_TO_CELL_EDIT,h.DBCLICK_TO_CELL_EDIT]).isRequired,onErrorMessageDisappear:p.default.func,blurToSave:p.default.bool,beforeSaveCell:p.default.func,afterSaveCell:p.default.func,nonEditableRows:p.default.func,timeToCloseMessage:p.default.number,errorMessage:p.default.string})},r}},function(e,t,n){"use strict";var r=n(7),o=n(8),i=n(9);e.exports=function(){function e(e,t,n,r,a,l){l!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){"use strict";function r(e,t,n,r,i,a,l,u){if(o(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,a,l,u],f=0;s=new Error(t.replace(/%s/g,function(){return c[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}var o=function(e){};e.exports=r},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(0),c=r(s),f=n(3),d=r(f),p=n(1),h=r(p),y=n(11),v=r(y),b=n(12),m=r(b),g=n(2);t.default=function(e){var t,n;return n=t=function(t){function n(e){o(this,n);var t=i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.indicatorTimer=null,t.clearTimer=t.clearTimer.bind(t),t.handleBlur=t.handleBlur.bind(t),t.handleClick=t.handleClick.bind(t),t.handleKeyDown=t.handleKeyDown.bind(t),t.beforeComplete=t.beforeComplete.bind(t),t.state={invalidMessage:null},t}return a(n,t),u(n,[{key:"componentWillReceiveProps",value:function(t){var n=t.message;e.isDefined(n)&&(this.createTimer(),this.setState(function(){return{invalidMessage:n}}))}},{key:"componentWillUnmount",value:function(){this.clearTimer()}},{key:"clearTimer",value:function(){this.indicatorTimer&&clearTimeout(this.indicatorTimer)}},{key:"createTimer",value:function(){var t=this;this.clearTimer();var n=this.props,r=n.timeToCloseMessage,o=n.onErrorMessageDisappear;this.indicatorTimer=e.sleep(function(){t.setState(function(){return{invalidMessage:null}}),e.isFunction(o)&&o()},r)}},{key:"beforeComplete",value:function(t,n,r){var o=this.props.onUpdate;if(e.isFunction(n.validator)){var i=n.validator(r,t,n);if(e.isObject(i)&&!i.valid)return this.setState(function(){return{invalidMessage:i.message}}),void this.createTimer()}o(t,n,r)}},{key:"handleBlur",value:function(){var t=this.props,n=t.onEscape,r=t.blurToSave,o=t.row,i=t.column;if(r){var a=this.editor.text.value;e.isDefined(a),this.beforeComplete(o,i,a)}else n()}},{key:"handleKeyDown",value:function(t){var n=this.props,r=n.onEscape,o=n.row,i=n.column;if(27===t.keyCode)r();else if(13===t.keyCode){var a=t.currentTarget.value;e.isDefined(a),this.beforeComplete(o,i,a)}}},{key:"handleClick",value:function(e){"TD"!==e.target.tagName&&e.stopPropagation()}},{key:"render",value:function(){var t=this,n=this.state.invalidMessage,r=this.props,o=r.row,i=r.column,a=r.className,u=r.style,s=r.rowIndex,f=r.columnIndex,p=i.dataField,h=e.get(o,p),y={onKeyDown:this.handleKeyDown,onBlur:this.handleBlur},b=e.isDefined(n),g=i.editorClasses||"";e.isFunction(i.editorClasses)&&(g=i.editorClasses(h,o,s,f));var _=i.editorStyle||{};e.isFunction(i.editorStyle)&&(_=i.editorStyle(h,o,s,f));var C=(0,d.default)({animated:b,shake:b},g);return c.default.createElement("td",{className:(0,d.default)("react-bootstrap-table-editing-cell",a),style:u,onClick:this.handleClick},c.default.createElement(v.default,l({ref:function(e){return t.editor=e},defaultValue:h,style:_,className:C},y)),b?c.default.createElement(m.default,{invalidMessage:n}):null)}}]),n}(s.Component),t.propTypes={row:h.default.object.isRequired,rowIndex:h.default.number.isRequired,column:h.default.object.isRequired,columnIndex:h.default.number.isRequired,onUpdate:h.default.func.isRequired,onEscape:h.default.func.isRequired,timeToCloseMessage:h.default.number,className:h.default.string,style:h.default.object},t.defaultProps={timeToCloseMessage:g.TIME_TO_CLOSE_MESSAGE,className:null,style:{}},n}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),f=r(c),d=n(3),p=r(d),h=n(1),y=r(h),v=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return l(t,e),s(t,[{key:"componentDidMount",value:function(){var e=this.props.defaultValue;this.text.value=e,this.text.focus()}},{key:"render",value:function(){var e=this,t=this.props,n=(t.defaultValue,t.className),r=o(t,["defaultValue","className"]),i=(0,p.default)("form-control editor edit-text",n);return f.default.createElement("input",u({ref:function(t){return e.text=t},type:"text",className:i},r))}}]),t}(c.Component);v.propTypes={className:y.default.oneOfType([y.default.string,y.default.object]),defaultValue:y.default.oneOfType([y.default.string,y.default.number])},v.defaultProps={className:null,defaultValue:""},t.default=v},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=r(o),a=n(1),l=r(a),u=function(e){var t=e.invalidMessage;return i.default.createElement("div",{className:"alert alert-danger fade in"},i.default.createElement("strong",null,t))};u.propTypes={invalidMessage:l.default.string},u.defaultProps={invalidMessage:null},t.default=u}])});
{
"name": "react-bootstrap-table2-editor",
"version": "0.1.5",
"version": "0.2.0",
"description": "it's the editor addon for react-bootstrap-table2",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -51,2 +51,5 @@ # react-bootstrap-table2-editor

## Validation
[column.validator](https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/column-props.html#columnvalidator-function) will help you to work on it!
## Customize Style/Class

@@ -62,4 +65,167 @@ ### Editing Cell

## Validation
## Rich Editors
`react-bootstrap-table2` have following predefined editor:
[`column.validator`](https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/column-props.html#columnvalidator-function) will help you to work on it!
* Text(Default)
* Dropdown
* Date
* Textarea
* Checkbox
In a nutshell, you just only give a [column.editor](https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/column-props.html#columneditor-object) and define the `type`:
```js
import { Type } from 'react-bootstrap-table2-editor';
const columns = [
..., {
dataField: 'done',
text: 'Done',
editor: {
type: Type.SELECT | Type.TEXTAREA | Type.CHECKBOX | Type.DATE,
... // The rest properties will be rendered into the editor's DOM element
}
}
]
```
In the following, we go though all the predefined editors:
### Dropdown Editor
Dropdown editor give a select menu to choose a data from a list, the `editor.options` is required property for dropdown editor.
```js
import { Type } from 'react-bootstrap-table2-editor';
const columns = [
..., {
dataField: 'type',
text: 'Job Type',
editor: {
type: Type.SELECT,
options: [{
value: 'A',
label: 'A'
}, {
value: 'B',
label: 'B'
}, {
value: 'C',
label: 'C'
}, {
value: 'D',
label: 'D'
}, {
value: 'E',
label: 'E'
}]
}
}];
```
### Date Editor
Date editor is use `<input type="date">`, the configuration is very simple:
```js
const columns = [
..., {
dataField: 'inStockDate',
text: 'Stock Date',
formatter: (cell) => {
let dateObj = cell;
if (typeof cell !== 'object') {
dateObj = new Date(cell);
}
return `${('0' + dateObj.getDate()).slice(-2)}/${('0' + (dateObj.getMonth() + 1)).slice(-2)}/${dateObj.getFullYear()}`;
},
editor: {
type: Type.DATE
}
}];
```
### Textarea Editor
Textarea editor is use `<input type="textarea">`, user can press `ENTER` to change line and in the `react-bootstrap-table2`, user allow to save result via press `SHIFT` + `ENTER`.
```js
const columns = [
..., {
dataField: 'comment',
text: 'Product Comments',
editor: {
type: Type.TEXTAREA
}
}];
```
### Checkbox Editor
Checkbox editor allow you to have a pair value choice, the `editor.value` is required value to represent the actual value for check and uncheck.
```js
const columns = [
..., {
dataField: 'comment',
text: 'Product Comments',
editor: {
type: Type.CHECKBOX,
value: 'Y:N'
}
}];
```
## Customize Editor
If you feel above predefined editors are not satisfied to your requirement, you can certainly custom the editor via [column.editorRenderer](https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/column-props.html#columneditorrenderer-function). It accept a function and pass following arguments when function called:
* `editorProps`: Some useful attributes you can use on DOM editor, like class, style etc.
* `value`: Current cell value
* `row`: Current row data
* `column`: Current column definition
* `rowIndex`: Current row index
* `columnIndex`: Current column index
> Note when implement a custom React editor component, this component should have a **getValue** function which return current value on editor
> Note when you want to save value, you can call **editorProps.onUpdate** function
Following is a short example:
```js
class QualityRanger extends React.Component {
static propTypes = {
value: PropTypes.number,
onUpdate: PropTypes.func.isRequired
}
static defaultProps = {
value: 0
}
getValue() {
return parseInt(this.range.value, 10);
}
render() {
const { value, onUpdate, ...rest } = this.props;
return [
<input
{ ...rest }
key="range"
ref={ node => this.range = node }
type="range"
min="0"
max="100"
/>,
<button
key="submit"
className="btn btn-default"
onClick={ () => onUpdate(this.getValue()) }
>
done
</button>
];
}
}
const columns = [
..., {
dataField: 'quality',
text: 'Product Quality',
editorRenderer: (editorProps, value, row, column, rowIndex, columnIndex) => (
<QualityRanger { ...editorProps } value={ value } />
)
}];
```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc