@capillarytech/creatives-library 8.0.168-beta.0 → 8.0.168

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": "8.0.168-beta.0",
4
+ "version": "8.0.168",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -20,7 +20,7 @@ import globalMessages from '../../v2Containers/Cap/messages';
20
20
  import whatsappMsg from '../../v2Containers/Whatsapp/messages';
21
21
  import messages from './messages';
22
22
  import './index.scss';
23
- import { isUrl, isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
23
+ import { isUrl, isValidWhatsappCtaText } from '../../v2Containers/Line/Container/Wrapper/utils';
24
24
  import TagList from '../../v2Containers/TagList';
25
25
  import {
26
26
  CTA_OPTIONS,
@@ -144,7 +144,7 @@ export const CapWhatsappCTA = (props) => {
144
144
  const onButtonTextChange = ({ target }) => {
145
145
  const { value, id } = target;
146
146
  let errorMessage = '';
147
- if (!isValidText(value)) {
147
+ if (!isValidWhatsappCtaText(value)) {
148
148
  errorMessage = formatMessage(messages.ctaButtonErrorMessage);
149
149
  }
150
150
  setButtonError(errorMessage);
@@ -34,7 +34,7 @@ import {
34
34
  KARIX_GUPSHUP_URL_OPTIONS, TWILIO_URL_OPTIONS, DYNAMIC_URL, STATIC_URL,
35
35
  } from "../CapWhatsappCTA/constants";
36
36
  import globalMessages from '../../v2Containers/Cap/messages';
37
- import { isUrl, isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
37
+ import { isUrl, isValidWhatsappCtaText } from '../../v2Containers/Line/Container/Wrapper/utils';
38
38
  import { HOST_TWILIO } from "../../v2Containers/Whatsapp/constants";
39
39
  import "./index.scss";
40
40
 
@@ -119,7 +119,7 @@ export const CapWhatsappCarouselButton = (props) => {
119
119
 
120
120
  const onButtonTextChange = (value, buttonIndex) => {
121
121
  let errorMessage = '';
122
- if (!isValidText(value)) {
122
+ if (!isValidWhatsappCtaText(value)) {
123
123
  errorMessage = formatMessage(capWhatsappCTAMsg.ctaButtonErrorMessage);
124
124
  }
125
125
  onValueChange(buttonIndex, [{fieldName: 'text', value}, {fieldName: 'textError', value: errorMessage}]);
@@ -1715,6 +1715,6 @@ const withConnect = connect(mapStatesToProps, mapDispatchToProps);
1715
1715
  const withReducer = injectReducer({ key: 'creativesContainer', reducer: creativesContainerReducer });
1716
1716
  const withSaga = injectSaga({ key: 'cap', saga: capSagaForFetchSchemaForEntity });
1717
1717
  const withLiquidSaga = injectSaga({ key: 'liquid', saga: capSagaLiquidEntity, mode: DAEMON });
1718
- const withDefaultTempSaga = injectSaga({ key: 'creativesContainer', saga: v2TemplateSagaWatchGetDefaultBeeTemplates, mode: DAEMON});
1718
+ const withDefaultTempSaga = injectSaga({ key: 'creativesContainer', saga: v2TemplateSagaWatchGetDefaultBeeTemplates });
1719
1719
 
1720
1720
  export default compose(withSaga, withLiquidSaga, withDefaultTempSaga, withReducer, withConnect)(injectIntl(Creatives));
@@ -78,3 +78,10 @@ export const isValidText = (text) => {
78
78
  return regex.test(text);
79
79
  };
80
80
 
81
+ // WhatsApp CTA button text validation- Allow multilingual characters and typical symbols
82
+ export const isValidWhatsappCtaText = (text) => {
83
+ if (typeof text !== 'string') return false;
84
+ // - Disallow control chars (newlines, tabs, etc.) | markup chars: *, _, ~, ` | emojis (U+1F300–U+1FAFF)
85
+ const invalid = /[\n\r\t\b\f\v*_~`]|[\u{1F300}-\u{1FAFF}]/u;
86
+ return !invalid.test(text);
87
+ };