@daoyi/nmtl-ui 2.0.1-beta.65 → 2.0.1-beta.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Filter.js +13 -7
- package/package.json +1 -1
package/lib/components/Filter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as _taggedTemplateLiteral, e as _defineProperty } from './_rollupPluginBabelHelpers-ed61ffc0.js';
|
|
2
|
-
import React__default, { useContext, createElement } from 'react';
|
|
2
|
+
import React__default, { useContext, createElement, useCallback } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { c as classNames } from './index-f491ebce.js';
|
|
5
5
|
import { q as queryString } from './index-7b60a97d.js';
|
|
@@ -727,11 +727,17 @@ var Filter = function Filter(_ref) {
|
|
|
727
727
|
textHoverColor = _ref.textHoverColor,
|
|
728
728
|
filter = _ref.filter,
|
|
729
729
|
disabled = _ref.disabled,
|
|
730
|
-
filterKey = _ref.filterKey
|
|
730
|
+
filterKey = _ref.filterKey,
|
|
731
|
+
onClick = _ref.onClick;
|
|
731
732
|
var history = useHistory();
|
|
732
733
|
var search = history.location.search;
|
|
733
734
|
var urlSearch = queryString.parse(search);
|
|
734
735
|
var FilterItem = He.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t\tcolor: ", ";\n\t\t.filter__item--active {\n\t\t\tcolor: ", ";\n\t\t}\n\t\t:hover {\n\t\t\tcolor: ", ";\n\t\t}\n\t\t::after {\n\t\t\tcolor: ", ";\n\t\t}\n\t"])), textColor, textHoverColor || textColor, textHoverColor || textColor, textColor);
|
|
736
|
+
var handleClick = useCallback(function (key) {
|
|
737
|
+
if (onClick && typeof onClick === 'function') onClick(key);else historyAppendSearch(_defineProperty({
|
|
738
|
+
history: history
|
|
739
|
+
}, filterKey, key));
|
|
740
|
+
}, [history, onClick]);
|
|
735
741
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
736
742
|
className: classNames('filter', className)
|
|
737
743
|
}, Array.isArray(filter) && filter.filter(function (_ref2) {
|
|
@@ -749,9 +755,7 @@ var Filter = function Filter(_ref) {
|
|
|
749
755
|
'filter__item--active': key === urlSearch[filterKey]
|
|
750
756
|
}),
|
|
751
757
|
onClick: function onClick() {
|
|
752
|
-
return
|
|
753
|
-
history: history
|
|
754
|
-
}, filterKey, key));
|
|
758
|
+
return handleClick(key);
|
|
755
759
|
}
|
|
756
760
|
}, "".concat(title, "(").concat(count, ")"));
|
|
757
761
|
}));
|
|
@@ -762,7 +766,8 @@ Filter.defaultProps = {
|
|
|
762
766
|
textHoverColor: undefined,
|
|
763
767
|
filter: undefined,
|
|
764
768
|
disabled: false,
|
|
765
|
-
filterKey: 'filterType'
|
|
769
|
+
filterKey: 'filterType',
|
|
770
|
+
onClick: undefined
|
|
766
771
|
};
|
|
767
772
|
Filter.propTypes = {
|
|
768
773
|
className: PropTypes.string,
|
|
@@ -770,7 +775,8 @@ Filter.propTypes = {
|
|
|
770
775
|
textHoverColor: PropTypes.string,
|
|
771
776
|
filter: PropTypes.arrayOf(PropTypes.any),
|
|
772
777
|
disabled: PropTypes.bool,
|
|
773
|
-
filterKey: PropTypes.string
|
|
778
|
+
filterKey: PropTypes.string,
|
|
779
|
+
onClick: PropTypes.func
|
|
774
780
|
};
|
|
775
781
|
|
|
776
782
|
export { Filter as default };
|
package/package.json
CHANGED