@capillarytech/creatives-library 8.0.316-alpha.1 → 8.0.316-alpha.3

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.316-alpha.1",
4
+ "version": "8.0.316-alpha.3",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -52,7 +52,7 @@ import './_formBuilder.scss';
52
52
  import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
53
53
  import { preprocessHtml, validateTagsCore, hasUnsubscribeTag } from '../../utils/tagValidations';
54
54
  import { containsBase64Images } from '../../utils/content';
55
- import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS,AI_CONTENT_BOT_DISABLED, EMAIL, LIQUID_SUPPORTED_CHANNELS, INAPP } from '../../v2Containers/CreativesContainer/constants';
55
+ import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS, EMAIL, LIQUID_SUPPORTED_CHANNELS, INAPP } from '../../v2Containers/CreativesContainer/constants';
56
56
  import globalMessages from '../../v2Containers/Cap/messages';
57
57
  import { convert } from 'html-to-text';
58
58
  import { OUTBOUND, ADD_LANGUAGE, UPLOAD, USE_EDITOR, COPY_PRIMARY_LANGUAGE, GLOBAL_CONVERT_OPTIONS } from './constants';
@@ -60,7 +60,7 @@ import { GET_TRANSLATION_MAPPED } from '../../constants/unified';
60
60
  import moment from 'moment';
61
61
  import { CUSTOMER_BARCODE_TAG , COPY_OF, ENTRY_TRIGGER_TAG_REGEX, SKIP_TAGS_REGEX_GROUPS} from '../../constants/unified';
62
62
  import { REQUEST } from '../../v2Containers/Cap/constants'
63
- import { isEmailUnsubscribeTagOptional } from '../../utils/common';
63
+ import { isEmailUnsubscribeTagOptional, isAiContentBotDisabled } from '../../utils/common';
64
64
  import { isUrl } from '../../v2Containers/Line/Container/Wrapper/utils';
65
65
  import { bindActionCreators } from 'redux';
66
66
  import { getChannelData, hasPersonalizationTags, validateLiquidTemplateContent, validateMobilePushContent } from '../../utils/commonUtils';
@@ -2790,10 +2790,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2790
2790
  const { MISSING_TAG_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
2791
2791
  const { formatMessage } = this.props.intl;
2792
2792
 
2793
- const { accessibleFeatures = [] } = this.props.currentOrgDetails || {};
2794
- const isAiContentBotDisabled = accessibleFeatures?.includes(
2795
- AI_CONTENT_BOT_DISABLED
2796
- );
2793
+ const aiContentBotDisabled = isAiContentBotDisabled();
2797
2794
 
2798
2795
  let errorMessageText = false;
2799
2796
  switch (errorType) {
@@ -2861,7 +2858,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2861
2858
  cols={cols}
2862
2859
  />
2863
2860
  {[SMS, MOBILE_PUSH].includes(this.props.schema?.channel)
2864
- && !isAiContentBotDisabled
2861
+ && !aiContentBotDisabled
2865
2862
  && (
2866
2863
  <CapAskAira.ContentGenerationBot
2867
2864
  text={messageContent || ""}
@@ -3397,10 +3394,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3397
3394
  switch (type) {
3398
3395
  case "input":
3399
3396
  const errorType = isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id];
3400
- const { accessibleFeatures = [] } = this.props.currentOrgDetails || {};
3401
- const isAiContentBotDisabled = accessibleFeatures?.includes(
3402
- AI_CONTENT_BOT_DISABLED
3403
- );
3397
+ const aiContentBotDisabled = isAiContentBotDisabled();
3404
3398
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
3405
3399
  const { TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
3406
3400
  const { formatMessage } = this.props.intl;
@@ -3433,7 +3427,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3433
3427
  size={val.size || "default"}
3434
3428
  />
3435
3429
  {this.props.schema?.channel === EMAIL &&
3436
- !isAiContentBotDisabled && (
3430
+ !aiContentBotDisabled && (
3437
3431
  <CapAskAira.ContentGenerationBot
3438
3432
  text={value || ""}
3439
3433
  setText={this.handleSetText.bind(this, val)}
@@ -53,7 +53,6 @@ import {
53
53
  IOS_CAPITAL,
54
54
  } from "./constants";
55
55
  import { GENERIC, INAPP, SMS } from "../CreativesContainer/constants";
56
- import { AI_CONTENT_BOT_DISABLED } from "../../constants/unified";
57
56
  import {
58
57
  ALL, TAG, EMBEDDED, DEFAULT, FULL, LIBRARY,
59
58
  } from "../Whatsapp/constants";
@@ -61,7 +60,7 @@ import { getCdnUrl } from "../../utils/cdnTransformation";
61
60
  import { getCtaObject, hasAnyErrors, getSingleTab } from "./utils";
62
61
  import { validateInAppContent } from "../../utils/commonUtils";
63
62
  import { validateTags } from "../../utils/tagValidations";
64
- import { hasNewEditorFlowInAppEnabled } from "../../utils/common";
63
+ import { hasNewEditorFlowInAppEnabled, isAiContentBotDisabled } from "../../utils/common";
65
64
  import formBuilderMessages from "../../v2Components/FormBuilder/messages";
66
65
  import HTMLEditor from "../../v2Components/HtmlEditor";
67
66
  import { HTML_EDITOR_VARIANTS } from "../../v2Components/HtmlEditor/constants";
@@ -1217,7 +1216,7 @@ export const InApp = (props) => {
1217
1216
  }
1218
1217
 
1219
1218
  // ── Old-flow helpers (used by CapDeviceContent when flag is disabled) ──────
1220
- const isAiContentBotDisabled = currentOrgDetails?.accessibleFeatures?.includes(AI_CONTENT_BOT_DISABLED);
1219
+ const aiContentBotDisabled = isAiContentBotDisabled();
1221
1220
 
1222
1221
  /**
1223
1222
  * Clears stored API/liquid errors for a specific device (and GENERIC) so
@@ -1367,7 +1366,7 @@ export const InApp = (props) => {
1367
1366
  templateDescErrorHandler={templateDescErrorHandler}
1368
1367
  templateTitleError={templateTitleErrorAndroid}
1369
1368
  setTemplateTitleError={setTemplateTitleErrorAndroid}
1370
- isAiContentBotDisabled={isAiContentBotDisabled}
1369
+ isAiContentBotDisabled={aiContentBotDisabled}
1371
1370
  injectedTags={injectedTags}
1372
1371
  selectedOfferDetails={selectedOfferDetails}
1373
1372
  location={location}
@@ -1412,7 +1411,7 @@ export const InApp = (props) => {
1412
1411
  templateDescErrorHandler={templateDescErrorHandler}
1413
1412
  templateTitleError={templateTitleErrorIos}
1414
1413
  setTemplateTitleError={setTemplateTitleErrorIos}
1415
- isAiContentBotDisabled={isAiContentBotDisabled}
1414
+ isAiContentBotDisabled={aiContentBotDisabled}
1416
1415
  injectedTags={injectedTags}
1417
1416
  selectedOfferDetails={selectedOfferDetails}
1418
1417
  location={location}
@@ -55,9 +55,9 @@ import {
55
55
  isLoadingMetaEntities,
56
56
  makeSelectMetaEntities,
57
57
  setInjectedTags,
58
- selectCurrentOrgDetails,
59
58
  } from '../Cap/selectors';
60
59
  import * as RcsActions from './actions';
60
+ import { isAiContentBotDisabled } from '../../utils/common';
61
61
  import * as TemplatesActions from '../Templates/actions';
62
62
  import './index.scss';
63
63
  import {
@@ -76,7 +76,6 @@ import {
76
76
  RCS_IMG_SIZE,
77
77
  RCS_DLT_MODE,
78
78
  CTA,
79
- AI_CONTENT_BOT_DISABLED,
80
79
  RCS_STATUSES,
81
80
  TITLE_TEXT,
82
81
  MESSAGE_TEXT,
@@ -148,7 +147,6 @@ export const Rcs = (props) => {
148
147
  isDltEnabled,
149
148
  smsRegister,
150
149
  selectedOfferDetails,
151
- currentOrgDetails,
152
150
  eventContextTags,
153
151
  accountData = {},
154
152
  // TestAndPreviewSlidebox props
@@ -331,10 +329,7 @@ export const Rcs = (props) => {
331
329
  label: formatMessage(messages.mediaVideo),
332
330
  },
333
331
  ];
334
- const { accessibleFeatures = [] } = currentOrgDetails || {};
335
- const isAiContentBotDisabled = accessibleFeatures?.includes(
336
- AI_CONTENT_BOT_DISABLED
337
- );
332
+ const aiContentBotDisabled = isAiContentBotDisabled();
338
333
 
339
334
  const updateButtonChange = (data, index) => {
340
335
  if (data && data.text) {
@@ -1240,7 +1235,7 @@ const splitTemplateVarString = (str) => {
1240
1235
  data-testid="rcs_text_area"
1241
1236
  disabled={(isEditFlow || !isFullMode)}
1242
1237
  />
1243
- {!isAiContentBotDisabled && !isEditFlow && (
1238
+ {!aiContentBotDisabled && !isEditFlow && (
1244
1239
  <CapAskAira.ContentGenerationBot
1245
1240
  text={templateDesc || ""}
1246
1241
  setText={(text) => onTemplateDescChange({ target: { value: text } })}
@@ -1627,7 +1622,7 @@ const splitTemplateVarString = (str) => {
1627
1622
  // errorMessage={fallbackMessageError}
1628
1623
  // value={fallbackMessage || ""}
1629
1624
  // />
1630
- // {!isAiContentBotDisabled && (
1625
+ // {!aiContentBotDisabled && (
1631
1626
  // <CapAskAira.ContentGenerationBot
1632
1627
  // text={fallbackMessage || ""}
1633
1628
  // setText={(text) => {
@@ -2466,7 +2461,6 @@ const mapStateToProps = createStructuredSelector({
2466
2461
  metaEntities: makeSelectMetaEntities(),
2467
2462
  loadingTags: isLoadingMetaEntities(),
2468
2463
  injectedTags: setInjectedTags(),
2469
- currentOrgDetails: selectCurrentOrgDetails(),
2470
2464
  });
2471
2465
 
2472
2466
  const mapDispatchToProps = (dispatch) => ({
@@ -30,7 +30,7 @@ import messages from './messages';
30
30
  import creativesMessages from '../CreativesContainer/messages';
31
31
  import TagList from '../TagList';
32
32
  import CapTagListWithInput from '../../v2Components/CapTagListWithInput';
33
- import { makeSelectMetaEntities, setInjectedTags, selectCurrentOrgDetails } from '../Cap/selectors';
33
+ import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
34
34
  import {
35
35
  ALLOWED_IMAGE_EXTENSIONS_REGEX_VIBER,
36
36
  ALLOWED_EXTENSIONS_VIDEO_REGEX_VIBER,
@@ -44,7 +44,6 @@ import {
44
44
  NONE,
45
45
  mediaRadioOptions,
46
46
  buttonRadioOptions,
47
- AI_CONTENT_BOT_DISABLED,
48
47
  } from './constants';
49
48
  import withCreatives from '../../hoc/withCreatives';
50
49
  import {
@@ -53,6 +52,7 @@ import {
53
52
  import { gtmPush } from '../../utils/gtmTrackers';
54
53
  import { VIBER } from '../CreativesContainer/constants';
55
54
  import { getCdnUrl } from '../../utils/cdnTransformation';
55
+ import { isAiContentBotDisabled } from '../../utils/common';
56
56
  import globalMessages from '../Cap/messages';
57
57
  import CapImageUpload from '../../v2Components/CapImageUpload';
58
58
  import CapVideoUpload from '../../v2Components/CapVideoUpload';
@@ -81,7 +81,6 @@ export const Viber = (props) => {
81
81
  getFormSubscriptionData,
82
82
  viberData = {},
83
83
  selectedOfferDetails = [],
84
- currentOrgDetails,
85
84
  eventContextTags,
86
85
  // TestAndPreviewSlidebox props
87
86
  showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
@@ -115,10 +114,7 @@ export const Viber = (props) => {
115
114
  const [buttonType, setButtonType] = useState(NONE);
116
115
  const [ctaData, setCtadata] = useState({});
117
116
  const [isCtaSaved, setIsCtaSaved] = useState(false);
118
- const { accessibleFeatures = [] } = currentOrgDetails || {};
119
- const isAiContentBotDisabled = accessibleFeatures?.includes(
120
- AI_CONTENT_BOT_DISABLED
121
- );
117
+ const aiContentBotDisabled = isAiContentBotDisabled();
122
118
 
123
119
  const updateImageSrc = React.useCallback((url) => {
124
120
  const newUrl = getCdnUrl({url, channelName: 'VIBER'});
@@ -306,7 +302,7 @@ export const Viber = (props) => {
306
302
  cols={2}
307
303
  placeholder={formatMessage(messages.enterMessage)}
308
304
  />
309
- {!isAiContentBotDisabled && (
305
+ {!aiContentBotDisabled && (
310
306
  <CapAskAira.ContentGenerationBot
311
307
  text={messageContent || ""}
312
308
  setText={(text) => {
@@ -887,7 +883,6 @@ const mapStateToProps = createStructuredSelector({
887
883
  injectedTags: setInjectedTags(),
888
884
  viberData: makeSelectViber(),
889
885
  viber: makeSelectCreateViber(),
890
- currentOrgDetails: selectCurrentOrgDetails(),
891
886
  });
892
887
 
893
888
  const mapDispatchToProps = (dispatch) => ({
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useState } from 'react';
1
+ import { useLayoutEffect, useMemo, useState } from 'react';
2
2
 
3
3
  const DEFAULT_BOTTOM = '0.83rem';
4
4
 
@@ -27,7 +27,7 @@ export const useAiraTriggerPosition = ({
27
27
  }) => {
28
28
  const [bottomOffset, setBottomOffset] = useState(DEFAULT_BOTTOM);
29
29
 
30
- useEffect(() => {
30
+ useLayoutEffect(() => {
31
31
  const wrapperElement = wrapperRef?.current;
32
32
  if (!wrapperElement) {
33
33
  setBottomOffset(DEFAULT_BOTTOM);
@@ -47,7 +47,8 @@ export const useAiraTriggerPosition = ({
47
47
  ));
48
48
  };
49
49
 
50
- const rafId = requestAnimationFrame(updatePosition);
50
+ updatePosition();
51
+
51
52
  let resizeObserver = null;
52
53
 
53
54
  if (window.ResizeObserver) {
@@ -61,7 +62,6 @@ export const useAiraTriggerPosition = ({
61
62
  }
62
63
 
63
64
  return () => {
64
- cancelAnimationFrame(rafId);
65
65
  if (resizeObserver) {
66
66
  resizeObserver.disconnect();
67
67
  }
@@ -11,12 +11,6 @@ describe('useAiraTriggerPosition', () => {
11
11
  disconnectMock = jest.fn();
12
12
  resizeObserverCallback = null;
13
13
 
14
- global.requestAnimationFrame = jest.fn((cb) => {
15
- cb();
16
- return 1;
17
- });
18
- global.cancelAnimationFrame = jest.fn();
19
-
20
14
  global.ResizeObserver = jest.fn((cb) => {
21
15
  resizeObserverCallback = cb;
22
16
  return {
@@ -43,12 +43,12 @@ import { makeSelectTemplates } from '../Templates/selectors';
43
43
  import {
44
44
  isLoadingMetaEntities,
45
45
  makeSelectMetaEntities,
46
- selectCurrentOrgDetails,
47
46
  setInjectedTags,
48
47
  selectMetaDataStatus,
49
48
  } from "../Cap/selectors";
50
49
  import * as WhatsappActions from './actions';
51
50
  import TestAndPreviewSlidebox from '../../v2Components/TestAndPreviewSlidebox';
51
+ import { isAiContentBotDisabled } from '../../utils/common';
52
52
  import './index.scss';
53
53
  import {
54
54
  UNSUBSCRIBE_TEXT_LENGTH,
@@ -88,7 +88,6 @@ import {
88
88
  BUTTON_TEXT,
89
89
  OTP_CONFIG_URI,
90
90
  WHATSAPP_CATEGORIES,
91
- AI_CONTENT_BOT_DISABLED,
92
91
  mediaTypeOptions,
93
92
  carouselMediaOptions,
94
93
  CAROUSEL_INITIAL_DATA,
@@ -180,7 +179,6 @@ export const Whatsapp = (props) => {
180
179
  loadingTags,
181
180
  getFormData,
182
181
  selectedOfferDetails,
183
- currentOrgDetails,
184
182
  eventContextTags,
185
183
  metaDataStatus = "",
186
184
  showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
@@ -268,10 +266,7 @@ export const Whatsapp = (props) => {
268
266
  const carouselBodyVarRegex = /{{[1-5]}}/g;
269
267
  const previewUrlMatchingRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/g;
270
268
 
271
- const { accessibleFeatures = [] } = currentOrgDetails || {};
272
- const isAiContentBotDisabled = accessibleFeatures?.includes(
273
- AI_CONTENT_BOT_DISABLED
274
- );
269
+ const aiContentBotDisabled = isAiContentBotDisabled();
275
270
  const isBtnTypeCta = buttonType === WHATSAPP_BUTTON_TYPES.CTA;
276
271
  const isBtnTypeQuickReply = buttonType === WHATSAPP_BUTTON_TYPES.QUICK_REPLY;
277
272
  const isMediaTypeText = templateMediaType === WHATSAPP_MEDIA_TYPES.TEXT;
@@ -2257,7 +2252,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2257
2252
  value={templateMessage || ""}
2258
2253
  disabled={isAuthenticationTemplate}
2259
2254
  />
2260
- {!isAiContentBotDisabled && (
2255
+ {!aiContentBotDisabled && (
2261
2256
  <CapAskAira.ContentGenerationBot
2262
2257
  text={templateMessage || ""}
2263
2258
  setText={(text) => onTemplateValueChange({ target: { value: text } }, MESSAGE_TEXT)}
@@ -3219,7 +3214,6 @@ const mapStateToProps = createStructuredSelector({
3219
3214
  metaEntities: makeSelectMetaEntities(),
3220
3215
  loadingTags: isLoadingMetaEntities(),
3221
3216
  injectedTags: setInjectedTags(),
3222
- currentOrgDetails: selectCurrentOrgDetails(),
3223
3217
  metaDataStatus: selectMetaDataStatus(),
3224
3218
  });
3225
3219