@canner/antd-share-toolbar
Advanced tools
Comparing version 0.4.2-alpha.19 to 0.4.2-alpha.21
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,94 +6,112 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; }(); | ||
require("antd/es/dropdown/style/css"); | ||
var _react = require('react'); | ||
var _dropdown = _interopRequireDefault(require("antd/es/dropdown")); | ||
var _react2 = _interopRequireDefault(_react); | ||
require("antd/es/button/style/css"); | ||
var _antd = require('antd'); | ||
var _button = _interopRequireDefault(require("antd/es/button")); | ||
var _reactIntl = require('react-intl'); | ||
require("antd/es/icon/style/css"); | ||
var _icon = _interopRequireDefault(require("antd/es/icon")); | ||
require("antd/es/menu/style/css"); | ||
var _menu = _interopRequireDefault(require("antd/es/menu")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _reactIntl = require("react-intl"); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _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 _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); } } | ||
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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var Sort = function (_Component) { | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var Sort = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Sort, _Component); | ||
function Sort() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, Sort); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Sort.__proto__ || Object.getPrototypeOf(Sort)).call.apply(_ref, [this].concat(args))), _this), _this.addFilter = function (e) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Sort)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addFilter", function (e) { | ||
var _this$props = _this.props, | ||
displayedFilters = _this$props.displayedFilters, | ||
addFilter = _this$props.addFilter; | ||
var index = Number(e.key); | ||
var index = Number(e.key); | ||
if (displayedFilters.indexOf(index) === -1) { | ||
addFilter(index); | ||
} | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(Sort, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
exportButton = _props.exportButton, | ||
importButton = _props.importButton, | ||
filterButton = _props.filterButton, | ||
filters = _props.filters; | ||
var _this$props2 = this.props, | ||
exportButton = _this$props2.exportButton, | ||
importButton = _this$props2.importButton, | ||
filterButton = _this$props2.filterButton, | ||
filters = _this$props2.filters; | ||
var menu = _react2.default.createElement( | ||
_antd.Menu, | ||
{ onClick: this.addFilter }, | ||
filters.map(function (filter, index) { | ||
return _react2.default.createElement( | ||
_antd.Menu.Item, | ||
{ key: index }, | ||
filter.label | ||
); | ||
}) | ||
); | ||
return _react2.default.createElement( | ||
_antd.Button.Group, | ||
null, | ||
exportButton && _react2.default.createElement( | ||
_antd.Button, | ||
null, | ||
_react2.default.createElement(_antd.Icon, { type: 'download' }), | ||
_react2.default.createElement(_reactIntl.FormattedMessage, { id: 'query.actions.export' }) | ||
), | ||
importButton && _react2.default.createElement( | ||
_antd.Button, | ||
null, | ||
_react2.default.createElement(_antd.Icon, { type: 'upload' }), | ||
_react2.default.createElement(_reactIntl.FormattedMessage, { id: 'query.actions.import' }) | ||
), | ||
filterButton && _react2.default.createElement( | ||
_antd.Dropdown, | ||
{ overlay: menu }, | ||
_react2.default.createElement( | ||
_antd.Button, | ||
null, | ||
_react2.default.createElement(_antd.Icon, { type: 'filter' }), | ||
_react2.default.createElement(_reactIntl.FormattedMessage, { id: 'query.actions.filter' }) | ||
) | ||
) | ||
); | ||
var menu = _react.default.createElement(_menu.default, { | ||
onClick: this.addFilter | ||
}, filters.map(function (filter, index) { | ||
return _react.default.createElement(_menu.default.Item, { | ||
key: index | ||
}, filter.label); | ||
})); | ||
return _react.default.createElement(_button.default.Group, null, exportButton && _react.default.createElement(_button.default, null, _react.default.createElement(_icon.default, { | ||
type: "download" | ||
}), _react.default.createElement(_reactIntl.FormattedMessage, { | ||
id: "query.actions.export" | ||
})), importButton && _react.default.createElement(_button.default, null, _react.default.createElement(_icon.default, { | ||
type: "upload" | ||
}), _react.default.createElement(_reactIntl.FormattedMessage, { | ||
id: "query.actions.import" | ||
})), filterButton && _react.default.createElement(_dropdown.default, { | ||
overlay: menu | ||
}, _react.default.createElement(_button.default, null, _react.default.createElement(_icon.default, { | ||
type: "filter" | ||
}), _react.default.createElement(_reactIntl.FormattedMessage, { | ||
id: "query.actions.filter" | ||
})))); | ||
} | ||
@@ -100,0 +118,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,77 +6,81 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; | ||
require("antd/es/icon/style/css"); | ||
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 _icon = _interopRequireDefault(require("antd/es/icon")); | ||
var _templateObject = _taggedTemplateLiteral(['\n transition: 200ms;\n maxWidth: 220px;\n position: relative;\n text-align: left;\n padding: 8px;\n\n &:hover {\n background-color: #f3f3f3;\n\n i {\n visibility: visible;\n opacity: 1;\n position: absolute;\n right: 0;\n top: 0;\n cursor: pointer;\n }\n }\n\n i {\n transition: all 200ms;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n\n h5 {\n margin-bottom: 0;\n }\n'], ['\n transition: 200ms;\n maxWidth: 220px;\n position: relative;\n text-align: left;\n padding: 8px;\n\n &:hover {\n background-color: #f3f3f3;\n\n i {\n visibility: visible;\n opacity: 1;\n position: absolute;\n right: 0;\n top: 0;\n cursor: pointer;\n }\n }\n\n i {\n transition: all 200ms;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n\n h5 {\n margin-bottom: 0;\n }\n']); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _select = _interopRequireDefault(require("./select")); | ||
var React = _interopRequireWildcard(_react); | ||
var _number = _interopRequireDefault(require("./number")); | ||
var _select = require('./select'); | ||
var _text = _interopRequireDefault(require("./text")); | ||
var _select2 = _interopRequireDefault(_select); | ||
var _styledComponents = _interopRequireDefault(require("styled-components")); | ||
var _number = require('./number'); | ||
var _debounce = _interopRequireDefault(require("lodash/debounce")); | ||
var _number2 = _interopRequireDefault(_number); | ||
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty")); | ||
var _text = require('./text'); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _text2 = _interopRequireDefault(_text); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _styledComponents = require('styled-components'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _styledComponents2 = _interopRequireDefault(_styledComponents); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _antd = require('antd'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _debounce = require('lodash/debounce'); | ||
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); } } | ||
var _debounce2 = _interopRequireDefault(_debounce); | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var _isEmpty = require('lodash/isEmpty'); | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
var _isEmpty2 = _interopRequireDefault(_isEmpty); | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
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 _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n transition: 200ms;\n maxWidth: 220px;\n position: relative;\n text-align: left;\n padding: 8px;\n\n &:hover {\n background-color: #f3f3f3;\n\n i {\n visibility: visible;\n opacity: 1;\n position: absolute;\n right: 0;\n top: 0;\n cursor: pointer;\n }\n }\n\n i {\n transition: all 200ms;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n\n h5 {\n margin-bottom: 0;\n }\n"]); | ||
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; } | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
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; } | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
// import DateRangeFilter from './dateRange'; | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var FilterWrapper = _styledComponents.default.div(_templateObject()); | ||
// import {FormattedMessage} from 'react-intl'; | ||
// import defaultMessage from '../locale'; | ||
var FilterWrapper = _styledComponents2.default.div(_templateObject); | ||
var FilterGroup = function (_React$Component) { | ||
var FilterGroup = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(FilterGroup, _React$Component); | ||
function FilterGroup() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, FilterGroup); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = FilterGroup.__proto__ || Object.getPrototypeOf(FilterGroup)).call.apply(_ref, [this].concat(args))), _this), _this.onChange = function (cond) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(FilterGroup)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChange", function (cond) { | ||
var _this$props = _this.props, | ||
@@ -86,3 +90,3 @@ where = _this$props.where, | ||
if ((0, _isEmpty2.default)(cond)) { | ||
if ((0, _isEmpty.default)(cond)) { | ||
changeFilter({}); | ||
@@ -92,2 +96,3 @@ } else { | ||
var newCond = cond[key]; | ||
if (newCond === undefined) { | ||
@@ -101,8 +106,10 @@ delete where[key]; | ||
} | ||
}, _this.deleteFilter = function (index) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "deleteFilter", function (index) { | ||
var _this$props2 = _this.props, | ||
deleteFilter = _this$props2.deleteFilter, | ||
filters = _this$props2.filters; | ||
var filter = filters[index]; | ||
var filter = filters[index]; | ||
if (filter.type === 'select') { | ||
@@ -117,2 +124,3 @@ var allField = filter.options.reduce(function (result, option) { | ||
}, {}); | ||
_this.onChange(allField); | ||
@@ -122,16 +130,19 @@ } else { | ||
} | ||
deleteFilter(index); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(FilterGroup, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
_props$filters = _props.filters, | ||
filters = _props$filters === undefined ? [] : _props$filters, | ||
displayedFilters = _props.displayedFilters, | ||
where = _props.where; | ||
var _this$props3 = this.props, | ||
_this$props3$filters = _this$props3.filters, | ||
filters = _this$props3$filters === void 0 ? [] : _this$props3$filters, | ||
displayedFilters = _this$props3.displayedFilters, | ||
where = _this$props3.where; | ||
@@ -141,9 +152,21 @@ if (!filters || !filters.length) { | ||
} | ||
var debounceChange = (0, _debounce2.default)(this.onChange, 500); | ||
var debounceChange = (0, _debounce.default)(this.onChange, 500); | ||
var renderFilter = function renderFilter(filter) { | ||
switch (filter.type) { | ||
case 'select': | ||
return React.createElement(_select2.default, _extends({ onChange: debounceChange, where: where }, filter)); | ||
return React.createElement(_select.default, _extends({ | ||
onChange: debounceChange, | ||
where: where | ||
}, filter)); | ||
case 'number': | ||
return React.createElement(_number2.default, { onChange: debounceChange, name: filter.field, where: where, placeholder: filter.placeholder }); | ||
return React.createElement(_number.default, { | ||
onChange: debounceChange, | ||
name: filter.field, | ||
where: where, | ||
placeholder: filter.placeholder | ||
}); | ||
/* | ||
@@ -153,4 +176,11 @@ case 'dateRange': | ||
*/ | ||
case 'text': | ||
return React.createElement(_text2.default, { onChange: debounceChange, name: filter.field, where: where, placeholder: filter.placeholder }); | ||
return React.createElement(_text.default, { | ||
onChange: debounceChange, | ||
name: filter.field, | ||
where: where, | ||
placeholder: filter.placeholder | ||
}); | ||
default: | ||
@@ -160,21 +190,18 @@ return null; | ||
}; | ||
return React.createElement( | ||
'div', | ||
{ style: { marginTop: 16, marginBottom: 16 } }, | ||
displayedFilters.map(function (index) { | ||
return React.createElement( | ||
FilterWrapper, | ||
{ key: index }, | ||
React.createElement( | ||
'h5', | ||
null, | ||
filters[index].label | ||
), | ||
renderFilter(filters[index]), | ||
!filters[index].alwaysDisplay && React.createElement(_antd.Icon, { type: 'close-circle-o', onClick: function onClick() { | ||
return _this2.deleteFilter(index); | ||
} }) | ||
); | ||
}) | ||
); | ||
return React.createElement("div", { | ||
style: { | ||
marginTop: 16, | ||
marginBottom: 16 | ||
} | ||
}, displayedFilters.map(function (index) { | ||
return React.createElement(FilterWrapper, { | ||
key: index | ||
}, React.createElement("h5", null, filters[index].label), renderFilter(filters[index]), !filters[index].alwaysDisplay && React.createElement(_icon.default, { | ||
type: "close-circle-o", | ||
onClick: function onClick() { | ||
return _this2.deleteFilter(index); | ||
} | ||
})); | ||
})); | ||
} | ||
@@ -181,0 +208,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,50 +6,78 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; }(); | ||
require("antd/es/input/style/css"); | ||
var _class, _class2, _temp; | ||
var _input = _interopRequireDefault(require("antd/es/input")); | ||
var _react = require('react'); | ||
require("antd/es/select/style/css"); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _select = _interopRequireDefault(require("antd/es/select")); | ||
var _propTypes = require('prop-types'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _antd = require('antd'); | ||
var _isNaN = _interopRequireDefault(require("lodash/isNaN")); | ||
var _isNaN = require('lodash/isNaN'); | ||
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty")); | ||
var _isNaN2 = _interopRequireDefault(_isNaN); | ||
var _reactIntl = require("react-intl"); | ||
var _isEmpty = require('lodash/isEmpty'); | ||
var _class, _class2, _temp; | ||
var _isEmpty2 = _interopRequireDefault(_isEmpty); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _reactIntl = require('react-intl'); | ||
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; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _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 _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); } } | ||
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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var Option = _antd.Select.Option; | ||
var InputGroup = _antd.Input.Group; | ||
var operators = [{ symbol: '>', value: 'gt' }, { symbol: '<', value: 'lt' }, { symbol: '=', value: 'eq' }, { symbol: '≥', value: 'gte' }, { symbol: '≤', value: 'lte' }]; | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
var NumberRangeFilter = (0, _reactIntl.injectIntl)(_class = (_temp = _class2 = function (_Component) { | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var Option = _select.default.Option; | ||
var InputGroup = _input.default.Group; | ||
var operators = [{ | ||
symbol: '>', | ||
value: 'gt' | ||
}, { | ||
symbol: '<', | ||
value: 'lt' | ||
}, { | ||
symbol: '=', | ||
value: 'eq' | ||
}, { | ||
symbol: '≥', | ||
value: 'gte' | ||
}, { | ||
symbol: '≤', | ||
value: 'lte' | ||
}]; | ||
var NumberRangeFilter = (0, _reactIntl.injectIntl)(_class = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(NumberRangeFilter, _Component); | ||
function NumberRangeFilter(props) { | ||
var _this; | ||
_classCallCheck(this, NumberRangeFilter); | ||
var _this = _possibleConstructorReturn(this, (NumberRangeFilter.__proto__ || Object.getPrototypeOf(NumberRangeFilter)).call(this, props)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(NumberRangeFilter).call(this, props)); | ||
_this.state = { | ||
@@ -60,6 +88,6 @@ input: '', | ||
}; | ||
_this.onInputLow = _this.onInputLow.bind(_this); | ||
_this.onInput = _this.onInput.bind(_this); | ||
_this.changeOperator = _this.changeOperator.bind(_this); | ||
_this.onChange = _this.onChange.bind(_this); | ||
_this.onInputLow = _this.onInputLow.bind(_assertThisInitialized(_assertThisInitialized(_this))); | ||
_this.onInput = _this.onInput.bind(_assertThisInitialized(_assertThisInitialized(_this))); | ||
_this.changeOperator = _this.changeOperator.bind(_assertThisInitialized(_assertThisInitialized(_this))); | ||
_this.onChange = _this.onChange.bind(_assertThisInitialized(_assertThisInitialized(_this))); | ||
return _this; | ||
@@ -69,8 +97,8 @@ } | ||
_createClass(NumberRangeFilter, [{ | ||
key: 'onInputLow', | ||
key: "onInputLow", | ||
value: function onInputLow(e) { | ||
var value = e.target.value; | ||
var reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/; | ||
var reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/; | ||
if (!(0, _isNaN2.default)(value) && reg.test(value) || value === '' || value === '-') { | ||
if (!(0, _isNaN.default)(value) && reg.test(value) || value === '' || value === '-') { | ||
this.setState({ | ||
@@ -82,8 +110,8 @@ lowInput: value | ||
}, { | ||
key: 'onInput', | ||
key: "onInput", | ||
value: function onInput(e) { | ||
var value = e.target.value; | ||
var reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/; | ||
var reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/; | ||
if (!(0, _isNaN2.default)(value) && reg.test(value) || value === '' || value === '-') { | ||
if (!(0, _isNaN.default)(value) && reg.test(value) || value === '' || value === '-') { | ||
this.setState({ | ||
@@ -95,3 +123,3 @@ input: value | ||
}, { | ||
key: 'changeOperator', | ||
key: "changeOperator", | ||
value: function changeOperator(val) { | ||
@@ -103,11 +131,11 @@ this.setState({ | ||
}, { | ||
key: 'onChange', | ||
key: "onChange", | ||
value: function onChange() { | ||
var _state = this.state, | ||
lowInput = _state.lowInput, | ||
input = _state.input, | ||
operator = _state.operator; | ||
var _props = this.props, | ||
name = _props.name, | ||
onChange = _props.onChange; | ||
var _this$state = this.state, | ||
lowInput = _this$state.lowInput, | ||
input = _this$state.input, | ||
operator = _this$state.operator; | ||
var _this$props = this.props, | ||
name = _this$props.name, | ||
onChange = _this$props.onChange; | ||
@@ -117,47 +145,43 @@ if (operator === '$between') { | ||
name: { | ||
$gt: (0, _isEmpty2.default)(lowInput) ? -Infinity : Number(lowInput), | ||
$lt: (0, _isEmpty2.default)(input) ? Infinity : Number(input) | ||
$gt: (0, _isEmpty.default)(lowInput) ? -Infinity : Number(lowInput), | ||
$lt: (0, _isEmpty.default)(input) ? Infinity : Number(input) | ||
} | ||
}); | ||
} else { | ||
onChange((0, _isEmpty2.default)(input) ? _defineProperty({}, name.split('.')[0], undefined) : _defineProperty({}, name, _defineProperty({}, operator, Number(input)))); | ||
onChange((0, _isEmpty.default)(input) ? _defineProperty({}, name.split('.')[0], undefined) : _defineProperty({}, name, _defineProperty({}, operator, Number(input)))); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props2 = this.props, | ||
intl = _props2.intl, | ||
placeholder = _props2.placeholder; | ||
var _state2 = this.state, | ||
operator = _state2.operator, | ||
input = _state2.input; | ||
var _this$props2 = this.props, | ||
intl = _this$props2.intl, | ||
placeholder = _this$props2.placeholder; | ||
var _this$state2 = this.state, | ||
operator = _this$state2.operator, | ||
input = _this$state2.input; | ||
var ph = placeholder || intl.formatMessage({ | ||
id: 'query.numberRange.placeholder' | ||
}); | ||
return _react2.default.createElement( | ||
InputGroup, | ||
{ compact: true }, | ||
_react2.default.createElement( | ||
_antd.Select, | ||
{ style: { width: 60 }, | ||
value: operator, | ||
onChange: this.changeOperator | ||
}, | ||
operators.map(function (operator) { | ||
return _react2.default.createElement( | ||
Option, | ||
{ key: operator.value, value: operator.value }, | ||
operator.symbol | ||
); | ||
}) | ||
), | ||
_react2.default.createElement(_antd.Input, { | ||
style: { width: 120 }, | ||
placeholder: ph, | ||
value: input, | ||
onChange: this.onInput | ||
}) | ||
); | ||
return _react.default.createElement(InputGroup, { | ||
compact: true | ||
}, _react.default.createElement(_select.default, { | ||
style: { | ||
width: 60 | ||
}, | ||
value: operator, | ||
onChange: this.changeOperator | ||
}, operators.map(function (operator) { | ||
return _react.default.createElement(Option, { | ||
key: operator.value, | ||
value: operator.value | ||
}, operator.symbol); | ||
})), _react.default.createElement(_input.default, { | ||
style: { | ||
width: 120 | ||
}, | ||
placeholder: ph, | ||
value: input, | ||
onChange: this.onInput | ||
})); | ||
} | ||
@@ -167,9 +191,9 @@ }]); | ||
return NumberRangeFilter; | ||
}(_react.Component), _class2.propTypes = { | ||
onChange: _propTypes2.default.func, | ||
name: _propTypes2.default.string, | ||
label: _propTypes2.default.string, | ||
intl: _propTypes2.default.object | ||
}, _temp)) || _class; | ||
}(_react.Component), _defineProperty(_class2, "propTypes", { | ||
onChange: _propTypes.default.func, | ||
name: _propTypes.default.string, | ||
label: _propTypes.default.string, | ||
intl: _propTypes.default.object | ||
}), _temp)) || _class; | ||
exports.default = NumberRangeFilter; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,49 +6,63 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; }(); | ||
require("antd/es/select/style/css"); | ||
var _class, _class2, _temp2; | ||
var _select = _interopRequireDefault(require("antd/es/select")); | ||
var _react = require('react'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = require('prop-types'); | ||
var _isUndefined = _interopRequireDefault(require("lodash/isUndefined")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _reactIntl = require("react-intl"); | ||
var _antd = require('antd'); | ||
var _class, _class2, _temp; | ||
var _isUndefined = require('lodash/isUndefined'); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _isUndefined2 = _interopRequireDefault(_isUndefined); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _reactIntl = require('react-intl'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _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); } } | ||
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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var Option = _antd.Select.Option; | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
var SelectFilter = (0, _reactIntl.injectIntl)(_class = (_temp2 = _class2 = function (_Component) { | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var Option = _select.default.Option; | ||
var SelectFilter = (0, _reactIntl.injectIntl)(_class = (_temp = _class2 = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(SelectFilter, _Component); | ||
function SelectFilter() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, SelectFilter); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SelectFilter.__proto__ || Object.getPrototypeOf(SelectFilter)).call.apply(_ref, [this].concat(args))), _this), _this.onSelect = function (val) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SelectFilter)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onSelect", function (val) { | ||
var _this$props = _this.props, | ||
@@ -58,41 +72,42 @@ onChange = _this$props.onChange, | ||
if ((0, _isUndefined2.default)(val)) { | ||
if ((0, _isUndefined.default)(val)) { | ||
return onChange({}); | ||
} | ||
var selectedCondition = options[val].condition; | ||
onChange(selectedCondition); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(SelectFilter, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
options = _props.options, | ||
intl = _props.intl, | ||
placeholder = _props.placeholder, | ||
defaultOptionIndex = _props.defaultOptionIndex; | ||
var defaultPlaceholder = intl.formatMessage({ id: 'query.filter.select.placeholder' }); | ||
return _react2.default.createElement( | ||
_antd.Select, | ||
{ | ||
style: { width: 120 }, | ||
placeholder: placeholder || defaultPlaceholder, | ||
onChange: function onChange(val) { | ||
return _this2.onSelect(val); | ||
}, | ||
defaultValue: defaultOptionIndex, | ||
allowClear: true | ||
var _this$props2 = this.props, | ||
options = _this$props2.options, | ||
intl = _this$props2.intl, | ||
placeholder = _this$props2.placeholder, | ||
defaultOptionIndex = _this$props2.defaultOptionIndex; | ||
var defaultPlaceholder = intl.formatMessage({ | ||
id: 'query.filter.select.placeholder' | ||
}); | ||
return _react.default.createElement(_select.default, { | ||
style: { | ||
width: 120 | ||
}, | ||
options.map(function (cond, i) { | ||
return _react2.default.createElement( | ||
Option, | ||
{ value: i, key: i }, | ||
cond.text | ||
); | ||
}) | ||
); | ||
placeholder: placeholder || defaultPlaceholder, | ||
onChange: function onChange(val) { | ||
return _this2.onSelect(val); | ||
}, | ||
defaultValue: defaultOptionIndex, | ||
allowClear: true | ||
}, options.map(function (cond, i) { | ||
return _react.default.createElement(Option, { | ||
value: i, | ||
key: i | ||
}, cond.text); | ||
})); | ||
} | ||
@@ -102,12 +117,12 @@ }]); | ||
return SelectFilter; | ||
}(_react.Component), _class2.propTypes = { | ||
onChange: _propTypes2.default.func, | ||
name: _propTypes2.default.string, | ||
options: _propTypes2.default.array, | ||
label: _propTypes2.default.string, | ||
intl: _propTypes2.default.object | ||
}, _class2.defaultProps = { | ||
}(_react.Component), _defineProperty(_class2, "propTypes", { | ||
onChange: _propTypes.default.func, | ||
name: _propTypes.default.string, | ||
options: _propTypes.default.array, | ||
label: _propTypes.default.string, | ||
intl: _propTypes.default.object | ||
}), _defineProperty(_class2, "defaultProps", { | ||
options: [] | ||
}, _temp2)) || _class; | ||
}), _temp)) || _class; | ||
exports.default = SelectFilter; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,51 +6,59 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; }(); | ||
require("antd/es/input/style/css"); | ||
var _class, _temp2; | ||
var _input = _interopRequireDefault(require("antd/es/input")); | ||
var _react = require('react'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = require('prop-types'); | ||
var _get = _interopRequireDefault(require("lodash/get")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _set = _interopRequireDefault(require("lodash/set")); | ||
var _antd = require('antd'); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _get = require('lodash/get'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _get2 = _interopRequireDefault(_get); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _set = require('lodash/set'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _set2 = _interopRequireDefault(_set); | ||
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); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
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; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var TextFilter = (_temp2 = _class = function (_Component) { | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var TextFilter = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(TextFilter, _Component); | ||
function TextFilter() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, TextFilter); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TextFilter.__proto__ || Object.getPrototypeOf(TextFilter)).call.apply(_ref, [this].concat(args))), _this), _this.onInput = function (e) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TextFilter)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onInput", function (e) { | ||
var _this$props = _this.props, | ||
@@ -64,20 +72,23 @@ name = _this$props.name, | ||
} else { | ||
onChange((0, _set2.default)({}, name + '.contains', value)); | ||
onChange((0, _set.default)({}, "".concat(name, ".contains"), value)); | ||
} | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(TextFilter, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
placeholder = _props.placeholder, | ||
where = _props.where, | ||
name = _props.name; | ||
return _react2.default.createElement(_antd.Input, { | ||
style: { width: 140 }, | ||
var _this$props2 = this.props, | ||
placeholder = _this$props2.placeholder, | ||
where = _this$props2.where, | ||
name = _this$props2.name; | ||
return _react.default.createElement(_input.default, { | ||
style: { | ||
width: 140 | ||
}, | ||
placeholder: placeholder || name, | ||
onChange: this.onInput, | ||
defaultValue: (0, _get2.default)(where, name + '.contains', '') | ||
defaultValue: (0, _get.default)(where, "".concat(name, ".contains"), '') | ||
}); | ||
@@ -88,7 +99,10 @@ } | ||
return TextFilter; | ||
}(_react.Component), _class.propTypes = { | ||
onChange: _propTypes2.default.func, | ||
name: _propTypes2.default.string, | ||
label: _propTypes2.default.string | ||
}, _temp2); | ||
exports.default = TextFilter; | ||
}(_react.Component); | ||
exports.default = TextFilter; | ||
_defineProperty(TextFilter, "propTypes", { | ||
onChange: _propTypes.default.func, | ||
name: _propTypes.default.string, | ||
label: _propTypes.default.string | ||
}); |
209
lib/index.js
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,59 +6,71 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var React = _interopRequireWildcard(require("react")); | ||
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 _toolbarlayout = _interopRequireDefault(require("./toolbarlayout")); | ||
var _react = require('react'); | ||
var _pagination = _interopRequireDefault(require("./pagination")); | ||
var React = _interopRequireWildcard(_react); | ||
var _sort = _interopRequireDefault(require("./sort")); | ||
var _toolbarlayout = require('./toolbarlayout'); | ||
var _filter = _interopRequireDefault(require("./filter")); | ||
var _toolbarlayout2 = _interopRequireDefault(_toolbarlayout); | ||
var _actions = _interopRequireDefault(require("./actions")); | ||
var _pagination = require('./pagination'); | ||
var _toLower = _interopRequireDefault(require("lodash/toLower")); | ||
var _pagination2 = _interopRequireDefault(_pagination); | ||
var _utils = require("./utils"); | ||
var _sort = require('./sort'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _sort2 = _interopRequireDefault(_sort); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _filter = require('./filter'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _filter2 = _interopRequireDefault(_filter); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _actions = require('./actions'); | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
var _actions2 = _interopRequireDefault(_actions); | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
var _toLower = require('lodash/toLower'); | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
var _toLower2 = _interopRequireDefault(_toLower); | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
var _utils = require('./utils'); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _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 _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); } } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
var Toolbar = function (_React$PureComponent) { | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var Toolbar = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inherits(Toolbar, _React$PureComponent); | ||
function Toolbar(props) { | ||
var _this; | ||
_classCallCheck(this, Toolbar); | ||
var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, props)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Toolbar).call(this, props)); | ||
_this.changeOrder = function (_ref) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "async", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changeOrder", function (_ref) { | ||
var sortField = _ref.sortField, | ||
@@ -81,18 +93,18 @@ sortType = _ref.sortType; | ||
} | ||
}; | ||
}); | ||
_this.changeFilter = function (where) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changeFilter", function (where) { | ||
_this.setState({ | ||
where: _extends({}, where, _this.permanentFilter), | ||
where: _objectSpread({}, where, _this.permanentFilter), | ||
current: 1 | ||
}); | ||
}; | ||
}); | ||
_this.addFilter = function (index) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addFilter", function (index) { | ||
_this.setState({ | ||
displayedFilterIndexs: _this.state.displayedFilterIndexs.concat(index) | ||
}); | ||
}; | ||
}); | ||
_this.deleteFilter = function (index) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "deleteFilter", function (index) { | ||
_this.setState({ | ||
@@ -103,11 +115,11 @@ displayedFilterIndexs: _this.state.displayedFilterIndexs.filter(function (i) { | ||
}); | ||
}; | ||
}); | ||
_this.changeSize = function (size) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changeSize", function (size) { | ||
_this.setState({ | ||
pageSize: size | ||
}); | ||
}; | ||
}); | ||
_this.changePage = function (page, size) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changePage", function (page, size) { | ||
_this.setState({ | ||
@@ -117,8 +129,7 @@ current: page, | ||
}); | ||
}; | ||
}); | ||
var _props$toolbar = props.toolbar, | ||
toolbar = _props$toolbar === undefined ? {} : _props$toolbar, | ||
toolbar = _props$toolbar === void 0 ? {} : _props$toolbar, | ||
recordValue = props.recordValue; | ||
_this.async = toolbar.async || false; | ||
@@ -128,6 +139,9 @@ _this.permanentFilter = {}; | ||
var defaultWhere = {}; | ||
if (toolbar.filter) { | ||
_this.permanentFilter = (0, _utils.getPermanentFilter)(toolbar, recordValue); | ||
_this.alwaysDisplayFilterIndexs = (toolbar.filter.filters || []).map(function (filter, i) { | ||
return _extends({}, filter, { __index: i }); | ||
return _objectSpread({}, filter, { | ||
__index: i | ||
}); | ||
}).filter(function (filter) { | ||
@@ -141,2 +155,3 @@ return filter.alwaysDisplay; | ||
}); | ||
if (defaultFilter) { | ||
@@ -146,5 +161,6 @@ defaultWhere = defaultFilter.options[defaultFilter.defaultOptionIndex].condition; | ||
} | ||
_this.state = { | ||
sorter: {}, | ||
where: _extends({}, _this.permanentFilter, defaultWhere), | ||
where: _objectSpread({}, _this.permanentFilter, defaultWhere), | ||
current: 1, | ||
@@ -158,9 +174,9 @@ pageSize: 10, | ||
_createClass(Toolbar, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
dataSource = _props.dataSource, | ||
children = _props.children, | ||
_props$toolbar2 = _props.toolbar, | ||
toolbar = _props$toolbar2 === undefined ? {} : _props$toolbar2; | ||
var _this$props = this.props, | ||
dataSource = _this$props.dataSource, | ||
children = _this$props.children, | ||
_this$props$toolbar = _this$props.toolbar, | ||
toolbar = _this$props$toolbar === void 0 ? {} : _this$props$toolbar; | ||
var displayedFilterIndexs = this.state.displayedFilterIndexs; | ||
@@ -172,57 +188,66 @@ var sorter = toolbar.sorter, | ||
actions = toolbar.actions; | ||
var ToolbarLayout = toolbarLayout && toolbarLayout.component ? toolbarLayout.component : _toolbarlayout2.default; | ||
var SortComponent = sorter && sorter.component ? sorter.component : _sort2.default; | ||
var FilterComponent = filter && filter.component ? filter.component : _filter2.default; | ||
var ActionsComponent = actions && actions.component ? actions.component : _actions2.default; | ||
var PaginationComponent = pagination && pagination.component ? pagination.component : _pagination2.default; | ||
var ToolbarLayout = toolbarLayout && toolbarLayout.component ? toolbarLayout.component : _toolbarlayout.default; | ||
var SortComponent = sorter && sorter.component ? sorter.component : _sort.default; | ||
var FilterComponent = filter && filter.component ? filter.component : _filter.default; | ||
var ActionsComponent = actions && actions.component ? actions.component : _actions.default; | ||
var PaginationComponent = pagination && pagination.component ? pagination.component : _pagination.default; | ||
var value = dataSource.map(function (data, i) { | ||
return _extends({}, data, { __index: i }); | ||
return _objectSpread({}, data, { | ||
__index: i | ||
}); | ||
}); | ||
if (!toolbar || toolbar.async) { | ||
return children({ value: value, showPagination: false }); | ||
return children({ | ||
value: value, | ||
showPagination: false | ||
}); | ||
} | ||
if (filter) { | ||
value = (0, _utils.filterWith)(value, this.state.where); | ||
} | ||
if (sorter) { | ||
value = (0, _utils.sortWith)(value, this.state.sorter.sortField, (0, _toLower2.default)(this.state.sorter.sortType)); | ||
value = (0, _utils.sortWith)(value, this.state.sorter.sortField, (0, _toLower.default)(this.state.sorter.sortType)); | ||
} | ||
var total = value.length; | ||
if (pagination) { | ||
value = (0, _utils.paginate)(value, this.state.current, this.state.pageSize); | ||
} | ||
return React.createElement( | ||
ToolbarLayout, | ||
{ | ||
Actions: actions ? React.createElement(ActionsComponent, _extends({}, actions, { | ||
filters: filter && filter.filters || [], | ||
displayedFilters: [].concat(_toConsumableArray(displayedFilterIndexs), _toConsumableArray(this.alwaysDisplayFilterIndexs)), | ||
addFilter: this.addFilter | ||
})) : React.createElement('div', null), | ||
Sort: sorter ? React.createElement(SortComponent, _extends({}, sorter, { | ||
defaultField: sorter.defaultField, | ||
options: sorter.options || [], | ||
changeOrder: this.changeOrder, | ||
sortField: this.state.sorter.sortField, | ||
sortType: this.state.sorter.sortType | ||
})) : null, | ||
Pagination: pagination ? React.createElement(PaginationComponent, _extends({}, pagination, { | ||
pageSize: this.state.pageSize, | ||
current: this.state.current, | ||
changePage: this.changePage, | ||
changeSize: this.changeSize, | ||
total: total | ||
})) : null, | ||
Filter: filter ? React.createElement(FilterComponent, _extends({ | ||
async: toolbar.async | ||
}, filter, { | ||
displayedFilters: [].concat(_toConsumableArray(displayedFilterIndexs), _toConsumableArray(this.alwaysDisplayFilterIndexs)), | ||
where: this.state.where, | ||
changeFilter: this.changeFilter, | ||
deleteFilter: this.deleteFilter | ||
})) : null | ||
}, | ||
children({ value: value, showPagination: false }) | ||
); | ||
return React.createElement(ToolbarLayout, { | ||
Actions: actions ? React.createElement(ActionsComponent, _extends({}, actions, { | ||
filters: filter && filter.filters || [], | ||
displayedFilters: _toConsumableArray(displayedFilterIndexs).concat(_toConsumableArray(this.alwaysDisplayFilterIndexs)), | ||
addFilter: this.addFilter | ||
})) : React.createElement("div", null), | ||
Sort: sorter ? React.createElement(SortComponent, _extends({}, sorter, { | ||
defaultField: sorter.defaultField, | ||
options: sorter.options || [], | ||
changeOrder: this.changeOrder, | ||
sortField: this.state.sorter.sortField, | ||
sortType: this.state.sorter.sortType | ||
})) : null, | ||
Pagination: pagination ? React.createElement(PaginationComponent, _extends({}, pagination, { | ||
pageSize: this.state.pageSize, | ||
current: this.state.current, | ||
changePage: this.changePage, | ||
changeSize: this.changeSize, | ||
total: total | ||
})) : null, | ||
Filter: filter ? React.createElement(FilterComponent, _extends({ | ||
async: toolbar.async | ||
}, filter, { | ||
displayedFilters: _toConsumableArray(displayedFilterIndexs).concat(_toConsumableArray(this.alwaysDisplayFilterIndexs)), | ||
where: this.state.where, | ||
changeFilter: this.changeFilter, | ||
deleteFilter: this.deleteFilter | ||
})) : null | ||
}, children({ | ||
value: value, | ||
showPagination: false | ||
})); | ||
} | ||
@@ -229,0 +254,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,29 +6,47 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; }(); | ||
require("antd/es/pagination/style/css"); | ||
var _templateObject = _taggedTemplateLiteral(['\n text-align: right;\n margin-top: ', 'px;\n margin-right: ', 'px;\n display: inline-block;\n'], ['\n text-align: right;\n margin-top: ', 'px;\n margin-right: ', 'px;\n display: inline-block;\n']); | ||
var _pagination = _interopRequireDefault(require("antd/es/pagination")); | ||
var _react = require('react'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _styledComponents = _interopRequireDefault(require("styled-components")); | ||
var _antd = require('antd'); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _styledComponents = require('styled-components'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _styledComponents2 = _interopRequireDefault(_styledComponents); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _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); } } | ||
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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
var Wrapper = _styledComponents2.default.div(_templateObject, function (props) { | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n text-align: right;\n margin-top: ", "px;\n margin-right: ", "px;\n display: inline-block;\n"]); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var Wrapper = _styledComponents.default.div(_templateObject(), function (props) { | ||
return props.marginTop; | ||
@@ -39,3 +57,5 @@ }, function (props) { | ||
var PaginationPlugin = function (_Component) { | ||
var PaginationPlugin = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(PaginationPlugin, _Component); | ||
@@ -46,30 +66,29 @@ | ||
return _possibleConstructorReturn(this, (PaginationPlugin.__proto__ || Object.getPrototypeOf(PaginationPlugin)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(PaginationPlugin).apply(this, arguments)); | ||
} | ||
_createClass(PaginationPlugin, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
total = _props.total, | ||
changePage = _props.changePage, | ||
current = _props.current, | ||
changeSize = _props.changeSize, | ||
pageSize = _props.pageSize; | ||
return _react2.default.createElement( | ||
'div', | ||
{ style: { display: 'flex', justifyContent: 'flex-end' } }, | ||
_react2.default.createElement( | ||
Wrapper, | ||
{ marginTop: 16, marginRight: 16 }, | ||
_react2.default.createElement(_antd.Pagination, { | ||
pageSize: pageSize, | ||
total: total, | ||
current: current, | ||
onShowSizeChange: changeSize, | ||
onChange: changePage | ||
}) | ||
) | ||
); | ||
var _this$props = this.props, | ||
total = _this$props.total, | ||
changePage = _this$props.changePage, | ||
current = _this$props.current, | ||
changeSize = _this$props.changeSize, | ||
pageSize = _this$props.pageSize; | ||
return _react.default.createElement("div", { | ||
style: { | ||
display: 'flex', | ||
justifyContent: 'flex-end' | ||
} | ||
}, _react.default.createElement(Wrapper, { | ||
marginTop: 16, | ||
marginRight: 16 | ||
}, _react.default.createElement(_pagination.default, { | ||
pageSize: pageSize, | ||
total: total, | ||
current: current, | ||
onShowSizeChange: changeSize, | ||
onChange: changePage | ||
}))); | ||
} | ||
@@ -76,0 +95,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,17 +6,36 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.Label = exports.FilterPlugin = undefined; | ||
exports.Label = exports.FilterPlugin = void 0; | ||
var _templateObject = _taggedTemplateLiteral(['\n flex: 1;\n margin-right: 15px;\n min-width: 100px;\n'], ['\n flex: 1;\n margin-right: 15px;\n min-width: 100px;\n']), | ||
_templateObject2 = _taggedTemplateLiteral(['\n color: #aaa;\n letter-spacing: 2px;\n font-size: 14px;\n margin-bottom: 5px;\n margin-left: 2px;\n'], ['\n color: #aaa;\n letter-spacing: 2px;\n font-size: 14px;\n margin-bottom: 5px;\n margin-left: 2px;\n']); | ||
var _styledComponents = _interopRequireDefault(require("styled-components")); | ||
var _styledComponents = require('styled-components'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _styledComponents2 = _interopRequireDefault(_styledComponents); | ||
function _templateObject2() { | ||
var data = _taggedTemplateLiteral(["\n color: #aaa;\n letter-spacing: 2px;\n font-size: 14px;\n margin-bottom: 5px;\n margin-left: 2px;\n"]); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
_templateObject2 = function _templateObject2() { | ||
return data; | ||
}; | ||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
return data; | ||
} | ||
var FilterPlugin = exports.FilterPlugin = _styledComponents2.default.div(_templateObject); | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n flex: 1;\n margin-right: 15px;\n min-width: 100px;\n"]); | ||
var Label = exports.Label = _styledComponents2.default.div(_templateObject2); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var FilterPlugin = _styledComponents.default.div(_templateObject()); | ||
exports.FilterPlugin = FilterPlugin; | ||
var Label = _styledComponents.default.div(_templateObject2()); | ||
exports.Label = Label; |
186
lib/sort.js
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,68 +6,121 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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; }; }(); | ||
require("antd/es/icon/style/css"); | ||
var _templateObject = _taggedTemplateLiteral(['\n width: 150px;\n margin: 0 15px;\n'], ['\n width: 150px;\n margin: 0 15px;\n']), | ||
_templateObject2 = _taggedTemplateLiteral(['\n cursor: pointer;\n display: flex;\n flex-direction: column;\n'], ['\n cursor: pointer;\n display: flex;\n flex-direction: column;\n']), | ||
_templateObject3 = _taggedTemplateLiteral(['\n color: ', ';\n'], ['\n color: ', ';\n']); | ||
var _icon = _interopRequireDefault(require("antd/es/icon")); | ||
var _react = require('react'); | ||
require("antd/es/select/style/css"); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _select = _interopRequireDefault(require("antd/es/select")); | ||
var _antd = require('antd'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _styledComponents = require('styled-components'); | ||
var _styledComponents = _interopRequireDefault(require("styled-components")); | ||
var _styledComponents2 = _interopRequireDefault(_styledComponents); | ||
var _reactIntl = require("react-intl"); | ||
var _reactIntl = require('react-intl'); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _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 _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); } } | ||
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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
var Option = _antd.Select.Option; | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
var Selector = (0, _styledComponents2.default)(_antd.Select)(_templateObject); | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var OrderSwitch = _styledComponents2.default.div(_templateObject2); | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
var UpIcon = (0, _styledComponents2.default)(_antd.Icon)(_templateObject3, function (props) { | ||
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; } | ||
function _templateObject4() { | ||
var data = _taggedTemplateLiteral(["\n color: ", ";\n"]); | ||
_templateObject4 = function _templateObject4() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject3() { | ||
var data = _taggedTemplateLiteral(["\n color: ", ";\n"]); | ||
_templateObject3 = function _templateObject3() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject2() { | ||
var data = _taggedTemplateLiteral(["\n cursor: pointer;\n display: flex;\n flex-direction: column;\n"]); | ||
_templateObject2 = function _templateObject2() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n width: 150px;\n margin: 0 15px;\n"]); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var Option = _select.default.Option; | ||
var Selector = (0, _styledComponents.default)(_select.default)(_templateObject()); | ||
var OrderSwitch = _styledComponents.default.div(_templateObject2()); | ||
var UpIcon = (0, _styledComponents.default)(_icon.default)(_templateObject3(), function (props) { | ||
return props.order > 0 ? '#333' : '#ccc'; | ||
}); | ||
var DownIcon = (0, _styledComponents2.default)(_antd.Icon)(_templateObject3, function (props) { | ||
var DownIcon = (0, _styledComponents.default)(_icon.default)(_templateObject4(), function (props) { | ||
return props.order > 0 ? '#ccc' : '#333'; | ||
}); | ||
var Sort = function (_Component) { | ||
var Sort = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Sort, _Component); | ||
function Sort(props) { | ||
var _this; | ||
_classCallCheck(this, Sort); | ||
var _this = _possibleConstructorReturn(this, (Sort.__proto__ || Object.getPrototypeOf(Sort)).call(this, props)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Sort).call(this, props)); | ||
_this.onChange = function (value) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChange", function (value) { | ||
_this.setState({ | ||
key: value | ||
}, _this.submit); | ||
}; | ||
}); | ||
_this.changeOrder = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changeOrder", function () { | ||
_this.setState({ | ||
order: !_this.state.order | ||
}, _this.submit); | ||
}; | ||
}); | ||
_this.submit = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "submit", function () { | ||
var changeOrder = _this.props.changeOrder; | ||
@@ -77,3 +130,2 @@ var _this$state = _this.state, | ||
order = _this$state.order; | ||
changeOrder({ | ||
@@ -83,3 +135,3 @@ sortField: key, | ||
}); | ||
}; | ||
}); | ||
@@ -94,14 +146,15 @@ _this.state = { | ||
_createClass(Sort, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _props = this.props, | ||
defaultField = _props.defaultField, | ||
options = _props.options; | ||
var _this$props = this.props, | ||
defaultField = _this$props.defaultField, | ||
options = _this$props.options; | ||
var field = options.find(function (option) { | ||
return option.field === defaultField; | ||
}); | ||
if (defaultField) { | ||
this.onChange(defaultField); | ||
} | ||
if (field) { | ||
@@ -114,32 +167,36 @@ this.setState({ | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props2 = this.props, | ||
options = _props2.options, | ||
defaultField = _props2.defaultField; | ||
var _state = this.state, | ||
key = _state.key, | ||
order = _state.order; | ||
return _react2.default.createElement( | ||
'div', | ||
{ style: { display: 'flex' } }, | ||
_react2.default.createElement( | ||
Selector, | ||
{ onChange: this.onChange, value: key, defaultValue: defaultField, allowClear: true, placeholder: _react2.default.createElement(_reactIntl.FormattedMessage, { id: 'query.sort.placeholder' }) }, | ||
(options || []).map(function (option, i) { | ||
return _react2.default.createElement( | ||
Option, | ||
{ key: i, value: option.field }, | ||
option.label | ||
); | ||
}) | ||
), | ||
_react2.default.createElement( | ||
OrderSwitch, | ||
{ onClick: this.changeOrder }, | ||
_react2.default.createElement(UpIcon, { order: order, type: 'caret-up' }), | ||
_react2.default.createElement(DownIcon, { order: order, type: 'caret-down' }) | ||
) | ||
); | ||
var _this$props2 = this.props, | ||
options = _this$props2.options, | ||
defaultField = _this$props2.defaultField; | ||
var _this$state2 = this.state, | ||
key = _this$state2.key, | ||
order = _this$state2.order; | ||
return _react.default.createElement("div", { | ||
style: { | ||
display: 'flex' | ||
} | ||
}, _react.default.createElement(Selector, { | ||
onChange: this.onChange, | ||
value: key, | ||
defaultValue: defaultField, | ||
allowClear: true, | ||
placeholder: _react.default.createElement(_reactIntl.FormattedMessage, { | ||
id: "query.sort.placeholder" | ||
}) | ||
}, (options || []).map(function (option, i) { | ||
return _react.default.createElement(Option, { | ||
key: i, | ||
value: option.field | ||
}, option.label); | ||
})), _react.default.createElement(OrderSwitch, { | ||
onClick: this.changeOrder | ||
}, _react.default.createElement(UpIcon, { | ||
order: order, | ||
type: "caret-up" | ||
}), _react.default.createElement(DownIcon, { | ||
order: order, | ||
type: "caret-down" | ||
}))); | ||
} | ||
@@ -153,5 +210,4 @@ }]); | ||
function order(sortField) { | ||
return sortField === 'ASC'; | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,19 +6,29 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = undefined; | ||
exports.default = void 0; | ||
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 = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var React = _interopRequireWildcard(_react); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
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 _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 _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); } } | ||
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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var ToolbarLayout = function (_React$PureComponent) { | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } 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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var ToolbarLayout = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inherits(ToolbarLayout, _React$PureComponent); | ||
@@ -29,44 +39,29 @@ | ||
return _possibleConstructorReturn(this, (ToolbarLayout.__proto__ || Object.getPrototypeOf(ToolbarLayout)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ToolbarLayout).apply(this, arguments)); | ||
} | ||
_createClass(ToolbarLayout, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
Filter = _props.Filter, | ||
Sort = _props.Sort, | ||
Actions = _props.Actions, | ||
children = _props.children, | ||
Pagination = _props.Pagination; | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
React.createElement( | ||
'div', | ||
{ style: { | ||
flexWrap: 'wrap' | ||
} }, | ||
React.createElement( | ||
'div', | ||
{ style: { | ||
display: 'flex', | ||
justifyContent: 'space-between' | ||
} }, | ||
Actions, | ||
Sort | ||
), | ||
React.createElement( | ||
'div', | ||
{ style: { | ||
display: 'flex', | ||
flexWrap: 'wrap' | ||
} }, | ||
Filter | ||
) | ||
), | ||
React.Children.only(children), | ||
Pagination | ||
); | ||
var _this$props = this.props, | ||
Filter = _this$props.Filter, | ||
Sort = _this$props.Sort, | ||
Actions = _this$props.Actions, | ||
children = _this$props.children, | ||
Pagination = _this$props.Pagination; | ||
return React.createElement(React.Fragment, null, React.createElement("div", { | ||
style: { | ||
flexWrap: 'wrap' | ||
} | ||
}, React.createElement("div", { | ||
style: { | ||
display: 'flex', | ||
justifyContent: 'space-between' | ||
} | ||
}, Actions, Sort), React.createElement("div", { | ||
style: { | ||
display: 'flex', | ||
flexWrap: 'wrap' | ||
} | ||
}, Filter)), React.Children.only(children), Pagination); | ||
} | ||
@@ -73,0 +68,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,5 +6,2 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
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; }; | ||
exports.paginate = paginate; | ||
@@ -16,11 +13,10 @@ exports.filterWith = filterWith; | ||
var _orderBy = require('lodash/orderBy'); | ||
var _orderBy = _interopRequireDefault(require("lodash/orderBy")); | ||
var _orderBy2 = _interopRequireDefault(_orderBy); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function paginate(value, currentPage) { | ||
var pageSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; | ||
var index = (currentPage - 1) * pageSize; | ||
@@ -42,4 +38,3 @@ return value.slice(index, index + pageSize); | ||
var sortType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'ASC'; | ||
return (0, _orderBy2.default)(value, sortField, sortType); | ||
return (0, _orderBy.default)(value, sortField, sortType); | ||
} | ||
@@ -51,2 +46,3 @@ | ||
var conditionValue = condition[conditionKey]; | ||
switch (conditionKey) { | ||
@@ -63,19 +59,26 @@ case 'contains': | ||
} | ||
break; | ||
} | ||
case 'eq': | ||
isPass = data === conditionValue; | ||
break; | ||
case 'gt': | ||
isPass = data > conditionValue; | ||
break; | ||
case 'gte': | ||
isPass = data >= conditionValue; | ||
break; | ||
case 'lt': | ||
isPass = data < conditionValue; | ||
break; | ||
case 'lte': | ||
isPass = data <= conditionValue; | ||
break; | ||
default: | ||
@@ -85,2 +88,3 @@ isPass = passCondition(data[conditionKey], conditionValue); | ||
} | ||
return result && isPass; | ||
@@ -87,0 +91,0 @@ }, true); |
{ | ||
"name": "@canner/antd-share-toolbar", | ||
"version": "0.4.2-alpha.19", | ||
"version": "0.4.2-alpha.21", | ||
"description": "string input", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@canner/antd-locales": "^0.4.2-alpha.19" | ||
"@canner/antd-locales": "^0.4.2-alpha.21" | ||
}, | ||
@@ -27,3 +27,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "e3d67c9e4c24124db4d3bba9d2ba12345deb8b99" | ||
"gitHead": "281b1eafa89d76630d213dc3b845676e270a9bea" | ||
} |
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
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
133338
2016