react-bootstrap-table-nextgen-filter
Advanced tools
Comparing version 1.3.3 to 1.4.0
100
lib/index.js
@@ -1,95 +0,72 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.customFilter = exports.dateFilter = exports.numberFilter = exports.multiSelectFilter = exports.selectFilter = exports.textFilter = exports.Comparator = exports.FILTER_TYPES = undefined; | ||
var _text = require('./src/components/text'); | ||
var _text2 = _interopRequireDefault(_text); | ||
var _select = require('./src/components/select'); | ||
var _select2 = _interopRequireDefault(_select); | ||
var _multiselect = require('./src/components/multiselect'); | ||
var _multiselect2 = _interopRequireDefault(_multiselect); | ||
var _number = require('./src/components/number'); | ||
var _number2 = _interopRequireDefault(_number); | ||
var _date = require('./src/components/date'); | ||
var _date2 = _interopRequireDefault(_date); | ||
var _context = require('./src/context'); | ||
var _context2 = _interopRequireDefault(_context); | ||
var _comparison = require('./src/comparison'); | ||
var Comparison = _interopRequireWildcard(_comparison); | ||
var _const = require('./src/const'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = function () { | ||
exports.textFilter = exports.selectFilter = exports.numberFilter = exports.multiSelectFilter = exports["default"] = exports.dateFilter = exports.customFilter = exports.FILTER_TYPES = exports.Comparator = void 0; | ||
var _text = _interopRequireDefault(require("./src/components/text")); | ||
var _select = _interopRequireDefault(require("./src/components/select")); | ||
var _multiselect = _interopRequireDefault(require("./src/components/multiselect")); | ||
var _number = _interopRequireDefault(require("./src/components/number")); | ||
var _date = _interopRequireDefault(require("./src/components/date")); | ||
var _context = _interopRequireDefault(require("./src/context")); | ||
var Comparison = _interopRequireWildcard(require("./src/comparison")); | ||
var _const = require("./src/const"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _default = function _default() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
createContext: _context2.default, | ||
createContext: _context["default"], | ||
options: options | ||
}; | ||
}; | ||
var FILTER_TYPES = exports.FILTER_TYPES = _const.FILTER_TYPE; | ||
var Comparator = exports.Comparator = Comparison; | ||
var textFilter = exports.textFilter = function textFilter() { | ||
exports["default"] = _default; | ||
var FILTER_TYPES = _const.FILTER_TYPE; | ||
exports.FILTER_TYPES = FILTER_TYPES; | ||
var Comparator = Comparison; | ||
exports.Comparator = Comparator; | ||
var textFilter = function textFilter() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
Filter: _text2.default, | ||
Filter: _text["default"], | ||
props: props | ||
}; | ||
}; | ||
var selectFilter = exports.selectFilter = function selectFilter() { | ||
exports.textFilter = textFilter; | ||
var selectFilter = function selectFilter() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
Filter: _select2.default, | ||
Filter: _select["default"], | ||
props: props | ||
}; | ||
}; | ||
var multiSelectFilter = exports.multiSelectFilter = function multiSelectFilter() { | ||
exports.selectFilter = selectFilter; | ||
var multiSelectFilter = function multiSelectFilter() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
Filter: _multiselect2.default, | ||
Filter: _multiselect["default"], | ||
props: props | ||
}; | ||
}; | ||
var numberFilter = exports.numberFilter = function numberFilter() { | ||
exports.multiSelectFilter = multiSelectFilter; | ||
var numberFilter = function numberFilter() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
Filter: _number2.default, | ||
Filter: _number["default"], | ||
props: props | ||
}; | ||
}; | ||
var dateFilter = exports.dateFilter = function dateFilter() { | ||
exports.numberFilter = numberFilter; | ||
var dateFilter = function dateFilter() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return { | ||
Filter: _date2.default, | ||
Filter: _date["default"], | ||
props: props | ||
}; | ||
}; | ||
var customFilter = exports.customFilter = function customFilter() { | ||
exports.dateFilter = dateFilter; | ||
var customFilter = function customFilter() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -99,2 +76,3 @@ return { | ||
}; | ||
}; | ||
}; | ||
exports.customFilter = customFilter; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,8 +6,16 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var LIKE = exports.LIKE = 'LIKE'; | ||
var EQ = exports.EQ = '='; | ||
var NE = exports.NE = '!='; | ||
var GT = exports.GT = '>'; | ||
var GE = exports.GE = '>='; | ||
var LT = exports.LT = '<'; | ||
var LE = exports.LE = '<='; | ||
exports.NE = exports.LT = exports.LIKE = exports.LE = exports.GT = exports.GE = exports.EQ = void 0; | ||
var LIKE = 'LIKE'; | ||
exports.LIKE = LIKE; | ||
var EQ = '='; | ||
exports.EQ = EQ; | ||
var NE = '!='; | ||
exports.NE = NE; | ||
var GT = '>'; | ||
exports.GT = GT; | ||
var GE = '>='; | ||
exports.GE = GE; | ||
var LT = '<'; | ||
exports.LT = LT; | ||
var LE = '<='; | ||
exports.LE = LE; |
@@ -1,64 +0,49 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
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 _propTypes = require('prop-types'); | ||
var _comparison = require('../comparison'); | ||
var Comparator = _interopRequireWildcard(_comparison); | ||
var _const = require('../const'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports["default"] = void 0; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = require("prop-types"); | ||
var Comparator = _interopRequireWildcard(require("../comparison")); | ||
var _const = require("../const"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
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 react/require-default-props: 0 */ | ||
/* eslint jsx-a11y/no-static-element-interactions: 0 */ | ||
/* eslint no-return-assign: 0 */ | ||
/* eslint prefer-template: 0 */ | ||
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, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* eslint react/require-default-props: 0 */ /* eslint jsx-a11y/no-static-element-interactions: 0 */ /* eslint no-return-assign: 0 */ /* eslint prefer-template: 0 */ | ||
var legalComparators = [Comparator.EQ, Comparator.NE, Comparator.GT, Comparator.GE, Comparator.LT, Comparator.LE]; | ||
function dateParser(d) { | ||
return d.getUTCFullYear() + '-' + ('0' + (d.getUTCMonth() + 1)).slice(-2) + '-' + ('0' + d.getUTCDate()).slice(-2); | ||
return "".concat(d.getUTCFullYear(), "-").concat(('0' + (d.getUTCMonth() + 1)).slice(-2), "-").concat(('0' + d.getUTCDate()).slice(-2)); | ||
} | ||
var DateFilter = function (_Component) { | ||
var DateFilter = /*#__PURE__*/function (_Component) { | ||
_inherits(DateFilter, _Component); | ||
var _super = _createSuper(DateFilter); | ||
function DateFilter(props) { | ||
var _this; | ||
_classCallCheck(this, DateFilter); | ||
var _this = _possibleConstructorReturn(this, (DateFilter.__proto__ || Object.getPrototypeOf(DateFilter)).call(this, props)); | ||
_this = _super.call(this, props); | ||
_this.timeout = null; | ||
_this.comparators = props.comparators || legalComparators; | ||
_this.applyFilter = _this.applyFilter.bind(_this); | ||
_this.onChangeDate = _this.onChangeDate.bind(_this); | ||
_this.onChangeComparator = _this.onChangeComparator.bind(_this); | ||
_this.applyFilter = _this.applyFilter.bind(_assertThisInitialized(_this)); | ||
_this.onChangeDate = _this.onChangeDate.bind(_assertThisInitialized(_this)); | ||
_this.onChangeComparator = _this.onChangeComparator.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
} | ||
_createClass(DateFilter, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
var getFilter = this.props.getFilter; | ||
var comparator = this.dateFilterComparator.value; | ||
@@ -73,6 +58,8 @@ var date = this.inputDate.value; | ||
getFilter(function (filterVal) { | ||
var nullableFilterVal = filterVal || { date: null, comparator: null }; | ||
var nullableFilterVal = filterVal || { | ||
date: null, | ||
comparator: null | ||
}; | ||
_this2.dateFilterComparator.value = nullableFilterVal.comparator; | ||
_this2.inputDate.value = nullableFilterVal.date ? dateParser(nullableFilterVal.date) : null; | ||
_this2.applyFilter(nullableFilterVal.date, nullableFilterVal.comparator); | ||
@@ -83,3 +70,3 @@ }); | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
@@ -89,3 +76,3 @@ if (this.timeout) clearTimeout(this.timeout); | ||
}, { | ||
key: 'onChangeDate', | ||
key: "onChangeDate", | ||
value: function onChangeDate(e) { | ||
@@ -97,3 +84,3 @@ var comparator = this.dateFilterComparator.value; | ||
}, { | ||
key: 'onChangeComparator', | ||
key: "onChangeComparator", | ||
value: function onChangeComparator(e) { | ||
@@ -105,16 +92,16 @@ var value = this.inputDate.value; | ||
}, { | ||
key: 'getComparatorOptions', | ||
key: "getComparatorOptions", | ||
value: function getComparatorOptions() { | ||
var optionTags = []; | ||
var withoutEmptyComparatorOption = this.props.withoutEmptyComparatorOption; | ||
if (!withoutEmptyComparatorOption) { | ||
optionTags.push(_react2.default.createElement('option', { key: '-1' })); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: "-1" | ||
})); | ||
} | ||
for (var i = 0; i < this.comparators.length; i += 1) { | ||
optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: i, value: this.comparators[i] }, | ||
this.comparators[i] | ||
)); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: i, | ||
value: this.comparators[i] | ||
}, this.comparators[i])); | ||
} | ||
@@ -124,8 +111,7 @@ return optionTags; | ||
}, { | ||
key: 'getDefaultComparator', | ||
key: "getDefaultComparator", | ||
value: function getDefaultComparator() { | ||
var _props = this.props, | ||
defaultValue = _props.defaultValue, | ||
filterState = _props.filterState; | ||
var _this$props = this.props, | ||
defaultValue = _this$props.defaultValue, | ||
filterState = _this$props.filterState; | ||
if (filterState && filterState.filterVal) { | ||
@@ -140,9 +126,8 @@ return filterState.filterVal.comparator; | ||
}, { | ||
key: 'getDefaultDate', | ||
key: "getDefaultDate", | ||
value: function getDefaultDate() { | ||
// Set the appropriate format for the input type=date, i.e. "YYYY-MM-DD" | ||
var _props2 = this.props, | ||
defaultValue = _props2.defaultValue, | ||
filterState = _props2.filterState; | ||
var _this$props2 = this.props, | ||
defaultValue = _this$props2.defaultValue, | ||
filterState = _this$props2.filterState; | ||
if (filterState && filterState.filterVal && filterState.filterVal.date) { | ||
@@ -157,3 +142,3 @@ return dateParser(filterState.filterVal.date); | ||
}, { | ||
key: 'applyFilter', | ||
key: "applyFilter", | ||
value: function applyFilter(value, comparator, isInitial) { | ||
@@ -163,7 +148,6 @@ // if (!comparator || !value) { | ||
// } | ||
var _props3 = this.props, | ||
column = _props3.column, | ||
onFilter = _props3.onFilter, | ||
delay = _props3.delay; | ||
var _this$props3 = this.props, | ||
column = _this$props3.column, | ||
onFilter = _this$props3.onFilter, | ||
delay = _this$props3.delay; | ||
var execute = function execute() { | ||
@@ -175,3 +159,6 @@ // Incoming value should always be a string, and the defaultDate | ||
var date = value === '' ? null : new Date(value); | ||
onFilter(column, _const.FILTER_TYPE.DATE, isInitial)({ date: date, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.DATE, isInitial)({ | ||
date: date, | ||
comparator: comparator | ||
}); | ||
}; | ||
@@ -187,87 +174,59 @@ if (delay) { | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _props4 = this.props, | ||
id = _props4.id, | ||
placeholder = _props4.placeholder, | ||
_props4$column = _props4.column, | ||
dataField = _props4$column.dataField, | ||
text = _props4$column.text, | ||
style = _props4.style, | ||
comparatorStyle = _props4.comparatorStyle, | ||
dateStyle = _props4.dateStyle, | ||
className = _props4.className, | ||
comparatorClassName = _props4.comparatorClassName, | ||
dateClassName = _props4.dateClassName; | ||
var comparatorElmId = 'date-filter-comparator-' + dataField + (id ? '-' + id : ''); | ||
var inputElmId = 'date-filter-column-' + dataField + (id ? '-' + id : ''); | ||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
className: 'filter date-filter ' + className, | ||
style: style | ||
var _this$props4 = this.props, | ||
id = _this$props4.id, | ||
placeholder = _this$props4.placeholder, | ||
_this$props4$column = _this$props4.column, | ||
dataField = _this$props4$column.dataField, | ||
text = _this$props4$column.text, | ||
style = _this$props4.style, | ||
comparatorStyle = _this$props4.comparatorStyle, | ||
dateStyle = _this$props4.dateStyle, | ||
className = _this$props4.className, | ||
comparatorClassName = _this$props4.comparatorClassName, | ||
dateClassName = _this$props4.dateClassName; | ||
var comparatorElmId = "date-filter-comparator-".concat(dataField).concat(id ? "-".concat(id) : ''); | ||
var inputElmId = "date-filter-column-".concat(dataField).concat(id ? "-".concat(id) : ''); | ||
return /*#__PURE__*/_react["default"].createElement("div", { | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
_react2.default.createElement( | ||
'label', | ||
{ | ||
className: 'filter-label', | ||
htmlFor: comparatorElmId | ||
}, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Filter comparator' | ||
), | ||
_react2.default.createElement( | ||
'select', | ||
{ | ||
ref: function ref(n) { | ||
return _this3.dateFilterComparator = n; | ||
}, | ||
id: comparatorElmId, | ||
style: comparatorStyle, | ||
className: 'date-filter-comparator form-control ' + comparatorClassName, | ||
onChange: this.onChangeComparator, | ||
defaultValue: this.getDefaultComparator() | ||
}, | ||
this.getComparatorOptions() | ||
) | ||
), | ||
_react2.default.createElement( | ||
'label', | ||
{ htmlFor: inputElmId }, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Enter $', | ||
text | ||
), | ||
_react2.default.createElement('input', { | ||
ref: function ref(n) { | ||
return _this3.inputDate = n; | ||
}, | ||
id: inputElmId, | ||
className: 'filter date-filter-input form-control ' + dateClassName, | ||
style: dateStyle, | ||
type: 'date', | ||
onChange: this.onChangeDate, | ||
placeholder: placeholder || 'Enter ' + text + '...', | ||
defaultValue: this.getDefaultDate() | ||
}) | ||
) | ||
); | ||
className: "filter date-filter ".concat(className), | ||
style: style | ||
}, /*#__PURE__*/_react["default"].createElement("label", { | ||
className: "filter-label", | ||
htmlFor: comparatorElmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Filter comparator"), /*#__PURE__*/_react["default"].createElement("select", { | ||
ref: function ref(n) { | ||
return _this3.dateFilterComparator = n; | ||
}, | ||
id: comparatorElmId, | ||
style: comparatorStyle, | ||
className: "date-filter-comparator form-control ".concat(comparatorClassName), | ||
onChange: this.onChangeComparator, | ||
defaultValue: this.getDefaultComparator() | ||
}, this.getComparatorOptions())), /*#__PURE__*/_react["default"].createElement("label", { | ||
htmlFor: inputElmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Enter $", text), /*#__PURE__*/_react["default"].createElement("input", { | ||
ref: function ref(n) { | ||
return _this3.inputDate = n; | ||
}, | ||
id: inputElmId, | ||
className: "filter date-filter-input form-control ".concat(dateClassName), | ||
style: dateStyle, | ||
type: "date", | ||
onChange: this.onChangeDate, | ||
placeholder: placeholder || "Enter ".concat(text, "..."), | ||
defaultValue: this.getDefaultDate() | ||
}))); | ||
} | ||
}]); | ||
return DateFilter; | ||
}(_react.Component); | ||
DateFilter.propTypes = { | ||
@@ -297,3 +256,3 @@ onFilter: _propTypes.PropTypes.func.isRequired, | ||
if (!comparatorIsValid) { | ||
return new Error('Date comparator provided is not supported.\n Use only ' + legalComparators); | ||
return new Error("Date comparator provided is not supported.\n Use only ".concat(legalComparators)); | ||
} | ||
@@ -312,3 +271,2 @@ } | ||
}; | ||
DateFilter.defaultProps = { | ||
@@ -332,3 +290,3 @@ delay: 0, | ||
}; | ||
exports.default = DateFilter; | ||
var _default = DateFilter; | ||
exports["default"] = _default; |
@@ -1,37 +0,31 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
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 _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _comparison = require('../comparison'); | ||
var _const = require('../const'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
exports["default"] = void 0; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _comparison = require("../comparison"); | ||
var _const = require("../const"); | ||
var _excluded = ["id", "style", "className", "filterState", "defaultValue", "onFilter", "column", "options", "comparator", "withoutEmptyOption", "caseSensitive", "getFilter"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
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 react/require-default-props: 0 */ | ||
/* eslint no-return-assign: 0 */ | ||
/* eslint no-param-reassign: 0 */ | ||
/* eslint react/no-unused-prop-types: 0 */ | ||
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, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* eslint react/require-default-props: 0 */ /* eslint no-return-assign: 0 */ /* eslint no-param-reassign: 0 */ /* eslint react/no-unused-prop-types: 0 */ | ||
function optionsEquals(currOpts, prevOpts) { | ||
@@ -46,3 +40,2 @@ var keys = Object.keys(currOpts); | ||
} | ||
var getSelections = function getSelections(container) { | ||
@@ -62,28 +55,24 @@ if (container.selectedOptions) { | ||
}; | ||
var MultiSelectFilter = function (_Component) { | ||
var MultiSelectFilter = /*#__PURE__*/function (_Component) { | ||
_inherits(MultiSelectFilter, _Component); | ||
var _super = _createSuper(MultiSelectFilter); | ||
function MultiSelectFilter(props) { | ||
var _this; | ||
_classCallCheck(this, MultiSelectFilter); | ||
var _this = _possibleConstructorReturn(this, (MultiSelectFilter.__proto__ || Object.getPrototypeOf(MultiSelectFilter)).call(this, props)); | ||
_this.filter = _this.filter.bind(_this); | ||
_this.applyFilter = _this.applyFilter.bind(_this); | ||
_this = _super.call(this, props); | ||
_this.filter = _this.filter.bind(_assertThisInitialized(_this)); | ||
_this.applyFilter = _this.applyFilter.bind(_assertThisInitialized(_this)); | ||
var isSelected = props.defaultValue.map(function (item) { | ||
return props.options[item]; | ||
}).length > 0; | ||
_this.state = { isSelected: isSelected }; | ||
_this.state = { | ||
isSelected: isSelected | ||
}; | ||
return _this; | ||
} | ||
_createClass(MultiSelectFilter, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
var getFilter = this.props.getFilter; | ||
var value = getSelections(this.selectInput); | ||
@@ -103,3 +92,3 @@ if (value && value.length > 0) { | ||
}, { | ||
key: 'componentDidUpdate', | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate(prevProps) { | ||
@@ -117,8 +106,7 @@ var needFilter = false; | ||
}, { | ||
key: 'getDefaultValue', | ||
key: "getDefaultValue", | ||
value: function getDefaultValue() { | ||
var _props = this.props, | ||
filterState = _props.filterState, | ||
defaultValue = _props.defaultValue; | ||
var _this$props = this.props, | ||
filterState = _this$props.filterState, | ||
defaultValue = _this$props.defaultValue; | ||
if (filterState && typeof filterState.filterVal !== 'undefined') { | ||
@@ -130,24 +118,21 @@ return filterState.filterVal; | ||
}, { | ||
key: 'getOptions', | ||
key: "getOptions", | ||
value: function getOptions() { | ||
var optionTags = []; | ||
var _props2 = this.props, | ||
options = _props2.options, | ||
placeholder = _props2.placeholder, | ||
column = _props2.column, | ||
withoutEmptyOption = _props2.withoutEmptyOption; | ||
var _this$props2 = this.props, | ||
options = _this$props2.options, | ||
placeholder = _this$props2.placeholder, | ||
column = _this$props2.column, | ||
withoutEmptyOption = _this$props2.withoutEmptyOption; | ||
if (!withoutEmptyOption) { | ||
optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: '-1', value: '' }, | ||
placeholder || 'Select ' + column.text + '...' | ||
)); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: "-1", | ||
value: "" | ||
}, placeholder || "Select ".concat(column.text, "..."))); | ||
} | ||
Object.keys(options).forEach(function (key) { | ||
return optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: key, value: key }, | ||
options[key] | ||
)); | ||
return optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: key, | ||
value: key | ||
}, options[key])); | ||
}); | ||
@@ -157,3 +142,3 @@ return optionTags; | ||
}, { | ||
key: 'cleanFiltered', | ||
key: "cleanFiltered", | ||
value: function cleanFiltered() { | ||
@@ -165,3 +150,3 @@ var value = this.props.defaultValue !== undefined ? this.props.defaultValue : []; | ||
}, { | ||
key: 'applyFilter', | ||
key: "applyFilter", | ||
value: function applyFilter(value) { | ||
@@ -172,3 +157,5 @@ if (value.length === 1 && value[0] === '') { | ||
this.setState(function () { | ||
return { isSelected: value.length > 0 }; | ||
return { | ||
isSelected: value.length > 0 | ||
}; | ||
}); | ||
@@ -178,3 +165,3 @@ this.props.onFilter(this.props.column, _const.FILTER_TYPE.MULTISELECT)(value); | ||
}, { | ||
key: 'filter', | ||
key: "filter", | ||
value: function filter(e) { | ||
@@ -185,77 +172,59 @@ var value = getSelections(e.target); | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _props3 = this.props, | ||
id = _props3.id, | ||
style = _props3.style, | ||
className = _props3.className, | ||
filterState = _props3.filterState, | ||
defaultValue = _props3.defaultValue, | ||
onFilter = _props3.onFilter, | ||
column = _props3.column, | ||
options = _props3.options, | ||
comparator = _props3.comparator, | ||
withoutEmptyOption = _props3.withoutEmptyOption, | ||
caseSensitive = _props3.caseSensitive, | ||
getFilter = _props3.getFilter, | ||
rest = _objectWithoutProperties(_props3, ['id', 'style', 'className', 'filterState', 'defaultValue', 'onFilter', 'column', 'options', 'comparator', 'withoutEmptyOption', 'caseSensitive', 'getFilter']); | ||
var selectClass = 'filter select-filter form-control ' + className + ' ' + (this.state.isSelected ? '' : 'placeholder-selected'); | ||
var elmId = 'multiselect-filter-column-' + column.dataField + (id ? '-' + id : ''); | ||
return _react2.default.createElement( | ||
'label', | ||
{ | ||
className: 'filter-label', | ||
htmlFor: elmId | ||
var _this$props3 = this.props, | ||
id = _this$props3.id, | ||
style = _this$props3.style, | ||
className = _this$props3.className, | ||
filterState = _this$props3.filterState, | ||
defaultValue = _this$props3.defaultValue, | ||
onFilter = _this$props3.onFilter, | ||
column = _this$props3.column, | ||
options = _this$props3.options, | ||
comparator = _this$props3.comparator, | ||
withoutEmptyOption = _this$props3.withoutEmptyOption, | ||
caseSensitive = _this$props3.caseSensitive, | ||
getFilter = _this$props3.getFilter, | ||
rest = _objectWithoutProperties(_this$props3, _excluded); | ||
var selectClass = "filter select-filter form-control ".concat(className, " ").concat(this.state.isSelected ? '' : 'placeholder-selected'); | ||
var elmId = "multiselect-filter-column-".concat(column.dataField).concat(id ? "-".concat(id) : ''); | ||
return /*#__PURE__*/_react["default"].createElement("label", { | ||
className: "filter-label", | ||
htmlFor: elmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Filter by ", column.text), /*#__PURE__*/_react["default"].createElement("select", _extends({}, rest, { | ||
ref: function ref(n) { | ||
return _this3.selectInput = n; | ||
}, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Filter by ', | ||
column.text | ||
), | ||
_react2.default.createElement( | ||
'select', | ||
_extends({}, rest, { | ||
ref: function ref(n) { | ||
return _this3.selectInput = n; | ||
}, | ||
id: elmId, | ||
style: style, | ||
multiple: true, | ||
className: selectClass, | ||
onChange: this.filter, | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
defaultValue: this.getDefaultValue() | ||
}), | ||
this.getOptions() | ||
) | ||
); | ||
id: elmId, | ||
style: style, | ||
multiple: true, | ||
className: selectClass, | ||
onChange: this.filter, | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
defaultValue: this.getDefaultValue() | ||
}), this.getOptions())); | ||
} | ||
}]); | ||
return MultiSelectFilter; | ||
}(_react.Component); | ||
MultiSelectFilter.propTypes = { | ||
onFilter: _propTypes2.default.func.isRequired, | ||
column: _propTypes2.default.object.isRequired, | ||
options: _propTypes2.default.object.isRequired, | ||
id: _propTypes2.default.string, | ||
filterState: _propTypes2.default.object, | ||
comparator: _propTypes2.default.oneOf([_comparison.LIKE, _comparison.EQ]), | ||
placeholder: _propTypes2.default.string, | ||
style: _propTypes2.default.object, | ||
className: _propTypes2.default.string, | ||
withoutEmptyOption: _propTypes2.default.bool, | ||
defaultValue: _propTypes2.default.array, | ||
caseSensitive: _propTypes2.default.bool, | ||
getFilter: _propTypes2.default.func | ||
onFilter: _propTypes["default"].func.isRequired, | ||
column: _propTypes["default"].object.isRequired, | ||
options: _propTypes["default"].object.isRequired, | ||
id: _propTypes["default"].string, | ||
filterState: _propTypes["default"].object, | ||
comparator: _propTypes["default"].oneOf([_comparison.LIKE, _comparison.EQ]), | ||
placeholder: _propTypes["default"].string, | ||
style: _propTypes["default"].object, | ||
className: _propTypes["default"].string, | ||
withoutEmptyOption: _propTypes["default"].bool, | ||
defaultValue: _propTypes["default"].array, | ||
caseSensitive: _propTypes["default"].bool, | ||
getFilter: _propTypes["default"].func | ||
}; | ||
MultiSelectFilter.defaultProps = { | ||
@@ -270,3 +239,3 @@ defaultValue: [], | ||
}; | ||
exports.default = MultiSelectFilter; | ||
var _default = MultiSelectFilter; | ||
exports["default"] = _default; |
@@ -1,45 +0,35 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
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 _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _comparison = require('../comparison'); | ||
var Comparator = _interopRequireWildcard(_comparison); | ||
var _const = require('../const'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports["default"] = void 0; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var Comparator = _interopRequireWildcard(require("../comparison")); | ||
var _const = require("../const"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
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 jsx-a11y/no-static-element-interactions: 0 */ | ||
/* eslint react/require-default-props: 0 */ | ||
/* eslint no-return-assign: 0 */ | ||
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, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* eslint jsx-a11y/no-static-element-interactions: 0 */ /* eslint react/require-default-props: 0 */ /* eslint no-return-assign: 0 */ | ||
var legalComparators = [Comparator.EQ, Comparator.NE, Comparator.GT, Comparator.GE, Comparator.LT, Comparator.LE]; | ||
var NumberFilter = function (_Component) { | ||
var NumberFilter = /*#__PURE__*/function (_Component) { | ||
_inherits(NumberFilter, _Component); | ||
var _super = _createSuper(NumberFilter); | ||
function NumberFilter(props) { | ||
var _this; | ||
_classCallCheck(this, NumberFilter); | ||
var _this = _possibleConstructorReturn(this, (NumberFilter.__proto__ || Object.getPrototypeOf(NumberFilter)).call(this, props)); | ||
_this = _super.call(this, props); | ||
_this.comparators = props.comparators || legalComparators; | ||
@@ -51,23 +41,25 @@ _this.timeout = null; | ||
} | ||
_this.state = { isSelected: isSelected }; | ||
_this.onChangeNumber = _this.onChangeNumber.bind(_this); | ||
_this.onChangeNumberSet = _this.onChangeNumberSet.bind(_this); | ||
_this.onChangeComparator = _this.onChangeComparator.bind(_this); | ||
_this.state = { | ||
isSelected: isSelected | ||
}; | ||
_this.onChangeNumber = _this.onChangeNumber.bind(_assertThisInitialized(_this)); | ||
_this.onChangeNumberSet = _this.onChangeNumberSet.bind(_assertThisInitialized(_this)); | ||
_this.onChangeComparator = _this.onChangeComparator.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
} | ||
_createClass(NumberFilter, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
column = _props.column, | ||
onFilter = _props.onFilter, | ||
getFilter = _props.getFilter; | ||
var _this$props = this.props, | ||
column = _this$props.column, | ||
onFilter = _this$props.onFilter, | ||
getFilter = _this$props.getFilter; | ||
var comparator = this.numberFilterComparator.value; | ||
var number = this.numberFilter.value; | ||
if (comparator && number) { | ||
onFilter(column, _const.FILTER_TYPE.NUMBER, true)({ number: number, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.NUMBER, true)({ | ||
number: number, | ||
comparator: comparator | ||
}); | ||
} | ||
@@ -79,7 +71,8 @@ | ||
_this2.setState(function () { | ||
return { isSelected: filterVal !== '' }; | ||
return { | ||
isSelected: filterVal !== '' | ||
}; | ||
}); | ||
_this2.numberFilterComparator.value = filterVal.comparator; | ||
_this2.numberFilter.value = filterVal.number; | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ | ||
@@ -93,3 +86,3 @@ number: filterVal.number, | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
@@ -99,9 +92,8 @@ clearTimeout(this.timeout); | ||
}, { | ||
key: 'onChangeNumber', | ||
key: "onChangeNumber", | ||
value: function onChangeNumber(e) { | ||
var _props2 = this.props, | ||
delay = _props2.delay, | ||
column = _props2.column, | ||
onFilter = _props2.onFilter; | ||
var _this$props2 = this.props, | ||
delay = _this$props2.delay, | ||
column = _this$props2.column, | ||
onFilter = _this$props2.onFilter; | ||
var comparator = this.numberFilterComparator.value; | ||
@@ -116,17 +108,20 @@ if (comparator === '') { | ||
this.timeout = setTimeout(function () { | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ number: filterValue, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ | ||
number: filterValue, | ||
comparator: comparator | ||
}); | ||
}, delay); | ||
} | ||
}, { | ||
key: 'onChangeNumberSet', | ||
key: "onChangeNumberSet", | ||
value: function onChangeNumberSet(e) { | ||
var _props3 = this.props, | ||
column = _props3.column, | ||
onFilter = _props3.onFilter; | ||
var _this$props3 = this.props, | ||
column = _this$props3.column, | ||
onFilter = _this$props3.onFilter; | ||
var comparator = this.numberFilterComparator.value; | ||
var value = e.target.value; | ||
this.setState(function () { | ||
return { isSelected: value !== '' }; | ||
return { | ||
isSelected: value !== '' | ||
}; | ||
}); | ||
@@ -136,11 +131,13 @@ // if (comparator === '') { | ||
// } | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ number: value, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ | ||
number: value, | ||
comparator: comparator | ||
}); | ||
} | ||
}, { | ||
key: 'onChangeComparator', | ||
key: "onChangeComparator", | ||
value: function onChangeComparator(e) { | ||
var _props4 = this.props, | ||
column = _props4.column, | ||
onFilter = _props4.onFilter; | ||
var _this$props4 = this.props, | ||
column = _this$props4.column, | ||
onFilter = _this$props4.onFilter; | ||
var value = this.numberFilter.value; | ||
@@ -151,11 +148,13 @@ var comparator = e.target.value; | ||
// } | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ number: value, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ | ||
number: value, | ||
comparator: comparator | ||
}); | ||
} | ||
}, { | ||
key: 'getDefaultComparator', | ||
key: "getDefaultComparator", | ||
value: function getDefaultComparator() { | ||
var _props5 = this.props, | ||
defaultValue = _props5.defaultValue, | ||
filterState = _props5.filterState; | ||
var _this$props5 = this.props, | ||
defaultValue = _this$props5.defaultValue, | ||
filterState = _this$props5.filterState; | ||
if (filterState && filterState.filterVal) { | ||
@@ -170,8 +169,7 @@ return filterState.filterVal.comparator; | ||
}, { | ||
key: 'getDefaultValue', | ||
key: "getDefaultValue", | ||
value: function getDefaultValue() { | ||
var _props6 = this.props, | ||
defaultValue = _props6.defaultValue, | ||
filterState = _props6.filterState; | ||
var _this$props6 = this.props, | ||
defaultValue = _this$props6.defaultValue, | ||
filterState = _this$props6.filterState; | ||
if (filterState && filterState.filterVal) { | ||
@@ -186,16 +184,16 @@ return filterState.filterVal.number; | ||
}, { | ||
key: 'getComparatorOptions', | ||
key: "getComparatorOptions", | ||
value: function getComparatorOptions() { | ||
var optionTags = []; | ||
var withoutEmptyComparatorOption = this.props.withoutEmptyComparatorOption; | ||
if (!withoutEmptyComparatorOption) { | ||
optionTags.push(_react2.default.createElement('option', { key: '-1' })); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: "-1" | ||
})); | ||
} | ||
for (var i = 0; i < this.comparators.length; i += 1) { | ||
optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: i, value: this.comparators[i] }, | ||
this.comparators[i] | ||
)); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: i, | ||
value: this.comparators[i] | ||
}, this.comparators[i])); | ||
} | ||
@@ -205,23 +203,20 @@ return optionTags; | ||
}, { | ||
key: 'getNumberOptions', | ||
key: "getNumberOptions", | ||
value: function getNumberOptions() { | ||
var optionTags = []; | ||
var _props7 = this.props, | ||
options = _props7.options, | ||
column = _props7.column, | ||
withoutEmptyNumberOption = _props7.withoutEmptyNumberOption; | ||
var _this$props7 = this.props, | ||
options = _this$props7.options, | ||
column = _this$props7.column, | ||
withoutEmptyNumberOption = _this$props7.withoutEmptyNumberOption; | ||
if (!withoutEmptyNumberOption) { | ||
optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: '-1', value: '' }, | ||
this.props.placeholder || 'Select ' + column.text + '...' | ||
)); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: "-1", | ||
value: "" | ||
}, this.props.placeholder || "Select ".concat(column.text, "..."))); | ||
} | ||
for (var i = 0; i < options.length; i += 1) { | ||
optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: i, value: options[i] }, | ||
options[i] | ||
)); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: i, | ||
value: options[i] | ||
}, options[i])); | ||
} | ||
@@ -231,156 +226,126 @@ return optionTags; | ||
}, { | ||
key: 'applyFilter', | ||
key: "applyFilter", | ||
value: function applyFilter(filterObj) { | ||
var _props8 = this.props, | ||
column = _props8.column, | ||
onFilter = _props8.onFilter; | ||
var _this$props8 = this.props, | ||
column = _this$props8.column, | ||
onFilter = _this$props8.onFilter; | ||
var number = filterObj.number, | ||
comparator = filterObj.comparator; | ||
comparator = filterObj.comparator; | ||
this.setState(function () { | ||
return { isSelected: number !== '' }; | ||
return { | ||
isSelected: number !== '' | ||
}; | ||
}); | ||
this.numberFilterComparator.value = comparator; | ||
this.numberFilter.value = number; | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ number: number, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ | ||
number: number, | ||
comparator: comparator | ||
}); | ||
} | ||
}, { | ||
key: 'cleanFiltered', | ||
key: "cleanFiltered", | ||
value: function cleanFiltered() { | ||
var _props9 = this.props, | ||
column = _props9.column, | ||
onFilter = _props9.onFilter, | ||
defaultValue = _props9.defaultValue; | ||
var _this$props9 = this.props, | ||
column = _this$props9.column, | ||
onFilter = _this$props9.onFilter, | ||
defaultValue = _this$props9.defaultValue; | ||
var value = defaultValue ? defaultValue.number : ''; | ||
var comparator = defaultValue ? defaultValue.comparator : ''; | ||
this.setState(function () { | ||
return { isSelected: value !== '' }; | ||
return { | ||
isSelected: value !== '' | ||
}; | ||
}); | ||
this.numberFilterComparator.value = comparator; | ||
this.numberFilter.value = value; | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ number: value, comparator: comparator }); | ||
onFilter(column, _const.FILTER_TYPE.NUMBER)({ | ||
number: value, | ||
comparator: comparator | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var isSelected = this.state.isSelected; | ||
var _props10 = this.props, | ||
id = _props10.id, | ||
column = _props10.column, | ||
options = _props10.options, | ||
style = _props10.style, | ||
className = _props10.className, | ||
numberStyle = _props10.numberStyle, | ||
numberClassName = _props10.numberClassName, | ||
comparatorStyle = _props10.comparatorStyle, | ||
comparatorClassName = _props10.comparatorClassName, | ||
placeholder = _props10.placeholder; | ||
var selectClass = '\n select-filter \n number-filter-input \n form-control \n ' + numberClassName + ' \n ' + (!isSelected ? 'placeholder-selected' : '') + '\n '; | ||
var comparatorElmId = 'number-filter-comparator-' + column.dataField + (id ? '-' + id : ''); | ||
var inputElmId = 'number-filter-column-' + column.dataField + (id ? '-' + id : ''); | ||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
className: 'filter number-filter ' + className, | ||
style: style | ||
var _this$props10 = this.props, | ||
id = _this$props10.id, | ||
column = _this$props10.column, | ||
options = _this$props10.options, | ||
style = _this$props10.style, | ||
className = _this$props10.className, | ||
numberStyle = _this$props10.numberStyle, | ||
numberClassName = _this$props10.numberClassName, | ||
comparatorStyle = _this$props10.comparatorStyle, | ||
comparatorClassName = _this$props10.comparatorClassName, | ||
placeholder = _this$props10.placeholder; | ||
var selectClass = "\n select-filter \n number-filter-input \n form-control \n ".concat(numberClassName, " \n ").concat(!isSelected ? 'placeholder-selected' : '', "\n "); | ||
var comparatorElmId = "number-filter-comparator-".concat(column.dataField).concat(id ? "-".concat(id) : ''); | ||
var inputElmId = "number-filter-column-".concat(column.dataField).concat(id ? "-".concat(id) : ''); | ||
return /*#__PURE__*/_react["default"].createElement("div", { | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
_react2.default.createElement( | ||
'label', | ||
{ | ||
className: 'filter-label', | ||
htmlFor: comparatorElmId | ||
}, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Filter comparator' | ||
), | ||
_react2.default.createElement( | ||
'select', | ||
{ | ||
ref: function ref(n) { | ||
return _this3.numberFilterComparator = n; | ||
}, | ||
style: comparatorStyle, | ||
id: comparatorElmId, | ||
className: 'number-filter-comparator form-control ' + comparatorClassName, | ||
onChange: this.onChangeComparator, | ||
defaultValue: this.getDefaultComparator() | ||
}, | ||
this.getComparatorOptions() | ||
) | ||
), | ||
options ? _react2.default.createElement( | ||
'label', | ||
{ | ||
className: 'filter-label', | ||
htmlFor: inputElmId | ||
}, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Select ' + column.text | ||
), | ||
_react2.default.createElement( | ||
'select', | ||
{ | ||
ref: function ref(n) { | ||
return _this3.numberFilter = n; | ||
}, | ||
id: inputElmId, | ||
style: numberStyle, | ||
className: selectClass, | ||
onChange: this.onChangeNumberSet, | ||
defaultValue: this.getDefaultValue() | ||
}, | ||
this.getNumberOptions() | ||
) | ||
) : _react2.default.createElement( | ||
'label', | ||
{ htmlFor: inputElmId }, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Enter ' + column.text | ||
), | ||
_react2.default.createElement('input', { | ||
ref: function ref(n) { | ||
return _this3.numberFilter = n; | ||
}, | ||
id: inputElmId, | ||
type: 'number', | ||
style: numberStyle, | ||
className: 'number-filter-input form-control ' + numberClassName, | ||
placeholder: placeholder || 'Enter ' + column.text + '...', | ||
onChange: this.onChangeNumber, | ||
defaultValue: this.getDefaultValue() | ||
}) | ||
) | ||
); | ||
className: "filter number-filter ".concat(className), | ||
style: style | ||
}, /*#__PURE__*/_react["default"].createElement("label", { | ||
className: "filter-label", | ||
htmlFor: comparatorElmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Filter comparator"), /*#__PURE__*/_react["default"].createElement("select", { | ||
ref: function ref(n) { | ||
return _this3.numberFilterComparator = n; | ||
}, | ||
style: comparatorStyle, | ||
id: comparatorElmId, | ||
className: "number-filter-comparator form-control ".concat(comparatorClassName), | ||
onChange: this.onChangeComparator, | ||
defaultValue: this.getDefaultComparator() | ||
}, this.getComparatorOptions())), options ? /*#__PURE__*/_react["default"].createElement("label", { | ||
className: "filter-label", | ||
htmlFor: inputElmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Select ".concat(column.text)), /*#__PURE__*/_react["default"].createElement("select", { | ||
ref: function ref(n) { | ||
return _this3.numberFilter = n; | ||
}, | ||
id: inputElmId, | ||
style: numberStyle, | ||
className: selectClass, | ||
onChange: this.onChangeNumberSet, | ||
defaultValue: this.getDefaultValue() | ||
}, this.getNumberOptions())) : /*#__PURE__*/_react["default"].createElement("label", { | ||
htmlFor: inputElmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Enter ".concat(column.text)), /*#__PURE__*/_react["default"].createElement("input", { | ||
ref: function ref(n) { | ||
return _this3.numberFilter = n; | ||
}, | ||
id: inputElmId, | ||
type: "number", | ||
style: numberStyle, | ||
className: "number-filter-input form-control ".concat(numberClassName), | ||
placeholder: placeholder || "Enter ".concat(column.text, "..."), | ||
onChange: this.onChangeNumber, | ||
defaultValue: this.getDefaultValue() | ||
}))); | ||
} | ||
}]); | ||
return NumberFilter; | ||
}(_react.Component); | ||
NumberFilter.propTypes = { | ||
onFilter: _propTypes2.default.func.isRequired, | ||
column: _propTypes2.default.object.isRequired, | ||
id: _propTypes2.default.string, | ||
filterState: _propTypes2.default.object, | ||
options: _propTypes2.default.arrayOf(_propTypes2.default.number), | ||
defaultValue: _propTypes2.default.shape({ | ||
number: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), | ||
comparator: _propTypes2.default.oneOf([].concat(legalComparators, [''])) | ||
onFilter: _propTypes["default"].func.isRequired, | ||
column: _propTypes["default"].object.isRequired, | ||
id: _propTypes["default"].string, | ||
filterState: _propTypes["default"].object, | ||
options: _propTypes["default"].arrayOf(_propTypes["default"].number), | ||
defaultValue: _propTypes["default"].shape({ | ||
number: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]), | ||
comparator: _propTypes["default"].oneOf([].concat(legalComparators, [''])) | ||
}), | ||
delay: _propTypes2.default.number, | ||
delay: _propTypes["default"].number, | ||
/* eslint consistent-return: 0 */ | ||
@@ -400,18 +365,17 @@ comparators: function comparators(props, propName) { | ||
if (!comparatorIsValid) { | ||
return new Error('Number comparator provided is not supported.\n Use only ' + legalComparators); | ||
return new Error("Number comparator provided is not supported.\n Use only ".concat(legalComparators)); | ||
} | ||
} | ||
}, | ||
placeholder: _propTypes2.default.string, | ||
withoutEmptyComparatorOption: _propTypes2.default.bool, | ||
withoutEmptyNumberOption: _propTypes2.default.bool, | ||
style: _propTypes2.default.object, | ||
className: _propTypes2.default.string, | ||
comparatorStyle: _propTypes2.default.object, | ||
comparatorClassName: _propTypes2.default.string, | ||
numberStyle: _propTypes2.default.object, | ||
numberClassName: _propTypes2.default.string, | ||
getFilter: _propTypes2.default.func | ||
placeholder: _propTypes["default"].string, | ||
withoutEmptyComparatorOption: _propTypes["default"].bool, | ||
withoutEmptyNumberOption: _propTypes["default"].bool, | ||
style: _propTypes["default"].object, | ||
className: _propTypes["default"].string, | ||
comparatorStyle: _propTypes["default"].object, | ||
comparatorClassName: _propTypes["default"].string, | ||
numberStyle: _propTypes["default"].object, | ||
numberClassName: _propTypes["default"].string, | ||
getFilter: _propTypes["default"].func | ||
}; | ||
NumberFilter.defaultProps = { | ||
@@ -437,3 +401,3 @@ delay: _const.FILTER_DELAY, | ||
}; | ||
exports.default = NumberFilter; | ||
var _default = NumberFilter; | ||
exports["default"] = _default; |
@@ -1,37 +0,31 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
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 _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _comparison = require('../comparison'); | ||
var _const = require('../const'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
exports["default"] = void 0; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _comparison = require("../comparison"); | ||
var _const = require("../const"); | ||
var _excluded = ["id", "style", "className", "defaultValue", "onFilter", "column", "options", "comparator", "withoutEmptyOption", "caseSensitive", "getFilter", "filterState"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
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 react/require-default-props: 0 */ | ||
/* eslint no-return-assign: 0 */ | ||
/* eslint react/no-unused-prop-types: 0 */ | ||
/* eslint class-methods-use-this: 0 */ | ||
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, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* eslint react/require-default-props: 0 */ /* eslint no-return-assign: 0 */ /* eslint react/no-unused-prop-types: 0 */ /* eslint class-methods-use-this: 0 */ | ||
function optionsEquals(currOpts, prevOpts) { | ||
@@ -57,3 +51,2 @@ if (Array.isArray(currOpts)) { | ||
} | ||
function getOptionValue(options, key) { | ||
@@ -72,29 +65,25 @@ if (Array.isArray(options)) { | ||
} | ||
var SelectFilter = function (_Component) { | ||
var SelectFilter = /*#__PURE__*/function (_Component) { | ||
_inherits(SelectFilter, _Component); | ||
var _super = _createSuper(SelectFilter); | ||
function SelectFilter(props) { | ||
var _this; | ||
_classCallCheck(this, SelectFilter); | ||
var _this = _possibleConstructorReturn(this, (SelectFilter.__proto__ || Object.getPrototypeOf(SelectFilter)).call(this, props)); | ||
_this.filter = _this.filter.bind(_this); | ||
_this = _super.call(this, props); | ||
_this.filter = _this.filter.bind(_assertThisInitialized(_this)); | ||
_this.options = _this.getOptions(props); | ||
var isSelected = getOptionValue(_this.options, _this.getDefaultValue()) !== undefined; | ||
_this.state = { isSelected: isSelected }; | ||
_this.state = { | ||
isSelected: isSelected | ||
}; | ||
return _this; | ||
} | ||
_createClass(SelectFilter, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
column = _props.column, | ||
onFilter = _props.onFilter, | ||
getFilter = _props.getFilter; | ||
var _this$props = this.props, | ||
column = _this$props.column, | ||
onFilter = _this$props.onFilter, | ||
getFilter = _this$props.getFilter; | ||
var value = this.selectInput.value; | ||
@@ -109,6 +98,7 @@ if (value && value !== '') { | ||
_this2.setState(function () { | ||
return { isSelected: filterVal !== '' }; | ||
return { | ||
isSelected: filterVal !== '' | ||
}; | ||
}); | ||
_this2.selectInput.value = filterVal; | ||
onFilter(column, _const.FILTER_TYPE.SELECT)(filterVal); | ||
@@ -119,10 +109,9 @@ }); | ||
}, { | ||
key: 'componentDidUpdate', | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate(prevProps) { | ||
var needFilter = false; | ||
var _props2 = this.props, | ||
column = _props2.column, | ||
onFilter = _props2.onFilter, | ||
defaultValue = _props2.defaultValue; | ||
var _this$props2 = this.props, | ||
column = _this$props2.column, | ||
onFilter = _this$props2.onFilter, | ||
defaultValue = _this$props2.defaultValue; | ||
var nextOptions = this.getOptions(this.props); | ||
@@ -143,3 +132,3 @@ if (defaultValue !== prevProps.defaultValue) { | ||
}, { | ||
key: 'getOptions', | ||
key: "getOptions", | ||
value: function getOptions(props) { | ||
@@ -149,8 +138,7 @@ return typeof props.options === 'function' ? props.options(props.column) : props.options; | ||
}, { | ||
key: 'getDefaultValue', | ||
key: "getDefaultValue", | ||
value: function getDefaultValue() { | ||
var _props3 = this.props, | ||
filterState = _props3.filterState, | ||
defaultValue = _props3.defaultValue; | ||
var _this$props3 = this.props, | ||
filterState = _this$props3.filterState, | ||
defaultValue = _this$props3.defaultValue; | ||
if (filterState && typeof filterState.filterVal !== 'undefined') { | ||
@@ -162,7 +150,9 @@ return filterState.filterVal; | ||
}, { | ||
key: 'cleanFiltered', | ||
key: "cleanFiltered", | ||
value: function cleanFiltered() { | ||
var value = this.props.defaultValue !== undefined ? this.props.defaultValue : ''; | ||
this.setState(function () { | ||
return { isSelected: value !== '' }; | ||
return { | ||
isSelected: value !== '' | ||
}; | ||
}); | ||
@@ -173,7 +163,9 @@ this.selectInput.value = value; | ||
}, { | ||
key: 'applyFilter', | ||
key: "applyFilter", | ||
value: function applyFilter(value) { | ||
this.selectInput.value = value; | ||
this.setState(function () { | ||
return { isSelected: value !== '' }; | ||
return { | ||
isSelected: value !== '' | ||
}; | ||
}); | ||
@@ -183,8 +175,9 @@ this.props.onFilter(this.props.column, _const.FILTER_TYPE.SELECT)(value); | ||
}, { | ||
key: 'filter', | ||
key: "filter", | ||
value: function filter(e) { | ||
var value = e.target.value; | ||
this.setState(function () { | ||
return { isSelected: value !== '' }; | ||
return { | ||
isSelected: value !== '' | ||
}; | ||
}); | ||
@@ -194,17 +187,15 @@ this.props.onFilter(this.props.column, _const.FILTER_TYPE.SELECT)(value); | ||
}, { | ||
key: 'renderOptions', | ||
key: "renderOptions", | ||
value: function renderOptions() { | ||
var optionTags = []; | ||
var options = this.options; | ||
var _props4 = this.props, | ||
placeholder = _props4.placeholder, | ||
column = _props4.column, | ||
withoutEmptyOption = _props4.withoutEmptyOption; | ||
var _this$props4 = this.props, | ||
placeholder = _this$props4.placeholder, | ||
column = _this$props4.column, | ||
withoutEmptyOption = _this$props4.withoutEmptyOption; | ||
if (!withoutEmptyOption) { | ||
optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: '-1', value: '' }, | ||
placeholder || 'Select ' + column.text + '...' | ||
)); | ||
optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: "-1", | ||
value: "" | ||
}, placeholder || "Select ".concat(column.text, "..."))); | ||
} | ||
@@ -214,16 +205,14 @@ if (Array.isArray(options)) { | ||
var value = _ref3.value, | ||
label = _ref3.label; | ||
return optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: value, value: value }, | ||
label | ||
)); | ||
label = _ref3.label; | ||
return optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: value, | ||
value: value | ||
}, label)); | ||
}); | ||
} else { | ||
Object.keys(options).forEach(function (key) { | ||
return optionTags.push(_react2.default.createElement( | ||
'option', | ||
{ key: key, value: key }, | ||
options[key] | ||
)); | ||
return optionTags.push( /*#__PURE__*/_react["default"].createElement("option", { | ||
key: key, | ||
value: key | ||
}, options[key])); | ||
}); | ||
@@ -234,76 +223,58 @@ } | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _props5 = this.props, | ||
id = _props5.id, | ||
style = _props5.style, | ||
className = _props5.className, | ||
defaultValue = _props5.defaultValue, | ||
onFilter = _props5.onFilter, | ||
column = _props5.column, | ||
options = _props5.options, | ||
comparator = _props5.comparator, | ||
withoutEmptyOption = _props5.withoutEmptyOption, | ||
caseSensitive = _props5.caseSensitive, | ||
getFilter = _props5.getFilter, | ||
filterState = _props5.filterState, | ||
rest = _objectWithoutProperties(_props5, ['id', 'style', 'className', 'defaultValue', 'onFilter', 'column', 'options', 'comparator', 'withoutEmptyOption', 'caseSensitive', 'getFilter', 'filterState']); | ||
var selectClass = 'filter select-filter form-control ' + className + ' ' + (this.state.isSelected ? '' : 'placeholder-selected'); | ||
var elmId = 'select-filter-column-' + column.dataField + (id ? '-' + id : ''); | ||
return _react2.default.createElement( | ||
'label', | ||
{ | ||
className: 'filter-label', | ||
htmlFor: elmId | ||
var _this$props5 = this.props, | ||
id = _this$props5.id, | ||
style = _this$props5.style, | ||
className = _this$props5.className, | ||
defaultValue = _this$props5.defaultValue, | ||
onFilter = _this$props5.onFilter, | ||
column = _this$props5.column, | ||
options = _this$props5.options, | ||
comparator = _this$props5.comparator, | ||
withoutEmptyOption = _this$props5.withoutEmptyOption, | ||
caseSensitive = _this$props5.caseSensitive, | ||
getFilter = _this$props5.getFilter, | ||
filterState = _this$props5.filterState, | ||
rest = _objectWithoutProperties(_this$props5, _excluded); | ||
var selectClass = "filter select-filter form-control ".concat(className, " ").concat(this.state.isSelected ? '' : 'placeholder-selected'); | ||
var elmId = "select-filter-column-".concat(column.dataField).concat(id ? "-".concat(id) : ''); | ||
return /*#__PURE__*/_react["default"].createElement("label", { | ||
className: "filter-label", | ||
htmlFor: elmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Filter by ", column.text), /*#__PURE__*/_react["default"].createElement("select", _extends({}, rest, { | ||
ref: function ref(n) { | ||
return _this3.selectInput = n; | ||
}, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Filter by ', | ||
column.text | ||
), | ||
_react2.default.createElement( | ||
'select', | ||
_extends({}, rest, { | ||
ref: function ref(n) { | ||
return _this3.selectInput = n; | ||
}, | ||
id: elmId, | ||
style: style, | ||
className: selectClass, | ||
onChange: this.filter, | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
defaultValue: this.getDefaultValue() || '' | ||
}), | ||
this.renderOptions() | ||
) | ||
); | ||
id: elmId, | ||
style: style, | ||
className: selectClass, | ||
onChange: this.filter, | ||
onClick: function onClick(e) { | ||
return e.stopPropagation(); | ||
}, | ||
defaultValue: this.getDefaultValue() || '' | ||
}), this.renderOptions())); | ||
} | ||
}]); | ||
return SelectFilter; | ||
}(_react.Component); | ||
SelectFilter.propTypes = { | ||
onFilter: _propTypes2.default.func.isRequired, | ||
column: _propTypes2.default.object.isRequired, | ||
id: _propTypes2.default.string, | ||
filterState: _propTypes2.default.object, | ||
options: _propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.array]).isRequired, | ||
comparator: _propTypes2.default.oneOf([_comparison.LIKE, _comparison.EQ]), | ||
placeholder: _propTypes2.default.string, | ||
style: _propTypes2.default.object, | ||
className: _propTypes2.default.string, | ||
withoutEmptyOption: _propTypes2.default.bool, | ||
defaultValue: _propTypes2.default.any, | ||
caseSensitive: _propTypes2.default.bool, | ||
getFilter: _propTypes2.default.func | ||
onFilter: _propTypes["default"].func.isRequired, | ||
column: _propTypes["default"].object.isRequired, | ||
id: _propTypes["default"].string, | ||
filterState: _propTypes["default"].object, | ||
options: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array]).isRequired, | ||
comparator: _propTypes["default"].oneOf([_comparison.LIKE, _comparison.EQ]), | ||
placeholder: _propTypes["default"].string, | ||
style: _propTypes["default"].object, | ||
className: _propTypes["default"].string, | ||
withoutEmptyOption: _propTypes["default"].bool, | ||
defaultValue: _propTypes["default"].any, | ||
caseSensitive: _propTypes["default"].bool, | ||
getFilter: _propTypes["default"].func | ||
}; | ||
SelectFilter.defaultProps = { | ||
@@ -318,3 +289,3 @@ defaultValue: '', | ||
}; | ||
exports.default = SelectFilter; | ||
var _default = SelectFilter; | ||
exports["default"] = _default; |
@@ -1,45 +0,39 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
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 _propTypes = require('prop-types'); | ||
var _comparison = require('../comparison'); | ||
var _const = require('../const'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
exports["default"] = void 0; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes = require("prop-types"); | ||
var _comparison = require("../comparison"); | ||
var _const = require("../const"); | ||
var _excluded = ["id", "placeholder", "column", "style", "className", "onFilter", "caseSensitive", "defaultValue", "getFilter", "filterState"]; | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
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 react/require-default-props: 0 */ | ||
/* eslint react/prop-types: 0 */ | ||
/* eslint no-return-assign: 0 */ | ||
/* eslint camelcase: 0 */ | ||
var TextFilter = function (_Component) { | ||
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, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* eslint react/require-default-props: 0 */ /* eslint react/prop-types: 0 */ /* eslint no-return-assign: 0 */ /* eslint camelcase: 0 */ | ||
var TextFilter = /*#__PURE__*/function (_Component) { | ||
_inherits(TextFilter, _Component); | ||
var _super = _createSuper(TextFilter); | ||
function TextFilter(props) { | ||
var _this; | ||
_classCallCheck(this, TextFilter); | ||
var _this = _possibleConstructorReturn(this, (TextFilter.__proto__ || Object.getPrototypeOf(TextFilter)).call(this, props)); | ||
_this.filter = _this.filter.bind(_this); | ||
_this.handleClick = _this.handleClick.bind(_this); | ||
_this = _super.call(this, props); | ||
_this.filter = _this.filter.bind(_assertThisInitialized(_this)); | ||
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this)); | ||
_this.timeout = null; | ||
@@ -57,15 +51,11 @@ function getDefaultValue() { | ||
} | ||
_createClass(TextFilter, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
onFilter = _props.onFilter, | ||
getFilter = _props.getFilter, | ||
column = _props.column; | ||
var _this$props = this.props, | ||
onFilter = _this$props.onFilter, | ||
getFilter = _this$props.getFilter, | ||
column = _this$props.column; | ||
var defaultValue = this.input.value; | ||
if (defaultValue) { | ||
@@ -79,3 +69,5 @@ onFilter(this.props.column, _const.FILTER_TYPE.TEXT, true)(defaultValue); | ||
_this2.setState(function () { | ||
return { value: filterVal }; | ||
return { | ||
value: filterVal | ||
}; | ||
}); | ||
@@ -87,3 +79,3 @@ onFilter(column, _const.FILTER_TYPE.TEXT)(filterVal); | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
@@ -93,3 +85,3 @@ this.cleanTimer(); | ||
}, { | ||
key: 'UNSAFE_componentWillReceiveProps', | ||
key: "UNSAFE_componentWillReceiveProps", | ||
value: function UNSAFE_componentWillReceiveProps(nextProps) { | ||
@@ -101,6 +93,5 @@ if (nextProps.defaultValue !== this.props.defaultValue) { | ||
}, { | ||
key: 'filter', | ||
key: "filter", | ||
value: function filter(e) { | ||
var _this3 = this; | ||
e.stopPropagation(); | ||
@@ -110,3 +101,5 @@ this.cleanTimer(); | ||
this.setState(function () { | ||
return { value: filterValue }; | ||
return { | ||
value: filterValue | ||
}; | ||
}); | ||
@@ -118,3 +111,3 @@ this.timeout = setTimeout(function () { | ||
}, { | ||
key: 'cleanTimer', | ||
key: "cleanTimer", | ||
value: function cleanTimer() { | ||
@@ -126,7 +119,9 @@ if (this.timeout) { | ||
}, { | ||
key: 'cleanFiltered', | ||
key: "cleanFiltered", | ||
value: function cleanFiltered() { | ||
var value = this.props.defaultValue; | ||
this.setState(function () { | ||
return { value: value }; | ||
return { | ||
value: value | ||
}; | ||
}); | ||
@@ -136,6 +131,8 @@ this.props.onFilter(this.props.column, _const.FILTER_TYPE.TEXT)(value); | ||
}, { | ||
key: 'applyFilter', | ||
key: "applyFilter", | ||
value: function applyFilter(filterText) { | ||
this.setState(function () { | ||
return { value: filterText }; | ||
return { | ||
value: filterText | ||
}; | ||
}); | ||
@@ -145,3 +142,3 @@ this.props.onFilter(this.props.column, _const.FILTER_TYPE.TEXT)(filterText); | ||
}, { | ||
key: 'handleClick', | ||
key: "handleClick", | ||
value: function handleClick(e) { | ||
@@ -154,55 +151,42 @@ e.stopPropagation(); | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this4 = this; | ||
var _props2 = this.props, | ||
id = _props2.id, | ||
placeholder = _props2.placeholder, | ||
_props2$column = _props2.column, | ||
dataField = _props2$column.dataField, | ||
text = _props2$column.text, | ||
style = _props2.style, | ||
className = _props2.className, | ||
onFilter = _props2.onFilter, | ||
caseSensitive = _props2.caseSensitive, | ||
defaultValue = _props2.defaultValue, | ||
getFilter = _props2.getFilter, | ||
filterState = _props2.filterState, | ||
rest = _objectWithoutProperties(_props2, ['id', 'placeholder', 'column', 'style', 'className', 'onFilter', 'caseSensitive', 'defaultValue', 'getFilter', 'filterState']); | ||
var elmId = 'text-filter-column-' + dataField + (id ? '-' + id : ''); | ||
return _react2.default.createElement( | ||
'label', | ||
{ | ||
className: 'filter-label', | ||
htmlFor: elmId | ||
var _this$props2 = this.props, | ||
id = _this$props2.id, | ||
placeholder = _this$props2.placeholder, | ||
_this$props2$column = _this$props2.column, | ||
dataField = _this$props2$column.dataField, | ||
text = _this$props2$column.text, | ||
style = _this$props2.style, | ||
className = _this$props2.className, | ||
onFilter = _this$props2.onFilter, | ||
caseSensitive = _this$props2.caseSensitive, | ||
defaultValue = _this$props2.defaultValue, | ||
getFilter = _this$props2.getFilter, | ||
filterState = _this$props2.filterState, | ||
rest = _objectWithoutProperties(_this$props2, _excluded); | ||
var elmId = "text-filter-column-".concat(dataField).concat(id ? "-".concat(id) : ''); | ||
return /*#__PURE__*/_react["default"].createElement("label", { | ||
className: "filter-label", | ||
htmlFor: elmId | ||
}, /*#__PURE__*/_react["default"].createElement("span", { | ||
className: "sr-only" | ||
}, "Filter by ", text), /*#__PURE__*/_react["default"].createElement("input", _extends({}, rest, { | ||
ref: function ref(n) { | ||
return _this4.input = n; | ||
}, | ||
_react2.default.createElement( | ||
'span', | ||
{ className: 'sr-only' }, | ||
'Filter by ', | ||
text | ||
), | ||
_react2.default.createElement('input', _extends({}, rest, { | ||
ref: function ref(n) { | ||
return _this4.input = n; | ||
}, | ||
type: 'text', | ||
id: elmId, | ||
className: 'filter text-filter form-control ' + className, | ||
style: style, | ||
onChange: this.filter, | ||
onClick: this.handleClick, | ||
placeholder: placeholder || 'Enter ' + text + '...', | ||
value: this.state.value | ||
})) | ||
); | ||
type: "text", | ||
id: elmId, | ||
className: "filter text-filter form-control ".concat(className), | ||
style: style, | ||
onChange: this.filter, | ||
onClick: this.handleClick, | ||
placeholder: placeholder || "Enter ".concat(text, "..."), | ||
value: this.state.value | ||
}))); | ||
} | ||
}]); | ||
return TextFilter; | ||
}(_react.Component); | ||
TextFilter.propTypes = { | ||
@@ -222,3 +206,2 @@ onFilter: _propTypes.PropTypes.func.isRequired, | ||
}; | ||
TextFilter.defaultProps = { | ||
@@ -231,3 +214,3 @@ delay: _const.FILTER_DELAY, | ||
}; | ||
exports.default = TextFilter; | ||
var _default = TextFilter; | ||
exports["default"] = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var FILTER_TYPE = exports.FILTER_TYPE = { | ||
exports.FILTER_TYPE = exports.FILTER_DELAY = void 0; | ||
var FILTER_TYPE = { | ||
TEXT: 'TEXT', | ||
@@ -14,3 +15,4 @@ SELECT: 'SELECT', | ||
}; | ||
var FILTER_DELAY = exports.FILTER_DELAY = 500; | ||
exports.FILTER_TYPE = FILTER_TYPE; | ||
var FILTER_DELAY = 500; | ||
exports.FILTER_DELAY = FILTER_DELAY; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,48 +6,37 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
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 _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _filter = require('./filter'); | ||
var _comparison = require('./comparison'); | ||
var _const = require('./const'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
exports["default"] = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _filter = require("./filter"); | ||
var _comparison = require("./comparison"); | ||
var _const = require("./const"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(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 react/prop-types: 0 */ | ||
/* eslint react/require-default-props: 0 */ | ||
/* eslint camelcase: 0 */ | ||
exports.default = function (_, isRemoteFiltering, handleFilterChange) { | ||
var FilterContext = _react2.default.createContext(); | ||
var FilterProvider = function (_React$Component) { | ||
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, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint react/prop-types: 0 */ /* eslint react/require-default-props: 0 */ /* eslint camelcase: 0 */ | ||
var _default = function _default(_, isRemoteFiltering, handleFilterChange) { | ||
var FilterContext = /*#__PURE__*/_react["default"].createContext(); | ||
var FilterProvider = /*#__PURE__*/function (_React$Component) { | ||
_inherits(FilterProvider, _React$Component); | ||
var _super = _createSuper(FilterProvider); | ||
function FilterProvider(props) { | ||
var _this; | ||
_classCallCheck(this, FilterProvider); | ||
var _this = _possibleConstructorReturn(this, (FilterProvider.__proto__ || Object.getPrototypeOf(FilterProvider)).call(this, props)); | ||
_this = _super.call(this, props); | ||
_this.currFilters = {}; | ||
_this.clearFilters = {}; | ||
_this.onFilter = _this.onFilter.bind(_this); | ||
_this.doFilter = _this.doFilter.bind(_this); | ||
_this.onExternalFilter = _this.onExternalFilter.bind(_this); | ||
_this.onFilter = _this.onFilter.bind(_assertThisInitialized(_this)); | ||
_this.doFilter = _this.doFilter.bind(_assertThisInitialized(_this)); | ||
_this.onExternalFilter = _this.onExternalFilter.bind(_assertThisInitialized(_this)); | ||
_this.data = props.data; | ||
@@ -57,5 +46,4 @@ _this.isEmitDataChange = false; | ||
} | ||
_createClass(FilterProvider, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
@@ -67,8 +55,6 @@ if (isRemoteFiltering() && Object.keys(this.currFilters).length > 0) { | ||
}, { | ||
key: 'onFilter', | ||
key: "onFilter", | ||
value: function onFilter(column, filterType) { | ||
var _this2 = this; | ||
var initialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
return function (filterVal) { | ||
@@ -79,23 +65,25 @@ // watch out here if migration to context API, #334 | ||
var dataField = column.dataField, | ||
filter = column.filter; | ||
filter = column.filter; | ||
var needClearFilters = !_.isDefined(filterVal) || filterVal === '' || filterVal.length === 0; | ||
if (needClearFilters) { | ||
delete currFilters[dataField]; | ||
_this2.clearFilters = _defineProperty({}, dataField, { clear: true, filterVal: filterVal }); | ||
_this2.clearFilters = _defineProperty({}, dataField, { | ||
clear: true, | ||
filterVal: filterVal | ||
}); | ||
} else { | ||
// select default comparator is EQ, others are LIKE | ||
var _filter$props = filter.props, | ||
_filter$props$compara = _filter$props.comparator, | ||
comparator = _filter$props$compara === undefined ? filterType === _const.FILTER_TYPE.SELECT ? _comparison.EQ : _comparison.LIKE : _filter$props$compara, | ||
_filter$props$caseSen = _filter$props.caseSensitive, | ||
caseSensitive = _filter$props$caseSen === undefined ? false : _filter$props$caseSen; | ||
currFilters[dataField] = { filterVal: filterVal, filterType: filterType, comparator: comparator, caseSensitive: caseSensitive }; | ||
_filter$props$compara = _filter$props.comparator, | ||
comparator = _filter$props$compara === void 0 ? filterType === _const.FILTER_TYPE.SELECT ? _comparison.EQ : _comparison.LIKE : _filter$props$compara, | ||
_filter$props$caseSen = _filter$props.caseSensitive, | ||
caseSensitive = _filter$props$caseSen === void 0 ? false : _filter$props$caseSen; | ||
currFilters[dataField] = { | ||
filterVal: filterVal, | ||
filterType: filterType, | ||
comparator: comparator, | ||
caseSensitive: caseSensitive | ||
}; | ||
} | ||
_this2.currFilters = currFilters; | ||
if (isRemoteFiltering()) { | ||
@@ -111,6 +99,5 @@ if (!initialize) { | ||
}, { | ||
key: 'onExternalFilter', | ||
key: "onExternalFilter", | ||
value: function onExternalFilter(column, filterType) { | ||
var _this3 = this; | ||
return function (value) { | ||
@@ -121,3 +108,3 @@ _this3.onFilter(column, filterType)(value); | ||
}, { | ||
key: 'getFiltered', | ||
key: "getFiltered", | ||
value: function getFiltered() { | ||
@@ -127,3 +114,3 @@ return this.data; | ||
}, { | ||
key: 'UNSAFE_componentWillReceiveProps', | ||
key: "UNSAFE_componentWillReceiveProps", | ||
value: function UNSAFE_componentWillReceiveProps(nextProps) { | ||
@@ -138,10 +125,9 @@ // let nextData = nextProps.data; | ||
}, { | ||
key: 'doFilter', | ||
key: "doFilter", | ||
value: function doFilter(props) { | ||
var ignoreEmitDataChange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var dataChangeListener = props.dataChangeListener, | ||
data = props.data, | ||
columns = props.columns, | ||
filter = props.filter; | ||
data = props.data, | ||
columns = props.columns, | ||
filter = props.filter; | ||
var result = (0, _filter.filters)(data, columns, _)(this.currFilters, this.clearFilters); | ||
@@ -161,28 +147,21 @@ if (filter.afterFilter) { | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
return _react2.default.createElement( | ||
FilterContext.Provider, | ||
{ value: { | ||
data: this.data, | ||
onFilter: this.onFilter, | ||
onExternalFilter: this.onExternalFilter, | ||
currFilters: this.currFilters | ||
} | ||
}, | ||
this.props.children | ||
); | ||
return /*#__PURE__*/_react["default"].createElement(FilterContext.Provider, { | ||
value: { | ||
data: this.data, | ||
onFilter: this.onFilter, | ||
onExternalFilter: this.onExternalFilter, | ||
currFilters: this.currFilters | ||
} | ||
}, this.props.children); | ||
} | ||
}]); | ||
return FilterProvider; | ||
}(_react2.default.Component); | ||
FilterProvider.propTypes = { | ||
data: _propTypes2.default.array.isRequired, | ||
columns: _propTypes2.default.array.isRequired, | ||
dataChangeListener: _propTypes2.default.object | ||
}; | ||
}(_react["default"].Component); | ||
_defineProperty(FilterProvider, "propTypes", { | ||
data: _propTypes["default"].array.isRequired, | ||
columns: _propTypes["default"].array.isRequired, | ||
dataChangeListener: _propTypes["default"].object | ||
}); | ||
return { | ||
@@ -192,2 +171,3 @@ Provider: FilterProvider, | ||
}; | ||
}; | ||
}; | ||
exports["default"] = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,25 +6,20 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.filters = exports.filterFactory = exports.filterByArray = exports.filterByDate = exports.filterByNumber = exports.filterByText = undefined; | ||
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; }; /* eslint eqeqeq: 0 */ | ||
/* eslint no-console: 0 */ | ||
var _const = require('./const'); | ||
var _comparison = require('./comparison'); | ||
var filterByText = exports.filterByText = function filterByText(_) { | ||
exports.filters = exports.filterFactory = exports.filterByText = exports.filterByNumber = exports.filterByDate = exports.filterByArray = void 0; | ||
var _const = require("./const"); | ||
var _comparison = require("./comparison"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } /* eslint eqeqeq: 0 */ /* eslint no-console: 0 */ | ||
var filterByText = function filterByText(_) { | ||
return function (data, dataField, _ref, customFilterValue) { | ||
var _ref$filterVal = _ref.filterVal, | ||
userInput = _ref$filterVal === undefined ? '' : _ref$filterVal, | ||
_ref$comparator = _ref.comparator, | ||
comparator = _ref$comparator === undefined ? _comparison.LIKE : _ref$comparator, | ||
caseSensitive = _ref.caseSensitive; | ||
userInput = _ref$filterVal === void 0 ? '' : _ref$filterVal, | ||
_ref$comparator = _ref.comparator, | ||
comparator = _ref$comparator === void 0 ? _comparison.LIKE : _ref$comparator, | ||
caseSensitive = _ref.caseSensitive; | ||
// make sure filter value to be a string | ||
var filterVal = userInput.toString(); | ||
return data.filter(function (row) { | ||
@@ -42,3 +37,2 @@ var cell = _.get(row, dataField); | ||
} | ||
return cellStr.toLocaleUpperCase().indexOf(filterVal.toLocaleUpperCase()) !== -1; | ||
@@ -48,16 +42,14 @@ }); | ||
}; | ||
var filterByNumber = exports.filterByNumber = function filterByNumber(_) { | ||
exports.filterByText = filterByText; | ||
var filterByNumber = function filterByNumber(_) { | ||
return function (data, dataField, _ref2, customFilterValue) { | ||
var _ref2$filterVal = _ref2.filterVal, | ||
comparator = _ref2$filterVal.comparator, | ||
number = _ref2$filterVal.number; | ||
comparator = _ref2$filterVal.comparator, | ||
number = _ref2$filterVal.number; | ||
return data.filter(function (row) { | ||
if (number === '' || !comparator) return true; | ||
var cell = _.get(row, dataField); | ||
if (customFilterValue) { | ||
cell = customFilterValue(cell, row); | ||
} | ||
switch (comparator) { | ||
@@ -97,9 +89,8 @@ case _comparison.EQ: | ||
}; | ||
var filterByDate = exports.filterByDate = function filterByDate(_) { | ||
exports.filterByNumber = filterByNumber; | ||
var filterByDate = function filterByDate(_) { | ||
return function (data, dataField, _ref3, customFilterValue) { | ||
var _ref3$filterVal = _ref3.filterVal, | ||
comparator = _ref3$filterVal.comparator, | ||
date = _ref3$filterVal.date; | ||
comparator = _ref3$filterVal.comparator, | ||
date = _ref3$filterVal.date; | ||
if (!date || !comparator) return data; | ||
@@ -109,19 +100,14 @@ var filterDate = date.getUTCDate(); | ||
var filterYear = date.getUTCFullYear(); | ||
return data.filter(function (row) { | ||
var valid = true; | ||
var cell = _.get(row, dataField); | ||
if (customFilterValue) { | ||
cell = customFilterValue(cell, row); | ||
} | ||
if ((typeof cell === 'undefined' ? 'undefined' : _typeof(cell)) !== 'object') { | ||
if (_typeof(cell) !== 'object') { | ||
cell = new Date(cell); | ||
} | ||
var targetDate = cell.getUTCDate(); | ||
var targetMonth = cell.getUTCMonth(); | ||
var targetYear = cell.getUTCFullYear(); | ||
switch (comparator) { | ||
@@ -188,8 +174,7 @@ case _comparison.EQ: | ||
}; | ||
var filterByArray = exports.filterByArray = function filterByArray(_) { | ||
exports.filterByDate = filterByDate; | ||
var filterByArray = function filterByArray(_) { | ||
return function (data, dataField, _ref4) { | ||
var filterVal = _ref4.filterVal, | ||
comparator = _ref4.comparator; | ||
comparator = _ref4.comparator; | ||
if (filterVal.length === 0) return data; | ||
@@ -214,4 +199,4 @@ var refinedFilterVal = filterVal.filter(function (x) { | ||
}; | ||
var filterFactory = exports.filterFactory = function filterFactory(_) { | ||
exports.filterByArray = filterByArray; | ||
var filterFactory = function filterFactory(_) { | ||
return function (filterType) { | ||
@@ -233,15 +218,14 @@ switch (filterType) { | ||
}; | ||
var filters = exports.filters = function filters(data, columns, _) { | ||
exports.filterFactory = filterFactory; | ||
var filters = function filters(data, columns, _) { | ||
return function (currFilters) { | ||
var clearFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var factory = filterFactory(_); | ||
var filterState = _extends({}, clearFilters, currFilters); | ||
var filterState = _objectSpread(_objectSpread({}, clearFilters), currFilters); | ||
var result = data; | ||
var filterFn = void 0; | ||
var filterFn; | ||
Object.keys(filterState).forEach(function (dataField) { | ||
var currentResult = void 0; | ||
var filterValue = void 0; | ||
var customFilter = void 0; | ||
var currentResult; | ||
var filterValue; | ||
var customFilter; | ||
for (var i = 0; i < columns.length; i += 1) { | ||
@@ -256,3 +240,2 @@ if (columns[i].dataField === dataField) { | ||
} | ||
if (clearFilters[dataField] && customFilter) { | ||
@@ -278,2 +261,3 @@ currentResult = customFilter(clearFilters[dataField].filterVal, result); | ||
}; | ||
}; | ||
}; | ||
exports.filters = filters; |
{ | ||
"name": "react-bootstrap-table-nextgen-filter", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"description": "It's a column filter addon for react-bootstrap-table-nextgen", | ||
@@ -45,6 +45,6 @@ "main": "./lib/index.js", | ||
"peerDependencies": { | ||
"prop-types": "^15.0.0", | ||
"react": "^16.3.0", | ||
"react-dom": "^16.3.0" | ||
"prop-types": "^15.8.1", | ||
"react": "^16.4.0", | ||
"react-dom": "^16.4.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
429325
16
2328
3
1