ywana-core8 0.0.137 → 0.0.138

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/dist/index.umd.js CHANGED
@@ -921,7 +921,9 @@
921
921
  _props$options = props.options,
922
922
  options = _props$options === void 0 ? [] : _props$options,
923
923
  value = props.value,
924
- onChange = props.onChange;
924
+ onChange = props.onChange,
925
+ _props$canFilter = props.canFilter,
926
+ canFilter = _props$canFilter === void 0 ? false : _props$canFilter;
925
927
 
926
928
  var _useState = React.useState(false),
927
929
  open = _useState[0],
@@ -931,6 +933,9 @@
931
933
  label = _useState2[0],
932
934
  setLabel = _useState2[1];
933
935
 
936
+ var _useState3 = React.useState(),
937
+ filter = _useState3[0];
938
+
934
939
  React.useEffect(function () {
935
940
  if (Array.isArray(options)) {
936
941
  var option = options.find(function (option) {
@@ -940,6 +945,14 @@
940
945
  }
941
946
  }, [value]);
942
947
 
948
+ function change(id, value) {
949
+ if (canFilter) {
950
+ setFilter(value);
951
+ } else {
952
+ if (onChange) onChange(id, value);
953
+ }
954
+ }
955
+
943
956
  function toggle() {
944
957
  if (site) {
945
958
  site.changeFocus({
@@ -962,11 +975,20 @@
962
975
  setOpen(false);
963
976
  }
964
977
 
978
+ var items = open == true && Array.isArray(options) ? options.filter(function (option) {
979
+ return canFilter === false || filter.toUpperCase().indexOf(option.label.toUpperCase()) >= 0;
980
+ }).map(function (option) {
981
+ return /*#__PURE__*/React__default["default"].createElement("li", {
982
+ key: option.value,
983
+ value: option.value
984
+ }, option.label);
985
+ }) : null;
965
986
  return /*#__PURE__*/React__default["default"].createElement("div", {
966
987
  className: "dropdown"
967
988
  }, /*#__PURE__*/React__default["default"].createElement(TextField, _extends({}, props, {
968
989
  onClick: toggle,
969
- value: label
990
+ value: label,
991
+ onChange: change
970
992
  })), /*#__PURE__*/React__default["default"].createElement(Icon, {
971
993
  icon: "expand_more",
972
994
  clickable: true,
@@ -974,12 +996,7 @@
974
996
  action: toggle
975
997
  }), open == true ? /*#__PURE__*/React__default["default"].createElement("menu", null, /*#__PURE__*/React__default["default"].createElement("ul", {
976
998
  onClick: select
977
- }, Array.isArray(options) ? options.map(function (option) {
978
- return /*#__PURE__*/React__default["default"].createElement("li", {
979
- key: option.value,
980
- value: option.value
981
- }, option.label);
982
- }) : null)) : null);
999
+ }, items)) : null);
983
1000
  };
984
1001
 
985
1002
  var isFunction$1 = function isFunction(value) {