@capillarytech/creatives-library 7.17.218 → 7.17.219-alpha.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.218",
4
+ "version": "7.17.219-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -106,13 +106,16 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
106
106
  getSearchedExpandedKeys(tags, value = '') {
107
107
  let list = [];
108
108
  _.forEach(tags, (val = {}, key) => {
109
+ const tagName = typeof(val?.name) === "string" ? _.toLower(_.get(val, 'name', '')) : _.toLower(_.get(val, 'name.props.defaultMessage', ''));
110
+ const tagNameWithoutUnderscore = tagName.replace(/_/g, ' ');
111
+ const searchStringLower = _.toLower(value);
109
112
  if (_.has(val, 'subtags')) {
110
- if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
113
+ if (val.name && (tagName.includes(searchStringLower) || tagNameWithoutUnderscore.includes(searchStringLower))) {
111
114
  list.push(key);
112
115
  }
113
116
  const temp = this.getSearchedExpandedKeys(val.subtags, value);
114
117
  list = list.concat(temp);
115
- } else if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
118
+ } else if (val.name && (tagName.includes(searchStringLower) || tagNameWithoutUnderscore.includes(searchStringLower))) {
116
119
  list.push(key);
117
120
  }
118
121
  });
@@ -185,7 +188,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
185
188
  this.setState({showModal: true, visible: false});
186
189
  };
187
190
 
188
- renderTags(tags, searchString = '') {
191
+ renderTags(tags) {
192
+ const searchString = this.state.searchValue || '';
189
193
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
190
194
  const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
191
195
  const hideDateTagsForJpLocale = accessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE);
@@ -210,40 +214,58 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
210
214
  supportedTagsString += `${supportedTag} ,`;
211
215
  });
212
216
  supportedTagsString = supportedTagsString.replace(/,\s*$/, "");
213
- const tagDescriptionOrName = _.toLower(String(_.get(val, 'desc', '') || _.get(val, 'name', '')));
217
+ const tagName = typeof(val?.name) === "string" ? _.toLower(_.get(val, 'name', '')) : _.toLower(_.get(val, 'name.props.defaultMessage', ''));
218
+ const tagNameWithoutUnderscore = tagName.replace(/_/g, ' ');
214
219
  const searchStringLower = _.toLower(searchString);
215
- const tagContainsSearchedString = tagDescriptionOrName.includes(searchStringLower);
220
+ const tagContainsSearchedString = searchStringLower && (tagName.includes(searchStringLower) || tagNameWithoutUnderscore.includes(searchStringLower));
216
221
  if (_.has(val, 'subtags')) {
217
222
  const disabled = disableRelatedTags ? parentTagstoDisable.includes(key) : false;
218
- const temp = this.renderTags(val.subtags, '', disabled);
219
- const tagValue = (
220
- <CapTreeNode
221
- title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val?.name}</CapTooltip> : val?.name}
222
- tag={val}
223
- key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
224
- disabled={disabled}
225
- >
226
- {temp}
227
- </CapTreeNode>
228
- );
229
- hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
230
- } else if (searchString === '' || !searchString || tagContainsSearchedString) {
223
+ const temp = this.renderTags(val?.subtags);
224
+ if (temp?.length) {
225
+ const tagValue = (
226
+ <CapTreeNode
227
+ title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val?.name}</CapTooltip> : val?.name}
228
+ tag={val}
229
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
230
+ disabled={disabled}
231
+ >
232
+ {temp}
233
+ </CapTreeNode>
234
+ );
235
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
236
+ }
237
+ } else {
231
238
  let childDisabled = true;
232
239
  if (key === CUSTOMER_BARCODE_TAG && !hasCustomerBarcodeFeatureEnabled()) {
233
240
  childDisabled = true;
234
241
  } else {
235
242
  childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
236
243
  }
237
- const tempNode = (
238
- <CapTreeNode
239
- title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val.desc || val.name}</CapTooltip> : (val.desc || val.name)}
240
- tag={val}
241
- isLeaf
242
- key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
243
- disabled={childDisabled}
244
- >
245
- </CapTreeNode>);
246
- hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
244
+ if (searchString) {
245
+ if (tagContainsSearchedString) {
246
+ const tempNode = (
247
+ <CapTreeNode
248
+ title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val?.desc || val?.name}</CapTooltip> : (val?.desc || val?.name)}
249
+ tag={val}
250
+ isLeaf
251
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
252
+ disabled={childDisabled}
253
+ >
254
+ </CapTreeNode>);
255
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
256
+ }
257
+ } else {
258
+ const tempNode = (
259
+ <CapTreeNode
260
+ title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val?.desc || val?.name}</CapTooltip> : (val?.desc || val?.name)}
261
+ tag={val}
262
+ isLeaf
263
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
264
+ disabled={childDisabled}
265
+ >
266
+ </CapTreeNode>);
267
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
268
+ }
247
269
  }
248
270
  });
249
271
  return list;