@capillarytech/creatives-library 8.0.313 → 8.0.314

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.313",
4
+ "version": "8.0.314",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1218,6 +1218,47 @@ export const InApp = (props) => {
1218
1218
  // ── Old-flow helpers (used by CapDeviceContent when flag is disabled) ──────
1219
1219
  const isAiContentBotDisabled = currentOrgDetails?.accessibleFeatures?.includes(AI_CONTENT_BOT_DISABLED);
1220
1220
 
1221
+ /**
1222
+ * Clears stored API/liquid errors for a specific device (and GENERIC) so
1223
+ * hasAnyErrors() goes false and Done can be re-clicked after editing.
1224
+ * Does NOT clear errors that belong only to the *other* device.
1225
+ */
1226
+ const clearDeviceErrors = useCallback((platform) => {
1227
+ const key = platform === IOS ? IOS_CAPITAL : ANDROID;
1228
+ setErrorMessage((prev) => ({
1229
+ STANDARD_ERROR_MSG: {
1230
+ ...prev.STANDARD_ERROR_MSG,
1231
+ [key]: [],
1232
+ GENERIC: [],
1233
+ },
1234
+ LIQUID_ERROR_MSG: {
1235
+ ...prev.LIQUID_ERROR_MSG,
1236
+ [key]: [],
1237
+ GENERIC: [],
1238
+ },
1239
+ }));
1240
+ }, [IOS_CAPITAL, ANDROID]);
1241
+
1242
+ const setTitleAndroidWithClear = useCallback((value) => {
1243
+ clearDeviceErrors(ANDROID);
1244
+ setTitleAndroid(value);
1245
+ }, [clearDeviceErrors]);
1246
+
1247
+ const setTitleIosWithClear = useCallback((value) => {
1248
+ clearDeviceErrors(IOS);
1249
+ setTitleIos(value);
1250
+ }, [clearDeviceErrors]);
1251
+
1252
+ const setTemplateMessageAndroidWithClear = useCallback((value) => {
1253
+ clearDeviceErrors(ANDROID);
1254
+ setTemplateMessageAndroid(value);
1255
+ }, [clearDeviceErrors]);
1256
+
1257
+ const setTemplateMessageIosWithClear = useCallback((value) => {
1258
+ clearDeviceErrors(IOS);
1259
+ setTemplateMessageIos(value);
1260
+ }, [clearDeviceErrors]);
1261
+
1221
1262
  const templateDescErrorHandler = (value) => {
1222
1263
  const { unsupportedTags, isBraceError } = validateTags({
1223
1264
  content: value,
@@ -1231,17 +1272,19 @@ export const InApp = (props) => {
1231
1272
  return formatMessage(globalMessages.unsupportedTagsValidationError, { unsupportedTags });
1232
1273
  }
1233
1274
  if (isBraceError) {
1234
- return formatMessage(globalMessages.braceValidationError);
1275
+ return formatMessage(globalMessages.unbalanacedCurlyBraces);
1235
1276
  }
1236
1277
  return '';
1237
1278
  };
1238
1279
 
1239
1280
  const onCopyTitleAndContent = () => {
1240
1281
  if (panes === ANDROID) {
1282
+ clearDeviceErrors(ANDROID);
1241
1283
  setTitleAndroid(titleIos);
1242
1284
  setTemplateMessageAndroid(templateMessageIos);
1243
1285
  setInAppImageSrcAndroid(inAppImageSrcIos);
1244
1286
  } else {
1287
+ clearDeviceErrors(IOS);
1245
1288
  setTitleIos(titleAndroid);
1246
1289
  setTemplateMessageIos(templateMessageAndroid);
1247
1290
  setInAppImageSrcIos(inAppImageSrcAndroid);
@@ -1251,12 +1294,13 @@ export const InApp = (props) => {
1251
1294
  const onTagSelect = (value, index) => {
1252
1295
  const tag = `{{${value}}}`;
1253
1296
  if (panes === ANDROID) {
1297
+ clearDeviceErrors(ANDROID);
1254
1298
  if (index === 0) setTitleAndroid((prev) => prev + tag);
1255
1299
  else setTemplateMessageAndroid((prev) => prev + tag);
1256
- } else if (index === 0) {
1257
- setTitleIos((prev) => prev + tag);
1258
1300
  } else {
1259
- setTemplateMessageIos((prev) => prev + tag);
1301
+ clearDeviceErrors(IOS);
1302
+ if (index === 0) setTitleIos((prev) => prev + tag);
1303
+ else setTemplateMessageIos((prev) => prev + tag);
1260
1304
  }
1261
1305
  };
1262
1306
 
@@ -1283,10 +1327,10 @@ export const InApp = (props) => {
1283
1327
  templateMediaType={templateMediaType}
1284
1328
  setTemplateMediaType={setTemplateMediaType}
1285
1329
  title={titleAndroid}
1286
- setTitle={setTitleAndroid}
1330
+ setTitle={setTitleAndroidWithClear}
1287
1331
  templateMessageError={templateMessageErrorAndroid}
1288
1332
  templateMessage={templateMessageAndroid}
1289
- setTemplateMessage={setTemplateMessageAndroid}
1333
+ setTemplateMessage={setTemplateMessageAndroidWithClear}
1290
1334
  setTemplateMessageError={setTemplateMessageErrorAndroid}
1291
1335
  addActionLink={addActionLinkAndroid}
1292
1336
  setAddActionLink={setAddActionLinkAndroid}
@@ -1328,10 +1372,10 @@ export const InApp = (props) => {
1328
1372
  templateMediaType={templateMediaType}
1329
1373
  setTemplateMediaType={setTemplateMediaType}
1330
1374
  title={titleIos}
1331
- setTitle={setTitleIos}
1375
+ setTitle={setTitleIosWithClear}
1332
1376
  templateMessageError={templateMessageErrorIos}
1333
1377
  templateMessage={templateMessageIos}
1334
- setTemplateMessage={setTemplateMessageIos}
1378
+ setTemplateMessage={setTemplateMessageIosWithClear}
1335
1379
  setTemplateMessageError={setTemplateMessageErrorIos}
1336
1380
  addActionLink={addActionLinkIos}
1337
1381
  setAddActionLink={setAddActionLinkIos}