@capillarytech/creatives-library 7.17.218 → 7.17.219

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.
@@ -28,3 +28,5 @@ export const JAPANESE_HIDE_DATE_TAGS = [
28
28
  "dd Mon",
29
29
  "dd/m/yyyy",
30
30
  ];
31
+
32
+ export const STRING = "string";
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",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -37,6 +37,7 @@ import {
37
37
  GET_TRANSLATION_MAPPED,
38
38
  JAPANESE_HELP_TEXT,
39
39
  TAG_TRANSLATION_DOC,
40
+ STRING,
40
41
  } from "../../containers/TagList/constants";
41
42
  import { EMAIL, JP_LOCALE_HIDE_FEATURE } from '../../v2Containers/App/constants';
42
43
  import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
@@ -106,13 +107,27 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
106
107
  getSearchedExpandedKeys(tags, value = '') {
107
108
  let list = [];
108
109
  _.forEach(tags, (val = {}, key) => {
109
- if (_.has(val, 'subtags')) {
110
- if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
110
+ const tagName =
111
+ typeof val?.name === STRING
112
+ ? _.toLower(_.get(val, "name", ""))
113
+ : _.toLower(_.get(val, "name.props.defaultMessage", ""));
114
+ const tagNameWithoutUnderscore = tagName.replace(/_/g, " ");
115
+ const searchStringLower = _.toLower(value);
116
+ if (_.has(val, "subtags")) {
117
+ if (
118
+ val?.name &&
119
+ (tagName.includes(searchStringLower) ||
120
+ tagNameWithoutUnderscore.includes(searchStringLower))
121
+ ) {
111
122
  list.push(key);
112
123
  }
113
- const temp = this.getSearchedExpandedKeys(val.subtags, value);
124
+ const temp = this.getSearchedExpandedKeys(val?.subtags, value);
114
125
  list = list.concat(temp);
115
- } else if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
126
+ } else if (
127
+ val?.name &&
128
+ (tagName.includes(searchStringLower) ||
129
+ tagNameWithoutUnderscore.includes(searchStringLower))
130
+ ) {
116
131
  list.push(key);
117
132
  }
118
133
  });
@@ -185,7 +200,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
185
200
  this.setState({showModal: true, visible: false});
186
201
  };
187
202
 
188
- renderTags(tags, searchString = '') {
203
+ renderTags(tags) {
204
+ const searchString = this.state.searchValue || '';
189
205
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
190
206
  const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
191
207
  const hideDateTagsForJpLocale = accessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE);
@@ -210,40 +226,110 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
210
226
  supportedTagsString += `${supportedTag} ,`;
211
227
  });
212
228
  supportedTagsString = supportedTagsString.replace(/,\s*$/, "");
213
- const tagDescriptionOrName = _.toLower(String(_.get(val, 'desc', '') || _.get(val, 'name', '')));
229
+ const tagName =
230
+ typeof val?.name === STRING
231
+ ? _.toLower(_.get(val, "name", ""))
232
+ : _.toLower(_.get(val, "name.props.defaultMessage", ""));
233
+ const tagNameWithoutUnderscore = tagName.replace(/_/g, " ");
214
234
  const searchStringLower = _.toLower(searchString);
215
- const tagContainsSearchedString = tagDescriptionOrName.includes(searchStringLower);
235
+ const tagContainsSearchedString =
236
+ searchStringLower &&
237
+ (tagName.includes(searchStringLower) ||
238
+ tagNameWithoutUnderscore.includes(searchStringLower));
216
239
  if (_.has(val, 'subtags')) {
217
240
  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) {
241
+ const temp = this.renderTags(val?.subtags);
242
+ if (temp?.length) {
243
+ const tagValue = (
244
+ <CapTreeNode
245
+ title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val?.name}</CapTooltip> : val?.name}
246
+ tag={val}
247
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
248
+ disabled={disabled}
249
+ >
250
+ {temp}
251
+ </CapTreeNode>
252
+ );
253
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
254
+ }
255
+ } else {
231
256
  let childDisabled = true;
232
257
  if (key === CUSTOMER_BARCODE_TAG && !hasCustomerBarcodeFeatureEnabled()) {
233
258
  childDisabled = true;
234
259
  } else {
235
260
  childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
236
261
  }
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);
262
+ if (searchString) {
263
+ if (tagContainsSearchedString) {
264
+ const tempNode = (
265
+ <CapTreeNode
266
+ title={
267
+ childDisabled ? (
268
+ <CapTooltip
269
+ title={
270
+ key === CUSTOMER_BARCODE_TAG
271
+ ? customerBarcodeDisableText
272
+ : loyaltyAttrDisableText
273
+ }
274
+ >
275
+ {val?.desc || val?.name}
276
+ </CapTooltip>
277
+ ) : (
278
+ val?.desc || val?.name
279
+ )
280
+ }
281
+ tag={val}
282
+ isLeaf
283
+ key={
284
+ val?.incentiveSeriesId
285
+ ? `${key}(${val?.incentiveSeriesId})`
286
+ : `${key}`
287
+ }
288
+ disabled={childDisabled}
289
+ ></CapTreeNode>
290
+ );
291
+ hidingDateTagsForJpLocale(
292
+ hideDateTagsForJpLocale,
293
+ val,
294
+ list,
295
+ tempNode
296
+ );
297
+ }
298
+ } else {
299
+ const tempNode = (
300
+ <CapTreeNode
301
+ title={
302
+ childDisabled ? (
303
+ <CapTooltip
304
+ title={
305
+ key === CUSTOMER_BARCODE_TAG
306
+ ? customerBarcodeDisableText
307
+ : loyaltyAttrDisableText
308
+ }
309
+ >
310
+ {val?.desc || val?.name}
311
+ </CapTooltip>
312
+ ) : (
313
+ val?.desc || val?.name
314
+ )
315
+ }
316
+ tag={val}
317
+ isLeaf
318
+ key={
319
+ val?.incentiveSeriesId
320
+ ? `${key}(${val?.incentiveSeriesId})`
321
+ : `${key}`
322
+ }
323
+ disabled={childDisabled}
324
+ ></CapTreeNode>
325
+ );
326
+ hidingDateTagsForJpLocale(
327
+ hideDateTagsForJpLocale,
328
+ val,
329
+ list,
330
+ tempNode
331
+ );
332
+ }
247
333
  }
248
334
  });
249
335
  return list;