@integry/sdk 4.5.42 → 4.5.45

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@integry/sdk",
3
- "version": "4.5.42",
3
+ "version": "4.5.45",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -21,10 +21,12 @@ interface ObjectFieldProps {
21
21
  parentFieldId?: string,
22
22
  index?: number,
23
23
  ) => void;
24
+ onChangeInFlow?: (val: string) => void;
24
25
  apiHandler: any;
25
26
  isArray?: boolean; // New prop to check if the input is an array
26
27
  activityOutputData: any;
27
28
  activityOutputDataRaw: any;
29
+ objectValue?: any;
28
30
  }
29
31
 
30
32
  type Option = {
@@ -95,13 +97,16 @@ const ObjectField = (props: ObjectFieldProps) => {
95
97
  connectedAccount,
96
98
  appName,
97
99
  onChange,
100
+ onChangeInFlow,
98
101
  apiHandler,
99
102
  isArray = false, // Default to false
100
103
  activityOutputData,
101
104
  activityOutputDataRaw,
105
+ objectValue,
102
106
  } = props;
103
107
  const [objectArray, setObjectArray] = useState<FieldObject[]>([{}]); // Start with one empty object in the array
104
108
  const [showAddMoreOption, setShowAddMoreOption] = useState(true);
109
+ const [objectHasFields, setObjectHasFields] = useState(true);
105
110
 
106
111
  let templateFields = [];
107
112
 
@@ -112,6 +117,7 @@ const ObjectField = (props: ObjectFieldProps) => {
112
117
  if (field.data_type === 'OBJECT[]' || field.data_type === 'OBJECT') {
113
118
  field.type = 'TEXTAREA';
114
119
  setShowAddMoreOption(false);
120
+ setObjectHasFields(false);
115
121
  }
116
122
 
117
123
  templateFields = [field];
@@ -122,6 +128,7 @@ const ObjectField = (props: ObjectFieldProps) => {
122
128
  field.properties = null;
123
129
  templateFields = [field];
124
130
  setShowAddMoreOption(false);
131
+ setObjectHasFields(false);
125
132
  }
126
133
  const normalizedField = {
127
134
  ...field,
@@ -146,15 +153,22 @@ const ObjectField = (props: ObjectFieldProps) => {
146
153
  setObjectArray(updatedObjectArray);
147
154
 
148
155
  // Optionally trigger the parent change handler
156
+ const isFlow = !field.properties && !!field.template_fields;
149
157
  if (isArray) {
150
- onChange(
151
- fieldId,
152
- updatedObjectArray,
153
- dataType,
154
- field.is_required,
155
- field.id,
156
- index,
157
- );
158
+ if (isFlow && onChangeInFlow) {
159
+ onChangeInFlow(value);
160
+ } else {
161
+ onChange(
162
+ fieldId,
163
+ updatedObjectArray,
164
+ dataType,
165
+ field.is_required,
166
+ field.id,
167
+ index,
168
+ );
169
+ }
170
+ } else if (isFlow && onChangeInFlow) {
171
+ onChangeInFlow(value);
158
172
  } else {
159
173
  onChange(fieldId, value, dataType, field.is_required, field.id);
160
174
  }
@@ -278,6 +292,7 @@ const ObjectField = (props: ObjectFieldProps) => {
278
292
  isMappable=${activityOutputDataRaw &&
279
293
  Object.entries(activityOutputDataRaw).length > 0}
280
294
  allowTagsInText=${activityOutputDataRaw}
295
+ value=${objectValue}
281
296
  ><//>
282
297
  `}
283
298
  ${fieldType === 'CHECKBOX' &&
@@ -328,8 +343,9 @@ const ObjectField = (props: ObjectFieldProps) => {
328
343
  ${objectArray.map(
329
344
  (_, index) =>
330
345
  html`
331
- <div class="${styles.objectFieldWrap}">
332
- <div class="${styles.label}">
346
+ <div class="${objectHasFields ? styles.objectFieldWrap : ''}">
347
+ ${objectHasFields &&
348
+ html`<div class="${styles.label}">
333
349
  <label class="${styles.subLabel}">
334
350
  <div>
335
351
  ${field.title}${isArray ? ` ${index + 1}` : ''}
@@ -371,7 +387,7 @@ const ObjectField = (props: ObjectFieldProps) => {
371
387
  </div>
372
388
  <div>${field.description}</div>
373
389
  </label>
374
- </div>
390
+ </div>`}
375
391
  ${renderFields(normalizedField.properties, index)}
376
392
  </div>
377
393
  `,
@@ -1560,6 +1560,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1560
1560
  <${ObjectField}
1561
1561
  field=${el}
1562
1562
  onChange=${this.onFieldChange}
1563
+ onChangeInFlow=${(val: string) => {
1564
+ this.onFieldChange({
1565
+ stepId: step.id,
1566
+ fieldId: el.id,
1567
+ value: val,
1568
+ isRequired: el.is_required,
1569
+ machineName:
1570
+ el.activity_field?.machine_name,
1571
+ });
1572
+ }}
1563
1573
  apiHandler=${this.props.apiHandler}
1564
1574
  isArray=${fieldType === 'OBJECT[]'}
1565
1575
  activityOutputData=${this.arrayToNestedJSONWithFirstValue(
@@ -1571,6 +1581,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1571
1581
  activityOutputDataRaw=${
1572
1582
  this.props.activityOutputData
1573
1583
  }
1584
+ objectValue=${
1585
+ (selectedStepData &&
1586
+ selectedStepData[el.id] &&
1587
+ selectedStepData[el.id].value &&
1588
+ selectedStepData[el.id].value !==
1589
+ 'x-integry-skipped-field' &&
1590
+ selectedStepData[el.id].value) ||
1591
+ el.default_value ||
1592
+ ''
1593
+ }
1574
1594
  />
1575
1595
  </${ConfigureFieldWrapper}>
1576
1596
  </div>