@integry/sdk 4.6.1 → 4.6.2

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.6.1",
3
+ "version": "4.6.2",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -1,5 +1,5 @@
1
1
  import { html } from 'htm/preact';
2
- import { useState } from 'preact/hooks';
2
+ import { useState, useEffect } from 'preact/hooks';
3
3
  import { Input } from '@/components/Input';
4
4
  import { TextArea } from '@/components/TextArea';
5
5
  import { CheckboxGroup } from '@/components/CheckboxGroup';
@@ -107,7 +107,9 @@ const ObjectField = (props: ObjectFieldProps) => {
107
107
  activityOutputDataRaw,
108
108
  objectValue,
109
109
  } = props;
110
- const [objectArray, setObjectArray] = useState<FieldObject[]>([{}]); // Start with one empty object in the array
110
+ const [objectArray, setObjectArray] = useState<FieldObject[]>(
111
+ Array.isArray(objectValue) ? objectValue : [{}],
112
+ ); // Start with one empty object in the array
111
113
  const [showAddMoreOption, setShowAddMoreOption] = useState(true);
112
114
  const [objectHasFields, setObjectHasFields] = useState(true);
113
115
 
@@ -158,6 +160,21 @@ const ObjectField = (props: ObjectFieldProps) => {
158
160
  );
159
161
  }
160
162
 
163
+ useEffect(() => {
164
+ let objectValueCopy = objectValue;
165
+ if (typeof objectValue === 'string' && objectValue.length > 0) {
166
+ // if default value was sent as a strinfiyed object
167
+ objectValueCopy = JSON.parse(objectValue);
168
+ }
169
+ if (objectValueCopy) {
170
+ if (Array.isArray(objectValueCopy)) {
171
+ setObjectArray(objectValueCopy);
172
+ } else {
173
+ setObjectArray([objectValueCopy]);
174
+ }
175
+ }
176
+ }, [objectValue]);
177
+
161
178
  // Method to handle field changes for each object in the array
162
179
  const handleFieldChange = (
163
180
  index: number,
@@ -280,7 +297,9 @@ const ObjectField = (props: ObjectFieldProps) => {
280
297
  activityOutputData=${activityOutputData}
281
298
  activityOutputDataRaw=${activityOutputDataRaw}
282
299
  description="${fieldDetails.meta.description_for_users}"
283
- value=${(objectArray[objectIndex] || {})[fieldName] || ''}
300
+ value=${(objectArray[objectIndex] || {})[
301
+ fieldDetails?.meta?.machine_name || ''
302
+ ] || ''}
284
303
  placeholder="${placeholder}"
285
304
  onChange=${(val: any) => {
286
305
  const valueReceived =