From 3272c459bf5dbf75999a85671745f6566c3763ec Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sun, 6 Dec 2015 14:39:06 +0800 Subject: [PATCH] enalbe import from RequireJS --- gulpfile.js | 7 +- lib/BootstrapTable.js | 740 ------------------------------- lib/Const.js | 24 - lib/Editor.js | 104 ----- lib/Notification.js | 66 --- lib/SelectRowHeaderColumn.js | 61 --- lib/TableBody.js | 367 --------------- lib/TableColumn.js | 95 ---- lib/TableEditColumn.js | 169 ------- lib/TableFilter.js | 108 ----- lib/TableHeader.js | 163 ------- lib/TableHeaderColumn.js | 114 ----- lib/TableRow.js | 84 ---- lib/csv_export_util.js | 37 -- lib/filesaver.js | 263 ----------- lib/index.js | 29 -- lib/pagination/PageButton.js | 65 --- lib/pagination/PaginationList.js | 212 --------- lib/store/TableDataStore.js | 311 ------------- lib/toolbar/ToolBar.js | 336 -------------- lib/util.js | 72 --- package.json | 3 +- 22 files changed, 5 insertions(+), 3425 deletions(-) delete mode 100644 lib/BootstrapTable.js delete mode 100644 lib/Const.js delete mode 100644 lib/Editor.js delete mode 100644 lib/Notification.js delete mode 100644 lib/SelectRowHeaderColumn.js delete mode 100644 lib/TableBody.js delete mode 100644 lib/TableColumn.js delete mode 100644 lib/TableEditColumn.js delete mode 100644 lib/TableFilter.js delete mode 100644 lib/TableHeader.js delete mode 100644 lib/TableHeaderColumn.js delete mode 100644 lib/TableRow.js delete mode 100644 lib/csv_export_util.js delete mode 100644 lib/filesaver.js delete mode 100644 lib/index.js delete mode 100644 lib/pagination/PageButton.js delete mode 100644 lib/pagination/PaginationList.js delete mode 100644 lib/store/TableDataStore.js delete mode 100644 lib/toolbar/ToolBar.js delete mode 100644 lib/util.js diff --git a/gulpfile.js b/gulpfile.js index a508b4a74..9fd39f43c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,9 +14,10 @@ var demo = false; gulp.task("default", ["prod"]); gulp.task("prod", function () { - gulp.src('./src/**/*.js') - .pipe(babel()) - .pipe(gulp.dest('./lib')); + // Don't use babel to build each library + // gulp.src('./src/**/*.js') + // .pipe(babel()) + // .pipe(gulp.dest('./lib')); gulp.src('./css/react-bootstrap-table.css') .pipe(concatCss("./react-bootstrap-table.min.css")) .pipe(cssmin()) diff --git a/lib/BootstrapTable.js b/lib/BootstrapTable.js deleted file mode 100644 index 7dd98db24..000000000 --- a/lib/BootstrapTable.js +++ /dev/null @@ -1,740 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _TableHeader = require('./TableHeader'); - -var _TableHeader2 = _interopRequireDefault(_TableHeader); - -var _TableBody = require('./TableBody'); - -var _TableBody2 = _interopRequireDefault(_TableBody); - -var _paginationPaginationList = require('./pagination/PaginationList'); - -var _paginationPaginationList2 = _interopRequireDefault(_paginationPaginationList); - -var _toolbarToolBar = require('./toolbar/ToolBar'); - -var _toolbarToolBar2 = _interopRequireDefault(_toolbarToolBar); - -var _TableFilter = require('./TableFilter'); - -var _TableFilter2 = _interopRequireDefault(_TableFilter); - -var _storeTableDataStore = require('./store/TableDataStore'); - -var _csv_export_util = require('./csv_export_util'); - -var _csv_export_util2 = _interopRequireDefault(_csv_export_util); - -var BootstrapTable = (function (_React$Component) { - _inherits(BootstrapTable, _React$Component); - - function BootstrapTable(props) { - var _this = this; - - _classCallCheck(this, BootstrapTable); - - _get(Object.getPrototypeOf(BootstrapTable.prototype), 'constructor', this).call(this, props); - - this._scrollHeader = function (e) { - _this.refs.header.refs.container.scrollLeft = e.currentTarget.scrollLeft; - }; - - this._adjustHeaderWidth = function () { - var tableHeaderDom = _this.refs.header.refs.container.childNodes[0]; - var tableBodyDom = _this.refs.body.refs.container.childNodes[0]; - if (tableHeaderDom.offsetWidth !== tableBodyDom.offsetWidth) { - tableHeaderDom.style.width = tableBodyDom.offsetWidth + "px"; - } - var headerProps = _this.refs.body.getBodyHeaderDomProp(); - _this.refs.header.fitHeader(headerProps, _this.refs.body.refs.container.scrollHeight > _this.refs.body.refs.container.clientHeight); - }; - - this._attachCellEditFunc(); - - if (!Array.isArray(this.props.data)) { - this.store = new _storeTableDataStore.TableDataStore(this.props.data.getData()); - this.props.data.clear(); - this.props.data.on('change', function (data) { - _this.store.setData(data); - _this.setState({ - data: _this.getTableData() - }); - }); - } else { - this.store = new _storeTableDataStore.TableDataStore(this.props.data); - } - - this.initTable(this.props); - - if (this.props.selectRow && this.props.selectRow.selected) { - this.store.setSelectedRowKey(this.props.selectRow.selected); - } - - this.state = { - data: this.getTableData(), - selectedRowKeys: this.store.getSelectedRowKeys() - }; - } - - _createClass(BootstrapTable, [{ - key: 'initTable', - value: function initTable(props) { - var keyField = props.keyField; - - var customSortFuncMap = {}; - - if (!(typeof keyField === 'string' && keyField.length)) { - _react2['default'].Children.forEach(props.children, function (column) { - if (column.props.isKey) { - if (keyField != null) { - throw "Error. Multiple key column be detected in TableHeaderColumn."; - } - keyField = column.props.dataField; - } - }, this); - } - - _react2['default'].Children.forEach(props.children, function (column) { - if (column.props.sortFunc) { - customSortFuncMap[column.props.dataField] = column.props.sortFunc; - } - }, this); - - if (keyField == null) throw "Error. No any key column defined in TableHeaderColumn." + "Use 'isKey={true}' to specify an unique column after version 0.5.4."; - - this.store.setProps({ - isPagination: props.pagination, - keyField: keyField, - customSortFuncMap: customSortFuncMap, - multiColumnSearch: props.multiColumnSearch, - remote: this.isRemoteDataSource() - }); - } - }, { - key: 'getTableData', - value: function getTableData() { - var result = []; - if (this.props.pagination) { - var page = undefined, - sizePerPage = undefined; - if (this.store.isChangedPage()) { - sizePerPage = this.refs.pagination.getSizePerPage(); - page = this.refs.pagination.getCurrentPage(); - } else { - sizePerPage = this.props.options.sizePerPage || _Const2['default'].SIZE_PER_PAGE_LIST[0]; - page = this.props.options.page || 1; - } - result = this.store.page(page, sizePerPage).get(); - } else { - result = this.store.get(); - } - return result; - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - this.initTable(nextProps); - if (Array.isArray(nextProps.data)) { - this.store.setData(nextProps.data); - this.store.page(nextProps.options.page || 1, nextProps.options.sizePerPage || _Const2['default'].SIZE_PER_PAGE_LIST[0]); - this.setState({ - data: this.getTableData() - }); - } - if (nextProps.selectRow && nextProps.selectRow.selected) { - //set default select rows to store. - this.store.setSelectedRowKey(nextProps.selectRow.selected); - this.setState({ - selectedRowKeys: nextProps.selectRow.selected - }); - } - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - this._adjustHeaderWidth(); - window.addEventListener('resize', this._adjustHeaderWidth); - this.refs.body.refs.container.addEventListener('scroll', this._scrollHeader); - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - window.removeEventListener('resize', this._adjustHeaderWidth); - this.refs.body.refs.container.removeEventListener('scroll', this._scrollHeader); - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate() { - this._adjustHeaderWidth(); - this._attachCellEditFunc(); - if (this.props.options.afterTableComplete) this.props.options.afterTableComplete(); - } - }, { - key: '_attachCellEditFunc', - value: function _attachCellEditFunc() { - if (this.props.cellEdit) { - this.props.cellEdit.__onCompleteEdit__ = this.handleEditCell.bind(this); - if (this.props.cellEdit.mode !== _Const2['default'].CELL_EDIT_NONE) this.props.selectRow.clickToSelect = false; - } - } - - /** - * Returns true if in the current configuration, - * the datagrid should load its data remotely. - * - * @param {Object} [props] Optional. If not given, this.props will be used - * @return {Boolean} - */ - }, { - key: 'isRemoteDataSource', - value: function isRemoteDataSource(props) { - return (props || this.props).remote; - } - }, { - key: 'render', - value: function render() { - - var tableClass = (0, _classnames2['default'])("react-bs-table"); - var childrens = this.props.children; - var style = { - height: this.props.height - }; - if (!Array.isArray(this.props.children)) { - childrens = [this.props.children]; - } - var columns = childrens.map(function (column, i) { - return { - name: column.props.dataField, - align: column.props.dataAlign, - sort: column.props.dataSort, - format: column.props.dataFormat, - editable: column.props.editable, - hidden: column.props.hidden, - className: column.props.columnClassName, - width: column.props.width, - text: column.props.children, - index: i - }; - }, this); - - var pagination = this.renderPagination(); - var toolBar = this.renderToolBar(); - var tableFilter = this.renderTableFilter(columns); - var isSelectAll = this.isSelectAll(); - return _react2['default'].createElement( - 'div', - { className: 'react-bs-container', ref: 'table' }, - toolBar, - _react2['default'].createElement( - 'div', - { className: 'react-bs-table-container', style: style }, - _react2['default'].createElement( - _TableHeader2['default'], - { - ref: 'header', - rowSelectType: this.props.selectRow.mode, - hideSelectColumn: this.props.selectRow.hideSelectColumn, - sortName: this.props.options.sortName, - sortOrder: this.props.options.sortOrder, - onSort: this.handleSort.bind(this), - onSelectAllRow: this.handleSelectAllRow.bind(this), - bordered: this.props.bordered, - condensed: this.props.condensed, - isSelectAll: isSelectAll }, - this.props.children - ), - _react2['default'].createElement(_TableBody2['default'], { - height: this.props.height, - ref: 'body', - data: this.state.data, - columns: columns, - trClassName: this.props.trClassName, - striped: this.props.striped, - bordered: this.props.bordered, - hover: this.props.hover, - keyField: this.store.getKeyField(), - condensed: this.props.condensed, - selectRow: this.props.selectRow, - cellEdit: this.props.cellEdit, - selectedRowKeys: this.state.selectedRowKeys, - onRowClick: this.handleRowClick.bind(this), - onSelectRow: this.handleSelectRow.bind(this) - }) - ), - tableFilter, - pagination - ); - } - }, { - key: 'isSelectAll', - value: function isSelectAll() { - var defaultSelectRowKeys = this.store.getSelectedRowKeys(); - var allRowKeys = this.store.getAllRowkey(); - if (defaultSelectRowKeys.length !== allRowKeys.length) { - return false; - } else { - return defaultSelectRowKeys.every(function (elm) { - return allRowKeys.indexOf(elm) > -1; - }); - } - } - }, { - key: 'handleSort', - value: function handleSort(order, sortField) { - if (this.props.options.onSortChange) { - this.props.options.onSortChange(sortField, order, this.props); - } - - if (this.isRemoteDataSource()) { - return; - } - - var result = this.store.sort(order, sortField).get(); - this.setState({ - data: result - }); - } - }, { - key: 'handlePaginationData', - value: function handlePaginationData(page, sizePerPage) { - var onPageChange = this.props.options.onPageChange; - - if (onPageChange) { - onPageChange(page, sizePerPage); - } - - if (this.isRemoteDataSource()) { - return; - } - - var result = this.store.page(page, sizePerPage).get(); - this.setState({ - data: result - }); - } - }, { - key: 'handleRowClick', - value: function handleRowClick(row) { - if (this.props.options.onRowClick) { - this.props.options.onRowClick(row); - } - } - }, { - key: 'handleSelectAllRow', - value: function handleSelectAllRow(e) { - var isSelected = e.currentTarget.checked; - var selectedRowKeys = []; - if (isSelected) { - selectedRowKeys = this.store.getAllRowkey(); - } - - this.store.setSelectedRowKey(selectedRowKeys); - this.setState({ - selectedRowKeys: selectedRowKeys - }); - - if (this.props.selectRow.onSelectAll) { - this.props.selectRow.onSelectAll(isSelected, isSelected ? this.store.get() : []); - } - } - }, { - key: 'handleSelectRow', - value: function handleSelectRow(row, isSelected) { - var currSelected = this.store.getSelectedRowKeys(); - var rowKey = row[this.store.getKeyField()]; - if (this.props.selectRow.mode === _Const2['default'].ROW_SELECT_SINGLE) { - currSelected = isSelected ? [rowKey] : []; - } else { - if (isSelected) { - currSelected.push(rowKey); - } else { - currSelected = currSelected.filter(function (key) { - return rowKey !== key; - }); - } - } - - this.store.setSelectedRowKey(currSelected); - this.setState({ - selectedRowKeys: currSelected - }); - - if (this.props.selectRow.onSelect) { - this.props.selectRow.onSelect(row, isSelected); - } - } - }, { - key: 'handleEditCell', - value: function handleEditCell(newVal, rowIndex, colIndex) { - var fieldName = undefined; - _react2['default'].Children.forEach(this.props.children, function (column, i) { - if (i == colIndex) { - fieldName = column.props.dataField; - return false; - } - }); - - var result = this.store.edit(newVal, rowIndex, fieldName).get(); - this.setState({ - data: result - }); - - if (this.props.cellEdit.afterSaveCell) { - this.props.cellEdit.afterSaveCell(this.state.data[rowIndex], fieldName, newVal); - } - } - }, { - key: 'handleAddRowBegin', - value: function handleAddRowBegin() { - if (this.refs.body) { - // this.refs.body.cancelEdit(); - } - } - }, { - key: 'handleAddRow', - value: function handleAddRow(newObj) { - var msg = null, - result = undefined; - try { - this.store.add(newObj); - } catch (e) { - return e; - } - - if (this.props.pagination) { - //if pagination is enabled and insert row be trigger, change to last page - var sizePerPage = this.refs.pagination.getSizePerPage(); - var currLastPage = Math.ceil(this.store.getDataNum() / sizePerPage); - result = this.store.page(currLastPage, sizePerPage).get(); - this.setState({ - data: result - }); - this.refs.pagination.changePage(currLastPage); - } else { - result = this.store.get(); - this.setState({ - data: result - }); - } - - if (this.props.options.afterInsertRow) { - this.props.options.afterInsertRow(newObj); - } - } - }, { - key: 'getSizePerPage', - value: function getSizePerPage() { - if (this.props.pagination) { - return this.refs.pagination.getSizePerPage(); - } - } - }, { - key: 'getCurrentPage', - value: function getCurrentPage() { - if (this.props.pagination) { - return this.refs.pagination.getCurrentPage(); - } - } - }, { - key: 'handleDropRow', - value: function handleDropRow() { - var result = undefined; - var dropRowKeys = this.store.getSelectedRowKeys(); - //add confirm befor the delete action - if (dropRowKeys && dropRowKeys.length > 0) { - if (!confirm('Are you sure want delete?')) { - return; - } - } - this.store.remove(dropRowKeys); //remove selected Row - this.store.setSelectedRowKey([]); //clear selected row key - - if (this.props.pagination) { - var sizePerPage = this.refs.pagination.getSizePerPage(); - var currLastPage = Math.ceil(this.store.getDataNum() / sizePerPage); - var currentPage = this.refs.pagination.getCurrentPage(); - if (currentPage > currLastPage) currentPage = currLastPage; - result = this.store.page(currentPage, sizePerPage).get(); - this.setState({ - data: result, - selectedRowKeys: this.store.getSelectedRowKeys() - }); - this.refs.pagination.changePage(currentPage); - } else { - result = this.store.get(); - this.setState({ - data: result, - selectedRowKeys: this.store.getSelectedRowKeys() - }); - } - if (this.props.options.afterDeleteRow) { - this.props.options.afterDeleteRow(dropRowKeys); - } - } - }, { - key: 'handleFilterData', - value: function handleFilterData(filterObj) { - this.store.filter(filterObj); - var result = undefined; - if (this.props.pagination) { - var sizePerPage = this.refs.pagination.getSizePerPage(); - result = this.store.page(1, sizePerPage).get(); - this.refs.pagination.changePage(1); - } else { - result = this.store.get(); - } - if (this.props.options.afterColumnFilter) this.props.options.afterColumnFilter(filterObj, this.store.getDataIgnoringPagination()); - this.setState({ - data: result - }); - } - }, { - key: 'handleExportCSV', - value: function handleExportCSV() { - var result = this.store.getDataIgnoringPagination(); - var keys = []; - this.props.children.map(function (column) { - if (column.props.hidden === false) { - keys.push(column.props.dataField); - } - }); - (0, _csv_export_util2['default'])(result, keys, this.props.csvFileName); - } - }, { - key: 'handleSearch', - value: function handleSearch(searchText) { - this.store.search(searchText); - var result = undefined; - if (this.props.pagination) { - var sizePerPage = this.refs.pagination.getSizePerPage(); - result = this.store.page(1, sizePerPage).get(); - this.refs.pagination.changePage(1); - } else { - result = this.store.get(); - } - if (this.props.options.afterSearch) this.props.options.afterSearch(searchText, this.store.getDataIgnoringPagination()); - this.setState({ - data: result - }); - } - }, { - key: 'renderPagination', - value: function renderPagination() { - if (this.props.pagination) { - var dataSize = undefined; - if (this.isRemoteDataSource()) { - dataSize = this.props.fetchInfo.dataTotalSize; - } else { - dataSize = this.store.getDataNum(); - } - return _react2['default'].createElement( - 'div', - null, - _react2['default'].createElement(_paginationPaginationList2['default'], { - ref: 'pagination', - currPage: this.props.options.page || 1, - changePage: this.handlePaginationData.bind(this), - sizePerPage: this.props.options.sizePerPage || _Const2['default'].SIZE_PER_PAGE_LIST[0], - sizePerPageList: this.props.options.sizePerPageList || _Const2['default'].SIZE_PER_PAGE_LIST, - paginationSize: this.props.options.paginationSize || _Const2['default'].PAGINATION_SIZE, - remote: this.isRemoteDataSource(), - dataSize: dataSize - }) - ); - } - return null; - } - }, { - key: 'renderToolBar', - value: function renderToolBar() { - var columns = undefined; - if (Array.isArray(this.props.children)) { - columns = this.props.children.map(function (column) { - var props = column.props; - return { - name: props.children, - field: props.dataField, - //when you want same auto generate value and not allow edit, example ID field - autoValue: props.autoValue || false, - //for create eidtor, no params for column.editable() indicate that editor for new row - editable: props.editable && typeof props.editable === "function" ? props.editable() : props.editable, - format: props.format ? format : false - }; - }); - } else { - columns = [{ - name: this.props.children.props.children, - field: this.props.children.props.dataField, - editable: this.props.children.props.editable - }]; - } - if (this.props.insertRow || this.props.deleteRow || this.props.search || this.props.exportCSV) { - return _react2['default'].createElement( - 'div', - { className: 'tool-bar' }, - _react2['default'].createElement(_toolbarToolBar2['default'], { - enableInsert: this.props.insertRow, - enableDelete: this.props.deleteRow, - enableSearch: this.props.search, - enableExportCSV: this.props.exportCSV, - columns: columns, - searchPlaceholder: this.props.searchPlaceholder, - onAddRow: this.handleAddRow.bind(this), - onAddRowBegin: this.handleAddRowBegin.bind(this), - onDropRow: this.handleDropRow.bind(this), - onSearch: this.handleSearch.bind(this), - onExportCSV: this.handleExportCSV.bind(this) - }) - ); - } else { - return null; - } - } - }, { - key: 'renderTableFilter', - value: function renderTableFilter(columns) { - if (this.props.columnFilter) { - return _react2['default'].createElement(_TableFilter2['default'], { columns: columns, - rowSelectType: this.props.selectRow.mode, - onFilter: this.handleFilterData.bind(this) }); - } else { - return null; - } - } - }]); - - return BootstrapTable; -})(_react2['default'].Component); - -BootstrapTable.propTypes = { - keyField: _react2['default'].PropTypes.string, - height: _react2['default'].PropTypes.string, - data: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.array, _react2['default'].PropTypes.object]), - remote: _react2['default'].PropTypes.bool, // remote data, default is false - striped: _react2['default'].PropTypes.bool, - bordered: _react2['default'].PropTypes.bool, - hover: _react2['default'].PropTypes.bool, - condensed: _react2['default'].PropTypes.bool, - pagination: _react2['default'].PropTypes.bool, - searchPlaceholder: _react2['default'].PropTypes.string, - selectRow: _react2['default'].PropTypes.shape({ - mode: _react2['default'].PropTypes.string, - bgColor: _react2['default'].PropTypes.string, - selected: _react2['default'].PropTypes.array, - onSelect: _react2['default'].PropTypes.func, - onSelectAll: _react2['default'].PropTypes.func, - clickToSelect: _react2['default'].PropTypes.bool, - hideSelectColumn: _react2['default'].PropTypes.bool, - clickToSelectAndEditCell: _react2['default'].PropTypes.bool - }), - cellEdit: _react2['default'].PropTypes.shape({ - mode: _react2['default'].PropTypes.string, - blurToSave: _react2['default'].PropTypes.bool, - afterSaveCell: _react2['default'].PropTypes.func - }), - insertRow: _react2['default'].PropTypes.bool, - deleteRow: _react2['default'].PropTypes.bool, - search: _react2['default'].PropTypes.bool, - columnFilter: _react2['default'].PropTypes.bool, - trClassName: _react2['default'].PropTypes.any, - options: _react2['default'].PropTypes.shape({ - sortName: _react2['default'].PropTypes.string, - sortOrder: _react2['default'].PropTypes.string, - afterTableComplete: _react2['default'].PropTypes.func, - afterDeleteRow: _react2['default'].PropTypes.func, - afterInsertRow: _react2['default'].PropTypes.func, - afterSearch: _react2['default'].PropTypes.func, - afterColumnFilter: _react2['default'].PropTypes.func, - onRowClick: _react2['default'].PropTypes.func, - page: _react2['default'].PropTypes.number, - sizePerPageList: _react2['default'].PropTypes.array, - sizePerPage: _react2['default'].PropTypes.number, - paginationSize: _react2['default'].PropTypes.number, - onSortChange: _react2['default'].PropTypes.func, - onPageChange: _react2['default'].PropTypes.func - }), - fetchInfo: _react2['default'].PropTypes.shape({ - dataTotalSize: _react2['default'].PropTypes.number - }), - exportCSV: _react2['default'].PropTypes.bool, - csvFileName: _react2['default'].PropTypes.string -}; -BootstrapTable.defaultProps = { - height: "100%", - striped: false, - bordered: true, - hover: false, - condensed: false, - pagination: false, - searchPlaceholder: undefined, - selectRow: { - mode: _Const2['default'].ROW_SELECT_NONE, - bgColor: _Const2['default'].ROW_SELECT_BG_COLOR, - selected: [], - onSelect: undefined, - onSelectAll: undefined, - clickToSelect: false, - hideSelectColumn: false, - clickToSelectAndEditCell: false - }, - cellEdit: { - mode: _Const2['default'].CELL_EDIT_NONE, - blurToSave: false, - afterSaveCell: undefined - }, - insertRow: false, - deleteRow: false, - search: false, - multiColumnSearch: false, - columnFilter: false, - trClassName: '', - options: { - sortName: undefined, - sortOrder: _Const2['default'].SORT_DESC, - afterTableComplete: undefined, - afterDeleteRow: undefined, - afterInsertRow: undefined, - afterSearch: undefined, - afterColumnFilter: undefined, - onRowClick: undefined, - page: 1, - sizePerPageList: _Const2['default'].SIZE_PER_PAGE_LIST, - sizePerPage: _Const2['default'].SIZE_PER_PAGE_LIST[0], - paginationSize: _Const2['default'].PAGINATION_SIZE - }, - fetchInfo: { - dataTotalSize: 0 - }, - exportCSV: false, - csvFileName: undefined -}; - -exports['default'] = BootstrapTable; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/Const.js b/lib/Const.js deleted file mode 100644 index b309e8f96..000000000 --- a/lib/Const.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports["default"] = { - SORT_DESC: "desc", - SORT_ASC: "asc", - SIZE_PER_PAGE: 10, - NEXT_PAGE: ">", - LAST_PAGE: ">>", - PRE_PAGE: "<", - FIRST_PAGE: "<<", - ROW_SELECT_BG_COLOR: "", - ROW_SELECT_NONE: "none", - ROW_SELECT_SINGLE: "radio", - ROW_SELECT_MULTI: "checkbox", - CELL_EDIT_NONE: "none", - CELL_EDIT_CLICK: "click", - CELL_EDIT_DBCLICK: "dbclick", - SIZE_PER_PAGE_LIST: [10, 25, 30, 50], - PAGINATION_SIZE: 5 -}; -module.exports = exports["default"]; \ No newline at end of file diff --git a/lib/Editor.js b/lib/Editor.js deleted file mode 100644 index 1c81f167c..000000000 --- a/lib/Editor.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var Editor = function Editor(editable, attr, format, editorClass, defaultValue) { - - if (editable === true || typeof editable === "string") { - //simple declare - var type = editable === true ? 'text' : editable; - return _react2['default'].createElement('input', _extends({}, attr, { type: type, defaultValue: defaultValue, - className: (editorClass || "") + " form-control editor edit-text" })); - } else if (!editable) { - var type = editable === true ? 'text' : editable; - return _react2['default'].createElement('input', _extends({}, attr, { type: type, defaultValue: defaultValue, disabled: 'disabled', - className: (editorClass || "") + " form-control editor edit-text" })); - } else if (editable.type) { - //standard declare - //put style if exist - editable.style && (attr.style = editable.style); - - //put class if exist - attr.className = (editorClass || "") + " form-control editor edit-" + editable.type + (editable.className ? " " + editable.className : ""); - - if (editable.type === 'select') { - //process select input - var options = [], - values = editable.options.values; - if (Array.isArray(values)) { - //only can use arrray data for options - var rowValue; - options = values.map(function (d, i) { - rowValue = format ? format(d) : d; - return _react2['default'].createElement( - 'option', - { key: 'option' + i, value: d }, - rowValue - ); - }); - } - return _react2['default'].createElement( - 'select', - _extends({}, attr, { defaultValue: defaultValue }), - options - ); - } else if (editable.type === 'textarea') { - //process textarea input - //put other if exist - editable.cols && (attr.cols = editable.cols); - editable.rows && (attr.rows = editable.rows); - var keyUpHandler = attr.onKeyDown, - saveBtn = null; - if (keyUpHandler) { - attr.onKeyDown = function (e) { - if (e.keyCode != 13) { - //not Pressed ENTER - keyUpHandler(e); - } - }; - saveBtn = _react2['default'].createElement( - 'butto', - { className: 'btn btn-info btn-xs textarea-save-btn', onClick: keyUpHandler }, - 'save' - ); - } - - return _react2['default'].createElement( - 'div', - null, - _react2['default'].createElement('textarea', _extends({}, attr, { defaultValue: defaultValue })), - saveBtn - ); - } else if (editable.type === 'checkbox') { - var _values = 'true:false'; - if (editable.options && editable.options.values) { - // values = editable.options.values.split(':'); - _values = editable.options.values; - } - attr.className = attr.className.replace('form-control', ''); - attr.className += ' checkbox pull-right'; - - var checked = defaultValue && defaultValue.toString() == _values.split(':')[0] ? true : false; - - return _react2['default'].createElement('input', _extends({}, attr, { type: 'checkbox', value: _values, defaultChecked: checked })); - } else { - //process other input type. as password,url,email... - return _react2['default'].createElement('input', _extends({}, attr, { type: type, defaultValue: defaultValue })); - } - } - //default return for other case of editable - return _react2['default'].createElement('input', _extends({}, attr, { type: 'text', className: (editorClass || "") + " form-control editor edit-text" })); -}; - -exports['default'] = Editor; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/Notification.js b/lib/Notification.js deleted file mode 100644 index cdf9378a3..000000000 --- a/lib/Notification.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _reactToastr = require('react-toastr'); - -var _reactToastr2 = _interopRequireDefault(_reactToastr); - -var ToastrContainer = _reactToastr2['default'].ToastContainer; -var ToastrMessageFactory = _react2['default'].createFactory(_reactToastr2['default'].ToastMessage.animation); - -var Notification = (function (_React$Component) { - _inherits(Notification, _React$Component); - - function Notification() { - _classCallCheck(this, Notification); - - _get(Object.getPrototypeOf(Notification.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(Notification, [{ - key: 'notice', - - // allow type is success,info,warning,error - value: function notice(type, msg, title) { - this.refs.toastr[type](msg, title, { - mode: 'single', - timeOut: 5000, - extendedTimeOut: 1000, - showAnimation: "animated bounceIn", - hideAnimation: "animated bounceOut" - }); - } - }, { - key: 'render', - value: function render() { - return _react2['default'].createElement(ToastrContainer, { ref: 'toastr', toastMessageFactory: ToastrMessageFactory, - id: 'toast-container', className: 'toast-top-right' }); - } - }]); - - return Notification; -})(_react2['default'].Component); - -exports['default'] = Notification; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/SelectRowHeaderColumn.js b/lib/SelectRowHeaderColumn.js deleted file mode 100644 index f9e288a46..000000000 --- a/lib/SelectRowHeaderColumn.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var SelectRowHeaderColumn = (function (_React$Component) { - _inherits(SelectRowHeaderColumn, _React$Component); - - function SelectRowHeaderColumn() { - _classCallCheck(this, SelectRowHeaderColumn); - - _get(Object.getPrototypeOf(SelectRowHeaderColumn.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(SelectRowHeaderColumn, [{ - key: 'render', - value: function render() { - var thStyle = { - width: 35 - }; - - return _react2['default'].createElement( - 'th', - { style: thStyle }, - _react2['default'].createElement( - 'div', - { className: 'th-inner table-header-column' }, - this.props.children - ) - ); - } - }]); - - return SelectRowHeaderColumn; -})(_react2['default'].Component); - -exports['default'] = SelectRowHeaderColumn; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableBody.js b/lib/TableBody.js deleted file mode 100644 index 395f6283b..000000000 --- a/lib/TableBody.js +++ /dev/null @@ -1,367 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _util = require('./util'); - -var _util2 = _interopRequireDefault(_util); - -var _TableRow = require('./TableRow'); - -var _TableRow2 = _interopRequireDefault(_TableRow); - -var _TableColumn = require('./TableColumn'); - -var _TableColumn2 = _interopRequireDefault(_TableColumn); - -var _TableEditColumn = require('./TableEditColumn'); - -var _TableEditColumn2 = _interopRequireDefault(_TableEditColumn); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var isFun = function isFun(obj) { - return obj && typeof obj === "function"; -}; - -var TableBody = (function (_React$Component) { - _inherits(TableBody, _React$Component); - - function TableBody(props) { - _classCallCheck(this, TableBody); - - _get(Object.getPrototypeOf(TableBody.prototype), 'constructor', this).call(this, props); - this.state = { - currEditCell: null - }; - this.editing = false; - } - - _createClass(TableBody, [{ - key: 'componentDidMount', - value: function componentDidMount() { - this.hardFixHeaderWidth(); - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate() { - this.hardFixHeaderWidth(); - } - }, { - key: 'render', - value: function render() { - var containerClasses = (0, _classnames2['default'])("table-container"); - - var tableClasses = (0, _classnames2['default'])("table", { - 'table-striped': this.props.striped, - 'table-bordered': this.props.bordered, - 'table-hover': this.props.hover, - 'table-condensed': this.props.condensed - }); - - var isSelectRowDefined = this._isSelectRowDefined(); - var tableHeader = this.renderTableHeader(isSelectRowDefined); - - var tableRows = this.props.data.map(function (data, r) { - var tableColumns = this.props.columns.map(function (column, i) { - var fieldValue = data[column.name]; - if (this.editing && column.name !== this.props.keyField && // Key field can't be edit - column.editable && // column is editable? default is true, user can set it false - this.state.currEditCell != null && this.state.currEditCell.rid == r && this.state.currEditCell.cid == i) { - var format = column.format ? function (value) { - return column.format(value, data).replace(/<.*?>/g, ''); - } : false; - - return _react2['default'].createElement( - _TableEditColumn2['default'], - { completeEdit: this.handleCompleteEditCell.bind(this), - //add by bluespring for column editor customize - editable: isFun(column.editable) ? column.editable(fieldValue, data, r, i) : column.editable, - format: column.format ? format : false, - key: i, - blurToSave: this.props.cellEdit.blurToSave, - rowIndex: r, - colIndex: i }, - fieldValue - ); - } else { - //add by bluespring for className customize - var tdClassName = isFun(column.className) ? column.className(fieldValue, data, r, i) : column.className; - - if (typeof column.format !== "undefined") { - var formattedValue = column.format(fieldValue, data); - if (!_react2['default'].isValidElement(formattedValue)) { - formattedValue = _react2['default'].createElement('div', { dangerouslySetInnerHTML: { __html: formattedValue } }); - } - return _react2['default'].createElement( - _TableColumn2['default'], - { dataAlign: column.align, - key: i, - className: tdClassName, - cellEdit: this.props.cellEdit, - onEdit: this.handleEditCell.bind(this), - width: column.width }, - formattedValue - ); - } else { - return _react2['default'].createElement( - _TableColumn2['default'], - { dataAlign: column.align, - key: i, - className: tdClassName, - cellEdit: this.props.cellEdit, - hidden: column.hidden, - onEdit: this.handleEditCell.bind(this), - width: column.width }, - fieldValue - ); - } - } - }, this); - var selected = this.props.selectedRowKeys.indexOf(data[this.props.keyField]) != -1; - var selectRowColumn = isSelectRowDefined && !this.props.selectRow.hideSelectColumn ? this.renderSelectRowColumn(selected) : null; - //add by bluespring for className customize - var trClassName = isFun(this.props.trClassName) ? this.props.trClassName(data, r) : this.props.trClassName; - return _react2['default'].createElement( - _TableRow2['default'], - { isSelected: selected, key: r, className: trClassName, - selectRow: isSelectRowDefined ? this.props.selectRow : undefined, - enableCellEdit: this.props.cellEdit.mode !== _Const2['default'].CELL_EDIT_NONE, - onRowClick: this.handleRowClick.bind(this), - onSelectRow: this.handleSelectRow.bind(this) }, - selectRowColumn, - tableColumns - ); - }, this); - - if (tableRows.length === 0) { - tableRows.push(_react2['default'].createElement( - _TableRow2['default'], - { key: '##table-empty##' }, - _react2['default'].createElement( - 'td', - { colSpan: this.props.columns.length + (isSelectRowDefined ? 1 : 0), - style: { textAlign: "center" } }, - 'There is no data to display' - ) - )); - } - - this.editing = false; - - var height = this.calculateContainerHeight().toString(); - - return _react2['default'].createElement( - 'div', - { ref: 'container', className: containerClasses, style: { height: height } }, - _react2['default'].createElement( - 'table', - { className: tableClasses }, - tableHeader, - _react2['default'].createElement( - 'tbody', - null, - tableRows - ) - ) - ); - } - }, { - key: 'renderTableHeader', - value: function renderTableHeader(isSelectRowDefined) { - var selectRowHeader = null; - - if (isSelectRowDefined) { - var style = { - width: 35, - minWidth: 35 - }; - selectRowHeader = this.props.selectRow.hideSelectColumn ? null : _react2['default'].createElement('th', { style: style, key: -1 }); - } - var theader = this.props.columns.map(function (column, i) { - var width = column.width == null ? column.width : parseInt(column.width); - var style = { - display: column.hidden ? "none" : null, - width: width, - maxWidth: width - /** add min-wdth to fix user assign column width not eq offsetWidth in large column table **/ - }; - var sortCaert = column.sort ? _util2['default'].renderReactSortCaret(_Const2['default'].SORT_DESC) : null; - return _react2['default'].createElement( - 'th', - { style: style, key: i, className: column.className }, - column.text, - sortCaert - ); - }); - - return _react2['default'].createElement( - 'thead', - { ref: 'header' }, - _react2['default'].createElement( - 'tr', - null, - selectRowHeader, - theader - ) - ); - } - }, { - key: 'handleRowClick', - value: function handleRowClick(rowIndex) { - var key, selectedRow; - this.props.data.forEach(function (row, i) { - if (i == rowIndex - 1) { - key = row[this.props.keyField]; - selectedRow = row; - } - }, this); - this.props.onRowClick(selectedRow); - } - }, { - key: 'handleSelectRow', - value: function handleSelectRow(rowIndex, isSelected) { - var key, selectedRow; - this.props.data.forEach(function (row, i) { - if (i == rowIndex - 1) { - key = row[this.props.keyField]; - selectedRow = row; - } - }, this); - this.props.onSelectRow(selectedRow, isSelected); - } - }, { - key: 'handleSelectRowColumChange', - value: function handleSelectRowColumChange(e) { - if (!this.props.selectRow.clickToSelect || !this.props.selectRow.clickToSelectAndEditCell) { - this.handleSelectRow(e.currentTarget.parentElement.parentElement.rowIndex, e.currentTarget.checked); - } - } - }, { - key: 'handleEditCell', - value: function handleEditCell(rowIndex, columnIndex) { - this.editing = true; - if (this._isSelectRowDefined()) { - columnIndex--; - if (this.props.selectRow.hideSelectColumn) columnIndex++; - } - rowIndex--; - var stateObj = { - currEditCell: { - rid: rowIndex, - cid: columnIndex - } - }; - - if (this.props.selectRow.clickToSelectAndEditCell) { - //if edit cell, trigger row selections also - var selected = this.props.selectedRowKeys.indexOf(this.props.data[rowIndex][this.props.keyField]) != -1; - this.handleSelectRow(rowIndex + 1, !selected); - } - this.setState(stateObj); - } - }, { - key: 'cancelEdit', - value: function cancelEdit() { - var currEditCell = this.state.currEditCell; - if (currEditCell) { - this.handleCompleteEditCell(null, currEditCell.rid, currEditCell.cid); - } - } - }, { - key: 'handleCompleteEditCell', - value: function handleCompleteEditCell(newVal, rowIndex, columnIndex) { - this.setState({ currEditCell: null }); - if (null != newVal) this.props.cellEdit.__onCompleteEdit__(newVal, rowIndex, columnIndex); - } - }, { - key: 'renderSelectRowColumn', - value: function renderSelectRowColumn(selected) { - if (this.props.selectRow.mode == _Const2['default'].ROW_SELECT_SINGLE) { - return _react2['default'].createElement( - _TableColumn2['default'], - null, - _react2['default'].createElement('input', { type: 'radio', name: 'selection', checked: selected, onChange: this.handleSelectRowColumChange.bind(this) }) - ); - } else { - return _react2['default'].createElement( - _TableColumn2['default'], - null, - _react2['default'].createElement('input', { type: 'checkbox', checked: selected, onChange: this.handleSelectRowColumChange.bind(this) }) - ); - } - } - }, { - key: 'getBodyHeaderDomProp', - value: function getBodyHeaderDomProp() { - var headers = this.refs.header.childNodes[0].childNodes; - var headerDomProps = []; - for (var i = 0; i < headers.length; i++) { - headerDomProps.push({ - width: headers[i].offsetWidth - }); - } - return headerDomProps; - } - }, { - key: 'hardFixHeaderWidth', - value: function hardFixHeaderWidth() { - var headers = this.refs.header.childNodes[0].childNodes; - for (var i = 0; i < headers.length; i++) { - headers[i].style.width = headers[i].offsetWidth + "px"; - } - } - }, { - key: 'calculateContainerHeight', - value: function calculateContainerHeight() { - if (this.props.height == "100%") return this.props.height;else { - return parseInt(this.props.height) - 42; - } - } - }, { - key: '_isSelectRowDefined', - value: function _isSelectRowDefined() { - return this.props.selectRow.mode == _Const2['default'].ROW_SELECT_SINGLE || this.props.selectRow.mode == _Const2['default'].ROW_SELECT_MULTI; - } - }]); - - return TableBody; -})(_react2['default'].Component); - -TableBody.propTypes = { - height: _react2['default'].PropTypes.string, - data: _react2['default'].PropTypes.array, - columns: _react2['default'].PropTypes.array, - striped: _react2['default'].PropTypes.bool, - bordered: _react2['default'].PropTypes.bool, - hover: _react2['default'].PropTypes.bool, - condensed: _react2['default'].PropTypes.bool, - keyField: _react2['default'].PropTypes.string, - selectedRowKeys: _react2['default'].PropTypes.array, - onRowClick: _react2['default'].PropTypes.func, - onSelectRow: _react2['default'].PropTypes.func -}; -exports['default'] = TableBody; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableColumn.js b/lib/TableColumn.js deleted file mode 100644 index d71ccfbba..000000000 --- a/lib/TableColumn.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var TableColumn = (function (_React$Component) { - _inherits(TableColumn, _React$Component); - - function TableColumn(props) { - _classCallCheck(this, TableColumn); - - _get(Object.getPrototypeOf(TableColumn.prototype), 'constructor', this).call(this, props); - } - - _createClass(TableColumn, [{ - key: 'handleCellEdit', - value: function handleCellEdit(e) { - if (this.props.cellEdit.mode == _Const2['default'].CELL_EDIT_DBCLICK) { - if (document.selection && document.selection.empty) { - document.selection.empty(); - } else if (window.getSelection) { - var sel = window.getSelection(); - sel.removeAllRanges(); - } - } - this.props.onEdit(e.currentTarget.parentElement.rowIndex, e.currentTarget.cellIndex); - } - }, { - key: 'render', - value: function render() { - var width = this.props.width == null ? this.props.width : parseInt(this.props.width); - var tdStyle = { - textAlign: this.props.dataAlign, - display: this.props.hidden ? "none" : null, - width: width, - maxWidth: width - }; - var classname = this.props.className; - if (this.props.width) { - classname += " col-md-" + width; - } - - var opts = {}; - if (this.props.cellEdit) { - if (this.props.cellEdit.mode == _Const2['default'].CELL_EDIT_CLICK) { - opts.onClick = this.handleCellEdit.bind(this); - } else if (this.props.cellEdit.mode == _Const2['default'].CELL_EDIT_DBCLICK) { - opts.onDoubleClick = this.handleCellEdit.bind(this); - } - } - return _react2['default'].createElement( - 'td', - _extends({ style: tdStyle, className: classname }, opts), - this.props.children - ); - } - }]); - - return TableColumn; -})(_react2['default'].Component); - -TableColumn.propTypes = { - dataAlign: _react2['default'].PropTypes.string, - hidden: _react2['default'].PropTypes.bool, - className: _react2['default'].PropTypes.string -}; - -TableColumn.defaultProps = { - dataAlign: "left", - hidden: false, - className: "" -}; -exports['default'] = TableColumn; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableEditColumn.js b/lib/TableEditColumn.js deleted file mode 100644 index cd25c8d9e..000000000 --- a/lib/TableEditColumn.js +++ /dev/null @@ -1,169 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _Editor = require('./Editor'); - -var _Editor2 = _interopRequireDefault(_Editor); - -var _NotificationJs = require('./Notification.js'); - -var _NotificationJs2 = _interopRequireDefault(_NotificationJs); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var TableEditColumn = (function (_React$Component) { - _inherits(TableEditColumn, _React$Component); - - function TableEditColumn(props) { - _classCallCheck(this, TableEditColumn); - - _get(Object.getPrototypeOf(TableEditColumn.prototype), 'constructor', this).call(this, props); - this.timeouteClear = 0; - this.state = { - shakeEditor: false - }; - } - - _createClass(TableEditColumn, [{ - key: 'handleKeyPress', - value: function handleKeyPress(e) { - if (e.keyCode == 13) { - //Pressed ENTER - var value = e.currentTarget.type == 'checkbox' ? this._getCheckBoxValue(e) : e.currentTarget.value; - - if (!this.validator(value)) { - return; - } - this.props.completeEdit(value, this.props.rowIndex, this.props.colIndex); - } else if (e.keyCode == 27) { - this.props.completeEdit(null, this.props.rowIndex, this.props.colIndex); - } - } - }, { - key: 'handleBlur', - value: function handleBlur(e) { - if (this.props.blurToSave) { - var value = e.currentTarget.type == 'checkbox' ? this._getCheckBoxValue(e) : e.currentTarget.value; - if (!this.validator(value)) { - return; - } - this.props.completeEdit(value, this.props.rowIndex, this.props.colIndex); - } - } - }, { - key: 'validator', - value: function validator(value) { - var ts = this; - if (ts.props.editable.validator) { - var valid = ts.props.editable.validator(value); - if (valid !== true) { - ts.refs.notifier.notice('error', valid, "Pressed ESC can cancel"); - var input = ts.refs.inputRef; - //animate input - ts.clearTimeout(); - ts.setState({ shakeEditor: true }); - ts.timeouteClear = setTimeout(function () { - ts.setState({ shakeEditor: false }); - }, 300); - input.focus(); - return false; - } - } - return true; - } - }, { - key: 'clearTimeout', - value: (function (_clearTimeout) { - function clearTimeout() { - return _clearTimeout.apply(this, arguments); - } - - clearTimeout.toString = function () { - return _clearTimeout.toString(); - }; - - return clearTimeout; - })(function () { - if (this.timeouteClear != 0) { - clearTimeout(this.timeouteClear); - this.timeouteClear = 0; - } - }) - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var input = this.refs.inputRef; - // input.value = this.props.children||''; - input.focus(); - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.clearTimeout(); - } - }, { - key: 'render', - value: function render() { - var editable = this.props.editable, - format = this.props.format, - attr = { - ref: "inputRef", - onKeyDown: this.handleKeyPress.bind(this), - onBlur: this.handleBlur.bind(this) - }; - //put placeholder if exist - editable.placeholder && (attr.placeholder = editable.placeholder); - - var editorClass = (0, _classnames2['default'])({ 'animated': this.state.shakeEditor, 'shake': this.state.shakeEditor }); - return _react2['default'].createElement( - 'td', - { ref: 'td', style: { position: 'relative' } }, - (0, _Editor2['default'])(editable, attr, format, editorClass, this.props.children || ''), - _react2['default'].createElement(_NotificationJs2['default'], { ref: 'notifier' }) - ); - } - }, { - key: '_getCheckBoxValue', - value: function _getCheckBoxValue(e) { - var value = ''; - var values = e.currentTarget.value.split(':'); - value = e.currentTarget.checked ? values[0] : values[1]; - return value; - } - }]); - - return TableEditColumn; -})(_react2['default'].Component); - -TableEditColumn.propTypes = { - completeEdit: _react2['default'].PropTypes.func, - rowIndex: _react2['default'].PropTypes.number, - colIndex: _react2['default'].PropTypes.number, - blurToSave: _react2['default'].PropTypes.bool -}; - -exports['default'] = TableEditColumn; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableFilter.js b/lib/TableFilter.js deleted file mode 100644 index f91215520..000000000 --- a/lib/TableFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var TableFilter = (function (_React$Component) { - _inherits(TableFilter, _React$Component); - - function TableFilter(props) { - _classCallCheck(this, TableFilter); - - _get(Object.getPrototypeOf(TableFilter.prototype), 'constructor', this).call(this, props); - this.filterObj = {}; - } - - _createClass(TableFilter, [{ - key: 'handleKeyUp', - value: function handleKeyUp(e) { - if (e.currentTarget.value.trim() === "") delete this.filterObj[e.currentTarget.name];else this.filterObj[e.currentTarget.name] = e.currentTarget.value; - - this.props.onFilter(this.filterObj); - } - }, { - key: 'render', - value: function render() { - var tableClasses = (0, _classnames2['default'])("table", { - 'table-striped': this.props.striped, - 'table-condensed': this.props.condensed - }); - var selectRowHeader = null; - - if (this.props.rowSelectType == _Const2['default'].ROW_SELECT_SINGLE || this.props.rowSelectType == _Const2['default'].ROW_SELECT_MULTI) { - var style = { - width: 35, - paddingLeft: 0, - paddingRight: 0 - }; - selectRowHeader = _react2['default'].createElement( - 'th', - { style: style, key: -1 }, - 'Filter' - ); - } - var filterField = this.props.columns.map(function (column) { - var thStyle = { - display: column.hidden ? "none" : null, - width: column.width - }; - return _react2['default'].createElement( - 'th', - { key: column.name, style: thStyle }, - _react2['default'].createElement( - 'div', - { className: 'th-inner table-header-column' }, - _react2['default'].createElement('input', { size: '10', type: 'text', placeholder: column.name, name: column.name, onKeyUp: this.handleKeyUp.bind(this) }) - ) - ); - }, this); - return _react2['default'].createElement( - 'table', - { className: tableClasses, style: { marginTop: 5 } }, - _react2['default'].createElement( - 'thead', - null, - _react2['default'].createElement( - 'tr', - { style: { borderBottomStyle: 'hidden' } }, - selectRowHeader, - filterField - ) - ) - ); - } - }]); - - return TableFilter; -})(_react2['default'].Component); - -TableFilter.propTypes = { - columns: _react2['default'].PropTypes.array, - rowSelectType: _react2['default'].PropTypes.string, - onFilter: _react2['default'].PropTypes.func -}; -exports['default'] = TableFilter; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableHeader.js b/lib/TableHeader.js deleted file mode 100644 index a8c26827e..000000000 --- a/lib/TableHeader.js +++ /dev/null @@ -1,163 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _util = require('./util'); - -var _util2 = _interopRequireDefault(_util); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _SelectRowHeaderColumn = require('./SelectRowHeaderColumn'); - -var _SelectRowHeaderColumn2 = _interopRequireDefault(_SelectRowHeaderColumn); - -var TableHeader = (function (_React$Component) { - _inherits(TableHeader, _React$Component); - - function TableHeader(props) { - _classCallCheck(this, TableHeader); - - _get(Object.getPrototypeOf(TableHeader.prototype), 'constructor', this).call(this, props); - } - - _createClass(TableHeader, [{ - key: 'clearSortCaret', - value: function clearSortCaret(order, sortField) { - var row = this.refs.header; - for (var i = 0; i < row.childElementCount; i++) { - var column = row.childNodes[i].childNodes[0]; - if (column.getElementsByClassName("order").length > 0) { - column.removeChild(column.getElementsByClassName("order")[0]); - } - } - this.props.onSort(order, sortField); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - //default sorting - if (this.props.sortName) { - this.clearSortCaret(this.props.sortOrder, this.props.sortName); - var row = this.refs.header; - for (var i = 0; i < row.childElementCount; i++) { - var column = row.childNodes[i].childNodes[0]; - if (column.getAttribute('data-field') === this.props.sortName) { - column.appendChild(_util2['default'].renderSortCaret(this.props.sortOrder)); - break; - } - } - } - } - }, { - key: 'render', - value: function render() { - var containerClasses = (0, _classnames2['default'])("table-header"); - var tableClasses = (0, _classnames2['default'])("table", "table-hover", { - "table-bordered": this.props.bordered, - "table-condensed": this.props.condensed - }); - var selectRowHeaderCol = this.props.hideSelectColumn ? null : this.renderSelectRowHeader(); - this._attachClearSortCaretFunc(); - - return _react2['default'].createElement( - 'div', - { ref: 'container', className: containerClasses }, - _react2['default'].createElement( - 'table', - { className: tableClasses }, - _react2['default'].createElement( - 'thead', - null, - _react2['default'].createElement( - 'tr', - { ref: 'header' }, - selectRowHeaderCol, - this.props.children - ) - ) - ) - ); - } - }, { - key: 'renderSelectRowHeader', - value: function renderSelectRowHeader() { - if (this.props.rowSelectType == _Const2['default'].ROW_SELECT_SINGLE) { - return _react2['default'].createElement(_SelectRowHeaderColumn2['default'], null); - } else if (this.props.rowSelectType == _Const2['default'].ROW_SELECT_MULTI) { - return _react2['default'].createElement( - _SelectRowHeaderColumn2['default'], - null, - _react2['default'].createElement('input', { type: 'checkbox', onChange: this.props.onSelectAllRow, checked: this.props.isSelectAll }) - ); - } else { - return null; - } - } - }, { - key: '_attachClearSortCaretFunc', - value: function _attachClearSortCaretFunc() { - if (Array.isArray(this.props.children)) { - for (var i = 0; i < this.props.children.length; i++) { - this.props.children[i] = _react2['default'].cloneElement(this.props.children[i], { key: i, clearSortCaret: this.clearSortCaret.bind(this) }); - } - } else { - this.props.children = _react2['default'].cloneElement(this.props.children, { key: 0, clearSortCaret: this.clearSortCaret.bind(this) }); - } - } - }, { - key: 'fitHeader', - value: function fitHeader(headerProps, isVerticalScrollBar) { - if (Array.isArray(this.props.children)) { - var startPosition = (this.props.rowSelectType == _Const2['default'].ROW_SELECT_SINGLE || this.props.rowSelectType == _Const2['default'].ROW_SELECT_MULTI) && !this.props.hideSelectColumn ? 1 : 0; - for (var i = 0; i < this.props.children.length; i++) { - this.props.children[i] = _react2['default'].cloneElement(this.props.children[i], { width: headerProps[i + startPosition].width + "px" }); - } - } else { - this.props.children = _react2['default'].cloneElement(this.props.children, { width: headerProps[0].width + "px" }); - } - this.forceUpdate(); - if (isVerticalScrollBar) this.refs.container.style.marginRight = _util2['default'].getScrollBarWidth() + "px"; - } - }]); - - return TableHeader; -})(_react2['default'].Component); - -TableHeader.propTypes = { - rowSelectType: _react2['default'].PropTypes.string, - onSort: _react2['default'].PropTypes.func, - onSelectAllRow: _react2['default'].PropTypes.func, - sortName: _react2['default'].PropTypes.string, - sortOrder: _react2['default'].PropTypes.string, - hideSelectColumn: _react2['default'].PropTypes.bool, - bordered: _react2['default'].PropTypes.bool, - condensed: _react2['default'].PropTypes.bool, - isSelectAll: _react2['default'].PropTypes.bool -}; - -TableHeader.defaultProps = {}; -exports['default'] = TableHeader; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableHeaderColumn.js b/lib/TableHeaderColumn.js deleted file mode 100644 index 0957f6111..000000000 --- a/lib/TableHeaderColumn.js +++ /dev/null @@ -1,114 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _util = require('./util'); - -var _util2 = _interopRequireDefault(_util); - -var TableHeaderColumn = (function (_React$Component) { - _inherits(TableHeaderColumn, _React$Component); - - function TableHeaderColumn() { - _classCallCheck(this, TableHeaderColumn); - - _get(Object.getPrototypeOf(TableHeaderColumn.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(TableHeaderColumn, [{ - key: 'handleColumnClick', - value: function handleColumnClick(e) { - if (!this.props.dataSort) return; - var dom = this.refs.innerDiv; - this.order = this.order == _Const2['default'].SORT_DESC ? _Const2['default'].SORT_ASC : _Const2['default'].SORT_DESC; - this.props.clearSortCaret(this.order, this.props.dataField); - dom.appendChild(_util2['default'].renderSortCaret(this.order)); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - this.refs.innerDiv.setAttribute("data-field", this.props.dataField); - } - }, { - key: 'render', - value: function render() { - var width = this.props.width !== null ? parseInt(this.props.width) : null; - var thStyle = { - textAlign: this.props.dataAlign, - display: this.props.hidden ? "none" : null, - width: width, - maxWidth: width - }; - - var classes = this.props.className + " " + (this.props.dataSort ? "sort-column" : ""); - return _react2['default'].createElement( - 'th', - { className: classes, style: thStyle }, - _react2['default'].createElement( - 'div', - { ref: 'innerDiv', className: 'th-inner table-header-column', - onClick: this.handleColumnClick.bind(this) }, - this.props.children - ) - ); - } - }]); - - return TableHeaderColumn; -})(_react2['default'].Component); - -TableHeaderColumn.propTypes = { - dataField: _react2['default'].PropTypes.string, - dataAlign: _react2['default'].PropTypes.string, - dataSort: _react2['default'].PropTypes.bool, - clearSortCaret: _react2['default'].PropTypes.func, - dataFormat: _react2['default'].PropTypes.func, - isKey: _react2['default'].PropTypes.bool, - editable: _react2['default'].PropTypes.any, - hidden: _react2['default'].PropTypes.bool, - className: _react2['default'].PropTypes.string, - width: _react2['default'].PropTypes.string, - sortFunc: _react2['default'].PropTypes.func, - columnClassName: _react2['default'].PropTypes.any -}; - -TableHeaderColumn.defaultProps = { - dataAlign: "left", - dataSort: false, - dataFormat: undefined, - isKey: false, - editable: true, - clearSortCaret: undefined, - hidden: false, - className: "", - width: null, - sortFunc: undefined, - columnClassName: '' -}; - -exports['default'] = TableHeaderColumn; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableRow.js b/lib/TableRow.js deleted file mode 100644 index 5c9d5fc18..000000000 --- a/lib/TableRow.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var TableRow = (function (_React$Component) { - _inherits(TableRow, _React$Component); - - function TableRow() { - _classCallCheck(this, TableRow); - - _get(Object.getPrototypeOf(TableRow.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(TableRow, [{ - key: 'rowClick', - value: function rowClick(e) { - if (e.target.tagName !== "INPUT") { - if (this.props.selectRow && this.props.selectRow.clickToSelect) this.props.onSelectRow(e.currentTarget.rowIndex, !this.props.isSelected); - if (this.props.onRowClick) this.props.onRowClick(e.currentTarget.rowIndex); - } - } - }, { - key: 'render', - value: function render() { - - var trCss = { - style: { - backgroundColor: this.props.isSelected ? this.props.selectRow.bgColor : null - }, - className: this.props.className || '' - }; - - if (this.props.selectRow && !this.props.enableCellEdit && (this.props.selectRow.clickToSelect || this.props.selectRow.clickToSelectAndEditCell) || this.props.onRowClick) { - return _react2['default'].createElement( - 'tr', - _extends({}, trCss, { onClick: this.rowClick.bind(this) }), - this.props.children - ); - } else { - return _react2['default'].createElement( - 'tr', - trCss, - this.props.children - ); - } - } - }]); - - return TableRow; -})(_react2['default'].Component); - -TableRow.propTypes = { - isSelected: _react2['default'].PropTypes.bool, - enableCellEdit: _react2['default'].PropTypes.bool, - onRowClick: _react2['default'].PropTypes.func, - onSelectRow: _react2['default'].PropTypes.func -}; -TableRow.defaultProps = { - onRowClick: undefined -}; -exports['default'] = TableRow; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/csv_export_util.js b/lib/csv_export_util.js deleted file mode 100644 index d7bc8d8c7..000000000 --- a/lib/csv_export_util.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -if (typeof window !== 'undefined') { - var filesaver = require('./filesaver'); - var saveAs = filesaver.saveAs; -} - -function toString(data, keys) { - var dataString = ""; - if (data.length === 0) return dataString; - - dataString += keys.join(',') + '\n'; - - data.map(function (row) { - keys.map(function (col) { - var cell = row[col] ? '"' + row[col] + '"' : ""; - dataString += cell + ','; - }); - - dataString += '\n'; - }); - - return dataString; -}; - -var exportCSV = function exportCSV(data, keys, filename) { - var dataString = toString(data, keys); - if (typeof window !== 'undefined') { - saveAs(new Blob([dataString], { type: "text/plain;charset=utf-8" }), filename || 'spreadsheet.csv'); - } -}; - -exports['default'] = exportCSV; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/filesaver.js b/lib/filesaver.js deleted file mode 100644 index 178fde166..000000000 --- a/lib/filesaver.js +++ /dev/null @@ -1,263 +0,0 @@ -/* FileSaver.js - * A saveAs() FileSaver implementation. - * 1.1.20151003 - * - * By Eli Grey, http://eligrey.com - * License: MIT - * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md - */ - -/*global self */ -/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */ - -/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ - -"use strict"; - -var saveAs = saveAs || (function (view) { - "use strict"; - // IE <10 is explicitly unsupported - if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { - return; - } - var doc = view.document, - - // only get URL when necessary in case Blob.js hasn't overridden it yet - get_URL = function get_URL() { - return view.URL || view.webkitURL || view; - }, - save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a"), - can_use_save_link = ("download" in save_link), - click = function click(node) { - var event = new MouseEvent("click"); - node.dispatchEvent(event); - }, - is_safari = /Version\/[\d\.]+.*Safari/.test(navigator.userAgent), - webkit_req_fs = view.webkitRequestFileSystem, - req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem, - throw_outside = function throw_outside(ex) { - (view.setImmediate || view.setTimeout)(function () { - throw ex; - }, 0); - }, - force_saveable_type = "application/octet-stream", - fs_min_size = 0, - - // See https://code.google.com/p/chromium/issues/detail?id=375297#c7 and - // https://github.com/eligrey/FileSaver.js/commit/485930a#commitcomment-8768047 - // for the reasoning behind the timeout and revocation flow - arbitrary_revoke_timeout = 500, - // in ms - revoke = function revoke(file) { - var revoker = function revoker() { - if (typeof file === "string") { - // file is an object URL - get_URL().revokeObjectURL(file); - } else { - // file is a File - file.remove(); - } - }; - if (view.chrome) { - revoker(); - } else { - setTimeout(revoker, arbitrary_revoke_timeout); - } - }, - dispatch = function dispatch(filesaver, event_types, event) { - event_types = [].concat(event_types); - var i = event_types.length; - while (i--) { - var listener = filesaver["on" + event_types[i]]; - if (typeof listener === "function") { - try { - listener.call(filesaver, event || filesaver); - } catch (ex) { - throw_outside(ex); - } - } - } - }, - auto_bom = function auto_bom(blob) { - // prepend BOM for UTF-8 XML and text/* types (including HTML) - if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { - return new Blob(["", blob], { type: blob.type }); - } - return blob; - }, - FileSaver = function FileSaver(blob, name, no_auto_bom) { - if (!no_auto_bom) { - blob = auto_bom(blob); - } - // First try a.download, then web filesystem, then object URLs - var filesaver = this, - type = blob.type, - blob_changed = false, - object_url, - target_view, - dispatch_all = function dispatch_all() { - dispatch(filesaver, "writestart progress write writeend".split(" ")); - }, - - // on any filesys errors revert to saving with object URLs - fs_error = function fs_error() { - if (target_view && is_safari && typeof FileReader !== "undefined") { - // Safari doesn't allow downloading of blob urls - var reader = new FileReader(); - reader.onloadend = function () { - var base64Data = reader.result; - target_view.location.href = "data:attachment/file" + base64Data.slice(base64Data.search(/[,;]/)); - filesaver.readyState = filesaver.DONE; - dispatch_all(); - }; - reader.readAsDataURL(blob); - filesaver.readyState = filesaver.INIT; - return; - } - // don't create more object URLs than needed - if (blob_changed || !object_url) { - object_url = get_URL().createObjectURL(blob); - } - if (target_view) { - target_view.location.href = object_url; - } else { - var new_tab = view.open(object_url, "_blank"); - if (new_tab == undefined && is_safari) { - //Apple do not allow window.open, see http://bit.ly/1kZffRI - view.location.href = object_url; - } - } - filesaver.readyState = filesaver.DONE; - dispatch_all(); - revoke(object_url); - }, - abortable = function abortable(func) { - return function () { - if (filesaver.readyState !== filesaver.DONE) { - return func.apply(this, arguments); - } - }; - }, - create_if_not_found = { create: true, exclusive: false }, - slice; - filesaver.readyState = filesaver.INIT; - if (!name) { - name = "download"; - } - if (can_use_save_link) { - object_url = get_URL().createObjectURL(blob); - save_link.href = object_url; - save_link.download = name; - setTimeout(function () { - click(save_link); - dispatch_all(); - revoke(object_url); - filesaver.readyState = filesaver.DONE; - }); - return; - } - // Object and web filesystem URLs have a problem saving in Google Chrome when - // viewed in a tab, so I force save with application/octet-stream - // http://code.google.com/p/chromium/issues/detail?id=91158 - // Update: Google errantly closed 91158, I submitted it again: - // https://code.google.com/p/chromium/issues/detail?id=389642 - if (view.chrome && type && type !== force_saveable_type) { - slice = blob.slice || blob.webkitSlice; - blob = slice.call(blob, 0, blob.size, force_saveable_type); - blob_changed = true; - } - // Since I can't be sure that the guessed media type will trigger a download - // in WebKit, I append .download to the filename. - // https://bugs.webkit.org/show_bug.cgi?id=65440 - if (webkit_req_fs && name !== "download") { - name += ".download"; - } - if (type === force_saveable_type || webkit_req_fs) { - target_view = view; - } - if (!req_fs) { - fs_error(); - return; - } - fs_min_size += blob.size; - req_fs(view.TEMPORARY, fs_min_size, abortable(function (fs) { - fs.root.getDirectory("saved", create_if_not_found, abortable(function (dir) { - var save = function save() { - dir.getFile(name, create_if_not_found, abortable(function (file) { - file.createWriter(abortable(function (writer) { - writer.onwriteend = function (event) { - target_view.location.href = file.toURL(); - filesaver.readyState = filesaver.DONE; - dispatch(filesaver, "writeend", event); - revoke(file); - }; - writer.onerror = function () { - var error = writer.error; - if (error.code !== error.ABORT_ERR) { - fs_error(); - } - }; - "writestart progress write abort".split(" ").forEach(function (event) { - writer["on" + event] = filesaver["on" + event]; - }); - writer.write(blob); - filesaver.abort = function () { - writer.abort(); - filesaver.readyState = filesaver.DONE; - }; - filesaver.readyState = filesaver.WRITING; - }), fs_error); - }), fs_error); - }; - dir.getFile(name, { create: false }, abortable(function (file) { - // delete file if it already exists - file.remove(); - save(); - }), abortable(function (ex) { - if (ex.code === ex.NOT_FOUND_ERR) { - save(); - } else { - fs_error(); - } - })); - }), fs_error); - }), fs_error); - }, - FS_proto = FileSaver.prototype, - saveAs = function saveAs(blob, name, no_auto_bom) { - return new FileSaver(blob, name, no_auto_bom); - }; - // IE 10+ (native saveAs) - if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { - return function (blob, name, no_auto_bom) { - if (!no_auto_bom) { - blob = auto_bom(blob); - } - return navigator.msSaveOrOpenBlob(blob, name || "download"); - }; - } - - FS_proto.abort = function () { - var filesaver = this; - filesaver.readyState = filesaver.DONE; - dispatch(filesaver, "abort"); - }; - FS_proto.readyState = FS_proto.INIT = 0; - FS_proto.WRITING = 1; - FS_proto.DONE = 2; - - FS_proto.error = FS_proto.onwritestart = FS_proto.onprogress = FS_proto.onwrite = FS_proto.onabort = FS_proto.onerror = FS_proto.onwriteend = null; - - return saveAs; -})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || undefined.content); -// `self` is undefined in Firefox for Android content script context -// while `this` is nsIContentFrameMessageManager -// with an attribute `content` that corresponds to the window - -if (typeof module !== "undefined" && module.exports) { - module.exports.saveAs = saveAs; -} else if (typeof define !== "undefined" && define !== null && define.amd != null) { - define([], function () { - return saveAs; - }); -} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 015433e43..000000000 --- a/lib/index.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _BootstrapTable = require('./BootstrapTable'); - -var _BootstrapTable2 = _interopRequireDefault(_BootstrapTable); - -var _TableHeaderColumn = require('./TableHeaderColumn'); - -var _TableHeaderColumn2 = _interopRequireDefault(_TableHeaderColumn); - -var _storeTableDataStore = require('./store/TableDataStore'); - -if (typeof window !== 'undefined') { - window.BootstrapTable = _BootstrapTable2['default']; - window.TableHeaderColumn = _TableHeaderColumn2['default']; - window.TableDataSet = _storeTableDataStore.TableDataSet; -} -exports['default'] = { - BootstrapTable: _BootstrapTable2['default'], - TableHeaderColumn: _TableHeaderColumn2['default'], - TableDataSet: _storeTableDataStore.TableDataSet -}; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/pagination/PageButton.js b/lib/pagination/PageButton.js deleted file mode 100644 index 9d7690d6e..000000000 --- a/lib/pagination/PageButton.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var PageButton = (function (_React$Component) { - _inherits(PageButton, _React$Component); - - function PageButton(props) { - _classCallCheck(this, PageButton); - - _get(Object.getPrototypeOf(PageButton.prototype), 'constructor', this).call(this, props); - } - - _createClass(PageButton, [{ - key: 'pageBtnClick', - value: function pageBtnClick(e) { - e.preventDefault(); - this.props.changePage(e.currentTarget.text); - } - }, { - key: 'render', - value: function render() { - var classes = this.props.active ? (0, _classnames2['default'])("active") : null; - return _react2['default'].createElement( - 'li', - { className: classes }, - _react2['default'].createElement( - 'a', - { href: '#', onClick: this.pageBtnClick.bind(this) }, - this.props.children - ) - ); - } - }]); - - return PageButton; -})(_react2['default'].Component); - -PageButton.propTypes = { - changePage: _react2['default'].PropTypes.func, - active: _react2['default'].PropTypes.bool -}; - -exports['default'] = PageButton; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/pagination/PaginationList.js b/lib/pagination/PaginationList.js deleted file mode 100644 index e5f47285f..000000000 --- a/lib/pagination/PaginationList.js +++ /dev/null @@ -1,212 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _PageButtonJs = require('./PageButton.js'); - -var _PageButtonJs2 = _interopRequireDefault(_PageButtonJs); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var PaginationList = (function (_React$Component) { - _inherits(PaginationList, _React$Component); - - function PaginationList(props) { - _classCallCheck(this, PaginationList); - - _get(Object.getPrototypeOf(PaginationList.prototype), 'constructor', this).call(this, props); - this.state = { - currentPage: this.props.currPage, - sizePerPage: this.props.sizePerPage - }; - } - - _createClass(PaginationList, [{ - key: 'changePage', - value: function changePage(page) { - if (page == _Const2['default'].PRE_PAGE) { - page = this.state.currentPage - 1 < 1 ? 1 : this.state.currentPage - 1; - } else if (page == _Const2['default'].NEXT_PAGE) { - page = this.state.currentPage + 1 > this.totalPages ? this.totalPages : this.state.currentPage + 1; - } else if (page == _Const2['default'].LAST_PAGE) { - page = this.totalPages; - } else if (page == _Const2['default'].FIRST_PAGE) { - page = 1; - } else { - page = parseInt(page); - } - - if (page != this.state.currentPage) { - this.setState({ currentPage: page }); - this.props.changePage(page, this.state.sizePerPage); - } - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - if (this.props.remote) { - if (nextProps.currPage || nextProps.sizePerPage) { - this.setState({ - currentPage: nextProps.currPage, - sizePerPage: nextProps.sizePerPage - }); - } - } - } - }, { - key: 'changeSizePerPage', - value: function changeSizePerPage(e) { - e.preventDefault(); - - var selectSize = parseInt(e.currentTarget.text); - if (selectSize != this.state.sizePerPage) { - this.totalPages = Math.ceil(this.props.dataSize / selectSize); - if (this.state.currentPage > this.totalPages) this.state.currentPage = this.totalPages; - - this.setState({ - sizePerPage: selectSize, - currentPage: this.state.currentPage - }); - this.props.changePage(this.state.currentPage, selectSize); - } - } - }, { - key: 'render', - value: function render() { - var _this = this; - - this.totalPages = Math.ceil(this.props.dataSize / this.state.sizePerPage); - var pageBtns = this.makePage(); - var pageListStyle = { - marginTop: "0px" //override the margin-top defined in .pagination class in bootstrap. - }; - - var sizePerPageList = this.props.sizePerPageList.map(function (sizePerPage) { - return _react2['default'].createElement( - 'li', - { key: sizePerPage, role: 'presentation' }, - _react2['default'].createElement( - 'a', - { role: 'menuitem', tabIndex: '-1', href: '#', onClick: _this.changeSizePerPage.bind(_this) }, - sizePerPage - ) - ); - }); - - return _react2['default'].createElement( - 'div', - { className: 'row' }, - this.props.sizePerPageList.length > 1 ? _react2['default'].createElement( - 'div', - { className: 'col-md-1' }, - _react2['default'].createElement( - 'div', - { className: 'dropdown' }, - _react2['default'].createElement( - 'button', - { className: 'btn btn-default dropdown-toggle', type: 'button', id: 'pageDropDown', 'data-toggle': 'dropdown', - 'aria-expanded': 'true' }, - this.state.sizePerPage, - _react2['default'].createElement('span', { className: 'caret' }) - ), - _react2['default'].createElement( - 'ul', - { className: 'dropdown-menu', role: 'menu', 'aria-labelledby': 'pageDropDown' }, - sizePerPageList - ) - ) - ) : "", - _react2['default'].createElement( - 'div', - { className: 'col-md-6' }, - _react2['default'].createElement( - 'ul', - { className: 'pagination', style: pageListStyle }, - pageBtns - ) - ) - ); - } - }, { - key: 'makePage', - value: function makePage() { - var pages = this.getPages(); - return pages.map(function (page) { - var isActive = page === this.state.currentPage; - return _react2['default'].createElement( - _PageButtonJs2['default'], - { changePage: this.changePage.bind(this), active: isActive, key: page }, - page - ); - }, this); - } - }, { - key: 'getPages', - value: function getPages() { - var startPage = 1, - endPage = this.totalPages; - - startPage = Math.max(this.state.currentPage - Math.floor(this.props.paginationSize / 2), 1); - endPage = startPage + this.props.paginationSize - 1; - - if (endPage > this.totalPages) { - endPage = this.totalPages; - startPage = endPage - this.props.paginationSize + 1; - } - var pages = [_Const2['default'].FIRST_PAGE, _Const2['default'].PRE_PAGE]; - for (var i = startPage; i <= endPage; i++) { - if (i > 0) pages.push(i); - } - pages.push(_Const2['default'].NEXT_PAGE); - pages.push(_Const2['default'].LAST_PAGE); - return pages; - } - }, { - key: 'getCurrentPage', - value: function getCurrentPage() { - return this.state.currentPage; - } - }, { - key: 'getSizePerPage', - value: function getSizePerPage() { - return this.state.sizePerPage; - } - }]); - - return PaginationList; -})(_react2['default'].Component); - -PaginationList.propTypes = { - currPage: _react2['default'].PropTypes.number, - sizePerPage: _react2['default'].PropTypes.number, - dataSize: _react2['default'].PropTypes.number, - changePage: _react2['default'].PropTypes.func, - sizePerPageList: _react2['default'].PropTypes.array, - paginationSize: _react2['default'].PropTypes.number, - remote: _react2['default'].PropTypes.bool -}; - -PaginationList.defaultProps = { - sizePerPage: _Const2['default'].SIZE_PER_PAGE -}; - -exports['default'] = PaginationList; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/store/TableDataStore.js b/lib/store/TableDataStore.js deleted file mode 100644 index d70968152..000000000 --- a/lib/store/TableDataStore.js +++ /dev/null @@ -1,311 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _Const = require("../Const"); - -var _Const2 = _interopRequireDefault(_Const); - -var EventEmitter = require('events').EventEmitter; - -function _sort(arr, sortField, order, sortFunc) { - order = order.toLowerCase(); - arr.sort(function (a, b) { - if (sortFunc) { - return sortFunc(a, b, order); - } else { - if (order == _Const2['default'].SORT_DESC) { - return a[sortField] > b[sortField] ? -1 : a[sortField] < b[sortField] ? 1 : 0; - } else { - return a[sortField] < b[sortField] ? -1 : a[sortField] > b[sortField] ? 1 : 0; - } - } - }); - - return arr; -} - -var TableDataSet = (function (_EventEmitter) { - _inherits(TableDataSet, _EventEmitter); - - function TableDataSet(data) { - _classCallCheck(this, TableDataSet); - - _get(Object.getPrototypeOf(TableDataSet.prototype), 'constructor', this).call(this, data); - this.data = data; - } - - _createClass(TableDataSet, [{ - key: 'setData', - value: function setData(data) { - this.emit('change', data); - } - }, { - key: 'clear', - value: function clear() { - this.data = null; - } - }, { - key: 'getData', - value: function getData() { - return this.data; - } - }]); - - return TableDataSet; -})(EventEmitter); - -exports.TableDataSet = TableDataSet; - -var TableDataStore = (function () { - function TableDataStore(data) { - _classCallCheck(this, TableDataStore); - - this.data = data; - this.customSortFuncMap = null; - this.filteredData = null; - this.isOnFilter = false; - this.filterObj = null; - this.searchText = null; - this.sortObj = null; - this.pageObj = {}; - this.selected = []; - this.multiColumnSearch = false; - this.remote = false; // remote data - } - - _createClass(TableDataStore, [{ - key: 'setProps', - value: function setProps(props) { - this.keyField = props.keyField; - this.enablePagination = props.isPagination; - this.customSortFuncMap = props.customSortFuncMap; - this.remote = props.remote; - this.multiColumnSearch = props.multiColumnSearch; - } - }, { - key: 'setData', - value: function setData(data) { - this.data = data; - if (this.isOnFilter) { - if (null !== this.filterObj) this.filter(this.filterObj); - if (null !== this.searchText) this.search(this.searchText); - } - if (this.sortObj) { - this.sort(this.sortObj.order, this.sortObj.sortField); - } - } - }, { - key: 'setSelectedRowKey', - value: function setSelectedRowKey(selectedRowKeys) { - this.selected = selectedRowKeys; - } - }, { - key: 'getSelectedRowKeys', - value: function getSelectedRowKeys() { - return this.selected; - } - }, { - key: 'getCurrentDisplayData', - value: function getCurrentDisplayData() { - if (this.isOnFilter) return this.filteredData;else return this.data; - } - }, { - key: 'sort', - value: function sort(order, sortField) { - this.sortObj = { - order: order, - sortField: sortField - }; - - var currentDisplayData = this.getCurrentDisplayData(); - var sortFunc = this.customSortFuncMap[sortField]; - currentDisplayData = _sort(currentDisplayData, sortField, order, sortFunc); - - return this; - } - }, { - key: 'page', - value: function page(_page, sizePerPage) { - this.pageObj.end = _page * sizePerPage - 1; - this.pageObj.start = this.pageObj.end - (sizePerPage - 1); - return this; - } - }, { - key: 'edit', - value: function edit(newVal, rowIndex, fieldName) { - var currentDisplayData = this.getCurrentDisplayData(); - var rowKeyCache = undefined; - if (!this.enablePagination) { - currentDisplayData[rowIndex][fieldName] = newVal; - rowKeyCache = currentDisplayData[rowIndex][this.keyField]; - } else { - currentDisplayData[this.pageObj.start + rowIndex][fieldName] = newVal; - rowKeyCache = currentDisplayData[this.pageObj.start + rowIndex][this.keyField]; - } - if (this.isOnFilter) { - this.data.forEach(function (row) { - if (row[this.keyField] === rowKeyCache) { - row[this.keyField][fieldName] = newVal; - } - }, this); - } - return this; - } - }, { - key: 'add', - value: function add(newObj) { - if (newObj[this.keyField].trim() === "") { - throw this.keyField + " can't be empty value."; - } - var currentDisplayData = this.getCurrentDisplayData(); - currentDisplayData.forEach(function (row) { - if (row[this.keyField].toString() === newObj[this.keyField]) { - throw this.keyField + " " + newObj[this.keyField] + " already exists"; - } - }, this); - - currentDisplayData.push(newObj); - if (this.isOnFilter) { - this.data.push(newObj); - } - } - }, { - key: 'remove', - value: function remove(rowKey) { - var currentDisplayData = this.getCurrentDisplayData(); - var result = currentDisplayData.filter(function (row) { - return rowKey.indexOf(row[this.keyField]) == -1; - }, this); - - if (this.isOnFilter) { - this.data = this.data.filter(function (row) { - return rowKey.indexOf(row[this.keyField]) == -1; - }, this); - this.filteredData = result; - } else { - this.data = result; - } - } - }, { - key: 'filter', - value: function filter(filterObj) { - if (Object.keys(filterObj).length == 0) { - this.filteredData = null; - this.isOnFilter = false; - this.filterObj = null; - } else { - this.filterObj = filterObj; - this.filteredData = this.data.filter(function (row) { - var valid = true; - for (var key in filterObj) { - if (row[key].toString().toLowerCase().indexOf(filterObj[key].toLowerCase()) == -1) { - valid = false; - break; - } - } - return valid; - }); - this.isOnFilter = true; - } - } - }, { - key: 'search', - value: function search(searchText) { - if (searchText.trim() === "") { - this.filteredData = null; - this.isOnFilter = false; - this.searchText = null; - } else { - this.searchText = searchText; - var searchTextArray = []; - this.filteredData = this.data.filter(function (row) { - var valid = false; - - if (this.multiColumnSearch) { - searchTextArray = searchText.split(' '); - } else { - searchTextArray.push(searchText); - } - - for (var key in row) { - if (row[key]) { - searchTextArray.forEach(function (text) { - if (row[key].toString().toLowerCase().indexOf(text.toLowerCase()) !== -1) { - valid = true; - } - }); - if (valid) break; - } - } - return valid; - }, this); - this.isOnFilter = true; - } - } - }, { - key: 'getDataIgnoringPagination', - value: function getDataIgnoringPagination() { - var _data = this.getCurrentDisplayData(); - return _data; - } - }, { - key: 'get', - value: function get() { - var _data = this.getCurrentDisplayData(); - - if (_data.length == 0) return _data; - - if (this.remote || !this.enablePagination) { - return _data; - } else { - var result = []; - for (var i = this.pageObj.start; i <= this.pageObj.end; i++) { - result.push(_data[i]); - if (i + 1 == _data.length) break; - } - return result; - } - } - }, { - key: 'getKeyField', - value: function getKeyField() { - return this.keyField; - } - }, { - key: 'getDataNum', - value: function getDataNum() { - return this.getCurrentDisplayData().length; - } - }, { - key: 'isChangedPage', - value: function isChangedPage() { - return this.pageObj.start && this.pageObj.end ? true : false; - } - }, { - key: 'getAllRowkey', - value: function getAllRowkey() { - return this.data.map(function (row) { - return row[this.keyField]; - }, this); - } - }]); - - return TableDataStore; -})(); - -exports.TableDataStore = TableDataStore; - -; \ No newline at end of file diff --git a/lib/toolbar/ToolBar.js b/lib/toolbar/ToolBar.js deleted file mode 100644 index 8f1f63df1..000000000 --- a/lib/toolbar/ToolBar.js +++ /dev/null @@ -1,336 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _Editor = require('../Editor'); - -var _Editor2 = _interopRequireDefault(_Editor); - -var _NotificationJs = require('../Notification.js'); - -var _NotificationJs2 = _interopRequireDefault(_NotificationJs); - -var ToolBar = (function (_React$Component) { - _inherits(ToolBar, _React$Component); - - function ToolBar(props) { - _classCallCheck(this, ToolBar); - - _get(Object.getPrototypeOf(ToolBar.prototype), 'constructor', this).call(this, props); - this.timeouteClear = 0; - this.state = { - isInsertRowTrigger: true, - validateState: null, - shakeEditor: false - }; - } - - _createClass(ToolBar, [{ - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.clearTimeout(); - } - }, { - key: 'clearTimeout', - value: (function (_clearTimeout) { - function clearTimeout() { - return _clearTimeout.apply(this, arguments); - } - - clearTimeout.toString = function () { - return _clearTimeout.toString(); - }; - - return clearTimeout; - })(function () { - if (this.timeouteClear) { - clearTimeout(this.timeouteClear); - this.timeouteClear = 0; - } - }) - }, { - key: 'checkAndParseForm', - value: function checkAndParseForm() { - var ts = this, - newObj = {}, - isValid = true, - tempValue, - tempMsg, - validateState = {}; - this.props.columns.forEach(function (column, i) { - if (column.autoValue) { - //when you want same auto generate value and not allow edit, example ID field - tempValue = typeof column.autoValue == 'function' ? column.autoValue() : 'autovalue-' + new Date().getTime(); - } else { - var dom = this.refs[column.field + i]; - tempValue = dom.value; - - if (column.editable && column.editable.type == 'checkbox') { - var values = dom.value.split(':'); - tempValue = dom.checked ? values[0] : values[1]; - } - - if (column.editable && column.editable.validator) { - //process validate - tempMsg = column.editable.validator(tempValue); - if (tempMsg !== true) { - isValid = false; - validateState[column.field] = tempMsg; - } - } - } - - newObj[column.field] = tempValue; - }, this); - - if (isValid) { - return newObj; - } else { - ts.clearTimeout(); - //show error in form and shake it - this.setState({ validateState: validateState, shakeEditor: true }); - //notifier error - ts.refs.notifier.notice('error', "Form validate errors, please checking!", "Pressed ESC can cancel"); - //clear animate class - ts.timeouteClear = setTimeout(function () { - ts.setState({ shakeEditor: false }); - }, 300); - return null; - } - } - }, { - key: 'handleSaveBtnClick', - value: function handleSaveBtnClick(e) { - var newObj = this.checkAndParseForm(); - if (!newObj) { - //validate errors - return; - } - var msg = this.props.onAddRow(newObj); - if (msg) { - var ts = this; - ts.refs.notifier.notice('error', msg, "Pressed ESC can cancel"); - ts.clearTimeout(); - //shake form and hack prevent modal hide - ts.setState({ shakeEditor: true, validateState: "this is hack for prevent bootstrap modal hide" }); - //clear animate class - ts.timeouteClear = setTimeout(function () { - ts.setState({ shakeEditor: false }); - }, 300); - } else { - //reset state and hide modal hide - this.setState({ - validateState: null, - shakeEditor: false - }); - //reset form - this.refs.form.reset(); - } - } - }, { - key: 'handleDropRowBtnClick', - value: function handleDropRowBtnClick(e) { - this.props.onDropRow(); - } - }, { - key: 'handleCloseBtn', - value: function handleCloseBtn(e) { - this.refs.warning.style.display = "none"; - } - }, { - key: 'handleKeyUp', - value: function handleKeyUp(e) { - this.props.onSearch(e.currentTarget.value); - } - }, { - key: 'handleExportCSV', - value: function handleExportCSV() { - this.props.onExportCSV(); - } - }, { - key: 'render', - value: function render() { - var modalClassName = "bs-table-modal-sm" + new Date().getTime(); - var insertBtn = this.props.enableInsert ? _react2['default'].createElement( - 'button', - { type: 'button', onClick: this.props.onAddRowBegin, className: 'btn btn-info', 'data-toggle': 'modal', 'data-target': '.' + modalClassName }, - _react2['default'].createElement('i', { className: 'glyphicon glyphicon-plus' }), - ' New' - ) : null; - - var deleteBtn = this.props.enableDelete ? _react2['default'].createElement( - 'button', - { type: 'button', className: 'btn btn-warning', 'data-toggle': 'tooltip', 'data-placement': 'right', title: 'Drop selected row', - onClick: this.handleDropRowBtnClick.bind(this) }, - _react2['default'].createElement('i', { className: 'glyphicon glyphicon-trash' }), - ' Delete' - ) : null; - var searchTextInput = this.props.enableSearch ? _react2['default'].createElement('input', { type: 'text', placeholder: this.props.searchPlaceholder ? this.props.searchPlaceholder : 'Search', onKeyUp: this.handleKeyUp.bind(this) }) : null; - var modal = this.props.enableInsert ? this.renderInsertRowModal(modalClassName) : null; - var warningStyle = { - display: "none", - marginBottom: 0 - }; - - var exportCSV = this.props.enableExportCSV ? _react2['default'].createElement( - 'button', - { type: 'button', className: 'btn btn-success', onClick: this.handleExportCSV.bind(this) }, - _react2['default'].createElement('i', { className: 'glyphicon glyphicon-export' }), - ' Export to CSV' - ) : null; - - return _react2['default'].createElement( - 'div', - null, - _react2['default'].createElement( - 'div', - { className: 'btn-group btn-group-xs', role: 'group', 'aria-label': '...' }, - exportCSV, - insertBtn, - deleteBtn - ), - searchTextInput, - _react2['default'].createElement(_NotificationJs2['default'], { ref: 'notifier' }), - modal - ); - } - }, { - key: 'renderInsertRowModal', - value: function renderInsertRowModal(modalClassName) { - var validateState = this.state.validateState || {}; - var inputField = this.props.columns.map(function (column, i) { - var editable = column.editable, - format = column.format, - attr = { ref: column.field + i, placeholder: editable.placeholder ? editable.placeholder : column.name }; - - if (column.autoValue) { - //when you want same auto generate value and not allow edit, example ID field - return null; - } - var error = validateState[column.field] ? _react2['default'].createElement( - 'span', - { className: 'help-block bg-danger' }, - validateState[column.field] - ) : null; - - // let editor = Editor(editable,attr,format); - // if(editor.props.type && editor.props.type == 'checkbox'){ - return _react2['default'].createElement( - 'div', - { className: 'form-group', key: column.field }, - _react2['default'].createElement( - 'label', - null, - column.name - ), - (0, _Editor2['default'])(editable, attr, format, ''), - error - ); - }); - var modalClass = (0, _classnames2['default'])("modal", "fade", modalClassName, { - 'in': this.state.shakeEditor || this.state.validateState //hack prevent bootstrap modal hide by reRender - }); - var dialogClass = (0, _classnames2['default'])("modal-dialog", "modal-sm", { - "animated": this.state.shakeEditor, - "shake": this.state.shakeEditor - }); - return _react2['default'].createElement( - 'div', - { ref: 'modal', className: modalClass, tabIndex: '-1', role: 'dialog' }, - _react2['default'].createElement( - 'div', - { className: dialogClass }, - _react2['default'].createElement( - 'div', - { className: 'modal-content' }, - _react2['default'].createElement( - 'div', - { className: 'modal-header' }, - _react2['default'].createElement( - 'button', - { type: 'button', className: 'close', 'data-dismiss': 'modal', 'aria-label': 'Close' }, - _react2['default'].createElement( - 'span', - { 'aria-hidden': 'true' }, - '×' - ) - ), - _react2['default'].createElement( - 'h4', - { className: 'modal-title' }, - 'New Record' - ) - ), - _react2['default'].createElement( - 'div', - { className: 'modal-body' }, - _react2['default'].createElement( - 'form', - { ref: 'form' }, - inputField - ) - ), - _react2['default'].createElement( - 'div', - { className: 'modal-footer' }, - _react2['default'].createElement( - 'button', - { type: 'button', className: 'btn btn-default', 'data-dismiss': 'modal' }, - 'Close' - ), - _react2['default'].createElement( - 'button', - { type: 'button', className: 'btn btn-info', onClick: this.handleSaveBtnClick.bind(this) }, - 'Save' - ) - ) - ) - ) - ); - } - }]); - - return ToolBar; -})(_react2['default'].Component); - -ToolBar.propTypes = { - onAddRow: _react2['default'].PropTypes.func, - onDropRow: _react2['default'].PropTypes.func, - enableInsert: _react2['default'].PropTypes.bool, - enableDelete: _react2['default'].PropTypes.bool, - enableSearch: _react2['default'].PropTypes.bool, - columns: _react2['default'].PropTypes.array, - searchPlaceholder: _react2['default'].PropTypes.string -}; - -ToolBar.defaultProps = { - enableInsert: false, - enableDelete: false, - enableSearch: false -}; -exports['default'] = ToolBar; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/util.js b/lib/util.js deleted file mode 100644 index 7b0b08eae..000000000 --- a/lib/util.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -exports['default'] = { - - renderSortCaret: function renderSortCaret(order) { - var wrap = document.createElement("span"); - wrap.className = "order"; - if (order == _Const2['default'].SORT_ASC) wrap.className += " dropup"; - var inner = document.createElement("span"); - inner.className = "caret"; - inner.style.margin = "10px 5px"; - wrap.appendChild(inner); - return wrap; - }, - - renderReactSortCaret: function renderReactSortCaret(order) { - var orderClass = (0, _classnames2['default'])("order", { - 'dropup': order == _Const2['default'].SORT_ASC - }); - return _react2['default'].createElement( - 'span', - { className: orderClass }, - _react2['default'].createElement('span', { className: 'caret', style: { margin: '10px 5px' } }) - ); - }, - - getScrollBarWidth: function getScrollBarWidth() { - var inner = document.createElement('p'); - inner.style.width = "100%"; - inner.style.height = "200px"; - - var outer = document.createElement('div'); - outer.style.position = "absolute"; - outer.style.top = "0px"; - outer.style.left = "0px"; - outer.style.visibility = "hidden"; - outer.style.width = "200px"; - outer.style.height = "150px"; - outer.style.overflow = "hidden"; - outer.appendChild(inner); - - document.body.appendChild(outer); - var w1 = inner.offsetWidth; - outer.style.overflow = 'scroll'; - var w2 = inner.offsetWidth; - if (w1 == w2) w2 = outer.clientWidth; - - document.body.removeChild(outer); - - return w1 - w2; - } - -}; -module.exports = exports['default']; \ No newline at end of file diff --git a/package.json b/package.json index 54744fe11..611cdda42 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-bootstrap-table", "version": "1.2.15", "description": "It' a react table for bootstrap", - "main": "./lib/index.js", + "main": "./dist/react-bootstrap-table.min.js", "repository": { "type": "git", "url": "https://github.com/AllenFang/react-bootstrap-table.git" @@ -21,7 +21,6 @@ "files": [ "README.md", "dist/", - "lib/", "css/" ], "author": "AllenFang",