From e00f585338104ea3f022a99bd1f1af87b0c940eb Mon Sep 17 00:00:00 2001 From: AllenFang Date: Wed, 14 Dec 2016 23:35:10 +0800 Subject: [PATCH] rm lib --- lib/BootstrapTable.js | 1465 ------------------------------ lib/Const.js | 55 -- lib/Editor.js | 135 --- lib/ExpandComponent.js | 75 -- lib/Filter.js | 80 -- lib/Notification.js | 76 -- lib/SelectRowHeaderColumn.js | 61 -- lib/TableBody.js | 465 ---------- lib/TableColumn.js | 158 ---- lib/TableEditColumn.js | 244 ----- lib/TableFilter.js | 147 --- lib/TableHeader.js | 192 ---- lib/TableHeaderColumn.js | 357 -------- lib/TableRow.js | 177 ---- lib/csv_export_util.js | 72 -- lib/filesaver.js | 275 ------ lib/filters/Date.js | 198 ---- lib/filters/Number.js | 245 ----- lib/filters/Regex.js | 123 --- lib/filters/Select.js | 141 --- lib/filters/Text.js | 123 --- lib/index.js | 32 - lib/pagination/PageButton.js | 92 -- lib/pagination/PaginationList.js | 331 ------- lib/store/TableDataStore.js | 676 -------------- lib/toolbar/ToolBar.js | 578 ------------ lib/util.js | 72 -- 27 files changed, 6645 deletions(-) delete mode 100644 lib/BootstrapTable.js delete mode 100644 lib/Const.js delete mode 100644 lib/Editor.js delete mode 100644 lib/ExpandComponent.js delete mode 100644 lib/Filter.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/filters/Date.js delete mode 100644 lib/filters/Number.js delete mode 100644 lib/filters/Regex.js delete mode 100644 lib/filters/Select.js delete mode 100644 lib/filters/Text.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/lib/BootstrapTable.js b/lib/BootstrapTable.js deleted file mode 100644 index 06c9db3c5..000000000 --- a/lib/BootstrapTable.js +++ /dev/null @@ -1,1465 +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 _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 _PaginationList = require('./pagination/PaginationList'); - -var _PaginationList2 = _interopRequireDefault(_PaginationList); - -var _ToolBar = require('./toolbar/ToolBar'); - -var _ToolBar2 = _interopRequireDefault(_ToolBar); - -var _TableFilter = require('./TableFilter'); - -var _TableFilter2 = _interopRequireDefault(_TableFilter); - -var _TableDataStore = require('./store/TableDataStore'); - -var _util = require('./util'); - -var _util2 = _interopRequireDefault(_util); - -var _csv_export_util = require('./csv_export_util'); - -var _csv_export_util2 = _interopRequireDefault(_csv_export_util); - -var _Filter = require('./Filter'); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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; } /* eslint no-alert: 0 */ -/* eslint max-len: 0 */ - - -var BootstrapTable = function (_Component) { - _inherits(BootstrapTable, _Component); - - function BootstrapTable(props) { - _classCallCheck(this, BootstrapTable); - - var _this = _possibleConstructorReturn(this, (BootstrapTable.__proto__ || Object.getPrototypeOf(BootstrapTable)).call(this, props)); - - _this.handleSort = function () { - return _this.__handleSort__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handlePaginationData = function () { - return _this.__handlePaginationData__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleMouseLeave = function () { - return _this.__handleMouseLeave__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleMouseEnter = function () { - return _this.__handleMouseEnter__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowMouseOut = function () { - return _this.__handleRowMouseOut__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowMouseOver = function () { - return _this.__handleRowMouseOver__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowClick = function () { - return _this.__handleRowClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowDoubleClick = function () { - return _this.__handleRowDoubleClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleSelectAllRow = function () { - return _this.__handleSelectAllRow__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleShowOnlySelected = function () { - return _this.__handleShowOnlySelected__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleSelectRow = function () { - return _this.__handleSelectRow__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleAddRow = function () { - return _this.__handleAddRow__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.getPageByRowKey = function () { - return _this.__getPageByRowKey__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleDropRow = function () { - return _this.__handleDropRow__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleFilterData = function () { - return _this.__handleFilterData__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleExportCSV = function () { - return _this.__handleExportCSV__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleSearch = function () { - return _this.__handleSearch__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this._scrollTop = function () { - return _this.___scrollTop__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this._scrollHeader = function () { - return _this.___scrollHeader__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this._adjustTable = function () { - return _this.___adjustTable__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this._adjustHeaderWidth = function () { - return _this.___adjustHeaderWidth__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this._adjustHeight = function () { - return _this.___adjustHeight__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.isIE = false; - _this._attachCellEditFunc(); - if (_util2.default.canUseDOM()) { - _this.isIE = document.documentMode; - } - _this.store = new _TableDataStore.TableDataStore(_this.props.data.slice()); - - _this.initTable(_this.props); - - if (_this.props.selectRow && _this.props.selectRow.selected) { - var copy = _this.props.selectRow.selected.slice(); - _this.store.setSelectedRowKey(copy); - } - var currPage = _Const2.default.PAGE_START_INDEX; - if (typeof _this.props.options.page !== 'undefined') { - currPage = _this.props.options.page; - } else if (typeof _this.props.options.pageStartIndex !== 'undefined') { - currPage = _this.props.options.pageStartIndex; - } - - _this.state = { - data: _this.getTableData(), - currPage: currPage, - sizePerPage: _this.props.options.sizePerPage || _Const2.default.SIZE_PER_PAGE_LIST[0], - selectedRowKeys: _this.store.getSelectedRowKeys() - }; - return _this; - } - - _createClass(BootstrapTable, [{ - key: 'initTable', - value: function initTable(props) { - var _this2 = this; - - var keyField = props.keyField; - - - var isKeyFieldDefined = typeof keyField === 'string' && keyField.length; - _react2.default.Children.forEach(props.children, function (column) { - if (column.props.isKey) { - if (keyField) { - throw new Error('Error. Multiple key column be detected in TableHeaderColumn.'); - } - keyField = column.props.dataField; - } - if (column.props.filter) { - // a column contains a filter - if (!_this2.filter) { - // first time create the filter on the BootstrapTable - _this2.filter = new _Filter.Filter(); - } - // pass the filter to column with filter - column.props.filter.emitter = _this2.filter; - } - }); - - if (this.filter) { - this.filter.removeAllListeners('onFilterChange'); - this.filter.on('onFilterChange', function (currentFilter) { - _this2.handleFilterData(currentFilter); - }); - } - - this.colInfos = this.getColumnsDescription(props).reduce(function (prev, curr) { - prev[curr.name] = curr; - return prev; - }, {}); - - if (!isKeyFieldDefined && !keyField) { - throw new Error('Error. No any key column defined in TableHeaderColumn.\n Use \'isKey={true}\' to specify a unique column after version 0.5.4.'); - } - - this.store.setProps({ - isPagination: props.pagination, - keyField: keyField, - colInfos: this.colInfos, - multiColumnSearch: props.multiColumnSearch, - remote: this.isRemoteDataSource() - }); - } - }, { - key: 'getTableData', - value: function getTableData() { - var result = []; - var _props = this.props, - options = _props.options, - pagination = _props.pagination; - - var sortName = options.defaultSortName || options.sortName; - var sortOrder = options.defaultSortOrder || options.sortOrder; - var searchText = options.defaultSearch; - if (sortName && sortOrder) { - this.store.sort(sortOrder, sortName); - } - - if (searchText) { - this.store.search(searchText); - } - - if (pagination) { - var page = void 0; - var sizePerPage = void 0; - if (this.store.isChangedPage()) { - sizePerPage = this.state.sizePerPage; - page = this.state.currPage; - } else { - sizePerPage = options.sizePerPage || _Const2.default.SIZE_PER_PAGE_LIST[0]; - page = options.page || 1; - } - result = this.store.page(page, sizePerPage).get(); - } else { - result = this.store.get(); - } - return result; - } - }, { - key: 'getColumnsDescription', - value: function getColumnsDescription(_ref) { - var children = _ref.children; - - return _react2.default.Children.map(children, function (column, i) { - return { - name: column.props.dataField, - align: column.props.dataAlign, - sort: column.props.dataSort, - format: column.props.dataFormat, - formatExtraData: column.props.formatExtraData, - filterFormatted: column.props.filterFormatted, - filterValue: column.props.filterValue, - editable: column.props.editable, - customEditor: column.props.customEditor, - hidden: column.props.hidden, - hiddenOnInsert: column.props.hiddenOnInsert, - searchable: column.props.searchable, - className: column.props.columnClassName, - columnTitle: column.props.columnTitle, - width: column.props.width, - text: column.props.children, - sortFunc: column.props.sortFunc, - sortFuncExtraData: column.props.sortFuncExtraData, - export: column.props.export, - index: i - }; - }); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - this.initTable(nextProps); - var options = nextProps.options, - selectRow = nextProps.selectRow; - - - this.store.setData(nextProps.data.slice()); - - // from #481 - var page = this.state.currPage; - if (this.props.options.page !== options.page) { - page = options.page; - } - // from #481 - var sizePerPage = this.state.sizePerPage; - if (this.props.options.sizePerPage !== options.sizePerPage) { - sizePerPage = options.sizePerPage; - } - - if (this.isRemoteDataSource()) { - this.setState({ - data: nextProps.data.slice(), - currPage: page, - sizePerPage: sizePerPage - }); - } else { - // #125 - // remove !options.page for #709 - if (page > Math.ceil(nextProps.data.length / sizePerPage)) { - page = 1; - } - var sortInfo = this.store.getSortInfo(); - var sortField = options.sortName || (sortInfo ? sortInfo.sortField : undefined); - var sortOrder = options.sortOrder || (sortInfo ? sortInfo.order : undefined); - if (sortField && sortOrder) this.store.sort(sortOrder, sortField); - var data = this.store.page(page, sizePerPage).get(); - this.setState({ - data: data, - currPage: page, - sizePerPage: sizePerPage - }); - } - - if (selectRow && selectRow.selected) { - // set default select rows to store. - var copy = selectRow.selected.slice(); - this.store.setSelectedRowKey(copy); - this.setState({ - selectedRowKeys: copy - }); - } - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - this._adjustTable(); - window.addEventListener('resize', this._adjustTable); - this.refs.body.refs.container.addEventListener('scroll', this._scrollHeader); - if (this.props.scrollTop) { - this._scrollTop(); - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - window.removeEventListener('resize', this._adjustTable); - this.refs.body.refs.container.removeEventListener('scroll', this._scrollHeader); - if (this.filter) { - this.filter.removeAllListeners('onFilterChange'); - } - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate() { - this._adjustTable(); - this._attachCellEditFunc(); - if (this.props.options.afterTableComplete) { - this.props.options.afterTableComplete(); - } - } - }, { - key: '_attachCellEditFunc', - value: function _attachCellEditFunc() { - var cellEdit = this.props.cellEdit; - - if (cellEdit) { - this.props.cellEdit.__onCompleteEdit__ = this.handleEditCell.bind(this); - if (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 style = { - height: this.props.height, - maxHeight: this.props.maxHeight - }; - - var columns = this.getColumnsDescription(this.props); - var sortInfo = this.store.getSortInfo(); - var pagination = this.renderPagination(); - var toolBar = this.renderToolBar(); - var tableFilter = this.renderTableFilter(columns); - var isSelectAll = this.isSelectAll(); - var sortIndicator = this.props.options.sortIndicator; - if (typeof this.props.options.sortIndicator === 'undefined') sortIndicator = true; - return _react2.default.createElement( - 'div', - { className: (0, _classnames2.default)('react-bs-table-container', this.props.containerClass), - style: this.props.containerStyle }, - toolBar, - _react2.default.createElement( - 'div', - { ref: 'table', - className: (0, _classnames2.default)('react-bs-table', this.props.tableContainerClass), - style: _extends({}, style, this.props.tableStyle), - onMouseEnter: this.handleMouseEnter, - onMouseLeave: this.handleMouseLeave }, - _react2.default.createElement( - _TableHeader2.default, - { - ref: 'header', - headerContainerClass: this.props.headerContainerClass, - tableHeaderClass: this.props.tableHeaderClass, - style: this.props.headerStyle, - rowSelectType: this.props.selectRow.mode, - customComponent: this.props.selectRow.customComponent, - hideSelectColumn: this.props.selectRow.hideSelectColumn, - sortName: sortInfo ? sortInfo.sortField : undefined, - sortOrder: sortInfo ? sortInfo.order : undefined, - sortIndicator: sortIndicator, - onSort: this.handleSort, - onSelectAllRow: this.handleSelectAllRow, - bordered: this.props.bordered, - condensed: this.props.condensed, - isFiltered: this.filter ? true : false, - isSelectAll: isSelectAll }, - this.props.children - ), - _react2.default.createElement(_TableBody2.default, { ref: 'body', - bodyContainerClass: this.props.bodyContainerClass, - tableBodyClass: this.props.tableBodyClass, - style: _extends({}, style, this.props.bodyStyle), - data: this.state.data, - expandComponent: this.props.expandComponent, - expandableRow: this.props.expandableRow, - expandRowBgColor: this.props.options.expandRowBgColor, - 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, - onRowDoubleClick: this.handleRowDoubleClick, - onRowMouseOver: this.handleRowMouseOver, - onRowMouseOut: this.handleRowMouseOut, - onSelectRow: this.handleSelectRow, - noDataText: this.props.options.noDataText, - adjustHeaderWidth: this._adjustHeaderWidth }) - ), - tableFilter, - pagination - ); - } - }, { - key: 'isSelectAll', - value: function isSelectAll() { - if (this.store.isEmpty()) return false; - var unselectable = this.props.selectRow.unselectable; - var defaultSelectRowKeys = this.store.getSelectedRowKeys(); - var allRowKeys = this.store.getAllRowkey(); - - if (defaultSelectRowKeys.length === 0) return false; - var match = 0; - var noFound = 0; - var unSelectableCnt = 0; - defaultSelectRowKeys.forEach(function (selected) { - if (allRowKeys.indexOf(selected) !== -1) match++;else noFound++; - if (unselectable && unselectable.indexOf(selected) !== -1) unSelectableCnt++; - }); - - if (noFound === defaultSelectRowKeys.length) return false; - if (match === allRowKeys.length) { - return true; - } else { - if (unselectable && match <= unSelectableCnt && unSelectableCnt === unselectable.length) return false;else return 'indeterminate'; - } - // return (match === allRowKeys.length) ? true : 'indeterminate'; - } - }, { - key: 'cleanSelected', - value: function cleanSelected() { - this.store.setSelectedRowKey([]); - this.setState({ - selectedRowKeys: [] - }); - } - }, { - key: '__handleSort__REACT_HOT_LOADER__', - value: function __handleSort__REACT_HOT_LOADER__(order, sortField) { - if (this.props.options.onSortChange) { - this.props.options.onSortChange(sortField, order, this.props); - } - - if (this.isRemoteDataSource()) { - this.store.setSortInfo(order, sortField); - return; - } - - var result = this.store.sort(order, sortField).get(); - this.setState({ - data: result - }); - } - }, { - key: '__handlePaginationData__REACT_HOT_LOADER__', - value: function __handlePaginationData__REACT_HOT_LOADER__(page, sizePerPage) { - var _props$options = this.props.options, - onPageChange = _props$options.onPageChange, - pageStartIndex = _props$options.pageStartIndex; - - if (onPageChange) { - onPageChange(page, sizePerPage); - } - - this.setState({ - currPage: page, - sizePerPage: sizePerPage - }); - - if (this.isRemoteDataSource()) { - return; - } - - // We calculate an offset here in order to properly fetch the indexed data, - // despite the page start index not always being 1 - var normalizedPage = void 0; - if (pageStartIndex !== undefined) { - var offset = Math.abs(_Const2.default.PAGE_START_INDEX - pageStartIndex); - normalizedPage = page + offset; - } else { - normalizedPage = page; - } - - var result = this.store.page(normalizedPage, sizePerPage).get(); - - this.setState({ data: result }); - } - }, { - key: '__handleMouseLeave__REACT_HOT_LOADER__', - value: function __handleMouseLeave__REACT_HOT_LOADER__() { - if (this.props.options.onMouseLeave) { - this.props.options.onMouseLeave(); - } - } - }, { - key: '__handleMouseEnter__REACT_HOT_LOADER__', - value: function __handleMouseEnter__REACT_HOT_LOADER__() { - if (this.props.options.onMouseEnter) { - this.props.options.onMouseEnter(); - } - } - }, { - key: '__handleRowMouseOut__REACT_HOT_LOADER__', - value: function __handleRowMouseOut__REACT_HOT_LOADER__(row, event) { - if (this.props.options.onRowMouseOut) { - this.props.options.onRowMouseOut(row, event); - } - } - }, { - key: '__handleRowMouseOver__REACT_HOT_LOADER__', - value: function __handleRowMouseOver__REACT_HOT_LOADER__(row, event) { - if (this.props.options.onRowMouseOver) { - this.props.options.onRowMouseOver(row, event); - } - } - }, { - key: '__handleRowClick__REACT_HOT_LOADER__', - value: function __handleRowClick__REACT_HOT_LOADER__(row) { - if (this.props.options.onRowClick) { - this.props.options.onRowClick(row); - } - } - }, { - key: '__handleRowDoubleClick__REACT_HOT_LOADER__', - value: function __handleRowDoubleClick__REACT_HOT_LOADER__(row) { - if (this.props.options.onRowDoubleClick) { - this.props.options.onRowDoubleClick(row); - } - } - }, { - key: '__handleSelectAllRow__REACT_HOT_LOADER__', - value: function __handleSelectAllRow__REACT_HOT_LOADER__(e) { - var isSelected = e.currentTarget.checked; - var keyField = this.store.getKeyField(); - var _props$selectRow = this.props.selectRow, - onSelectAll = _props$selectRow.onSelectAll, - unselectable = _props$selectRow.unselectable, - selected = _props$selectRow.selected; - - var selectedRowKeys = []; - var result = true; - var rows = isSelected ? this.store.get() : this.store.getRowByKey(this.state.selectedRowKeys); - - if (unselectable && unselectable.length > 0) { - if (isSelected) { - rows = rows.filter(function (r) { - return unselectable.indexOf(r[keyField]) === -1 || selected && selected.indexOf(r[keyField]) !== -1; - }); - } else { - rows = rows.filter(function (r) { - return unselectable.indexOf(r[keyField]) === -1; - }); - } - } - - if (onSelectAll) { - result = this.props.selectRow.onSelectAll(isSelected, rows); - } - - if (typeof result == 'undefined' || result !== false) { - if (isSelected) { - selectedRowKeys = Array.isArray(result) ? result : rows.map(function (r) { - return r[keyField]; - }); - } else { - if (unselectable && selected) { - selectedRowKeys = selected.filter(function (r) { - return unselectable.indexOf(r) > -1; - }); - } - } - - this.store.setSelectedRowKey(selectedRowKeys); - this.setState({ selectedRowKeys: selectedRowKeys }); - } - } - }, { - key: '__handleShowOnlySelected__REACT_HOT_LOADER__', - value: function __handleShowOnlySelected__REACT_HOT_LOADER__() { - this.store.ignoreNonSelected(); - var result = void 0; - if (this.props.pagination) { - result = this.store.page(1, this.state.sizePerPage).get(); - } else { - result = this.store.get(); - } - this.setState({ - data: result, - currPage: this.props.options.pageStartIndex || _Const2.default.PAGE_START_INDEX - }); - } - }, { - key: '__handleSelectRow__REACT_HOT_LOADER__', - value: function __handleSelectRow__REACT_HOT_LOADER__(row, isSelected, e) { - var result = true; - var currSelected = this.store.getSelectedRowKeys(); - var rowKey = row[this.store.getKeyField()]; - var selectRow = this.props.selectRow; - - if (selectRow.onSelect) { - result = selectRow.onSelect(row, isSelected, e); - } - - if (typeof result === 'undefined' || result !== false) { - if (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 - }); - } - } - }, { - key: 'handleEditCell', - value: function handleEditCell(newVal, rowIndex, colIndex) { - var onCellEdit = this.props.options.onCellEdit; - var _props$cellEdit = this.props.cellEdit, - beforeSaveCell = _props$cellEdit.beforeSaveCell, - afterSaveCell = _props$cellEdit.afterSaveCell; - - var fieldName = void 0; - _react2.default.Children.forEach(this.props.children, function (column, i) { - if (i === colIndex) { - fieldName = column.props.dataField; - return false; - } - }); - - if (beforeSaveCell) { - var isValid = beforeSaveCell(this.state.data[rowIndex], fieldName, newVal); - if (!isValid && typeof isValid !== 'undefined') { - this.setState({ - data: this.store.get() - }); - return; - } - } - - if (onCellEdit) { - newVal = onCellEdit(this.state.data[rowIndex], fieldName, newVal); - } - - if (this.isRemoteDataSource()) { - if (afterSaveCell) { - afterSaveCell(this.state.data[rowIndex], fieldName, newVal); - } - return; - } - - var result = this.store.edit(newVal, rowIndex, fieldName).get(); - this.setState({ - data: result - }); - - if (afterSaveCell) { - afterSaveCell(this.state.data[rowIndex], fieldName, newVal); - } - } - }, { - key: 'handleAddRowAtBegin', - value: function handleAddRowAtBegin(newObj) { - try { - this.store.addAtBegin(newObj); - } catch (e) { - return e; - } - this._handleAfterAddingRow(newObj, true); - } - }, { - key: '__handleAddRow__REACT_HOT_LOADER__', - value: function __handleAddRow__REACT_HOT_LOADER__(newObj) { - var onAddRow = this.props.options.onAddRow; - - if (onAddRow) { - var colInfos = this.store.getColInfos(); - onAddRow(newObj, colInfos); - } - - if (this.isRemoteDataSource()) { - if (this.props.options.afterInsertRow) { - this.props.options.afterInsertRow(newObj); - } - return null; - } - - try { - this.store.add(newObj); - } catch (e) { - return e.message; - } - this._handleAfterAddingRow(newObj, false); - } - }, { - key: 'getSizePerPage', - value: function getSizePerPage() { - return this.state.sizePerPage; - } - }, { - key: 'getCurrentPage', - value: function getCurrentPage() { - return this.state.currPage; - } - }, { - key: 'getTableDataIgnorePaging', - value: function getTableDataIgnorePaging() { - return this.store.getCurrentDisplayData(); - } - }, { - key: '__getPageByRowKey__REACT_HOT_LOADER__', - value: function __getPageByRowKey__REACT_HOT_LOADER__(rowKey) { - var sizePerPage = this.state.sizePerPage; - - var currentData = this.store.getCurrentDisplayData(); - var keyField = this.store.getKeyField(); - var result = currentData.findIndex(function (x) { - return x[keyField] === rowKey; - }); - if (result > -1) { - return parseInt(result / sizePerPage, 10) + 1; - } else { - return result; - } - } - }, { - key: '__handleDropRow__REACT_HOT_LOADER__', - value: function __handleDropRow__REACT_HOT_LOADER__(rowKeys) { - var _this3 = this; - - var dropRowKeys = rowKeys ? rowKeys : this.store.getSelectedRowKeys(); - // add confirm before the delete action if that option is set. - if (dropRowKeys && dropRowKeys.length > 0) { - if (this.props.options.handleConfirmDeleteRow) { - this.props.options.handleConfirmDeleteRow(function () { - _this3.deleteRow(dropRowKeys); - }, dropRowKeys); - } else if (confirm('Are you sure you want to delete?')) { - this.deleteRow(dropRowKeys); - } - } - } - }, { - key: 'deleteRow', - value: function deleteRow(dropRowKeys) { - var onDeleteRow = this.props.options.onDeleteRow; - - if (onDeleteRow) { - onDeleteRow(dropRowKeys); - } - - this.store.setSelectedRowKey([]); // clear selected row key - - if (this.isRemoteDataSource()) { - if (this.props.options.afterDeleteRow) { - this.props.options.afterDeleteRow(dropRowKeys); - } - return; - } - - this.store.remove(dropRowKeys); // remove selected Row - var result = void 0; - if (this.props.pagination) { - var sizePerPage = this.state.sizePerPage; - - var currLastPage = Math.ceil(this.store.getDataNum() / sizePerPage); - var currPage = this.state.currPage; - - if (currPage > currLastPage) currPage = currLastPage; - result = this.store.page(currPage, sizePerPage).get(); - this.setState({ - data: result, - selectedRowKeys: this.store.getSelectedRowKeys(), - currPage: currPage - }); - } 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__REACT_HOT_LOADER__', - value: function __handleFilterData__REACT_HOT_LOADER__(filterObj) { - var onFilterChange = this.props.options.onFilterChange; - - if (onFilterChange) { - var colInfos = this.store.getColInfos(); - onFilterChange(filterObj, colInfos); - } - - this.setState({ - currPage: this.props.options.pageStartIndex || _Const2.default.PAGE_START_INDEX - }); - - if (this.isRemoteDataSource()) { - if (this.props.options.afterColumnFilter) { - this.props.options.afterColumnFilter(filterObj, this.store.getDataIgnoringPagination()); - } - return; - } - - this.store.filter(filterObj); - - var sortObj = this.store.getSortInfo(); - - if (sortObj) { - this.store.sort(sortObj.order, sortObj.sortField); - } - - var result = void 0; - - if (this.props.pagination) { - var sizePerPage = this.state.sizePerPage; - - result = this.store.page(1, sizePerPage).get(); - } else { - result = this.store.get(); - } - if (this.props.options.afterColumnFilter) { - this.props.options.afterColumnFilter(filterObj, this.store.getDataIgnoringPagination()); - } - this.setState({ - data: result - }); - } - }, { - key: '__handleExportCSV__REACT_HOT_LOADER__', - value: function __handleExportCSV__REACT_HOT_LOADER__() { - var result = {}; - - var csvFileName = this.props.csvFileName; - var onExportToCSV = this.props.options.onExportToCSV; - - if (onExportToCSV) { - result = onExportToCSV(); - } else { - result = this.store.getDataIgnoringPagination(); - } - - var keys = []; - this.props.children.map(function (column) { - if (column.props.export === true || typeof column.props.export === 'undefined' && column.props.hidden === false) { - keys.push({ - field: column.props.dataField, - format: column.props.csvFormat, - header: column.props.csvHeader || column.props.dataField - }); - } - }); - - if (typeof csvFileName === 'function') { - csvFileName = csvFileName(); - } - - (0, _csv_export_util2.default)(result, keys, csvFileName); - } - }, { - key: '__handleSearch__REACT_HOT_LOADER__', - value: function __handleSearch__REACT_HOT_LOADER__(searchText) { - // Set search field if this function being called outside - // but it's not necessary if calling fron inside. - if (this.refs.toolbar) { - this.refs.toolbar.setSearchInput(searchText); - } - var onSearchChange = this.props.options.onSearchChange; - - if (onSearchChange) { - var colInfos = this.store.getColInfos(); - onSearchChange(searchText, colInfos, this.props.multiColumnSearch); - } - - this.setState({ - currPage: this.props.options.pageStartIndex || _Const2.default.PAGE_START_INDEX - }); - - if (this.isRemoteDataSource()) { - if (this.props.options.afterSearch) { - this.props.options.afterSearch(searchText, this.store.getDataIgnoringPagination()); - } - return; - } - - this.store.search(searchText); - - var sortObj = this.store.getSortInfo(); - - if (sortObj) { - this.store.sort(sortObj.order, sortObj.sortField); - } - - var result = void 0; - if (this.props.pagination) { - var sizePerPage = this.state.sizePerPage; - - result = this.store.page(1, sizePerPage).get(); - } 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 = void 0; - if (this.isRemoteDataSource()) { - dataSize = this.props.fetchInfo.dataTotalSize; - } else { - dataSize = this.store.getDataNum(); - } - var options = this.props.options; - - if (Math.ceil(dataSize / this.state.sizePerPage) <= 1 && this.props.ignoreSinglePage) return null; - return _react2.default.createElement( - 'div', - { className: 'react-bs-table-pagination' }, - _react2.default.createElement(_PaginationList2.default, { - ref: 'pagination', - currPage: this.state.currPage, - changePage: this.handlePaginationData, - sizePerPage: this.state.sizePerPage, - sizePerPageList: options.sizePerPageList || _Const2.default.SIZE_PER_PAGE_LIST, - pageStartIndex: options.pageStartIndex, - paginationShowsTotal: options.paginationShowsTotal, - paginationSize: options.paginationSize || _Const2.default.PAGINATION_SIZE, - remote: this.isRemoteDataSource(), - dataSize: dataSize, - onSizePerPageList: options.onSizePerPageList, - prePage: options.prePage || _Const2.default.PRE_PAGE, - nextPage: options.nextPage || _Const2.default.NEXT_PAGE, - firstPage: options.firstPage || _Const2.default.FIRST_PAGE, - lastPage: options.lastPage || _Const2.default.LAST_PAGE, - hideSizePerPage: options.hideSizePerPage }) - ); - } - return null; - } - }, { - key: 'renderToolBar', - value: function renderToolBar() { - var _props2 = this.props, - selectRow = _props2.selectRow, - insertRow = _props2.insertRow, - deleteRow = _props2.deleteRow, - search = _props2.search, - children = _props2.children; - - var enableShowOnlySelected = selectRow && selectRow.showOnlySelected; - if (enableShowOnlySelected || insertRow || deleteRow || search || this.props.exportCSV) { - var columns = void 0; - if (Array.isArray(children)) { - columns = children.map(function (column, r) { - var props = column.props; - - return { - name: props.children, - field: props.dataField, - hiddenOnInsert: props.hiddenOnInsert, - // when you want same auto generate value and not allow edit, example ID field - autoValue: props.autoValue || false, - // for create editor, no params for column.editable() indicate that editor for new row - editable: props.editable && typeof props.editable === 'function' ? props.editable() : props.editable, - format: props.dataFormat ? function (value) { - return props.dataFormat(value, null, props.formatExtraData, r).replace(/<.*?>/g, ''); - } : false - }; - }); - } else { - columns = [{ - name: children.props.children, - field: children.props.dataField, - editable: children.props.editable, - hiddenOnInsert: children.props.hiddenOnInsert - }]; - } - return _react2.default.createElement( - 'div', - { className: 'react-bs-table-tool-bar' }, - _react2.default.createElement(_ToolBar2.default, { - ref: 'toolbar', - defaultSearch: this.props.options.defaultSearch, - clearSearch: this.props.options.clearSearch, - searchDelayTime: this.props.options.searchDelayTime, - enableInsert: insertRow, - enableDelete: deleteRow, - enableSearch: search, - enableExportCSV: this.props.exportCSV, - enableShowOnlySelected: enableShowOnlySelected, - columns: columns, - searchPlaceholder: this.props.searchPlaceholder, - exportCSVText: this.props.options.exportCSVText, - insertText: this.props.options.insertText, - deleteText: this.props.options.deleteText, - saveText: this.props.options.saveText, - closeText: this.props.options.closeText, - ignoreEditable: this.props.options.ignoreEditable, - onAddRow: this.handleAddRow, - onDropRow: this.handleDropRow, - onSearch: this.handleSearch, - onExportCSV: this.handleExportCSV, - onShowOnlySelected: this.handleShowOnlySelected }) - ); - } 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 }); - } else { - return null; - } - } - }, { - key: '___scrollTop__REACT_HOT_LOADER__', - value: function ___scrollTop__REACT_HOT_LOADER__() { - var scrollTop = this.props.scrollTop; - - if (scrollTop === _Const2.default.SCROLL_TOP) { - this.refs.body.refs.container.scrollTop = 0; - } else if (scrollTop === _Const2.default.SCROLL_BOTTOM) { - this.refs.body.refs.container.scrollTop = this.refs.body.refs.container.scrollHeight; - } else if (typeof scrollTop === 'number' && !isNaN(scrollTop)) { - this.refs.body.refs.container.scrollTop = scrollTop; - } - } - }, { - key: '___scrollHeader__REACT_HOT_LOADER__', - value: function ___scrollHeader__REACT_HOT_LOADER__(e) { - this.refs.header.refs.container.scrollLeft = e.currentTarget.scrollLeft; - } - }, { - key: '___adjustTable__REACT_HOT_LOADER__', - value: function ___adjustTable__REACT_HOT_LOADER__() { - if (!this.props.printable) { - this._adjustHeaderWidth(); - } - this._adjustHeight(); - } - }, { - key: '___adjustHeaderWidth__REACT_HOT_LOADER__', - value: function ___adjustHeaderWidth__REACT_HOT_LOADER__() { - var header = this.refs.header.refs.header; - var headerContainer = this.refs.header.refs.container; - var tbody = this.refs.body.refs.tbody; - var firstRow = tbody.childNodes[0]; - var isScroll = headerContainer.offsetWidth !== tbody.parentNode.offsetWidth; - var scrollBarWidth = isScroll ? _util2.default.getScrollBarWidth() : 0; - if (firstRow && this.store.getDataNum()) { - var cells = firstRow.childNodes; - for (var i = 0; i < cells.length; i++) { - var cell = cells[i]; - var computedStyle = window.getComputedStyle(cell); - var width = parseFloat(computedStyle.width.replace('px', '')); - if (this.isIE) { - var paddingLeftWidth = parseFloat(computedStyle.paddingLeft.replace('px', '')); - var paddingRightWidth = parseFloat(computedStyle.paddingRight.replace('px', '')); - var borderRightWidth = parseFloat(computedStyle.borderRightWidth.replace('px', '')); - var borderLeftWidth = parseFloat(computedStyle.borderLeftWidth.replace('px', '')); - width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth; - } - var lastPadding = cells.length - 1 === i ? scrollBarWidth : 0; - if (width <= 0) { - width = 120; - cell.width = width + lastPadding + 'px'; - } - var result = width + lastPadding + 'px'; - header.childNodes[i].style.width = result; - header.childNodes[i].style.minWidth = result; - } - } else { - _react2.default.Children.forEach(this.props.children, function (child, i) { - if (child.props.width) { - header.childNodes[i].style.width = child.props.width + 'px'; - header.childNodes[i].style.minWidth = child.props.width + 'px'; - } - }); - } - } - }, { - key: '___adjustHeight__REACT_HOT_LOADER__', - value: function ___adjustHeight__REACT_HOT_LOADER__() { - var height = this.props.height; - var maxHeight = this.props.maxHeight; - - if (typeof height === 'number' && !isNaN(height) || height.indexOf('%') === -1) { - this.refs.body.refs.container.style.height = parseFloat(height, 10) - this.refs.header.refs.container.offsetHeight + 'px'; - } - if (maxHeight) { - maxHeight = typeof maxHeight === 'number' ? maxHeight : parseInt(maxHeight.replace('px', ''), 10); - - this.refs.body.refs.container.style.maxHeight = maxHeight - this.refs.header.refs.container.offsetHeight + 'px'; - } - } - }, { - key: '_handleAfterAddingRow', - value: function _handleAfterAddingRow(newObj, atTheBeginning) { - var result = void 0; - if (this.props.pagination) { - // if pagination is enabled and inserting row at the end, - // change page to the last page - // otherwise, change it to the first page - var sizePerPage = this.state.sizePerPage; - - - if (atTheBeginning) { - var firstPage = this.props.options.pageStartIndex || _Const2.default.PAGE_START_INDEX; - result = this.store.page(firstPage, sizePerPage).get(); - this.setState({ - data: result, - currPage: firstPage - }); - } else { - var currLastPage = Math.ceil(this.store.getDataNum() / sizePerPage); - result = this.store.page(currLastPage, sizePerPage).get(); - this.setState({ - data: result, - currPage: currLastPage - }); - } - } else { - result = this.store.get(); - this.setState({ - data: result - }); - } - - if (this.props.options.afterInsertRow) { - this.props.options.afterInsertRow(newObj); - } - } - }]); - - return BootstrapTable; -}(_react.Component); - -BootstrapTable.propTypes = { - keyField: _react.PropTypes.string, - height: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]), - maxHeight: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]), - data: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.object]), - remote: _react.PropTypes.bool, // remote data, default is false - scrollTop: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]), - striped: _react.PropTypes.bool, - bordered: _react.PropTypes.bool, - hover: _react.PropTypes.bool, - condensed: _react.PropTypes.bool, - pagination: _react.PropTypes.bool, - printable: _react.PropTypes.bool, - searchPlaceholder: _react.PropTypes.string, - selectRow: _react.PropTypes.shape({ - mode: _react.PropTypes.oneOf([_Const2.default.ROW_SELECT_NONE, _Const2.default.ROW_SELECT_SINGLE, _Const2.default.ROW_SELECT_MULTI]), - customComponent: _react.PropTypes.func, - bgColor: _react.PropTypes.string, - selected: _react.PropTypes.array, - onSelect: _react.PropTypes.func, - onSelectAll: _react.PropTypes.func, - clickToSelect: _react.PropTypes.bool, - hideSelectColumn: _react.PropTypes.bool, - clickToSelectAndEditCell: _react.PropTypes.bool, - showOnlySelected: _react.PropTypes.bool, - unselectable: _react.PropTypes.array - }), - cellEdit: _react.PropTypes.shape({ - mode: _react.PropTypes.string, - blurToSave: _react.PropTypes.bool, - beforeSaveCell: _react.PropTypes.func, - afterSaveCell: _react.PropTypes.func, - nonEditableRows: _react.PropTypes.func - }), - insertRow: _react.PropTypes.bool, - deleteRow: _react.PropTypes.bool, - search: _react.PropTypes.bool, - columnFilter: _react.PropTypes.bool, - trClassName: _react.PropTypes.any, - tableStyle: _react.PropTypes.object, - containerStyle: _react.PropTypes.object, - headerStyle: _react.PropTypes.object, - bodyStyle: _react.PropTypes.object, - containerClass: _react.PropTypes.string, - tableContainerClass: _react.PropTypes.string, - headerContainerClass: _react.PropTypes.string, - bodyContainerClass: _react.PropTypes.string, - tableHeaderClass: _react.PropTypes.string, - tableBodyClass: _react.PropTypes.string, - options: _react.PropTypes.shape({ - clearSearch: _react.PropTypes.bool, - sortName: _react.PropTypes.string, - sortOrder: _react.PropTypes.string, - defaultSortName: _react.PropTypes.string, - defaultSortOrder: _react.PropTypes.string, - sortIndicator: _react.PropTypes.bool, - afterTableComplete: _react.PropTypes.func, - afterDeleteRow: _react.PropTypes.func, - afterInsertRow: _react.PropTypes.func, - afterSearch: _react.PropTypes.func, - afterColumnFilter: _react.PropTypes.func, - onRowClick: _react.PropTypes.func, - onRowDoubleClick: _react.PropTypes.func, - page: _react.PropTypes.number, - pageStartIndex: _react.PropTypes.number, - paginationShowsTotal: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.func]), - sizePerPageList: _react.PropTypes.array, - sizePerPage: _react.PropTypes.number, - paginationSize: _react.PropTypes.number, - hideSizePerPage: _react.PropTypes.bool, - onSortChange: _react.PropTypes.func, - onPageChange: _react.PropTypes.func, - onSizePerPageList: _react.PropTypes.func, - onFilterChange: _react2.default.PropTypes.func, - onSearchChange: _react2.default.PropTypes.func, - onAddRow: _react2.default.PropTypes.func, - onExportToCSV: _react2.default.PropTypes.func, - onCellEdit: _react2.default.PropTypes.func, - noDataText: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object]), - handleConfirmDeleteRow: _react.PropTypes.func, - prePage: _react.PropTypes.string, - nextPage: _react.PropTypes.string, - firstPage: _react.PropTypes.string, - lastPage: _react.PropTypes.string, - searchDelayTime: _react.PropTypes.number, - exportCSVText: _react.PropTypes.string, - insertText: _react.PropTypes.string, - deleteText: _react.PropTypes.string, - saveText: _react.PropTypes.string, - closeText: _react.PropTypes.string, - ignoreEditable: _react.PropTypes.bool, - defaultSearch: _react.PropTypes.string, - expandRowBgColor: _react.PropTypes.string - }), - fetchInfo: _react.PropTypes.shape({ - dataTotalSize: _react.PropTypes.number - }), - exportCSV: _react.PropTypes.bool, - csvFileName: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.func]), - ignoreSinglePage: _react.PropTypes.bool, - expandableRow: _react.PropTypes.func, - expandComponent: _react.PropTypes.func -}; -BootstrapTable.defaultProps = { - scrollTop: undefined, - expandComponent: undefined, - expandableRow: undefined, - height: '100%', - maxHeight: undefined, - striped: false, - bordered: true, - hover: false, - condensed: false, - pagination: false, - printable: 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, - showOnlySelected: false, - unselectable: [], - customComponent: undefined - }, - cellEdit: { - mode: _Const2.default.CELL_EDIT_NONE, - blurToSave: false, - beforeSaveCell: undefined, - afterSaveCell: undefined, - nonEditableRows: undefined - }, - insertRow: false, - deleteRow: false, - search: false, - multiColumnSearch: false, - columnFilter: false, - trClassName: '', - tableStyle: undefined, - containerStyle: undefined, - headerStyle: undefined, - bodyStyle: undefined, - containerClass: null, - tableContainerClass: null, - headerContainerClass: null, - bodyContainerClass: null, - tableHeaderClass: null, - tableBodyClass: null, - options: { - clearSearch: false, - sortName: undefined, - sortOrder: undefined, - defaultSortName: undefined, - defaultSortOrder: undefined, - sortIndicator: true, - afterTableComplete: undefined, - afterDeleteRow: undefined, - afterInsertRow: undefined, - afterSearch: undefined, - afterColumnFilter: undefined, - onRowClick: undefined, - onRowDoubleClick: undefined, - onMouseLeave: undefined, - onMouseEnter: undefined, - onRowMouseOut: undefined, - onRowMouseOver: undefined, - page: undefined, - paginationShowsTotal: false, - sizePerPageList: _Const2.default.SIZE_PER_PAGE_LIST, - sizePerPage: undefined, - paginationSize: _Const2.default.PAGINATION_SIZE, - hideSizePerPage: false, - onSizePerPageList: undefined, - noDataText: undefined, - handleConfirmDeleteRow: undefined, - prePage: _Const2.default.PRE_PAGE, - nextPage: _Const2.default.NEXT_PAGE, - firstPage: _Const2.default.FIRST_PAGE, - lastPage: _Const2.default.LAST_PAGE, - pageStartIndex: undefined, - searchDelayTime: undefined, - exportCSVText: _Const2.default.EXPORT_CSV_TEXT, - insertText: _Const2.default.INSERT_BTN_TEXT, - deleteText: _Const2.default.DELETE_BTN_TEXT, - saveText: _Const2.default.SAVE_BTN_TEXT, - closeText: _Const2.default.CLOSE_BTN_TEXT, - ignoreEditable: false, - defaultSearch: '', - expandRowBgColor: undefined - }, - fetchInfo: { - dataTotalSize: 0 - }, - exportCSV: false, - csvFileName: 'spreadsheet.csv', - ignoreSinglePage: false -}; - -var _default = BootstrapTable; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(BootstrapTable, 'BootstrapTable', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/BootstrapTable.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/BootstrapTable.js'); -}(); - -; \ No newline at end of file diff --git a/lib/Const.js b/lib/Const.js deleted file mode 100644 index 789488156..000000000 --- a/lib/Const.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _default = { - SORT_DESC: 'desc', - SORT_ASC: 'asc', - SIZE_PER_PAGE: 10, - NEXT_PAGE: '>', - LAST_PAGE: '>>', - PRE_PAGE: '<', - FIRST_PAGE: '<<', - PAGE_START_INDEX: 1, - 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, - NO_DATA_TEXT: 'There is no data to display', - SHOW_ONLY_SELECT: 'Show Selected Only', - SHOW_ALL: 'Show All', - EXPORT_CSV_TEXT: 'Export to CSV', - INSERT_BTN_TEXT: 'New', - DELETE_BTN_TEXT: 'Delete', - SAVE_BTN_TEXT: 'Save', - CLOSE_BTN_TEXT: 'Close', - FILTER_DELAY: 500, - SCROLL_TOP: 'Top', - SCROLL_BOTTOM: 'Bottom', - FILTER_TYPE: { - TEXT: 'TextFilter', - REGEX: 'RegexFilter', - SELECT: 'SelectFilter', - NUMBER: 'NumberFilter', - DATE: 'DateFilter', - CUSTOM: 'CustomFilter' - } -}; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Const.js'); -}(); - -; \ No newline at end of file diff --git a/lib/Editor.js b/lib/Editor.js deleted file mode 100644 index 6db211d26..000000000 --- a/lib/Editor.js +++ /dev/null @@ -1,135 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var editor = function editor(editable, attr, format, editorClass, defaultValue, ignoreEditable) { - if (editable === true || editable === false && ignoreEditable || typeof editable === 'string') { - // simple declare - var type = editable ? '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 ? '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 && (editable.type === undefined || editable.type === null || editable.type.trim() === '')) { - var _type2 = editable ? 'text' : editable; - return _react2.default.createElement('input', _extends({}, attr, { type: _type2, defaultValue: defaultValue, - 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 = []; - var values = editable.options.values; - if (Array.isArray(values)) { - (function () { - // only can use arrray data for options - var rowValue = void 0; - 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') { - var _ret2 = function () { - // process textarea input - // put other if exist - editable.cols && (attr.cols = editable.cols); - editable.rows && (attr.rows = editable.rows); - var saveBtn = void 0; - var keyUpHandler = attr.onKeyDown; - if (keyUpHandler) { - attr.onKeyDown = function (e) { - if (e.keyCode !== 13) { - // not Pressed ENTER - keyUpHandler(e); - } - }; - saveBtn = _react2.default.createElement( - 'button', - { - className: 'btn btn-info btn-xs textarea-save-btn', - onClick: keyUpHandler }, - 'save' - ); - } - return { - v: _react2.default.createElement( - 'div', - null, - _react2.default.createElement('textarea', _extends({}, attr, { defaultValue: defaultValue })), - saveBtn - ) - }; - }(); - - if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; - } 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 if (editable.type === 'datetime') { - return _react2.default.createElement('input', _extends({}, attr, { type: 'datetime-local', defaultValue: defaultValue })); - } else { - // process other input type. as password,url,email... - return _react2.default.createElement('input', _extends({}, attr, { type: 'text', 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' })); -}; - -var _default = editor; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(editor, 'editor', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Editor.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Editor.js'); -}(); - -; \ No newline at end of file diff --git a/lib/ExpandComponent.js b/lib/ExpandComponent.js deleted file mode 100644 index 24228a233..000000000 --- a/lib/ExpandComponent.js +++ /dev/null @@ -1,75 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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; } /* eslint max-len: 0 */ - - -var ExpandComponent = function (_Component) { - _inherits(ExpandComponent, _Component); - - function ExpandComponent() { - _classCallCheck(this, ExpandComponent); - - return _possibleConstructorReturn(this, (ExpandComponent.__proto__ || Object.getPrototypeOf(ExpandComponent)).apply(this, arguments)); - } - - _createClass(ExpandComponent, [{ - key: 'render', - value: function render() { - var trCss = { - style: { - backgroundColor: this.props.bgColor - }, - className: (0, _classnames2.default)(this.props.isSelected ? this.props.selectRow.className : null, this.props.className) - }; - return _react2.default.createElement( - 'tr', - _extends({ hidden: this.props.hidden, width: this.props.width }, trCss), - _react2.default.createElement( - 'td', - { colSpan: this.props.colSpan }, - this.props.children - ) - ); - } - }]); - - return ExpandComponent; -}(_react.Component); - -var _default = ExpandComponent; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(ExpandComponent, 'ExpandComponent', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/ExpandComponent.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/ExpandComponent.js'); -}(); - -; \ No newline at end of file diff --git a/lib/Filter.js b/lib/Filter.js deleted file mode 100644 index cfd987cc4..000000000 --- a/lib/Filter.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Filter = undefined; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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 _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _events = require('events'); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 Filter = exports.Filter = function (_EventEmitter) { - _inherits(Filter, _EventEmitter); - - function Filter(data) { - _classCallCheck(this, Filter); - - var _this = _possibleConstructorReturn(this, (Filter.__proto__ || Object.getPrototypeOf(Filter)).call(this, data)); - - _this.currentFilter = {}; - return _this; - } - - _createClass(Filter, [{ - key: 'handleFilter', - value: function handleFilter(dataField, value, type) { - var filterType = type || _Const2.default.FILTER_TYPE.CUSTOM; - - if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { - // value of the filter is an object - var hasValue = true; - for (var prop in value) { - if (!value[prop] || value[prop] === '') { - hasValue = false; - break; - } - } - // if one of the object properties is undefined or empty, we remove the filter - if (hasValue) { - this.currentFilter[dataField] = { value: value, type: filterType }; - } else { - delete this.currentFilter[dataField]; - } - } else if (!value || value.trim() === '') { - delete this.currentFilter[dataField]; - } else { - this.currentFilter[dataField] = { value: value.trim(), type: filterType }; - } - this.emit('onFilterChange', this.currentFilter); - } - }]); - - return Filter; -}(_events.EventEmitter); - -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(Filter, 'Filter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Filter.js'); -}(); - -; \ No newline at end of file diff --git a/lib/Notification.js b/lib/Notification.js deleted file mode 100644 index f6002fd3c..000000000 --- a/lib/Notification.js +++ /dev/null @@ -1,76 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactToastr = require('@allenfang/react-toastr'); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 ToastrMessageFactory = _react2.default.createFactory(_reactToastr.ToastMessage.animation); - -var Notification = function (_Component) { - _inherits(Notification, _Component); - - function Notification() { - _classCallCheck(this, Notification); - - return _possibleConstructorReturn(this, (Notification.__proto__ || Object.getPrototypeOf(Notification)).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(_reactToastr.ToastContainer, { ref: 'toastr', - toastMessageFactory: ToastrMessageFactory, - id: 'toast-container', - className: 'toast-top-right' }); - } - }]); - - return Notification; -}(_react.Component); - -var _default = Notification; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(ToastrMessageFactory, 'ToastrMessageFactory', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Notification.js'); - - __REACT_HOT_LOADER__.register(Notification, 'Notification', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Notification.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/Notification.js'); -}(); - -; \ No newline at end of file diff --git a/lib/SelectRowHeaderColumn.js b/lib/SelectRowHeaderColumn.js deleted file mode 100644 index 79e9224bb..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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 SelectRowHeaderColumn = function (_Component) { - _inherits(SelectRowHeaderColumn, _Component); - - function SelectRowHeaderColumn() { - _classCallCheck(this, SelectRowHeaderColumn); - - return _possibleConstructorReturn(this, (SelectRowHeaderColumn.__proto__ || Object.getPrototypeOf(SelectRowHeaderColumn)).apply(this, arguments)); - } - - _createClass(SelectRowHeaderColumn, [{ - key: 'render', - value: function render() { - return _react2.default.createElement( - 'th', - { style: { textAlign: 'center' } }, - this.props.children - ); - } - }]); - - return SelectRowHeaderColumn; -}(_react.Component); - -SelectRowHeaderColumn.propTypes = { - children: _react.PropTypes.node -}; -var _default = SelectRowHeaderColumn; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(SelectRowHeaderColumn, 'SelectRowHeaderColumn', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/SelectRowHeaderColumn.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/SelectRowHeaderColumn.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableBody.js b/lib/TableBody.js deleted file mode 100644 index 9a3041fcb..000000000 --- a/lib/TableBody.js +++ /dev/null @@ -1,465 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _ExpandComponent = require('./ExpandComponent'); - -var _ExpandComponent2 = _interopRequireDefault(_ExpandComponent); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 isFun = function isFun(obj) { - return obj && typeof obj === 'function'; -}; - -var TableBody = function (_Component) { - _inherits(TableBody, _Component); - - function TableBody(props) { - _classCallCheck(this, TableBody); - - var _this = _possibleConstructorReturn(this, (TableBody.__proto__ || Object.getPrototypeOf(TableBody)).call(this, props)); - - _this.handleRowMouseOut = function () { - return _this.__handleRowMouseOut__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowMouseOver = function () { - return _this.__handleRowMouseOver__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowClick = function () { - return _this.__handleRowClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleRowDoubleClick = function () { - return _this.__handleRowDoubleClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleSelectRow = function () { - return _this.__handleSelectRow__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleSelectRowColumChange = function () { - return _this.__handleSelectRowColumChange__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleEditCell = function () { - return _this.__handleEditCell__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleCompleteEditCell = function () { - return _this.__handleCompleteEditCell__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.state = { - currEditCell: null, - expanding: [], - lastExpand: null - }; - return _this; - } - - _createClass(TableBody, [{ - key: 'render', - value: function render() { - var cellEdit = this.props.cellEdit; - - 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 - }, this.props.tableBodyClass); - - var noneditableRows = cellEdit.nonEditableRows && cellEdit.nonEditableRows() || []; - var unselectable = this.props.selectRow.unselectable || []; - var isSelectRowDefined = this._isSelectRowDefined(); - var tableHeader = this.renderTableHeader(isSelectRowDefined); - var inputType = this.props.selectRow.mode === _Const2.default.ROW_SELECT_SINGLE ? 'radio' : 'checkbox'; - var CustomComponent = this.props.selectRow.customComponent; - - var tableRows = this.props.data.map(function (data, r) { - var tableColumns = this.props.columns.map(function (column, i) { - var fieldValue = data[column.name]; - if (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 && noneditableRows.indexOf(data[this.props.keyField]) === -1) { - var editable = column.editable; - var format = column.format ? function (value) { - return column.format(value, data, column.formatExtraData, r).replace(/<.*?>/g, ''); - } : false; - if (isFun(column.editable)) { - editable = column.editable(fieldValue, data, r, i); - } - - return _react2.default.createElement(_TableEditColumn2.default, { - completeEdit: this.handleCompleteEditCell - // add by bluespring for column editor customize - , editable: editable, - customEditor: column.customEditor, - format: column.format ? format : false, - key: i, - blurToSave: cellEdit.blurToSave, - rowIndex: r, - colIndex: i, - row: data, - fieldValue: fieldValue }); - } else { - // add by bluespring for className customize - var columnChild = fieldValue && fieldValue.toString(); - var columnTitle = null; - var tdClassName = column.className; - if (isFun(column.className)) { - tdClassName = column.className(fieldValue, data, r, i); - } - - if (typeof column.format !== 'undefined') { - var formattedValue = column.format(fieldValue, data, column.formatExtraData, r); - if (!_react2.default.isValidElement(formattedValue)) { - columnChild = _react2.default.createElement('div', { dangerouslySetInnerHTML: { __html: formattedValue } }); - } else { - columnChild = formattedValue; - columnTitle = column.columnTitle && formattedValue ? formattedValue.toString() : null; - } - } else { - columnTitle = column.columnTitle && fieldValue ? fieldValue.toString() : null; - } - return _react2.default.createElement( - _TableColumn2.default, - { key: i, - rIndex: r, - dataAlign: column.align, - className: tdClassName, - columnTitle: columnTitle, - cellEdit: cellEdit, - hidden: column.hidden, - onEdit: this.handleEditCell, - width: column.width }, - columnChild - ); - } - }, this); - var key = data[this.props.keyField]; - var disable = unselectable.indexOf(key) !== -1; - var selected = this.props.selectedRowKeys.indexOf(key) !== -1; - var selectRowColumn = isSelectRowDefined && !this.props.selectRow.hideSelectColumn ? this.renderSelectRowColumn(selected, inputType, disable, CustomComponent, r) : null; - // add by bluespring for className customize - var trClassName = this.props.trClassName; - if (isFun(this.props.trClassName)) { - trClassName = this.props.trClassName(data, r); - } - var result = [_react2.default.createElement( - _TableRow2.default, - { isSelected: selected, key: key, className: trClassName, - index: r, - selectRow: isSelectRowDefined ? this.props.selectRow : undefined, - enableCellEdit: cellEdit.mode !== _Const2.default.CELL_EDIT_NONE, - onRowClick: this.handleRowClick, - onRowDoubleClick: this.handleRowDoubleClick, - onRowMouseOver: this.handleRowMouseOver, - onRowMouseOut: this.handleRowMouseOut, - onSelectRow: this.handleSelectRow, - unselectableRow: disable }, - selectRowColumn, - tableColumns - )]; - - if (this.props.expandableRow && this.props.expandableRow(data)) { - var colSpan = this.props.columns.length; - var bgColor = this.props.expandRowBgColor || this.props.selectRow.bgColor || undefined; - if (isSelectRowDefined && !this.props.selectRow.hideSelectColumn) { - colSpan += 1; - } - result.push(_react2.default.createElement( - _ExpandComponent2.default, - { - className: trClassName, - bgColor: bgColor, - hidden: !(this.state.expanding.indexOf(key) > -1), - colSpan: colSpan, - width: "100%" }, - this.props.expandComponent(data) - )); - } - return result; - }, this); - if (tableRows.length === 0) { - tableRows.push(_react2.default.createElement( - _TableRow2.default, - { key: '##table-empty##' }, - _react2.default.createElement( - 'td', - { 'data-toggle': 'collapse', - colSpan: this.props.columns.length + (isSelectRowDefined ? 1 : 0), - className: 'react-bs-table-no-data' }, - this.props.noDataText || _Const2.default.NO_DATA_TEXT - ) - )); - } - - return _react2.default.createElement( - 'div', - { ref: 'container', - className: (0, _classnames2.default)('react-bs-container-body', this.props.bodyContainerClass), - style: this.props.style }, - _react2.default.createElement( - 'table', - { className: tableClasses }, - tableHeader, - _react2.default.createElement( - 'tbody', - { ref: 'tbody' }, - tableRows - ) - ) - ); - } - }, { - key: 'renderTableHeader', - value: function renderTableHeader(isSelectRowDefined) { - var selectRowHeader = null; - - if (isSelectRowDefined) { - var style = { - width: 30, - minWidth: 30 - }; - if (!this.props.selectRow.hideSelectColumn) { - selectRowHeader = _react2.default.createElement('col', { style: style, key: -1 }); - } - } - var theader = this.props.columns.map(function (column, i) { - var style = { - display: column.hidden ? 'none' : null - }; - if (column.width) { - var width = parseInt(column.width, 10); - style.width = width; - /** add min-wdth to fix user assign column width - not eq offsetWidth in large column table **/ - style.minWidth = width; - } - return _react2.default.createElement('col', { style: style, key: i, className: column.className }); - }); - - return _react2.default.createElement( - 'colgroup', - { ref: 'header' }, - selectRowHeader, - theader - ); - } - }, { - key: '__handleRowMouseOut__REACT_HOT_LOADER__', - value: function __handleRowMouseOut__REACT_HOT_LOADER__(rowIndex, event) { - var targetRow = this.props.data[rowIndex]; - this.props.onRowMouseOut(targetRow, event); - } - }, { - key: '__handleRowMouseOver__REACT_HOT_LOADER__', - value: function __handleRowMouseOver__REACT_HOT_LOADER__(rowIndex, event) { - var targetRow = this.props.data[rowIndex]; - this.props.onRowMouseOver(targetRow, event); - } - }, { - key: '__handleRowClick__REACT_HOT_LOADER__', - value: function __handleRowClick__REACT_HOT_LOADER__(rowIndex) { - var _this2 = this; - - var selectedRow = void 0; - var _props = this.props, - data = _props.data, - onRowClick = _props.onRowClick; - - data.forEach(function (row, i) { - if (i === rowIndex - 1) { - selectedRow = row; - } - }); - var rowKey = selectedRow[this.props.keyField]; - if (this.props.expandableRow) { - var expanding = this.state.expanding; - if (this.state.expanding.indexOf(rowKey) > -1) { - expanding = expanding.filter(function (k) { - return k !== rowKey; - }); - } else { - expanding.push(rowKey); - } - this.setState({ expanding: expanding }, function () { - _this2.props.adjustHeaderWidth(); - }); - } - onRowClick(selectedRow); - } - }, { - key: '__handleRowDoubleClick__REACT_HOT_LOADER__', - value: function __handleRowDoubleClick__REACT_HOT_LOADER__(rowIndex) { - var selectedRow = void 0; - var _props2 = this.props, - data = _props2.data, - onRowDoubleClick = _props2.onRowDoubleClick; - - data.forEach(function (row, i) { - if (i === rowIndex - 1) { - selectedRow = row; - } - }); - onRowDoubleClick(selectedRow); - } - }, { - key: '__handleSelectRow__REACT_HOT_LOADER__', - value: function __handleSelectRow__REACT_HOT_LOADER__(rowIndex, isSelected, e) { - var selectedRow = void 0; - var _props3 = this.props, - data = _props3.data, - onSelectRow = _props3.onSelectRow; - - data.forEach(function (row, i) { - if (i === rowIndex - 1) { - selectedRow = row; - return false; - } - }); - onSelectRow(selectedRow, isSelected, e); - } - }, { - key: '__handleSelectRowColumChange__REACT_HOT_LOADER__', - value: function __handleSelectRowColumChange__REACT_HOT_LOADER__(e, rowIndex) { - if (!this.props.selectRow.clickToSelect || !this.props.selectRow.clickToSelectAndEditCell) { - this.handleSelectRow(rowIndex + 1, e.currentTarget.checked, e); - } - } - }, { - key: '__handleEditCell__REACT_HOT_LOADER__', - value: function __handleEditCell__REACT_HOT_LOADER__(rowIndex, columnIndex, e) { - if (this._isSelectRowDefined()) { - columnIndex--; - if (this.props.selectRow.hideSelectColumn) columnIndex++; - } - rowIndex--; - var stateObj = { - currEditCell: { - rid: rowIndex, - cid: columnIndex - } - }; - - if (this.props.selectRow.clickToSelectAndEditCell && this.props.cellEdit.mode !== _Const2.default.CELL_EDIT_DBCLICK) { - var selected = this.props.selectedRowKeys.indexOf(this.props.data[rowIndex][this.props.keyField]) !== -1; - this.handleSelectRow(rowIndex + 1, !selected, e); - } - this.setState(stateObj); - } - }, { - key: '__handleCompleteEditCell__REACT_HOT_LOADER__', - value: function __handleCompleteEditCell__REACT_HOT_LOADER__(newVal, rowIndex, columnIndex) { - this.setState({ currEditCell: null }); - if (newVal !== null) { - this.props.cellEdit.__onCompleteEdit__(newVal, rowIndex, columnIndex); - } - } - }, { - key: 'renderSelectRowColumn', - value: function renderSelectRowColumn(selected, inputType, disabled) { - var _this3 = this; - - var CustomComponent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - var rowIndex = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - - return _react2.default.createElement( - _TableColumn2.default, - { dataAlign: 'center' }, - CustomComponent ? _react2.default.createElement(CustomComponent, { type: inputType, checked: selected, disabled: disabled, - rowIndex: rowIndex, - onChange: function onChange(e) { - return _this3.handleSelectRowColumChange(e, rowIndex); - } }) : _react2.default.createElement('input', { type: inputType, checked: selected, disabled: disabled, - onChange: function onChange(e) { - return _this3.handleSelectRowColumChange(e, rowIndex); - } }) - ); - } - }, { - 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; -}(_react.Component); - -TableBody.propTypes = { - data: _react.PropTypes.array, - columns: _react.PropTypes.array, - striped: _react.PropTypes.bool, - bordered: _react.PropTypes.bool, - hover: _react.PropTypes.bool, - condensed: _react.PropTypes.bool, - keyField: _react.PropTypes.string, - selectedRowKeys: _react.PropTypes.array, - onRowClick: _react.PropTypes.func, - onRowDoubleClick: _react.PropTypes.func, - onSelectRow: _react.PropTypes.func, - noDataText: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object]), - style: _react.PropTypes.object, - tableBodyClass: _react.PropTypes.string, - bodyContainerClass: _react.PropTypes.string, - expandableRow: _react.PropTypes.func, - expandComponent: _react.PropTypes.func, - expandRowBgColor: _react.PropTypes.string, - adjustHeaderWidth: _react.PropTypes.func -}; -var _default = TableBody; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(isFun, 'isFun', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableBody.js'); - - __REACT_HOT_LOADER__.register(TableBody, 'TableBody', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableBody.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableBody.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableColumn.js b/lib/TableColumn.js deleted file mode 100644 index 7d9de0408..000000000 --- a/lib/TableColumn.js +++ /dev/null @@ -1,158 +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 _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 TableColumn = function (_Component) { - _inherits(TableColumn, _Component); - - function TableColumn(props) { - _classCallCheck(this, TableColumn); - - var _this = _possibleConstructorReturn(this, (TableColumn.__proto__ || Object.getPrototypeOf(TableColumn)).call(this, props)); - - _this.handleCellEdit = function () { - return _this.__handleCellEdit__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - return _this; - } - /* eslint no-unused-vars: [0, { "args": "after-used" }] */ - - - _createClass(TableColumn, [{ - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps, nextState) { - var children = this.props.children; - - var shouldUpdated = this.props.width !== nextProps.width || this.props.className !== nextProps.className || this.props.hidden !== nextProps.hidden || this.props.dataAlign !== nextProps.dataAlign || (typeof children === 'undefined' ? 'undefined' : _typeof(children)) !== _typeof(nextProps.children) || ('' + this.props.onEdit).toString() !== ('' + nextProps.onEdit).toString(); - - if (shouldUpdated) { - return shouldUpdated; - } - - if ((typeof children === 'undefined' ? 'undefined' : _typeof(children)) === 'object' && children !== null && children.props !== null) { - if (children.props.type === 'checkbox' || children.props.type === 'radio') { - shouldUpdated = shouldUpdated || children.props.type !== nextProps.children.props.type || children.props.checked !== nextProps.children.props.checked || children.props.disabled !== nextProps.children.props.disabled; - } else { - shouldUpdated = true; - } - } else { - shouldUpdated = shouldUpdated || children !== nextProps.children; - } - - if (shouldUpdated) { - return shouldUpdated; - } - - if (!(this.props.cellEdit && nextProps.cellEdit)) { - return false; - } else { - return shouldUpdated || this.props.cellEdit.mode !== nextProps.cellEdit.mode; - } - } - }, { - key: '__handleCellEdit__REACT_HOT_LOADER__', - value: function __handleCellEdit__REACT_HOT_LOADER__(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(this.props.rIndex + 1, e.currentTarget.cellIndex, e); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - children = _props.children, - columnTitle = _props.columnTitle, - className = _props.className, - dataAlign = _props.dataAlign, - hidden = _props.hidden, - cellEdit = _props.cellEdit; - - - var tdStyle = { - textAlign: dataAlign, - display: hidden ? 'none' : null - }; - - var opts = {}; - - if (cellEdit) { - if (cellEdit.mode === _Const2.default.CELL_EDIT_CLICK) { - opts.onClick = this.handleCellEdit; - } else if (cellEdit.mode === _Const2.default.CELL_EDIT_DBCLICK) { - opts.onDoubleClick = this.handleCellEdit; - } - } - return _react2.default.createElement( - 'td', - _extends({ style: tdStyle, - title: columnTitle, - className: className - }, opts), - typeof children === 'boolean' ? children.toString() : children - ); - } - }]); - - return TableColumn; -}(_react.Component); - -TableColumn.propTypes = { - rIndex: _react.PropTypes.number, - dataAlign: _react.PropTypes.string, - hidden: _react.PropTypes.bool, - className: _react.PropTypes.string, - columnTitle: _react.PropTypes.string, - children: _react.PropTypes.node -}; - -TableColumn.defaultProps = { - dataAlign: 'left', - hidden: false, - className: '' -}; -var _default = TableColumn; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(TableColumn, 'TableColumn', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableColumn.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableColumn.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableEditColumn.js b/lib/TableEditColumn.js deleted file mode 100644 index 2e929ead1..000000000 --- a/lib/TableEditColumn.js +++ /dev/null @@ -1,244 +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 _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Editor = require('./Editor'); - -var _Editor2 = _interopRequireDefault(_Editor); - -var _Notification = require('./Notification.js'); - -var _Notification2 = _interopRequireDefault(_Notification); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 TableEditColumn = function (_Component) { - _inherits(TableEditColumn, _Component); - - function TableEditColumn(props) { - _classCallCheck(this, TableEditColumn); - - var _this = _possibleConstructorReturn(this, (TableEditColumn.__proto__ || Object.getPrototypeOf(TableEditColumn)).call(this, props)); - - _this.handleKeyPress = function () { - return _this.__handleKeyPress__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleBlur = function () { - return _this.__handleBlur__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleCustomUpdate = function () { - return _this.__handleCustomUpdate__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.timeouteClear = 0; - _this.state = { - shakeEditor: false - }; - return _this; - } - - _createClass(TableEditColumn, [{ - key: '__handleKeyPress__REACT_HOT_LOADER__', - value: function __handleKeyPress__REACT_HOT_LOADER__(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); - } else if (e.type === 'click' && !this.props.blurToSave) { - // textarea click save button - var _value = e.target.parentElement.firstChild.value; - if (!this.validator(_value)) { - return; - } - this.props.completeEdit(_value, this.props.rowIndex, this.props.colIndex); - } - } - }, { - key: '__handleBlur__REACT_HOT_LOADER__', - value: function __handleBlur__REACT_HOT_LOADER__(e) { - e.stopPropagation(); - 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: '__handleCustomUpdate__REACT_HOT_LOADER__', - - - // modified by iuculanop - // BEGIN - value: function __handleCustomUpdate__REACT_HOT_LOADER__(value) { - this.props.completeEdit(value, this.props.rowIndex, this.props.colIndex); - } - }, { - key: 'validator', - value: function validator(value) { - var ts = this; - var valid = true; - if (ts.props.editable.validator) { - var input = ts.refs.inputRef; - var checkVal = ts.props.editable.validator(value); - var responseType = typeof checkVal === 'undefined' ? 'undefined' : _typeof(checkVal); - if (responseType !== 'object' && checkVal !== true) { - valid = false; - ts.refs.notifier.notice('error', checkVal, 'Pressed ESC can cancel'); - } else if (responseType === 'object' && checkVal.isValid !== true) { - valid = false; - ts.refs.notifier.notice(checkVal.notification.type, checkVal.notification.msg, checkVal.notification.title); - } - if (!valid) { - // animate input - ts.clearTimeout(); - ts.setState({ shakeEditor: true }); - ts.timeouteClear = setTimeout(function () { - ts.setState({ shakeEditor: false }); - }, 300); - input.focus(); - return valid; - } - } - return valid; - } - // END - - }, { - 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() { - this.refs.inputRef.focus(); - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.clearTimeout(); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - editable = _props.editable, - format = _props.format, - customEditor = _props.customEditor; - var shakeEditor = this.state.shakeEditor; - - var attr = { - ref: 'inputRef', - onKeyDown: this.handleKeyPress, - onBlur: this.handleBlur - }; - var fieldValue = this.props.fieldValue; - // put placeholder if exist - - editable.placeholder && (attr.placeholder = editable.placeholder); - - var editorClass = (0, _classnames2.default)({ 'animated': shakeEditor, 'shake': shakeEditor }); - var cellEditor = void 0; - if (customEditor) { - var customEditorProps = _extends({ - row: this.props.row - }, attr, { - defaultValue: fieldValue || '' - }, customEditor.customEditorParameters); - cellEditor = customEditor.getElement(this.handleCustomUpdate, customEditorProps); - } else { - fieldValue = fieldValue === 0 ? '0' : fieldValue; - cellEditor = (0, _Editor2.default)(editable, attr, format, editorClass, fieldValue || ''); - } - - return _react2.default.createElement( - 'td', - { ref: 'td', style: { position: 'relative' } }, - cellEditor, - _react2.default.createElement(_Notification2.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; -}(_react.Component); - -TableEditColumn.propTypes = { - completeEdit: _react.PropTypes.func, - rowIndex: _react.PropTypes.number, - colIndex: _react.PropTypes.number, - blurToSave: _react.PropTypes.bool, - editable: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.object]), - format: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.func]), - row: _react.PropTypes.any, - fieldValue: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.bool, _react.PropTypes.number, _react.PropTypes.array, _react.PropTypes.object]) -}; - -var _default = TableEditColumn; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(TableEditColumn, 'TableEditColumn', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableEditColumn.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableEditColumn.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableFilter.js b/lib/TableFilter.js deleted file mode 100644 index 29576c445..000000000 --- a/lib/TableFilter.js +++ /dev/null @@ -1,147 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 TableFilter = function (_Component) { - _inherits(TableFilter, _Component); - - function TableFilter(props) { - _classCallCheck(this, TableFilter); - - var _this = _possibleConstructorReturn(this, (TableFilter.__proto__ || Object.getPrototypeOf(TableFilter)).call(this, props)); - - _this.handleKeyUp = function () { - return _this.__handleKeyUp__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.filterObj = {}; - return _this; - } - - _createClass(TableFilter, [{ - key: '__handleKeyUp__REACT_HOT_LOADER__', - value: function __handleKeyUp__REACT_HOT_LOADER__(e) { - var _e$currentTarget = e.currentTarget, - value = _e$currentTarget.value, - name = _e$currentTarget.name; - - if (value.trim() === '') { - delete this.filterObj[name]; - } else { - this.filterObj[name] = value; - } - this.props.onFilter(this.filterObj); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - striped = _props.striped, - condensed = _props.condensed, - rowSelectType = _props.rowSelectType, - columns = _props.columns; - - var tableClasses = (0, _classnames2.default)('table', { - 'table-striped': striped, - 'table-condensed': condensed - }); - var selectRowHeader = null; - - if (rowSelectType === _Const2.default.ROW_SELECT_SINGLE || 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 = columns.map(function (column) { - var hidden = column.hidden, - width = column.width, - name = column.name; - - var thStyle = { - display: hidden ? 'none' : null, - width: width - }; - return _react2.default.createElement( - 'th', - { key: name, style: thStyle }, - _react2.default.createElement( - 'div', - { className: 'th-inner table-header-column' }, - _react2.default.createElement('input', { size: '10', type: 'text', - placeholder: name, name: name, onKeyUp: this.handleKeyUp }) - ) - ); - }, 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; -}(_react.Component); - -TableFilter.propTypes = { - columns: _react.PropTypes.array, - rowSelectType: _react.PropTypes.string, - onFilter: _react.PropTypes.func -}; -var _default = TableFilter; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(TableFilter, 'TableFilter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableFilter.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableFilter.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableHeader.js b/lib/TableHeader.js deleted file mode 100644 index e0a8264eb..000000000 --- a/lib/TableHeader.js +++ /dev/null @@ -1,192 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactDom = require('react-dom'); - -var _reactDom2 = _interopRequireDefault(_reactDom); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _SelectRowHeaderColumn = require('./SelectRowHeaderColumn'); - -var _SelectRowHeaderColumn2 = _interopRequireDefault(_SelectRowHeaderColumn); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 Checkbox = function (_Component) { - _inherits(Checkbox, _Component); - - function Checkbox() { - _classCallCheck(this, Checkbox); - - return _possibleConstructorReturn(this, (Checkbox.__proto__ || Object.getPrototypeOf(Checkbox)).apply(this, arguments)); - } - - _createClass(Checkbox, [{ - key: 'componentDidMount', - value: function componentDidMount() { - this.update(this.props.checked); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { - this.update(props.checked); - } - }, { - key: 'update', - value: function update(checked) { - _reactDom2.default.findDOMNode(this).indeterminate = checked === 'indeterminate'; - } - }, { - key: 'render', - value: function render() { - return _react2.default.createElement('input', { className: 'react-bs-select-all', - type: 'checkbox', - checked: this.props.checked, - onChange: this.props.onChange }); - } - }]); - - return Checkbox; -}(_react.Component); - -var TableHeader = function (_Component2) { - _inherits(TableHeader, _Component2); - - function TableHeader() { - _classCallCheck(this, TableHeader); - - return _possibleConstructorReturn(this, (TableHeader.__proto__ || Object.getPrototypeOf(TableHeader)).apply(this, arguments)); - } - - _createClass(TableHeader, [{ - key: 'render', - value: function render() { - var _this3 = this; - - var containerClasses = (0, _classnames2.default)('react-bs-container-header', 'table-header-wrapper', this.props.headerContainerClass); - var tableClasses = (0, _classnames2.default)('table', 'table-hover', { - 'table-bordered': this.props.bordered, - 'table-condensed': this.props.condensed - }, this.props.tableHeaderClass); - var selectRowHeaderCol = null; - if (!this.props.hideSelectColumn) selectRowHeaderCol = this.renderSelectRowHeader(); - var i = 0; - return _react2.default.createElement( - 'div', - { ref: 'container', className: containerClasses, style: this.props.style }, - _react2.default.createElement( - 'table', - { className: tableClasses }, - _react2.default.createElement( - 'thead', - null, - _react2.default.createElement( - 'tr', - { ref: 'header' }, - selectRowHeaderCol, - _react2.default.Children.map(this.props.children, function (elm) { - var _props = _this3.props, - sortIndicator = _props.sortIndicator, - sortName = _props.sortName, - sortOrder = _props.sortOrder, - onSort = _props.onSort; - var _elm$props = elm.props, - dataField = _elm$props.dataField, - dataSort = _elm$props.dataSort; - - var sort = dataSort && dataField === sortName ? sortOrder : undefined; - return _react2.default.cloneElement(elm, { key: i++, onSort: onSort, sort: sort, sortIndicator: sortIndicator }); - }) - ) - ) - ) - ); - } - }, { - key: 'renderSelectRowHeader', - value: function renderSelectRowHeader() { - if (this.props.customComponent) { - var CustomComponent = this.props.customComponent; - return _react2.default.createElement( - _SelectRowHeaderColumn2.default, - null, - _react2.default.createElement(CustomComponent, { type: 'checkbox', checked: this.props.isSelectAll, - indeterminate: this.props.isSelectAll === 'indeterminate', disabled: false, - onChange: this.props.onSelectAllRow, rowIndex: 'Header' }) - ); - } else 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(Checkbox, { - onChange: this.props.onSelectAllRow, - checked: this.props.isSelectAll }) - ); - } else { - return null; - } - } - }]); - - return TableHeader; -}(_react.Component); - -TableHeader.propTypes = { - headerContainerClass: _react.PropTypes.string, - tableHeaderClass: _react.PropTypes.string, - style: _react.PropTypes.object, - rowSelectType: _react.PropTypes.string, - onSort: _react.PropTypes.func, - onSelectAllRow: _react.PropTypes.func, - sortName: _react.PropTypes.string, - sortOrder: _react.PropTypes.string, - hideSelectColumn: _react.PropTypes.bool, - bordered: _react.PropTypes.bool, - condensed: _react.PropTypes.bool, - isFiltered: _react.PropTypes.bool, - isSelectAll: _react.PropTypes.oneOf([true, 'indeterminate', false]), - sortIndicator: _react.PropTypes.bool, - customComponent: _react.PropTypes.func -}; - -var _default = TableHeader; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(Checkbox, 'Checkbox', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableHeader.js'); - - __REACT_HOT_LOADER__.register(TableHeader, 'TableHeader', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableHeader.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableHeader.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableHeaderColumn.js b/lib/TableHeaderColumn.js deleted file mode 100644 index 0ed2f6b39..000000000 --- a/lib/TableHeaderColumn.js +++ /dev/null @@ -1,357 +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 _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 _Date = require('./filters/Date'); - -var _Date2 = _interopRequireDefault(_Date); - -var _Text = require('./filters/Text'); - -var _Text2 = _interopRequireDefault(_Text); - -var _Regex = require('./filters/Regex'); - -var _Regex2 = _interopRequireDefault(_Regex); - -var _Select = require('./filters/Select'); - -var _Select2 = _interopRequireDefault(_Select); - -var _Number = require('./filters/Number'); - -var _Number2 = _interopRequireDefault(_Number); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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; } /* eslint default-case: 0 */ -/* eslint guard-for-in: 0 */ - - -var TableHeaderColumn = function (_Component) { - _inherits(TableHeaderColumn, _Component); - - function TableHeaderColumn(props) { - _classCallCheck(this, TableHeaderColumn); - - var _this = _possibleConstructorReturn(this, (TableHeaderColumn.__proto__ || Object.getPrototypeOf(TableHeaderColumn)).call(this, props)); - - _this.handleColumnClick = function () { - return _this.__handleColumnClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleFilter = _this.handleFilter.bind(_this); - return _this; - } - - _createClass(TableHeaderColumn, [{ - key: '__handleColumnClick__REACT_HOT_LOADER__', - value: function __handleColumnClick__REACT_HOT_LOADER__() { - if (!this.props.dataSort) return; - var order = this.props.sort === _Const2.default.SORT_DESC ? _Const2.default.SORT_ASC : _Const2.default.SORT_DESC; - this.props.onSort(order, this.props.dataField); - } - }, { - key: 'handleFilter', - value: function handleFilter(value, type) { - this.props.filter.emitter.handleFilter(this.props.dataField, value, type); - } - }, { - key: 'getFilters', - value: function getFilters() { - switch (this.props.filter.type) { - case _Const2.default.FILTER_TYPE.TEXT: - { - return _react2.default.createElement(_Text2.default, _extends({ ref: 'textFilter' }, this.props.filter, { - columnName: this.props.children, filterHandler: this.handleFilter })); - } - case _Const2.default.FILTER_TYPE.REGEX: - { - return _react2.default.createElement(_Regex2.default, _extends({ ref: 'regexFilter' }, this.props.filter, { - columnName: this.props.children, filterHandler: this.handleFilter })); - } - case _Const2.default.FILTER_TYPE.SELECT: - { - return _react2.default.createElement(_Select2.default, _extends({ ref: 'selectFilter' }, this.props.filter, { - columnName: this.props.children, filterHandler: this.handleFilter })); - } - case _Const2.default.FILTER_TYPE.NUMBER: - { - return _react2.default.createElement(_Number2.default, _extends({ ref: 'numberFilter' }, this.props.filter, { - columnName: this.props.children, filterHandler: this.handleFilter })); - } - case _Const2.default.FILTER_TYPE.DATE: - { - return _react2.default.createElement(_Date2.default, _extends({ ref: 'dateFilter' }, this.props.filter, { - columnName: this.props.children, filterHandler: this.handleFilter })); - } - case _Const2.default.FILTER_TYPE.CUSTOM: - { - var elm = this.props.filter.getElement(this.handleFilter, this.props.filter.customFilterParameters); - - return _react2.default.cloneElement(elm, { ref: 'customFilter' }); - } - } - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - this.refs['header-col'].setAttribute('data-field', this.props.dataField); - } - }, { - key: 'render', - value: function render() { - var defaultCaret = void 0; - var _props = this.props, - dataAlign = _props.dataAlign, - dataField = _props.dataField, - headerAlign = _props.headerAlign, - headerTitle = _props.headerTitle, - hidden = _props.hidden, - sort = _props.sort, - dataSort = _props.dataSort, - sortIndicator = _props.sortIndicator, - children = _props.children, - caretRender = _props.caretRender, - className = _props.className; - - var thStyle = { - textAlign: headerAlign || dataAlign, - display: hidden ? 'none' : null - }; - if (sortIndicator) { - defaultCaret = !dataSort ? null : _react2.default.createElement( - 'span', - { className: 'order' }, - _react2.default.createElement( - 'span', - { className: 'dropdown' }, - _react2.default.createElement('span', { className: 'caret', style: { margin: '10px 0 10px 5px', color: '#ccc' } }) - ), - _react2.default.createElement( - 'span', - { className: 'dropup' }, - _react2.default.createElement('span', { className: 'caret', style: { margin: '10px 0', color: '#ccc' } }) - ) - ); - } - var sortCaret = sort ? _util2.default.renderReactSortCaret(sort) : defaultCaret; - if (caretRender) { - sortCaret = caretRender(sort, dataField); - } - var classes = (0, _classnames2.default)(typeof className === 'function' ? className() : className, dataSort ? 'sort-column' : ''); - - var title = headerTitle && typeof children === 'string' ? { title: children } : null; - return _react2.default.createElement( - 'th', - _extends({ ref: 'header-col', - className: classes, - style: thStyle, - onClick: this.handleColumnClick - }, title), - children, - sortCaret, - _react2.default.createElement( - 'div', - { onClick: function onClick(e) { - return e.stopPropagation(); - } }, - this.props.filter ? this.getFilters() : null - ) - ); - } - }, { - key: 'cleanFiltered', - value: function cleanFiltered() { - if (this.props.filter === undefined) { - return; - } - - switch (this.props.filter.type) { - case _Const2.default.FILTER_TYPE.TEXT: - { - this.refs.textFilter.cleanFiltered(); - break; - } - case _Const2.default.FILTER_TYPE.REGEX: - { - this.refs.regexFilter.cleanFiltered(); - break; - } - case _Const2.default.FILTER_TYPE.SELECT: - { - this.refs.selectFilter.cleanFiltered(); - break; - } - case _Const2.default.FILTER_TYPE.NUMBER: - { - this.refs.numberFilter.cleanFiltered(); - break; - } - case _Const2.default.FILTER_TYPE.DATE: - { - this.refs.dateFilter.cleanFiltered(); - break; - } - case _Const2.default.FILTER_TYPE.CUSTOM: - { - this.refs.customFilter.cleanFiltered(); - break; - } - } - } - }, { - key: 'applyFilter', - value: function applyFilter(val) { - if (this.props.filter === undefined) return; - switch (this.props.filter.type) { - case _Const2.default.FILTER_TYPE.TEXT: - { - this.refs.textFilter.applyFilter(val); - break; - } - case _Const2.default.FILTER_TYPE.REGEX: - { - this.refs.regexFilter.applyFilter(val); - break; - } - case _Const2.default.FILTER_TYPE.SELECT: - { - this.refs.selectFilter.applyFilter(val); - break; - } - case _Const2.default.FILTER_TYPE.NUMBER: - { - this.refs.numberFilter.applyFilter(val); - break; - } - case _Const2.default.FILTER_TYPE.DATE: - { - this.refs.dateFilter.applyFilter(val); - break; - } - } - } - }]); - - return TableHeaderColumn; -}(_react.Component); - -var filterTypeArray = []; -for (var key in _Const2.default.FILTER_TYPE) { - filterTypeArray.push(_Const2.default.FILTER_TYPE[key]); -} - -TableHeaderColumn.propTypes = { - dataField: _react.PropTypes.string, - dataAlign: _react.PropTypes.string, - headerAlign: _react.PropTypes.string, - headerTitle: _react.PropTypes.bool, - dataSort: _react.PropTypes.bool, - onSort: _react.PropTypes.func, - dataFormat: _react.PropTypes.func, - csvFormat: _react.PropTypes.func, - csvHeader: _react.PropTypes.string, - isKey: _react.PropTypes.bool, - editable: _react.PropTypes.any, - hidden: _react.PropTypes.bool, - hiddenOnInsert: _react.PropTypes.bool, - searchable: _react.PropTypes.bool, - className: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.func]), - width: _react.PropTypes.string, - sortFunc: _react.PropTypes.func, - sortFuncExtraData: _react.PropTypes.any, - columnClassName: _react.PropTypes.any, - columnTitle: _react.PropTypes.bool, - filterFormatted: _react.PropTypes.bool, - filterValue: _react.PropTypes.func, - sort: _react.PropTypes.string, - caretRender: _react.PropTypes.func, - formatExtraData: _react.PropTypes.any, - filter: _react.PropTypes.shape({ - type: _react.PropTypes.oneOf(filterTypeArray), - delay: _react.PropTypes.number, - options: _react.PropTypes.oneOfType([_react.PropTypes.object, // for SelectFilter - _react.PropTypes.arrayOf(_react.PropTypes.number) // for NumberFilter - ]), - numberComparators: _react.PropTypes.arrayOf(_react.PropTypes.string), - emitter: _react.PropTypes.object, - placeholder: _react.PropTypes.string, - getElement: _react.PropTypes.func, - customFilterParameters: _react.PropTypes.object - }), - sortIndicator: _react.PropTypes.bool, - export: _react.PropTypes.bool -}; - -TableHeaderColumn.defaultProps = { - dataAlign: 'left', - headerAlign: undefined, - headerTitle: true, - dataSort: false, - dataFormat: undefined, - csvFormat: undefined, - csvHeader: undefined, - isKey: false, - editable: true, - onSort: undefined, - hidden: false, - hiddenOnInsert: false, - searchable: true, - className: '', - columnTitle: false, - width: null, - sortFunc: undefined, - columnClassName: '', - filterFormatted: false, - filterValue: undefined, - sort: undefined, - formatExtraData: undefined, - sortFuncExtraData: undefined, - filter: undefined, - sortIndicator: true -}; - -var _default = TableHeaderColumn; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(TableHeaderColumn, 'TableHeaderColumn', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableHeaderColumn.js'); - - __REACT_HOT_LOADER__.register(filterTypeArray, 'filterTypeArray', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableHeaderColumn.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableHeaderColumn.js'); -}(); - -; \ No newline at end of file diff --git a/lib/TableRow.js b/lib/TableRow.js deleted file mode 100644 index fb73f91b2..000000000 --- a/lib/TableRow.js +++ /dev/null @@ -1,177 +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 _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 TableRow = function (_Component) { - _inherits(TableRow, _Component); - - function TableRow(props) { - _classCallCheck(this, TableRow); - - var _this = _possibleConstructorReturn(this, (TableRow.__proto__ || Object.getPrototypeOf(TableRow)).call(this, props)); - - _this.rowClick = function () { - return _this.__rowClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.rowDoubleClick = function () { - return _this.__rowDoubleClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.rowMouseOut = function () { - return _this.__rowMouseOut__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.rowMouseOver = function () { - return _this.__rowMouseOver__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.clickNum = 0; - return _this; - } - - _createClass(TableRow, [{ - key: '__rowClick__REACT_HOT_LOADER__', - value: function __rowClick__REACT_HOT_LOADER__(e) { - var _this2 = this; - - if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'SELECT' && e.target.tagName !== 'TEXTAREA') { - (function () { - var rowIndex = _this2.props.index + 1; - var _props = _this2.props, - selectRow = _props.selectRow, - unselectableRow = _props.unselectableRow, - isSelected = _props.isSelected, - onSelectRow = _props.onSelectRow; - - if (selectRow) { - if (selectRow.clickToSelect && !unselectableRow) { - onSelectRow(rowIndex, !isSelected, e); - } else if (selectRow.clickToSelectAndEditCell && !unselectableRow) { - _this2.clickNum++; - /** if clickToSelectAndEditCell is enabled, - * there should be a delay to prevent a selection changed when - * user dblick to edit cell on same row but different cell - **/ - setTimeout(function () { - if (_this2.clickNum === 1) { - onSelectRow(rowIndex, !isSelected, e); - } - _this2.clickNum = 0; - }, 200); - } - } - if (_this2.props.onRowClick) _this2.props.onRowClick(rowIndex); - })(); - } - } - }, { - key: '__rowDoubleClick__REACT_HOT_LOADER__', - value: function __rowDoubleClick__REACT_HOT_LOADER__(e) { - if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'SELECT' && e.target.tagName !== 'TEXTAREA') { - var rowIndex = e.currentTarget.rowIndex + 1; - if (this.props.onRowDoubleClick) { - this.props.onRowDoubleClick(rowIndex); - } - } - } - }, { - key: '__rowMouseOut__REACT_HOT_LOADER__', - value: function __rowMouseOut__REACT_HOT_LOADER__(e) { - if (this.props.onRowMouseOut) { - this.props.onRowMouseOut(e.currentTarget.rowIndex, e); - } - } - }, { - key: '__rowMouseOver__REACT_HOT_LOADER__', - value: function __rowMouseOver__REACT_HOT_LOADER__(e) { - if (this.props.onRowMouseOver) { - this.props.onRowMouseOver(e.currentTarget.rowIndex, e); - } - } - }, { - key: 'render', - value: function render() { - this.clickNum = 0; - var trCss = { - style: { - backgroundColor: this.props.isSelected ? this.props.selectRow.bgColor : null - }, - className: (0, _classnames2.default)(this.props.isSelected ? this.props.selectRow.className : null, this.props.className) - }; - - if (this.props.selectRow && (this.props.selectRow.clickToSelect || this.props.selectRow.clickToSelectAndEditCell) || this.props.onRowClick || this.props.onRowDoubleClick) { - return _react2.default.createElement( - 'tr', - _extends({}, trCss, { - onMouseOver: this.rowMouseOver, - onMouseOut: this.rowMouseOut, - onClick: this.rowClick, - onDoubleClick: this.rowDoubleClick }), - this.props.children - ); - } else { - return _react2.default.createElement( - 'tr', - trCss, - this.props.children - ); - } - } - }]); - - return TableRow; -}(_react.Component); - -TableRow.propTypes = { - index: _react.PropTypes.number, - isSelected: _react.PropTypes.bool, - enableCellEdit: _react.PropTypes.bool, - onRowClick: _react.PropTypes.func, - onRowDoubleClick: _react.PropTypes.func, - onSelectRow: _react.PropTypes.func, - onRowMouseOut: _react.PropTypes.func, - onRowMouseOver: _react.PropTypes.func, - unselectableRow: _react.PropTypes.bool -}; -TableRow.defaultProps = { - onRowClick: undefined, - onRowDoubleClick: undefined -}; -var _default = TableRow; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(TableRow, 'TableRow', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableRow.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/TableRow.js'); -}(); - -; \ 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 35da899a0..000000000 --- a/lib/csv_export_util.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _util = require('./util'); - -var _util2 = _interopRequireDefault(_util); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (_util2.default.canUseDOM()) { - var filesaver = require('./filesaver'); - var saveAs = filesaver.saveAs; -} /* eslint block-scoped-var: 0 */ -/* eslint vars-on-top: 0 */ -/* eslint no-var: 0 */ -/* eslint no-unused-vars: 0 */ - - -function toString(data, keys) { - var dataString = ''; - if (data.length === 0) return dataString; - - dataString += keys.map(function (x) { - return x.header; - }).join(',') + '\n'; - - data.map(function (row) { - keys.map(function (col, i) { - var field = col.field, - format = col.format; - - var value = typeof format !== 'undefined' ? format(row[field], row) : row[field]; - var cell = typeof value !== 'undefined' ? '"' + value + '"' : ''; - dataString += cell; - if (i + 1 < keys.length) dataString += ','; - }); - - 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, true); - } -}; - -var _default = exportCSV; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(saveAs, 'saveAs', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/csv_export_util.js'); - - __REACT_HOT_LOADER__.register(toString, 'toString', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/csv_export_util.js'); - - __REACT_HOT_LOADER__.register(exportCSV, 'exportCSV', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/csv_export_util.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/csv_export_util.js'); -}(); - -; \ No newline at end of file diff --git a/lib/filesaver.js b/lib/filesaver.js deleted file mode 100644 index 4c4bcea5f..000000000 --- a/lib/filesaver.js +++ /dev/null @@ -1,275 +0,0 @@ -"use strict"; - -/* 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 */ - -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(["\uFEFF", 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; - }); -} -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(saveAs, "saveAs", "/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filesaver.js"); -}(); - -; \ No newline at end of file diff --git a/lib/filters/Date.js b/lib/filters/Date.js deleted file mode 100644 index 205f66f44..000000000 --- a/lib/filters/Date.js +++ /dev/null @@ -1,198 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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; } /* eslint quotes: 0 */ -/* eslint max-len: 0 */ - - -var legalComparators = ['=', '>', '>=', '<', '<=', '!=']; - -function dateParser(d) { - return d.getFullYear() + '-' + ("0" + (d.getMonth() + 1)).slice(-2) + '-' + ("0" + d.getDate()).slice(-2); -} - -var DateFilter = function (_Component) { - _inherits(DateFilter, _Component); - - function DateFilter(props) { - _classCallCheck(this, DateFilter); - - var _this = _possibleConstructorReturn(this, (DateFilter.__proto__ || Object.getPrototypeOf(DateFilter)).call(this, props)); - - _this.dateComparators = _this.props.dateComparators || legalComparators; - _this.filter = _this.filter.bind(_this); - _this.onChangeComparator = _this.onChangeComparator.bind(_this); - return _this; - } - - _createClass(DateFilter, [{ - key: 'setDefaultDate', - value: function setDefaultDate() { - var defaultDate = ''; - var defaultValue = this.props.defaultValue; - - if (defaultValue && defaultValue.date) { - // Set the appropriate format for the input type=date, i.e. "YYYY-MM-DD" - defaultDate = dateParser(new Date(defaultValue.date)); - } - return defaultDate; - } - }, { - key: 'onChangeComparator', - value: function onChangeComparator(event) { - var date = this.refs.inputDate.value; - var comparator = event.target.value; - if (date === '') { - return; - } - date = new Date(date); - this.props.filterHandler({ date: date, comparator: comparator }, _Const2.default.FILTER_TYPE.DATE); - } - }, { - key: 'getComparatorOptions', - value: function getComparatorOptions() { - var optionTags = []; - optionTags.push(_react2.default.createElement('option', { key: '-1' })); - for (var i = 0; i < this.dateComparators.length; i++) { - optionTags.push(_react2.default.createElement( - 'option', - { key: i, value: this.dateComparators[i] }, - this.dateComparators[i] - )); - } - return optionTags; - } - }, { - key: 'filter', - value: function filter(event) { - var comparator = this.refs.dateFilterComparator.value; - var dateValue = event.target.value; - if (dateValue) { - this.props.filterHandler({ date: new Date(dateValue), comparator: comparator }, _Const2.default.FILTER_TYPE.DATE); - } else { - this.props.filterHandler(null, _Const2.default.FILTER_TYPE.DATE); - } - } - }, { - key: 'cleanFiltered', - value: function cleanFiltered() { - var value = this.setDefaultDate(); - var comparator = this.props.defaultValue ? this.props.defaultValue.comparator : ''; - this.setState({ isPlaceholderSelected: value === '' }); - this.refs.dateFilterComparator.value = comparator; - this.refs.inputDate.value = value; - this.props.filterHandler({ date: new Date(value), comparator: comparator }, _Const2.default.FILTER_TYPE.DATE); - } - }, { - key: 'applyFilter', - value: function applyFilter(filterDateObj) { - var date = filterDateObj.date, - comparator = filterDateObj.comparator; - - this.setState({ isPlaceholderSelected: date === '' }); - this.refs.dateFilterComparator.value = comparator; - this.refs.inputDate.value = dateParser(date); - this.props.filterHandler({ date: date, comparator: comparator }, _Const2.default.FILTER_TYPE.DATE); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var comparator = this.refs.dateFilterComparator.value; - var dateValue = this.refs.inputDate.value; - if (comparator && dateValue) { - this.props.filterHandler({ date: new Date(dateValue), comparator: comparator }, _Const2.default.FILTER_TYPE.DATE); - } - } - }, { - key: 'render', - value: function render() { - var defaultValue = this.props.defaultValue; - - return _react2.default.createElement( - 'div', - { className: 'filter date-filter' }, - _react2.default.createElement( - 'select', - { ref: 'dateFilterComparator', - className: 'date-filter-comparator form-control', - onChange: this.onChangeComparator, - defaultValue: defaultValue ? defaultValue.comparator : '' }, - this.getComparatorOptions() - ), - _react2.default.createElement('input', { ref: 'inputDate', - className: 'filter date-filter-input form-control', - type: 'date', - onChange: this.filter, - defaultValue: this.setDefaultDate() }) - ); - } - }]); - - return DateFilter; -}(_react.Component); - -DateFilter.propTypes = { - filterHandler: _react.PropTypes.func.isRequired, - defaultValue: _react.PropTypes.shape({ - date: _react.PropTypes.object, - comparator: _react.PropTypes.oneOf(legalComparators) - }), - /* eslint consistent-return: 0 */ - dateComparators: function dateComparators(props, propName) { - if (!props[propName]) { - return; - } - for (var i = 0; i < props[propName].length; i++) { - var comparatorIsValid = false; - for (var j = 0; j < legalComparators.length; j++) { - if (legalComparators[j] === props[propName][i]) { - comparatorIsValid = true; - break; - } - } - if (!comparatorIsValid) { - return new Error('Date comparator provided is not supported.\n Use only ' + legalComparators); - } - } - }, - columnName: _react.PropTypes.string -}; - -var _default = DateFilter; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(legalComparators, 'legalComparators', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Date.js'); - - __REACT_HOT_LOADER__.register(dateParser, 'dateParser', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Date.js'); - - __REACT_HOT_LOADER__.register(DateFilter, 'DateFilter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Date.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Date.js'); -}(); - -; \ No newline at end of file diff --git a/lib/filters/Number.js b/lib/filters/Number.js deleted file mode 100644 index a3f221181..000000000 --- a/lib/filters/Number.js +++ /dev/null @@ -1,245 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 legalComparators = ['=', '>', '>=', '<', '<=', '!=']; - -var NumberFilter = function (_Component) { - _inherits(NumberFilter, _Component); - - function NumberFilter(props) { - _classCallCheck(this, NumberFilter); - - var _this = _possibleConstructorReturn(this, (NumberFilter.__proto__ || Object.getPrototypeOf(NumberFilter)).call(this, props)); - - _this.numberComparators = _this.props.numberComparators || legalComparators; - _this.timeout = null; - _this.state = { - isPlaceholderSelected: _this.props.defaultValue === undefined || _this.props.defaultValue.number === undefined || _this.props.options && _this.props.options.indexOf(_this.props.defaultValue.number) === -1 - }; - _this.onChangeNumber = _this.onChangeNumber.bind(_this); - _this.onChangeNumberSet = _this.onChangeNumberSet.bind(_this); - _this.onChangeComparator = _this.onChangeComparator.bind(_this); - return _this; - } - - _createClass(NumberFilter, [{ - key: 'onChangeNumber', - value: function onChangeNumber(event) { - var _this2 = this; - - var comparator = this.refs.numberFilterComparator.value; - if (comparator === '') { - return; - } - if (this.timeout) { - clearTimeout(this.timeout); - } - var filterValue = event.target.value; - this.timeout = setTimeout(function () { - _this2.props.filterHandler({ number: filterValue, comparator: comparator }, _Const2.default.FILTER_TYPE.NUMBER); - }, this.props.delay); - } - }, { - key: 'onChangeNumberSet', - value: function onChangeNumberSet(event) { - var comparator = this.refs.numberFilterComparator.value; - var value = event.target.value; - - this.setState({ isPlaceholderSelected: value === '' }); - if (comparator === '') { - return; - } - this.props.filterHandler({ number: value, comparator: comparator }, _Const2.default.FILTER_TYPE.NUMBER); - } - }, { - key: 'onChangeComparator', - value: function onChangeComparator(event) { - var value = this.refs.numberFilter.value; - var comparator = event.target.value; - if (value === '') { - return; - } - this.props.filterHandler({ number: value, comparator: comparator }, _Const2.default.FILTER_TYPE.NUMBER); - } - }, { - key: 'cleanFiltered', - value: function cleanFiltered() { - var value = this.props.defaultValue ? this.props.defaultValue.number : ''; - var comparator = this.props.defaultValue ? this.props.defaultValue.comparator : ''; - this.setState({ isPlaceholderSelected: value === '' }); - this.refs.numberFilterComparator.value = comparator; - this.refs.numberFilter.value = value; - this.props.filterHandler({ number: value, comparator: comparator }, _Const2.default.FILTER_TYPE.NUMBER); - } - }, { - key: 'applyFilter', - value: function applyFilter(filterObj) { - var number = filterObj.number, - comparator = filterObj.comparator; - - this.setState({ isPlaceholderSelected: number === '' }); - this.refs.numberFilterComparator.value = comparator; - this.refs.numberFilter.value = number; - this.props.filterHandler({ number: number, comparator: comparator }, _Const2.default.FILTER_TYPE.NUMBER); - } - }, { - key: 'getComparatorOptions', - value: function getComparatorOptions() { - var optionTags = []; - optionTags.push(_react2.default.createElement('option', { key: '-1' })); - for (var i = 0; i < this.numberComparators.length; i++) { - optionTags.push(_react2.default.createElement( - 'option', - { key: i, value: this.numberComparators[i] }, - this.numberComparators[i] - )); - } - return optionTags; - } - }, { - key: 'getNumberOptions', - value: function getNumberOptions() { - var optionTags = []; - var options = this.props.options; - - - optionTags.push(_react2.default.createElement( - 'option', - { key: '-1', value: '' }, - this.props.placeholder || 'Select ' + this.props.columnName + '...' - )); - for (var i = 0; i < options.length; i++) { - optionTags.push(_react2.default.createElement( - 'option', - { key: i, value: options[i] }, - options[i] - )); - } - return optionTags; - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var comparator = this.refs.numberFilterComparator.value; - var number = this.refs.numberFilter.value; - if (comparator && number) { - this.props.filterHandler({ number: number, comparator: comparator }, _Const2.default.FILTER_TYPE.NUMBER); - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - clearTimeout(this.timeout); - } - }, { - key: 'render', - value: function render() { - var selectClass = (0, _classnames2.default)('select-filter', 'number-filter-input', 'form-control', { 'placeholder-selected': this.state.isPlaceholderSelected }); - - return _react2.default.createElement( - 'div', - { className: 'filter number-filter' }, - _react2.default.createElement( - 'select', - { ref: 'numberFilterComparator', - className: 'number-filter-comparator form-control', - onChange: this.onChangeComparator, - defaultValue: this.props.defaultValue ? this.props.defaultValue.comparator : '' }, - this.getComparatorOptions() - ), - this.props.options ? _react2.default.createElement( - 'select', - { ref: 'numberFilter', - className: selectClass, - onChange: this.onChangeNumberSet, - defaultValue: this.props.defaultValue ? this.props.defaultValue.number : '' }, - this.getNumberOptions() - ) : _react2.default.createElement('input', { ref: 'numberFilter', - type: 'number', - className: 'number-filter-input form-control', - placeholder: this.props.placeholder || 'Enter ' + this.props.columnName + '...', - onChange: this.onChangeNumber, - defaultValue: this.props.defaultValue ? this.props.defaultValue.number : '' }) - ); - } - }]); - - return NumberFilter; -}(_react.Component); - -NumberFilter.propTypes = { - filterHandler: _react.PropTypes.func.isRequired, - options: _react.PropTypes.arrayOf(_react.PropTypes.number), - defaultValue: _react.PropTypes.shape({ - number: _react.PropTypes.number, - comparator: _react.PropTypes.oneOf(legalComparators) - }), - delay: _react.PropTypes.number, - /* eslint consistent-return: 0 */ - numberComparators: function numberComparators(props, propName) { - if (!props[propName]) { - return; - } - for (var i = 0; i < props[propName].length; i++) { - var comparatorIsValid = false; - for (var j = 0; j < legalComparators.length; j++) { - if (legalComparators[j] === props[propName][i]) { - comparatorIsValid = true; - break; - } - } - if (!comparatorIsValid) { - return new Error('Number comparator provided is not supported.\n Use only ' + legalComparators); - } - } - }, - placeholder: _react.PropTypes.string, - columnName: _react.PropTypes.string -}; - -NumberFilter.defaultProps = { - delay: _Const2.default.FILTER_DELAY -}; - -var _default = NumberFilter; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(legalComparators, 'legalComparators', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Number.js'); - - __REACT_HOT_LOADER__.register(NumberFilter, 'NumberFilter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Number.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Number.js'); -}(); - -; \ No newline at end of file diff --git a/lib/filters/Regex.js b/lib/filters/Regex.js deleted file mode 100644 index ae8bcd10e..000000000 --- a/lib/filters/Regex.js +++ /dev/null @@ -1,123 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 RegexFilter = function (_Component) { - _inherits(RegexFilter, _Component); - - function RegexFilter(props) { - _classCallCheck(this, RegexFilter); - - var _this = _possibleConstructorReturn(this, (RegexFilter.__proto__ || Object.getPrototypeOf(RegexFilter)).call(this, props)); - - _this.filter = _this.filter.bind(_this); - _this.timeout = null; - return _this; - } - - _createClass(RegexFilter, [{ - key: 'filter', - value: function filter(event) { - var _this2 = this; - - if (this.timeout) { - clearTimeout(this.timeout); - } - var filterValue = event.target.value; - this.timeout = setTimeout(function () { - _this2.props.filterHandler(filterValue, _Const2.default.FILTER_TYPE.REGEX); - }, this.props.delay); - } - }, { - key: 'cleanFiltered', - value: function cleanFiltered() { - var value = this.props.defaultValue ? this.props.defaultValue : ''; - this.refs.inputText.value = value; - this.props.filterHandler(value, _Const2.default.FILTER_TYPE.TEXT); - } - }, { - key: 'applyFilter', - value: function applyFilter(filterRegx) { - this.refs.inputText.value = filterRegx; - this.props.filterHandler(filterRegx, _Const2.default.FILTER_TYPE.REGEX); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var value = this.refs.inputText.value; - if (value) { - this.props.filterHandler(value, _Const2.default.FILTER_TYPE.REGEX); - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - clearTimeout(this.timeout); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - defaultValue = _props.defaultValue, - placeholder = _props.placeholder, - columnName = _props.columnName; - - return _react2.default.createElement('input', { ref: 'inputText', - className: 'filter text-filter form-control', - type: 'text', - onChange: this.filter, - placeholder: placeholder || 'Enter Regex for ' + columnName + '...', - defaultValue: defaultValue ? defaultValue : '' }); - } - }]); - - return RegexFilter; -}(_react.Component); - -RegexFilter.propTypes = { - filterHandler: _react.PropTypes.func.isRequired, - defaultValue: _react.PropTypes.string, - delay: _react.PropTypes.number, - placeholder: _react.PropTypes.string, - columnName: _react.PropTypes.string -}; - -RegexFilter.defaultProps = { - delay: _Const2.default.FILTER_DELAY -}; - -var _default = RegexFilter; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(RegexFilter, 'RegexFilter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Regex.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Regex.js'); -}(); - -; \ No newline at end of file diff --git a/lib/filters/Select.js b/lib/filters/Select.js deleted file mode 100644 index 679d6c66e..000000000 --- a/lib/filters/Select.js +++ /dev/null @@ -1,141 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 SelectFilter = function (_Component) { - _inherits(SelectFilter, _Component); - - function SelectFilter(props) { - _classCallCheck(this, SelectFilter); - - var _this = _possibleConstructorReturn(this, (SelectFilter.__proto__ || Object.getPrototypeOf(SelectFilter)).call(this, props)); - - _this.filter = _this.filter.bind(_this); - _this.state = { - isPlaceholderSelected: _this.props.defaultValue === undefined || !_this.props.options.hasOwnProperty(_this.props.defaultValue) - }; - return _this; - } - - _createClass(SelectFilter, [{ - key: 'filter', - value: function filter(event) { - var value = event.target.value; - - this.setState({ isPlaceholderSelected: value === '' }); - this.props.filterHandler(value, _Const2.default.FILTER_TYPE.SELECT); - } - }, { - key: 'cleanFiltered', - value: function cleanFiltered() { - var value = this.props.defaultValue !== undefined ? this.props.defaultValue : ''; - this.setState({ isPlaceholderSelected: value === '' }); - this.refs.selectInput.value = value; - this.props.filterHandler(value, _Const2.default.FILTER_TYPE.SELECT); - } - }, { - key: 'applyFilter', - value: function applyFilter(filterOption) { - filterOption = filterOption + ''; - this.setState({ isPlaceholderSelected: filterOption === '' }); - this.refs.selectInput.value = filterOption; - this.props.filterHandler(filterOption, _Const2.default.FILTER_TYPE.SELECT); - } - }, { - key: 'getOptions', - value: function getOptions() { - var optionTags = []; - var _props = this.props, - options = _props.options, - placeholder = _props.placeholder, - columnName = _props.columnName, - selectText = _props.selectText; - - var selectTextValue = selectText !== undefined ? selectText : 'Select'; - optionTags.push(_react2.default.createElement( - 'option', - { key: '-1', value: '' }, - placeholder || selectTextValue + ' ' + columnName + '...' - )); - Object.keys(options).map(function (key) { - optionTags.push(_react2.default.createElement( - 'option', - { key: key, value: key }, - options[key] + '' - )); - }); - return optionTags; - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var value = this.refs.selectInput.value; - if (value) { - this.props.filterHandler(value, _Const2.default.FILTER_TYPE.SELECT); - } - } - }, { - key: 'render', - value: function render() { - var selectClass = (0, _classnames2.default)('filter', 'select-filter', 'form-control', { 'placeholder-selected': this.state.isPlaceholderSelected }); - - return _react2.default.createElement( - 'select', - { ref: 'selectInput', - className: selectClass, - onChange: this.filter, - defaultValue: this.props.defaultValue !== undefined ? this.props.defaultValue : '' }, - this.getOptions() - ); - } - }]); - - return SelectFilter; -}(_react.Component); - -SelectFilter.propTypes = { - filterHandler: _react.PropTypes.func.isRequired, - options: _react.PropTypes.object.isRequired, - placeholder: _react.PropTypes.string, - columnName: _react.PropTypes.string -}; - -var _default = SelectFilter; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(SelectFilter, 'SelectFilter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Select.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Select.js'); -}(); - -; \ No newline at end of file diff --git a/lib/filters/Text.js b/lib/filters/Text.js deleted file mode 100644 index 176eb2221..000000000 --- a/lib/filters/Text.js +++ /dev/null @@ -1,123 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 TextFilter = function (_Component) { - _inherits(TextFilter, _Component); - - function TextFilter(props) { - _classCallCheck(this, TextFilter); - - var _this = _possibleConstructorReturn(this, (TextFilter.__proto__ || Object.getPrototypeOf(TextFilter)).call(this, props)); - - _this.filter = _this.filter.bind(_this); - _this.timeout = null; - return _this; - } - - _createClass(TextFilter, [{ - key: 'filter', - value: function filter(event) { - var _this2 = this; - - if (this.timeout) { - clearTimeout(this.timeout); - } - var filterValue = event.target.value; - this.timeout = setTimeout(function () { - _this2.props.filterHandler(filterValue, _Const2.default.FILTER_TYPE.TEXT); - }, this.props.delay); - } - }, { - key: 'cleanFiltered', - value: function cleanFiltered() { - var value = this.props.defaultValue ? this.props.defaultValue : ''; - this.refs.inputText.value = value; - this.props.filterHandler(value, _Const2.default.FILTER_TYPE.TEXT); - } - }, { - key: 'applyFilter', - value: function applyFilter(filterText) { - this.refs.inputText.value = filterText; - this.props.filterHandler(filterText, _Const2.default.FILTER_TYPE.TEXT); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var defaultValue = this.refs.inputText.value; - if (defaultValue) { - this.props.filterHandler(defaultValue, _Const2.default.FILTER_TYPE.TEXT); - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - clearTimeout(this.timeout); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - placeholder = _props.placeholder, - columnName = _props.columnName, - defaultValue = _props.defaultValue; - - return _react2.default.createElement('input', { ref: 'inputText', - className: 'filter text-filter form-control', - type: 'text', - onChange: this.filter, - placeholder: placeholder || 'Enter ' + columnName + '...', - defaultValue: defaultValue ? defaultValue : '' }); - } - }]); - - return TextFilter; -}(_react.Component); - -TextFilter.propTypes = { - filterHandler: _react.PropTypes.func.isRequired, - defaultValue: _react.PropTypes.string, - delay: _react.PropTypes.number, - placeholder: _react.PropTypes.string, - columnName: _react.PropTypes.string -}; - -TextFilter.defaultProps = { - delay: _Const2.default.FILTER_DELAY -}; - -var _default = TextFilter; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(TextFilter, 'TextFilter', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Text.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/filters/Text.js'); -}(); - -; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a2b61947..000000000 --- a/lib/index.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.TableHeaderColumn = exports.BootstrapTable = undefined; - -var _BootstrapTable = require('./BootstrapTable'); - -var _BootstrapTable2 = _interopRequireDefault(_BootstrapTable); - -var _TableHeaderColumn = require('./TableHeaderColumn'); - -var _TableHeaderColumn2 = _interopRequireDefault(_TableHeaderColumn); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (typeof window !== 'undefined') { - window.BootstrapTable = _BootstrapTable2.default; - window.TableHeaderColumn = _TableHeaderColumn2.default; -} -exports.BootstrapTable = _BootstrapTable2.default; -exports.TableHeaderColumn = _TableHeaderColumn2.default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } -}(); - -; \ No newline at end of file diff --git a/lib/pagination/PageButton.js b/lib/pagination/PageButton.js deleted file mode 100644 index 3750ac65b..000000000 --- a/lib/pagination/PageButton.js +++ /dev/null @@ -1,92 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 PageButton = function (_Component) { - _inherits(PageButton, _Component); - - function PageButton(props) { - _classCallCheck(this, PageButton); - - var _this = _possibleConstructorReturn(this, (PageButton.__proto__ || Object.getPrototypeOf(PageButton)).call(this, props)); - - _this.pageBtnClick = function () { - return _this.__pageBtnClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - return _this; - } - - _createClass(PageButton, [{ - key: '__pageBtnClick__REACT_HOT_LOADER__', - value: function __pageBtnClick__REACT_HOT_LOADER__(e) { - e.preventDefault(); - this.props.changePage(e.currentTarget.textContent); - } - }, { - key: 'render', - value: function render() { - var classes = (0, _classnames2.default)({ - 'active': this.props.active, - 'disabled': this.props.disable, - 'hidden': this.props.hidden, - 'page-item': true - }); - return _react2.default.createElement( - 'li', - { className: classes }, - _react2.default.createElement( - 'a', - { href: '#', onClick: this.pageBtnClick, className: 'page-link' }, - this.props.children - ) - ); - } - }]); - - return PageButton; -}(_react.Component); - -PageButton.propTypes = { - changePage: _react.PropTypes.func, - active: _react.PropTypes.bool, - disable: _react.PropTypes.bool, - hidden: _react.PropTypes.bool, - children: _react.PropTypes.node -}; - -var _default = PageButton; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(PageButton, 'PageButton', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/pagination/PageButton.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/pagination/PageButton.js'); -}(); - -; \ No newline at end of file diff --git a/lib/pagination/PaginationList.js b/lib/pagination/PaginationList.js deleted file mode 100644 index 80fba1019..000000000 --- a/lib/pagination/PaginationList.js +++ /dev/null @@ -1,331 +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 _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _PageButton = require('./PageButton.js'); - -var _PageButton2 = _interopRequireDefault(_PageButton); - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 PaginationList = function (_Component) { - _inherits(PaginationList, _Component); - - function PaginationList() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, PaginationList); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = PaginationList.__proto__ || Object.getPrototypeOf(PaginationList)).call.apply(_ref, [this].concat(args))), _this), _this.changePage = function () { - var _this2; - - return (_this2 = _this).__changePage__REACT_HOT_LOADER__.apply(_this2, arguments); - }, _this.changeSizePerPage = function () { - var _this3; - - return (_this3 = _this).__changeSizePerPage__REACT_HOT_LOADER__.apply(_this3, arguments); - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(PaginationList, [{ - key: '__changePage__REACT_HOT_LOADER__', - value: function __changePage__REACT_HOT_LOADER__(page) { - var _props = this.props, - pageStartIndex = _props.pageStartIndex, - prePage = _props.prePage, - currPage = _props.currPage, - nextPage = _props.nextPage, - lastPage = _props.lastPage, - firstPage = _props.firstPage, - sizePerPage = _props.sizePerPage; - - - if (page === prePage) { - page = currPage - 1 < pageStartIndex ? pageStartIndex : currPage - 1; - } else if (page === nextPage) { - page = currPage + 1 > this.lastPage ? this.lastPage : currPage + 1; - } else if (page === lastPage) { - page = this.lastPage; - } else if (page === firstPage) { - page = pageStartIndex; - } else { - page = parseInt(page, 10); - } - - if (page !== currPage) { - this.props.changePage(page, sizePerPage); - } - } - }, { - key: '__changeSizePerPage__REACT_HOT_LOADER__', - value: function __changeSizePerPage__REACT_HOT_LOADER__(e) { - e.preventDefault(); - - var selectSize = parseInt(e.currentTarget.getAttribute('data-page'), 10); - var currPage = this.props.currPage; - - if (selectSize !== this.props.sizePerPage) { - this.totalPages = Math.ceil(this.props.dataSize / selectSize); - this.lastPage = this.props.pageStartIndex + this.totalPages - 1; - if (currPage > this.lastPage) currPage = this.lastPage; - this.props.changePage(currPage, selectSize); - if (this.props.onSizePerPageList) { - this.props.onSizePerPageList(selectSize); - } - } - } - }, { - key: 'render', - value: function render() { - var _this4 = this; - - var _props2 = this.props, - currPage = _props2.currPage, - dataSize = _props2.dataSize, - sizePerPage = _props2.sizePerPage, - sizePerPageList = _props2.sizePerPageList, - paginationShowsTotal = _props2.paginationShowsTotal, - pageStartIndex = _props2.pageStartIndex, - hideSizePerPage = _props2.hideSizePerPage; - - var sizePerPageText = ''; - this.totalPages = Math.ceil(dataSize / sizePerPage); - this.lastPage = this.props.pageStartIndex + this.totalPages - 1; - var pageBtns = this.makePage(); - var pageListStyle = { - float: 'right', - // override the margin-top defined in .pagination class in bootstrap. - marginTop: '0px' - }; - - var sizePerPageOptions = sizePerPageList.map(function (_sizePerPage) { - var pageText = _sizePerPage.text || _sizePerPage; - var pageNum = _sizePerPage.value || _sizePerPage; - if (sizePerPage === pageNum) sizePerPageText = pageText; - return _react2.default.createElement( - 'li', - { key: pageText, role: 'presentation' }, - _react2.default.createElement( - 'a', - { role: 'menuitem', - tabIndex: '-1', href: '#', - 'data-page': pageNum, - onClick: _this4.changeSizePerPage }, - pageText - ) - ); - }); - - var offset = Math.abs(_Const2.default.PAGE_START_INDEX - pageStartIndex); - var start = (currPage - pageStartIndex) * sizePerPage; - start = dataSize === 0 ? 0 : start + 1; - var to = Math.min(sizePerPage * (currPage + offset) - 1, dataSize); - if (to >= dataSize) to--; - var total = paginationShowsTotal ? _react2.default.createElement( - 'span', - null, - 'Showing rows ', - start, - ' to\xA0', - to + 1, - ' of\xA0', - dataSize - ) : null; - - if (typeof paginationShowsTotal === 'function') { - total = paginationShowsTotal(start, to + 1, dataSize); - } - - var dropDownStyle = { - visibility: hideSizePerPage ? 'hidden' : 'visible' - }; - - return _react2.default.createElement( - 'div', - { className: 'row', style: { marginTop: 15 } }, - sizePerPageList.length > 1 ? _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'div', - { className: 'col-md-6' }, - total, - ' ', - _react2.default.createElement( - 'span', - { className: 'dropdown', style: dropDownStyle }, - _react2.default.createElement( - 'button', - { className: 'btn btn-default dropdown-toggle', - type: 'button', id: 'pageDropDown', 'data-toggle': 'dropdown', - 'aria-expanded': 'true' }, - sizePerPageText, - _react2.default.createElement( - 'span', - null, - ' ', - _react2.default.createElement('span', { className: 'caret' }) - ) - ), - _react2.default.createElement( - 'ul', - { className: 'dropdown-menu', role: 'menu', 'aria-labelledby': 'pageDropDown' }, - sizePerPageOptions - ) - ) - ), - _react2.default.createElement( - 'div', - { className: 'col-md-6' }, - _react2.default.createElement( - 'ul', - { className: 'pagination', style: pageListStyle }, - pageBtns - ) - ) - ) : _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'div', - { className: 'col-md-6' }, - total - ), - _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.props.currPage; - var disabled = false; - var hidden = false; - if (this.props.currPage === this.props.pageStartIndex && (page === this.props.firstPage || page === this.props.prePage)) { - disabled = true; - hidden = true; - } - if (this.props.currPage === this.lastPage && (page === this.props.nextPage || page === this.props.lastPage)) { - disabled = true; - hidden = true; - } - return _react2.default.createElement( - _PageButton2.default, - { key: page, - changePage: this.changePage, - active: isActive, - disable: disabled, - hidden: hidden }, - page - ); - }, this); - } - }, { - key: 'getPages', - value: function getPages() { - var pages = void 0; - var endPage = this.totalPages; - if (endPage <= 0) return []; - var startPage = Math.max(this.props.currPage - Math.floor(this.props.paginationSize / 2), this.props.pageStartIndex); - endPage = startPage + this.props.paginationSize - 1; - - if (endPage > this.lastPage) { - endPage = this.lastPage; - startPage = endPage - this.props.paginationSize + 1; - } - - if (startPage !== this.props.pageStartIndex && this.totalPages > this.props.paginationSize) { - pages = [this.props.firstPage, this.props.prePage]; - } else if (this.totalPages > 1) { - pages = [this.props.prePage]; - } else { - pages = []; - } - - for (var i = startPage; i <= endPage; i++) { - if (i >= this.props.pageStartIndex) pages.push(i); - } - - if (endPage < this.lastPage) { - pages.push(this.props.nextPage); - pages.push(this.props.lastPage); - } else if (endPage === this.lastPage && this.props.currPage !== this.lastPage) { - pages.push(this.props.nextPage); - } - - return pages; - } - }]); - - return PaginationList; -}(_react.Component); - -PaginationList.propTypes = { - currPage: _react.PropTypes.number, - sizePerPage: _react.PropTypes.number, - dataSize: _react.PropTypes.number, - changePage: _react.PropTypes.func, - sizePerPageList: _react.PropTypes.array, - paginationShowsTotal: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.func]), - paginationSize: _react.PropTypes.number, - remote: _react.PropTypes.bool, - onSizePerPageList: _react.PropTypes.func, - prePage: _react.PropTypes.string, - pageStartIndex: _react.PropTypes.number, - hideSizePerPage: _react.PropTypes.bool -}; - -PaginationList.defaultProps = { - sizePerPage: _Const2.default.SIZE_PER_PAGE, - pageStartIndex: _Const2.default.PAGE_START_INDEX -}; - -var _default = PaginationList; -exports.default = _default; -; - -var _temp2 = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(PaginationList, 'PaginationList', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/pagination/PaginationList.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/pagination/PaginationList.js'); -}(); - -; \ No newline at end of file diff --git a/lib/store/TableDataStore.js b/lib/store/TableDataStore.js deleted file mode 100644 index 0f2d0a3aa..000000000 --- a/lib/store/TableDataStore.js +++ /dev/null @@ -1,676 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.TableDataStore = undefined; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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; }; }(); /* eslint no-nested-ternary: 0 */ -/* eslint guard-for-in: 0 */ -/* eslint no-console: 0 */ -/* eslint eqeqeq: 0 */ -/* eslint one-var: 0 */ - - -var _Const = require('../Const'); - -var _Const2 = _interopRequireDefault(_Const); - -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 _sort(arr, sortField, order, sortFunc, sortFuncExtraData) { - order = order.toLowerCase(); - var isDesc = order === _Const2.default.SORT_DESC; - arr.sort(function (a, b) { - if (sortFunc) { - return sortFunc(a, b, order, sortField, sortFuncExtraData); - } else { - var valueA = a[sortField] === null ? '' : a[sortField]; - var valueB = b[sortField] === null ? '' : b[sortField]; - if (isDesc) { - if (typeof valueB === 'string') { - return valueB.localeCompare(valueA); - } else { - return valueA > valueB ? -1 : valueA < valueB ? 1 : 0; - } - } else { - if (typeof valueA === 'string') { - return valueA.localeCompare(valueB); - } else { - return valueA < valueB ? -1 : valueA > valueB ? 1 : 0; - } - } - } - }); - - return arr; -} - -var TableDataStore = function () { - function TableDataStore(data) { - _classCallCheck(this, TableDataStore); - - this.data = data; - this.colInfos = null; - this.filteredData = null; - this.isOnFilter = false; - this.filterObj = null; - this.searchText = null; - this.sortObj = null; - this.pageObj = {}; - this.selected = []; - this.multiColumnSearch = false; - this.showOnlySelected = false; - this.remote = false; // remote data - } - - _createClass(TableDataStore, [{ - key: 'setProps', - value: function setProps(props) { - this.keyField = props.keyField; - this.enablePagination = props.isPagination; - this.colInfos = props.colInfos; - this.remote = props.remote; - this.multiColumnSearch = props.multiColumnSearch; - } - }, { - key: 'setData', - value: function setData(data) { - this.data = data; - if (this.remote) { - return; - } - - this._refresh(true); - } - }, { - key: 'getColInfos', - value: function getColInfos() { - return this.colInfos; - } - }, { - key: 'getSortInfo', - value: function getSortInfo() { - return this.sortObj; - } - }, { - key: 'setSortInfo', - value: function setSortInfo(order, sortField) { - this.sortObj = { - order: order, - sortField: sortField - }; - } - }, { - key: 'setSelectedRowKey', - value: function setSelectedRowKey(selectedRowKeys) { - this.selected = selectedRowKeys; - } - }, { - key: 'getRowByKey', - value: function getRowByKey(keys) { - var _this = this; - - return keys.map(function (key) { - var result = _this.data.filter(function (d) { - return d[_this.keyField] === key; - }); - if (result.length !== 0) return result[0]; - }); - } - }, { - key: 'getSelectedRowKeys', - value: function getSelectedRowKeys() { - return this.selected; - } - }, { - key: 'getCurrentDisplayData', - value: function getCurrentDisplayData() { - if (this.isOnFilter) return this.filteredData;else return this.data; - } - }, { - key: '_refresh', - value: function _refresh(skipSorting) { - if (this.isOnFilter) { - if (this.filterObj !== null) this.filter(this.filterObj); - if (this.searchText !== null) this.search(this.searchText); - } - if (!skipSorting && this.sortObj) { - this.sort(this.sortObj.order, this.sortObj.sortField); - } - } - }, { - key: 'ignoreNonSelected', - value: function ignoreNonSelected() { - var _this2 = this; - - this.showOnlySelected = !this.showOnlySelected; - if (this.showOnlySelected) { - this.isOnFilter = true; - this.filteredData = this.data.filter(function (row) { - var result = _this2.selected.find(function (x) { - return row[_this2.keyField] === x; - }); - return typeof result !== 'undefined' ? true : false; - }); - } else { - this.isOnFilter = false; - } - } - }, { - key: 'sort', - value: function sort(order, sortField) { - this.setSortInfo(order, sortField); - - var currentDisplayData = this.getCurrentDisplayData(); - if (!this.colInfos[sortField]) return this; - - var _colInfos$sortField = this.colInfos[sortField], - sortFunc = _colInfos$sortField.sortFunc, - sortFuncExtraData = _colInfos$sortField.sortFuncExtraData; - - currentDisplayData = _sort(currentDisplayData, sortField, order, sortFunc, sortFuncExtraData); - - 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 = void 0; - 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[fieldName] = newVal; - } - }, this); - if (this.filterObj !== null) this.filter(this.filterObj); - if (this.searchText !== null) this.search(this.searchText); - } - return this; - } - }, { - key: 'addAtBegin', - value: function addAtBegin(newObj) { - if (!newObj[this.keyField] || newObj[this.keyField].toString() === '') { - throw new Error(this.keyField + ' can\'t be empty value.'); - } - var currentDisplayData = this.getCurrentDisplayData(); - currentDisplayData.forEach(function (row) { - if (row[this.keyField].toString() === newObj[this.keyField].toString()) { - throw new Error(this.keyField + ' ' + newObj[this.keyField] + ' already exists'); - } - }, this); - currentDisplayData.unshift(newObj); - if (this.isOnFilter) { - this.data.unshift(newObj); - } - this._refresh(false); - } - }, { - key: 'add', - value: function add(newObj) { - if (!newObj[this.keyField] || newObj[this.keyField].toString() === '') { - throw new Error(this.keyField + ' can\'t be empty value.'); - } - var currentDisplayData = this.getCurrentDisplayData(); - currentDisplayData.forEach(function (row) { - if (row[this.keyField].toString() === newObj[this.keyField].toString()) { - throw new Error(this.keyField + ' ' + newObj[this.keyField] + ' already exists'); - } - }, this); - - currentDisplayData.push(newObj); - if (this.isOnFilter) { - this.data.push(newObj); - } - this._refresh(false); - } - }, { - key: 'remove', - value: function remove(rowKey) { - var _this3 = this; - - var currentDisplayData = this.getCurrentDisplayData(); - var result = currentDisplayData.filter(function (row) { - return rowKey.indexOf(row[_this3.keyField]) === -1; - }); - - if (this.isOnFilter) { - this.data = this.data.filter(function (row) { - return rowKey.indexOf(row[_this3.keyField]) === -1; - }); - 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; - if (this.searchText) this._search(this.data); - } else { - var source = this.data; - this.filterObj = filterObj; - if (this.searchText) { - this._search(source); - source = this.filteredData; - } - this._filter(source); - } - } - }, { - key: 'filterNumber', - value: function filterNumber(targetVal, filterVal, comparator) { - var valid = true; - switch (comparator) { - case '=': - { - if (targetVal != filterVal) { - valid = false; - } - break; - } - case '>': - { - if (targetVal <= filterVal) { - valid = false; - } - break; - } - case '>=': - { - if (targetVal < filterVal) { - valid = false; - } - break; - } - case '<': - { - if (targetVal >= filterVal) { - valid = false; - } - break; - } - case '<=': - { - if (targetVal > filterVal) { - valid = false; - } - break; - } - case '!=': - { - if (targetVal == filterVal) { - valid = false; - } - break; - } - default: - { - console.error('Number comparator provided is not supported'); - break; - } - } - return valid; - } - }, { - key: 'filterDate', - value: function filterDate(targetVal, filterVal, comparator) { - // if (!targetVal) { - // return false; - // } - // return (targetVal.getDate() === filterVal.getDate() && - // targetVal.getMonth() === filterVal.getMonth() && - // targetVal.getFullYear() === filterVal.getFullYear()); - - var valid = true; - switch (comparator) { - case '=': - { - if (targetVal != filterVal) { - valid = false; - } - break; - } - case '>': - { - if (targetVal <= filterVal) { - valid = false; - } - break; - } - case '>=': - { - if (targetVal < filterVal) { - valid = false; - } - break; - } - case '<': - { - if (targetVal >= filterVal) { - valid = false; - } - break; - } - case '<=': - { - if (targetVal > filterVal) { - valid = false; - } - break; - } - case '!=': - { - if (targetVal == filterVal) { - valid = false; - } - break; - } - default: - { - console.error('Date comparator provided is not supported'); - break; - } - } - return valid; - } - }, { - key: 'filterRegex', - value: function filterRegex(targetVal, filterVal) { - try { - return new RegExp(filterVal, 'i').test(targetVal); - } catch (e) { - return true; - } - } - }, { - key: 'filterCustom', - value: function filterCustom(targetVal, filterVal, callbackInfo) { - if (callbackInfo !== null && (typeof callbackInfo === 'undefined' ? 'undefined' : _typeof(callbackInfo)) === 'object') { - return callbackInfo.callback(targetVal, callbackInfo.callbackParameters); - } - - return this.filterText(targetVal, filterVal); - } - }, { - key: 'filterText', - value: function filterText(targetVal, filterVal) { - targetVal = targetVal.toString().toLowerCase(); - filterVal = filterVal.toString().toLowerCase(); - if (targetVal.indexOf(filterVal) === -1) { - return false; - } - return true; - } - - /* General search function - * It will search for the text if the input includes that text; - */ - - }, { - key: 'search', - value: function search(searchText) { - if (searchText.trim() === '') { - this.filteredData = null; - this.isOnFilter = false; - this.searchText = null; - if (this.filterObj) this._filter(this.data); - } else { - var source = this.data; - this.searchText = searchText; - if (this.filterObj) { - this._filter(source); - source = this.filteredData; - } - this._search(source); - } - } - }, { - key: '_filter', - value: function _filter(source) { - var _this4 = this; - - var filterObj = this.filterObj; - this.filteredData = source.filter(function (row, r) { - var valid = true; - var filterVal = void 0; - for (var key in filterObj) { - var targetVal = row[key]; - if (targetVal === null || targetVal === undefined) { - targetVal = ''; - } - - switch (filterObj[key].type) { - case _Const2.default.FILTER_TYPE.NUMBER: - { - filterVal = filterObj[key].value.number; - break; - } - case _Const2.default.FILTER_TYPE.CUSTOM: - { - filterVal = _typeof(filterObj[key].value) === 'object' ? undefined : typeof filterObj[key].value === 'string' ? filterObj[key].value.toLowerCase() : filterObj[key].value; - break; - } - case _Const2.default.FILTER_TYPE.DATE: - { - filterVal = filterObj[key].value.date; - break; - } - case _Const2.default.FILTER_TYPE.REGEX: - { - filterVal = filterObj[key].value; - break; - } - default: - { - filterVal = typeof filterObj[key].value === 'string' ? filterObj[key].value.toLowerCase() : filterObj[key].value; - if (filterVal === undefined) { - // Support old filter - filterVal = filterObj[key].toLowerCase(); - } - break; - } - } - var format = void 0, - filterFormatted = void 0, - formatExtraData = void 0, - filterValue = void 0; - if (_this4.colInfos[key]) { - format = _this4.colInfos[key].format; - filterFormatted = _this4.colInfos[key].filterFormatted; - formatExtraData = _this4.colInfos[key].formatExtraData; - filterValue = _this4.colInfos[key].filterValue; - if (filterFormatted && format) { - targetVal = format(row[key], row, formatExtraData, r); - } else if (filterValue) { - targetVal = filterValue(row[key], row); - } - } - - switch (filterObj[key].type) { - case _Const2.default.FILTER_TYPE.NUMBER: - { - valid = _this4.filterNumber(targetVal, filterVal, filterObj[key].value.comparator); - break; - } - case _Const2.default.FILTER_TYPE.DATE: - { - valid = _this4.filterDate(targetVal, filterVal, filterObj[key].value.comparator); - break; - } - case _Const2.default.FILTER_TYPE.REGEX: - { - valid = _this4.filterRegex(targetVal, filterVal); - break; - } - case _Const2.default.FILTER_TYPE.CUSTOM: - { - valid = _this4.filterCustom(targetVal, filterVal, filterObj[key].value); - break; - } - default: - { - if (filterObj[key].type === _Const2.default.FILTER_TYPE.SELECT && filterFormatted && filterFormatted && format) { - filterVal = format(filterVal, row, formatExtraData, r); - } - valid = _this4.filterText(targetVal, filterVal); - break; - } - } - if (!valid) { - break; - } - } - return valid; - }); - this.isOnFilter = true; - } - }, { - key: '_search', - value: function _search(source) { - var _this5 = this; - - var searchTextArray = []; - - if (this.multiColumnSearch) { - searchTextArray = this.searchText.split(' '); - } else { - searchTextArray.push(this.searchText); - } - this.filteredData = source.filter(function (row, r) { - var keys = Object.keys(row); - var valid = false; - // for loops are ugly, but performance matters here. - // And you cant break from a forEach. - // http://jsperf.com/for-vs-foreach/66 - for (var i = 0, keysLength = keys.length; i < keysLength; i++) { - var key = keys[i]; - // fixed data filter when misunderstand 0 is false - var filterSpecialNum = false; - if (!isNaN(row[key]) && parseInt(row[key], 10) === 0) { - filterSpecialNum = true; - } - if (_this5.colInfos[key] && (row[key] || filterSpecialNum)) { - var _colInfos$key = _this5.colInfos[key], - format = _colInfos$key.format, - filterFormatted = _colInfos$key.filterFormatted, - filterValue = _colInfos$key.filterValue, - formatExtraData = _colInfos$key.formatExtraData, - searchable = _colInfos$key.searchable; - - var targetVal = row[key]; - if (searchable) { - if (filterFormatted && format) { - targetVal = format(targetVal, row, formatExtraData, r); - } else if (filterValue) { - targetVal = filterValue(targetVal, row); - } - for (var j = 0, textLength = searchTextArray.length; j < textLength; j++) { - var filterVal = searchTextArray[j].toLowerCase(); - if (targetVal.toString().toLowerCase().indexOf(filterVal) !== -1) { - valid = true; - break; - } - } - } - } - } - return valid; - }); - this.isOnFilter = true; - } - }, { - key: 'getDataIgnoringPagination', - value: function getDataIgnoringPagination() { - return this.getCurrentDisplayData(); - } - }, { - 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: 'isEmpty', - value: function isEmpty() { - return this.data.length === 0 || this.data === null || this.data === undefined; - } - }, { - key: 'getAllRowkey', - value: function getAllRowkey() { - var _this6 = this; - - return this.data.map(function (row) { - return row[_this6.keyField]; - }); - } - }]); - - return TableDataStore; -}(); - -exports.TableDataStore = TableDataStore; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(_sort, '_sort', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/store/TableDataStore.js'); - - __REACT_HOT_LOADER__.register(TableDataStore, 'TableDataStore', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/store/TableDataStore.js'); -}(); - -; \ No newline at end of file diff --git a/lib/toolbar/ToolBar.js b/lib/toolbar/ToolBar.js deleted file mode 100644 index ae9b96bd5..000000000 --- a/lib/toolbar/ToolBar.js +++ /dev/null @@ -1,578 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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 _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 _Notification = require('../Notification.js'); - -var _Notification2 = _interopRequireDefault(_Notification); - -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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -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 ToolBar = function (_Component) { - _inherits(ToolBar, _Component); - - function ToolBar(props) { - var _arguments = arguments; - - _classCallCheck(this, ToolBar); - - var _this = _possibleConstructorReturn(this, (ToolBar.__proto__ || Object.getPrototypeOf(ToolBar)).call(this, props)); - - _this.handleSaveBtnClick = function () { - return _this.__handleSaveBtnClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleShowOnlyToggle = function () { - return _this.__handleShowOnlyToggle__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleDropRowBtnClick = function () { - return _this.__handleDropRowBtnClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleDebounce = function (func, wait, immediate) { - var timeout = void 0; - - return function () { - var later = function later() { - timeout = null; - - if (!immediate) { - func.apply(_this, _arguments); - } - }; - - var callNow = immediate && !timeout; - - clearTimeout(timeout); - - timeout = setTimeout(later, wait || 0); - - if (callNow) { - func.appy(_this, _arguments); - } - }; - }; - - _this.handleKeyUp = function () { - return _this.__handleKeyUp__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleExportCSV = function () { - return _this.__handleExportCSV__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.handleClearBtnClick = function () { - return _this.__handleClearBtnClick__REACT_HOT_LOADER__.apply(_this, arguments); - }; - - _this.timeouteClear = 0; - _this.modalClassName; - _this.state = { - isInsertRowTrigger: true, - validateState: null, - shakeEditor: false, - showSelected: false - }; - return _this; - } - - _createClass(ToolBar, [{ - key: 'componentWillMount', - value: function componentWillMount() { - var _this2 = this; - - var delay = this.props.searchDelayTime ? this.props.searchDelayTime : 0; - this.debounceCallback = this.handleDebounce(function () { - _this2.props.onSearch(_this2.refs.seachInput.value); - }, delay); - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.clearTimeout(); - } - }, { - key: 'setSearchInput', - value: function setSearchInput(text) { - if (this.refs.seachInput.value !== text) { - this.refs.seachInput.value = text; - } - } - }, { - 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; - } - }) - - // modified by iuculanop - // BEGIN - - }, { - key: 'checkAndParseForm', - value: function checkAndParseForm() { - var _this3 = this; - - var newObj = {}; - var validateState = {}; - var isValid = true; - var checkVal = void 0; - var responseType = void 0; - var tempValue = void 0; - - this.props.columns.forEach(function (column, i) { - if (column.autoValue) { - // when you want same auto generate value and not allow edit, example ID field - var time = new Date().getTime(); - tempValue = typeof column.autoValue === 'function' ? column.autoValue() : 'autovalue-' + time; - } else if (column.hiddenOnInsert) { - tempValue = ''; - } else { - var dom = this.refs[column.field + i]; - tempValue = dom.value; - - if (column.editable && column.editable.type === 'checkbox') { - var values = tempValue.split(':'); - tempValue = dom.checked ? values[0] : values[1]; - } - - if (column.editable && column.editable.validator) { - // process validate - checkVal = column.editable.validator(tempValue); - responseType = typeof checkVal === 'undefined' ? 'undefined' : _typeof(checkVal); - if (responseType !== 'object' && checkVal !== true) { - this.refs.notifier.notice('error', 'Form validate errors, please checking!', 'Pressed ESC can cancel'); - isValid = false; - validateState[column.field] = checkVal; - } else if (responseType === 'object' && checkVal.isValid !== true) { - this.refs.notifier.notice(checkVal.notification.type, checkVal.notification.msg, checkVal.notification.title); - isValid = false; - validateState[column.field] = checkVal.notification.msg; - } - } - } - - newObj[column.field] = tempValue; - }, this); - - if (isValid) { - return newObj; - } else { - this.clearTimeout(); - // show error in form and shake it - this.setState({ validateState: validateState, shakeEditor: true }); - this.timeouteClear = setTimeout(function () { - _this3.setState({ shakeEditor: false }); - }, 300); - return null; - } - } - // END - - }, { - key: '__handleSaveBtnClick__REACT_HOT_LOADER__', - value: function __handleSaveBtnClick__REACT_HOT_LOADER__() { - var _this4 = this; - - var newObj = this.checkAndParseForm(); - if (!newObj) { - // validate errors - return; - } - var msg = this.props.onAddRow(newObj); - if (msg) { - this.refs.notifier.notice('error', msg, 'Pressed ESC can cancel'); - this.clearTimeout(); - // shake form and hack prevent modal hide - this.setState({ - shakeEditor: true, - validateState: 'this is hack for prevent bootstrap modal hide' - }); - // clear animate class - this.timeouteClear = setTimeout(function () { - _this4.setState({ shakeEditor: false }); - }, 300); - } else { - // reset state and hide modal hide - this.setState({ - validateState: null, - shakeEditor: false - }, function () { - document.querySelector('.modal-backdrop').click(); - document.querySelector('.' + _this4.modalClassName).click(); - }); - // reset form - this.refs.form.reset(); - } - } - }, { - key: '__handleShowOnlyToggle__REACT_HOT_LOADER__', - value: function __handleShowOnlyToggle__REACT_HOT_LOADER__() { - this.setState({ - showSelected: !this.state.showSelected - }); - this.props.onShowOnlySelected(); - } - }, { - key: '__handleDropRowBtnClick__REACT_HOT_LOADER__', - value: function __handleDropRowBtnClick__REACT_HOT_LOADER__() { - this.props.onDropRow(); - } - }, { - key: 'handleCloseBtn', - value: function handleCloseBtn() { - this.refs.warning.style.display = 'none'; - } - }, { - key: '__handleKeyUp__REACT_HOT_LOADER__', - value: function __handleKeyUp__REACT_HOT_LOADER__(event) { - event.persist(); - this.debounceCallback(event); - } - }, { - key: '__handleExportCSV__REACT_HOT_LOADER__', - value: function __handleExportCSV__REACT_HOT_LOADER__() { - this.props.onExportCSV(); - } - }, { - key: '__handleClearBtnClick__REACT_HOT_LOADER__', - value: function __handleClearBtnClick__REACT_HOT_LOADER__() { - this.refs.seachInput.value = ''; - this.props.onSearch(''); - } - }, { - key: 'render', - value: function render() { - this.modalClassName = 'bs-table-modal-sm' + ToolBar.modalSeq++; - var insertBtn = null; - var deleteBtn = null; - var exportCSV = null; - var showSelectedOnlyBtn = null; - - if (this.props.enableInsert) { - insertBtn = _react2.default.createElement( - 'button', - { type: 'button', - className: 'btn btn-info react-bs-table-add-btn', - 'data-toggle': 'modal', - 'data-target': '.' + this.modalClassName }, - _react2.default.createElement('i', { className: 'glyphicon glyphicon-plus' }), - ' ', - this.props.insertText - ); - } - - if (this.props.enableDelete) { - deleteBtn = _react2.default.createElement( - 'button', - { type: 'button', - className: 'btn btn-warning react-bs-table-del-btn', - 'data-toggle': 'tooltip', - 'data-placement': 'right', - title: 'Drop selected row', - onClick: this.handleDropRowBtnClick }, - _react2.default.createElement('i', { className: 'glyphicon glyphicon-trash' }), - ' ', - this.props.deleteText - ); - } - - if (this.props.enableShowOnlySelected) { - showSelectedOnlyBtn = _react2.default.createElement( - 'button', - { type: 'button', - onClick: this.handleShowOnlyToggle, - className: 'btn btn-primary', - 'data-toggle': 'button', - 'aria-pressed': 'false' }, - this.state.showSelected ? _Const2.default.SHOW_ALL : _Const2.default.SHOW_ONLY_SELECT - ); - } - - if (this.props.enableExportCSV) { - exportCSV = _react2.default.createElement( - 'button', - { type: 'button', - className: 'btn btn-success hidden-print', - onClick: this.handleExportCSV }, - _react2.default.createElement('i', { className: 'glyphicon glyphicon-export' }), - this.props.exportCSVText - ); - } - - var searchTextInput = this.renderSearchPanel(); - var modal = this.props.enableInsert ? this.renderInsertRowModal() : null; - - return _react2.default.createElement( - 'div', - { className: 'row' }, - _react2.default.createElement( - 'div', - { className: 'col-xs-12 col-sm-6 col-md-6 col-lg-8' }, - _react2.default.createElement( - 'div', - { className: 'btn-group btn-group-sm', role: 'group' }, - exportCSV, - insertBtn, - deleteBtn, - showSelectedOnlyBtn - ) - ), - _react2.default.createElement( - 'div', - { className: 'col-xs-12 col-sm-6 col-md-6 col-lg-4' }, - searchTextInput - ), - _react2.default.createElement(_Notification2.default, { ref: 'notifier' }), - modal - ); - } - }, { - key: 'renderSearchPanel', - value: function renderSearchPanel() { - if (this.props.enableSearch) { - var classNames = 'form-group form-group-sm react-bs-table-search-form'; - var clearBtn = null; - if (this.props.clearSearch) { - clearBtn = _react2.default.createElement( - 'span', - { className: 'input-group-btn' }, - _react2.default.createElement( - 'button', - { - className: 'btn btn-default', - type: 'button', - onClick: this.handleClearBtnClick }, - 'Clear' - ) - ); - classNames += ' input-group input-group-sm'; - } - - return _react2.default.createElement( - 'div', - { className: classNames }, - _react2.default.createElement('input', { ref: 'seachInput', - className: 'form-control', - type: 'text', - defaultValue: this.props.defaultSearch, - placeholder: this.props.searchPlaceholder ? this.props.searchPlaceholder : 'Search', - onKeyUp: this.handleKeyUp }), - clearBtn - ); - } else { - return null; - } - } - }, { - key: 'renderInsertRowModal', - value: function renderInsertRowModal() { - var _this5 = this; - - var validateState = this.state.validateState || {}; - var shakeEditor = this.state.shakeEditor; - var inputField = this.props.columns.map(function (column, i) { - var editable = column.editable, - format = column.format, - field = column.field, - name = column.name, - autoValue = column.autoValue, - hiddenOnInsert = column.hiddenOnInsert; - - var attr = { - ref: field + i, - placeholder: editable.placeholder ? editable.placeholder : name - }; - - if (autoValue || hiddenOnInsert) { - // when you want same auto generate value - // and not allow edit, for example ID field - return null; - } - var error = validateState[field] ? _react2.default.createElement( - 'span', - { className: 'help-block bg-danger' }, - validateState[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: field }, - _react2.default.createElement( - 'label', - null, - name - ), - (0, _Editor2.default)(editable, attr, format, '', undefined, _this5.props.ignoreEditable), - error - ); - }); - var modalClass = (0, _classnames2.default)('modal', 'fade', this.modalClassName, { - // hack prevent bootstrap modal hide by reRender - 'in': shakeEditor || this.state.validateState - }); - var dialogClass = (0, _classnames2.default)('modal-dialog', 'modal-sm', { - 'animated': shakeEditor, - 'shake': 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' }, - '\xD7' - ) - ), - _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' }, - this.props.closeText - ), - _react2.default.createElement( - 'button', - { type: 'button', - className: 'btn btn-primary', - onClick: this.handleSaveBtnClick }, - this.props.saveText - ) - ) - ) - ) - ); - } - }]); - - return ToolBar; -}(_react.Component); - -ToolBar.modalSeq = 0; - - -ToolBar.propTypes = { - onAddRow: _react.PropTypes.func, - onDropRow: _react.PropTypes.func, - onShowOnlySelected: _react.PropTypes.func, - enableInsert: _react.PropTypes.bool, - enableDelete: _react.PropTypes.bool, - enableSearch: _react.PropTypes.bool, - enableShowOnlySelected: _react.PropTypes.bool, - columns: _react.PropTypes.array, - searchPlaceholder: _react.PropTypes.string, - exportCSVText: _react.PropTypes.string, - insertText: _react.PropTypes.string, - deleteText: _react.PropTypes.string, - saveText: _react.PropTypes.string, - closeText: _react.PropTypes.string, - clearSearch: _react.PropTypes.bool, - ignoreEditable: _react.PropTypes.bool, - defaultSearch: _react.PropTypes.string -}; - -ToolBar.defaultProps = { - enableInsert: false, - enableDelete: false, - enableSearch: false, - enableShowOnlySelected: false, - clearSearch: false, - ignoreEditable: false, - exportCSVText: _Const2.default.EXPORT_CSV_TEXT, - insertText: _Const2.default.INSERT_BTN_TEXT, - deleteText: _Const2.default.DELETE_BTN_TEXT, - saveText: _Const2.default.SAVE_BTN_TEXT, - closeText: _Const2.default.CLOSE_BTN_TEXT -}; - -var _default = ToolBar; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(ToolBar, 'ToolBar', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/toolbar/ToolBar.js'); - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/toolbar/ToolBar.js'); -}(); - -; \ No newline at end of file diff --git a/lib/util.js b/lib/util.js deleted file mode 100644 index babad163c..000000000 --- a/lib/util.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Const = require('./Const'); - -var _Const2 = _interopRequireDefault(_Const); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _default = { - 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; - }, - canUseDOM: function canUseDOM() { - return typeof window !== 'undefined' && typeof window.document !== 'undefined'; - } -}; -exports.default = _default; -; - -var _temp = function () { - if (typeof __REACT_HOT_LOADER__ === 'undefined') { - return; - } - - __REACT_HOT_LOADER__.register(_default, 'default', '/Users/allen/Node/react-bootstrap-table-new/react-bootstrap-table/src/util.js'); -}(); - -; \ No newline at end of file