ywana-core8 0.0.536 → 0.0.537

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.
@@ -4916,6 +4916,7 @@ var CollectionPage = function CollectionPage(props) {
4916
4916
  canFilter = _props$canFilter === void 0 ? false : _props$canFilter,
4917
4917
  _props$canAdd = props.canAdd,
4918
4918
  canAdd = _props$canAdd === void 0 ? false : _props$canAdd,
4919
+ searchBy = props.searchBy,
4919
4920
  _props$autosave = props.autosave,
4920
4921
  autosave = _props$autosave === void 0 ? false : _props$autosave,
4921
4922
  _props$delay = props.delay,
@@ -4993,10 +4994,12 @@ var CollectionPage = function CollectionPage(props) {
4993
4994
  icon: icon,
4994
4995
  levels: levels,
4995
4996
  onSelect: onSelect,
4996
- sorter: sorter
4997
+ sorter: sorter,
4998
+ searchBy: searchBy
4997
4999
  }) : /*#__PURE__*/React.createElement(CollectionList, {
4998
5000
  groupBy: groupBy,
4999
- onSelect: onSelect
5001
+ onSelect: onSelect,
5002
+ searchBy: searchBy
5000
5003
  })), /*#__PURE__*/React.createElement("main", {
5001
5004
  key: id,
5002
5005
  className: "collection-page " + className
@@ -5086,7 +5089,9 @@ var CollectionList = function CollectionList(props) {
5086
5089
  };
5087
5090
 
5088
5091
  var groupBy = props.groupBy,
5089
- onSelect = props.onSelect;
5092
+ onSelect = props.onSelect,
5093
+ _props$searchBy = props.searchBy,
5094
+ searchBy = _props$searchBy === void 0 ? [] : _props$searchBy;
5090
5095
 
5091
5096
  var _useContext2 = useContext(PageContext),
5092
5097
  pageContext = _useContext2[0],
@@ -5104,13 +5109,22 @@ var CollectionList = function CollectionList(props) {
5104
5109
  setPageContext(Object.assign({}, pageContext));
5105
5110
  }
5106
5111
 
5107
- function search(id, value) {
5112
+ function changeSearch(id, value) {
5108
5113
  setFilter(value);
5109
5114
  }
5110
5115
 
5111
- var items = filter ? all.filter(function (item) {
5112
- return item.name.toUpperCase().indexOf(filter.toUpperCase()) >= 0;
5113
- }) : all;
5116
+ function search() {
5117
+ var items = filter ? all.filter(function (item) {
5118
+ var result = searchBy.some(function (fieldName) {
5119
+ var value = item[fieldName];
5120
+ return value ? value.indexOf(filter.toUpperCase()) >= 0 : false;
5121
+ });
5122
+ return result;
5123
+ }) : all;
5124
+ return items;
5125
+ }
5126
+
5127
+ var items = search();
5114
5128
  var items2 = items.map(function (content) {
5115
5129
  return {
5116
5130
  id: content.id,
@@ -5129,7 +5143,7 @@ var CollectionList = function CollectionList(props) {
5129
5143
  }, /*#__PURE__*/React.createElement(TextField, {
5130
5144
  icon: "search",
5131
5145
  label: "Search",
5132
- onChange: search,
5146
+ onChange: changeSearch,
5133
5147
  outlined: true,
5134
5148
  className: "search-box"
5135
5149
  }))));
@@ -5156,7 +5170,9 @@ var CollectionTree = function CollectionTree(props) {
5156
5170
  icon = _props$icon === void 0 ? "description" : _props$icon,
5157
5171
  levels = props.levels,
5158
5172
  onSelect = props.onSelect,
5159
- sorter = props.sorter;
5173
+ sorter = props.sorter,
5174
+ _props$searchBy2 = props.searchBy,
5175
+ searchBy = _props$searchBy2 === void 0 ? [] : _props$searchBy2;
5160
5176
 
5161
5177
  var _useContext3 = useContext(PageContext),
5162
5178
  pageContext = _useContext3[0],
@@ -5174,7 +5190,7 @@ var CollectionTree = function CollectionTree(props) {
5174
5190
  setPageContext(Object.assign({}, pageContext));
5175
5191
  }
5176
5192
 
5177
- function search(id, value) {
5193
+ function changeSearch(id, value) {
5178
5194
  setFilter(value);
5179
5195
  }
5180
5196
 
@@ -5228,17 +5244,26 @@ var CollectionTree = function CollectionTree(props) {
5228
5244
  });
5229
5245
  }
5230
5246
 
5231
- var items = sorter ? sorter(all) : all;
5232
- var items2 = filter ? items.filter(function (item) {
5233
- return item.name.toUpperCase().indexOf(filter.toUpperCase()) >= 0;
5234
- }) : items;
5247
+ function search() {
5248
+ var items = filter ? all.filter(function (item) {
5249
+ var result = searchBy.some(function (fieldName) {
5250
+ var value = item[fieldName];
5251
+ return value ? value.indexOf(filter.toUpperCase()) >= 0 : false;
5252
+ });
5253
+ return result;
5254
+ }) : all;
5255
+ return items;
5256
+ }
5257
+
5258
+ var items = search();
5259
+ var items2 = sorter ? sorter(items) : items;
5235
5260
  var nodes = generateNodes(levels, items2);
5236
5261
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(Tree, null, renderNodes(nodes))), /*#__PURE__*/React.createElement("footer", null, /*#__PURE__*/React.createElement("div", {
5237
5262
  className: "search-box"
5238
5263
  }, /*#__PURE__*/React.createElement(TextField, {
5239
5264
  icon: "search",
5240
5265
  label: "Search",
5241
- onChange: search,
5266
+ onChange: changeSearch,
5242
5267
  outlined: true,
5243
5268
  className: "search-box"
5244
5269
  }))));