@capillarytech/creatives-library 9.0.13-alpha.0 → 9.0.13-beta.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": "9.0.13-alpha.0",
4
+ "version": "9.0.13-beta.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -176,29 +176,29 @@ const FormBuilderShell = (props) => {
176
176
  // Full mode submits directly; outside it, liquid-supported channels run liquid-tag
177
177
  // validation first — a clean result submits, an error goes to the footer and blocks.
178
178
  const submitValidForm = (legacy, validErrorData) => {
179
- const p = propsRef.current;
179
+ const currentProps = propsRef.current;
180
180
  const runLiquid = liquidEnabled && !isFullMode;
181
- const getLiquidTags = p.actions?.getLiquidTags;
181
+ const getLiquidTags = currentProps.actions?.getLiquidTags;
182
182
  if (!runLiquid || typeof getLiquidTags !== 'function') {
183
- if (p.onSubmit) p.onSubmit(adapter.buildSubmitPayload(legacy));
183
+ if (currentProps.onSubmit) currentProps.onSubmit(adapter.buildSubmitPayload(legacy));
184
184
  return;
185
185
  }
186
186
  const content = adapter.getLiquidContent
187
- ? adapter.getLiquidContent(legacy, { baseLanguage: p.baseLanguage })
187
+ ? adapter.getLiquidContent(legacy, { baseLanguage: currentProps.baseLanguage })
188
188
  : adapter.buildSubmitPayload(legacy);
189
189
  validateLiquidTemplateContent(content, {
190
190
  getLiquidTags,
191
- formatMessage: p.intl.formatMessage,
191
+ formatMessage: currentProps.intl.formatMessage,
192
192
  messages: formMessages,
193
193
  onError: ({ standardErrors, liquidErrors }) => {
194
194
  pushFooter({ STANDARD_ERROR_MSG: standardErrors, LIQUID_ERROR_MSG: liquidErrors });
195
- if (p.stopValidation) p.stopValidation();
195
+ if (currentProps.stopValidation) currentProps.stopValidation();
196
196
  // Classic passes the (clean) sync errorData here: the footer carries the
197
197
  // liquid error, not a per-field error.
198
- if (p.onFormValidityChange) p.onFormValidityChange(false, validErrorData);
198
+ if (currentProps.onFormValidityChange) currentProps.onFormValidityChange(false, validErrorData);
199
199
  },
200
200
  onSuccess: () => {
201
- if (p.onSubmit) p.onSubmit(adapter.buildSubmitPayload(legacy));
201
+ if (currentProps.onSubmit) currentProps.onSubmit(adapter.buildSubmitPayload(legacy));
202
202
  },
203
203
  });
204
204
  };
@@ -37,3 +37,6 @@ export const MEMOIZED_TYPES = new Set([FIELD_TYPE.INPUT, FIELD_TYPE.TEXTAREA, FI
37
37
  export const ACTIVE_TAB_INDEX = 0;
38
38
 
39
39
  export const HIGH_FREQ_FIELDS = ['template-name', 'template-subject'];
40
+
41
+ export const ASCII = 'ASCII';
42
+ export const UNICODE = 'Unicode';
@@ -67,9 +67,7 @@ const Section = ({ section, renderContext }) => {
67
67
  return (
68
68
  <CapRow useLegacy style={section?.rowStyle || {}}>
69
69
  {section?.childSections?.map((childSection, index) => (
70
- // Schema layout is a frozen, never-reordered descriptor -> index is a stable key.
71
- // eslint-disable-next-line react/no-array-index-key
72
- <CapColumn key={index} span={childSection?.width} offset={childSection?.offset} style={childSection?.colStyle || {}}>
70
+ <CapColumn key={`${childSection}-${index}`} span={childSection?.width} offset={childSection?.offset} style={childSection?.colStyle || {}}>
73
71
  <Section section={childSection} renderContext={renderContext} />
74
72
  </CapColumn>
75
73
  ))}
@@ -18,7 +18,7 @@ import { isAiContentBotDisabled } from '../../../../utils/common';
18
18
  import { SMS } from '../../../../v2Containers/CreativesContainer/constants';
19
19
  import { EMBEDDED } from '../../../../constants/unified';
20
20
  import { createFieldRegistry } from '../core/schema/fieldRegistry';
21
- import { FIELD_TYPE } from '../constants';
21
+ import { ASCII, FIELD_TYPE, UNICODE } from '../constants';
22
22
  import { fieldIds, SMS_TAB } from '../channels/sms/config';
23
23
 
24
24
  const { TextArea } = CapInput;
@@ -40,10 +40,6 @@ const dataFieldDefaultProps = {
40
40
  export const InputField = ({
41
41
  field, value, error, onChange, onBlur, renderContext,
42
42
  }) => {
43
- // Errors show only after validation is triggered (checkValidation). We drive the
44
- // border via `status` and render the message in our own span rather than passing
45
- // CapInput's errorMessage: toggling its antd suffix remounts the <input> and drops
46
- // focus mid-keystroke.
47
43
  const showError = Boolean(renderContext?.checkValidation && error);
48
44
  return (
49
45
  <CapColumn key={field.id} span={field.width} offset={field.offset} style={field.style || {}}>
@@ -51,7 +47,7 @@ export const InputField = ({
51
47
  id={field.id}
52
48
  label={field.label}
53
49
  placeholder={field.placeholder}
54
- status={showError ? 'error' : undefined}
50
+ errorMessage={showError && field.errorMessage ? field.errorMessage : ''}
55
51
  className={`input-primary chart-name-input${showError ? ' error' : ''}`}
56
52
  value={value || ''}
57
53
  onChange={(e) => onChange(e.target.value)}
@@ -59,9 +55,6 @@ export const InputField = ({
59
55
  disabled={field.disabled}
60
56
  size={field.size || 'default'}
61
57
  />
62
- {showError && field.errorMessage ? (
63
- <span className="component-with-label-error-message">{field.errorMessage}</span>
64
- ) : null}
65
58
  </CapColumn>
66
59
  );
67
60
  };
@@ -214,7 +207,7 @@ export const SmsPreviewField = ({ field, renderContext }) => {
214
207
  showDeviceToggle={false}
215
208
  showHeader={false}
216
209
  formatMessage={renderContext?.intl?.formatMessage}
217
- senderId={unicodeEnabled ? 'Unicode' : 'ASCII'}
210
+ senderId={unicodeEnabled ? UNICODE : ASCII}
218
211
  />
219
212
  </CapColumn>
220
213
  );
@@ -22,22 +22,20 @@ describe('InputField', () => {
22
22
  id: 'template-name', type: 'input', width: 18, errorMessage: 'Name required',
23
23
  };
24
24
 
25
- it('shows the error span + status=error when validation triggered and error present', () => {
25
+ it('passes errorMessage to CapInput (warning icon + status + message) when validation triggered and error present', () => {
26
26
  const el = InputField({
27
27
  field, value: '', error: true, onChange: () => {}, onBlur: () => {}, renderContext: { checkValidation: true },
28
28
  });
29
- const [input, span] = kids(el);
30
- expect(input.props.status).toBe('error');
31
- expect(span.props.children).toBe('Name required');
29
+ const [input] = kids(el);
30
+ expect(input.props.errorMessage).toBe('Name required');
32
31
  });
33
32
 
34
- it('no error span when validation not triggered', () => {
33
+ it('no errorMessage when validation not triggered', () => {
35
34
  const el = InputField({
36
35
  field, value: 'x', error: true, onChange: () => {}, onBlur: () => {}, renderContext: { checkValidation: false },
37
36
  });
38
- const [input, span] = kids(el);
39
- expect(input.props.status).toBeUndefined();
40
- expect(span).toBeUndefined();
37
+ const [input] = kids(el);
38
+ expect(input.props.errorMessage).toBe('');
41
39
  });
42
40
  });
43
41
 
@@ -46,13 +46,10 @@
46
46
  .error .error-message{
47
47
  top: revert;
48
48
  }
49
- // SMS message-body error ("Invalid label, please close all curly braces"):
50
- // drop the default top gap and add breathing room below the message box.
51
- .sms-message-content {
52
- .component-with-label-error-message {
53
- margin-top: 0 !important;
54
- margin-bottom: 8px !important;
55
- }
49
+
50
+ .sms-message-content .component-with-label-error-message {
51
+ margin-top: -$CAP_SPACE_04;
52
+ margin-bottom: $CAP_SPACE_08;
56
53
  }
57
54
  .tabs-error {
58
55
  .ant-tabs-ink-bar .ant-tabs-ink-bar-animated {
@@ -1,171 +0,0 @@
1
- @coderabbitai
2
- coderabbitai Bot
3
- 2 days ago
4
- ⚠️ Potential issue | 🟠 Major | ⚡ Quick win
5
-
6
- Guard non-string channel values before calling toUpperCase().
7
-
8
- Current normalization crashes for truthy non-string channel values instead of returning null.
9
-
10
- Proposed fix
11
- -export const getChannelAdapter = (channel) => adapters[(channel || '').toUpperCase()] || null;
12
- +export const getChannelAdapter = (channel) => {
13
- + const key = typeof channel === 'string' ? channel.toUpperCase() : '';
14
- + return adapters[key] || null;
15
- +};
16
- 🤖 Prompt for AI Agents
17
- Verify each finding against current code. Fix only still-valid issues, skip the
18
- rest with a brief reason, keep changes minimal, and validate.
19
-
20
- In `@app/v2Components/FormBuilder/Functional/channels/registry.js` at line 12, The
21
- getChannelAdapter function does not guard against non-string values for the
22
- channel parameter. When a truthy non-string value (like a number or object) is
23
- passed, calling toUpperCase() on it will crash. Add a type check to ensure the
24
- channel value is a string before attempting to call toUpperCase() on it. If
25
- channel is not a string, return null directly. This prevents the crash while
26
- maintaining the existing behavior for null, undefined, and string values.
27
-
28
-
29
-
30
-
31
- coderabbitai Bot
32
- 2 days ago
33
- ⚠️ Potential issue | 🟠 Major | ⚡ Quick win
34
-
35
- Guard MULTICOLS row dereference to prevent schema-driven crashes.
36
-
37
- Line 38/39 assumes every row exists. A null row from schema data will throw before form initialization completes.
38
-
39
- Proposed fix
40
- - (section.inputFields || []).forEach((row) => (row.cols || []).forEach(visit));
41
- - (section.actionFields || []).forEach((row) => (row.cols || []).forEach(visit));
42
- + (section.inputFields || []).forEach((row) => (row?.cols || []).forEach(visit));
43
- + (section.actionFields || []).forEach((row) => (row?.cols || []).forEach(visit));
44
- 🤖 Prompt for AI Agents
45
- Verify each finding against current code. Fix only still-valid issues, skip the
46
- rest with a brief reason, keep changes minimal, and validate.
47
-
48
- In `@app/v2Components/FormBuilder/Functional/core/schema/initializeFormState.js`
49
- around lines 37 - 40, The MULTICOLS case in the section type handling does not
50
- guard against null or undefined row values before accessing the cols property,
51
- which will cause a crash if schema data contains null rows. Add a null check for
52
- each row within the forEach callbacks for both inputFields and actionFields
53
- processing to ensure the row exists before attempting to access row.cols,
54
- preventing dereferencing of null values during form initialization.
55
-
56
-
57
-
58
-
59
- coderabbitai Bot
60
- 2 days ago
61
- ⚠️ Potential issue | 🟠 Major | ⚡ Quick win
62
-
63
- Preserve original numeric tab indices when decoding legacy formData.
64
-
65
- Line 52 compacts tab keys into a dense array. For sparse legacy keys (e.g., only 1 present), toLegacy writes them back as 0, changing payload shape and base-tab addressing.
66
-
67
- Proposed fix
68
- 📝 Committable suggestion
69
- ‼️ IMPORTANT
70
- Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
71
-
72
- Suggested change
73
- const orderedIndices = Object.keys(tabsByIndex)
74
- .map(Number)
75
- .sort((a, b) => a - b);
76
- const tabs = orderedIndices.map((index) => tabsByIndex[index]);
77
- const foundBase = tabs.findIndex((tab) => tab?.base);
78
- const baseTabIndex = foundBase === -1 ? 0 : foundBase;
79
- const orderedIndices = Object.keys(tabsByIndex)
80
- .map(Number)
81
- .sort((a, b) => a - b);
82
- const tabs = [];
83
- orderedIndices.forEach((index) => {
84
- tabs[index] = tabsByIndex[index];
85
- });
86
- const foundBase = orderedIndices.find((index) => tabsByIndex[index]?.base);
87
- const baseTabIndex = foundBase === undefined ? 0 : foundBase;
88
- 🤖 Prompt for AI Agents
89
- Verify each finding against current code. Fix only still-valid issues, skip the
90
- rest with a brief reason, keep changes minimal, and validate.
91
-
92
- In `@app/v2Components/FormBuilder/Functional/core/store/toLegacyFormData.js`
93
- around lines 49 - 56, The issue is that the code compacts sparse tab indices
94
- into a dense array by mapping orderedIndices to a new tabs array, which loses
95
- the original numeric indices and changes the payload shape when converting back
96
- to legacy format. Instead of creating a compacted tabs array using
97
- orderedIndices.map, preserve the sparse structure by keeping the original
98
- numeric keys from tabsByIndex and adjusting the baseTabIndex calculation to work
99
- with the actual tab indices rather than array positions.
100
-
101
-
102
- @coderabbitai
103
- coderabbitai Bot
104
- 2 days ago
105
- ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
106
-
107
- Fix TagList prop contract types/defaults in FormBuilderShell.
108
-
109
- selectedOfferDetails and waitEventContextTags are typed opposite to how app/v2Containers/TagList/index.js consumes them (array and object respectively), which weakens contract checks and can hide wrong-shape regressions.
110
-
111
- Suggested fix
112
- FormBuilderShell.propTypes = {
113
- @@
114
- - selectedOfferDetails: PropTypes.object,
115
- + selectedOfferDetails: PropTypes.array,
116
- @@
117
- - waitEventContextTags: PropTypes.array,
118
- + waitEventContextTags: PropTypes.object,
119
- @@
120
- FormBuilderShell.defaultProps = {
121
- @@
122
- - selectedOfferDetails: undefined,
123
- + selectedOfferDetails: [],
124
- @@
125
- - waitEventContextTags: [],
126
- + waitEventContextTags: {},
127
- Also applies to: 361-364
128
-
129
- 🤖 Prompt for AI Agents
130
- Verify each finding against current code. Fix only still-valid issues, skip the
131
- rest with a brief reason, keep changes minimal, and validate.
132
-
133
- In `@app/v2Components/FormBuilder/Functional/FormBuilderShell.js` around lines 348
134
- - 350, The PropTypes definitions for selectedOfferDetails and
135
- waitEventContextTags in the FormBuilderShell propTypes are typed incorrectly
136
- compared to how they are consumed in the TagList component. Change
137
- selectedOfferDetails from PropTypes.object to PropTypes.array, and change
138
- waitEventContextTags from PropTypes.array to PropTypes.object. Apply the same
139
- type corrections to any other instances of these props mentioned in the file
140
- (lines 361-364).
141
-
142
-
143
- @coderabbitai
144
- coderabbitai Bot
145
- 2 days ago
146
- ⚠️ Potential issue | 🟠 Major | ⚡ Quick win
147
-
148
- Characterization can unintentionally run Functional instead of Classic.
149
-
150
- Line 22 imports the entry-gated FormBuilder (../index), and that gate can route SMS to Functional based on feature access. For a Classic golden suite, this makes the target non-deterministic and can hide Classic regressions.
151
-
152
- Suggested fix
153
- -import FormBuilder from '../index';
154
- +import ClassicFormBuilder from '../Classic';
155
- @@
156
- -const ComponentToRender = injectIntl(FormBuilder);
157
- +const ComponentToRender = injectIntl(ClassicFormBuilder);
158
- Also applies to: 47-47
159
-
160
- 🤖 Prompt for AI Agents
161
- Verify each finding against current code. Fix only still-valid issues, skip the
162
- rest with a brief reason, keep changes minimal, and validate.
163
-
164
- In `@app/v2Components/FormBuilder/tests/sms.characterization.test.js` around lines
165
- 22 - 23, The imports on line 22 and line 47 use the entry-gated FormBuilder from
166
- ../index which can route SMS to Functional based on feature access. For the
167
- Classic characterization test to be deterministic and properly test Classic
168
- behavior, import the Classic FormBuilder implementation directly rather than
169
- going through the gated entry point. Replace the imports from ../index with
170
- direct imports to the Classic FormBuilder implementation to ensure the test
171
- always uses the Classic version.