@daoyi/nmtl-ui 2.0.1-beta.65 → 2.0.1-beta.66

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.
@@ -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) {
@@ -748,11 +754,7 @@ var Filter = function Filter(_ref) {
748
754
  }, {
749
755
  'filter__item--active': key === urlSearch[filterKey]
750
756
  }),
751
- onClick: function onClick() {
752
- return historyAppendSearch(_defineProperty({
753
- history: history
754
- }, filterKey, key));
755
- }
757
+ onClick: handleClick
756
758
  }, "".concat(title, "(").concat(count, ")"));
757
759
  }));
758
760
  };
@@ -762,7 +764,8 @@ Filter.defaultProps = {
762
764
  textHoverColor: undefined,
763
765
  filter: undefined,
764
766
  disabled: false,
765
- filterKey: 'filterType'
767
+ filterKey: 'filterType',
768
+ onClick: undefined
766
769
  };
767
770
  Filter.propTypes = {
768
771
  className: PropTypes.string,
@@ -770,7 +773,8 @@ Filter.propTypes = {
770
773
  textHoverColor: PropTypes.string,
771
774
  filter: PropTypes.arrayOf(PropTypes.any),
772
775
  disabled: PropTypes.bool,
773
- filterKey: PropTypes.string
776
+ filterKey: PropTypes.string,
777
+ onClick: PropTypes.func
774
778
  };
775
779
 
776
780
  export { Filter as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daoyi/nmtl-ui",
3
- "version": "2.0.1-beta.65",
3
+ "version": "2.0.1-beta.66",
4
4
  "description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
5
5
  "author": "daoyi",
6
6
  "main": "lib/index.js",