@integry/sdk 4.7.28 → 4.7.30
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
|
@@ -636,7 +636,10 @@ const MultipurposeField = (props: MultipurposeFieldProps) => {
|
|
|
636
636
|
const vallueToUse = Array.isArray(currentValue)
|
|
637
637
|
? currentValue[0]
|
|
638
638
|
: currentValue;
|
|
639
|
-
const isTag =
|
|
639
|
+
const isTag =
|
|
640
|
+
typeof vallueToUse === 'string'
|
|
641
|
+
? vallueToUse?.startsWith('{') && vallueToUse?.endsWith('}')
|
|
642
|
+
: false;
|
|
640
643
|
if (isEditable && !allowTagsInText && isMappable && isTag) {
|
|
641
644
|
setTempPlaceholder(vallueToUse || '');
|
|
642
645
|
}
|
|
@@ -651,7 +654,7 @@ const MultipurposeField = (props: MultipurposeFieldProps) => {
|
|
|
651
654
|
const getStringFromEnd = (str: string): string => {
|
|
652
655
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
653
656
|
const regex = /\{([^{}]+)$/;
|
|
654
|
-
const matches = (str || '').match(regex);
|
|
657
|
+
const matches = typeof str === 'string' ? (str || '').match(regex) : [];
|
|
655
658
|
|
|
656
659
|
if (matches && matches.length > 1) {
|
|
657
660
|
const capturedString = matches[0];
|
|
@@ -115,11 +115,67 @@ const ObjectField = (props: ObjectFieldProps) => {
|
|
|
115
115
|
tagsTree = null,
|
|
116
116
|
showMenuOnLeft = false, // Default to false
|
|
117
117
|
} = props;
|
|
118
|
+
|
|
119
|
+
// Calculate initial state based on field properties
|
|
120
|
+
const calculateInitialObjectHasFields = (f: any) => {
|
|
121
|
+
// Special case for the Blocks field or similar fields
|
|
122
|
+
if (
|
|
123
|
+
field.type === 'TEXTAREA' &&
|
|
124
|
+
(field.data_type === 'OBJECT[]' || field.data_type === 'OBJECT') &&
|
|
125
|
+
(!field.template_fields || field.template_fields.length === 0)
|
|
126
|
+
) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// For other cases, use the original logic
|
|
131
|
+
if (Array.isArray(field.template_fields)) {
|
|
132
|
+
if (field.template_fields.length > 0) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
if (field.type === 'TEXTAREA' || field.type === 'DYNAMIC') {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
} else if (field.properties && Object.keys(field.properties).length === 0) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return true;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const calculateInitialShowAddMoreOption = (f: any) => {
|
|
146
|
+
// Special case for the Blocks field or similar fields
|
|
147
|
+
if (
|
|
148
|
+
field.type === 'TEXTAREA' &&
|
|
149
|
+
(field.data_type === 'OBJECT[]' || field.data_type === 'OBJECT') &&
|
|
150
|
+
(!field.template_fields || field.template_fields.length === 0)
|
|
151
|
+
) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// For other cases, use the original logic
|
|
156
|
+
if (Array.isArray(field.template_fields)) {
|
|
157
|
+
if (field.template_fields.length > 0) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (field.type === 'TEXTAREA' || field.type === 'DYNAMIC') {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
} else if (field.properties && Object.keys(field.properties).length === 0) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return true;
|
|
168
|
+
};
|
|
169
|
+
|
|
118
170
|
const [objectArray, setObjectArray] = useState<FieldObject[]>(
|
|
119
171
|
Array.isArray(objectValue) ? objectValue : [{}],
|
|
120
172
|
); // Start with one empty object in the array
|
|
121
|
-
const [showAddMoreOption, setShowAddMoreOption] = useState(
|
|
122
|
-
|
|
173
|
+
const [showAddMoreOption, setShowAddMoreOption] = useState(() =>
|
|
174
|
+
calculateInitialShowAddMoreOption(field),
|
|
175
|
+
);
|
|
176
|
+
const [objectHasFields, setObjectHasFields] = useState(() =>
|
|
177
|
+
calculateInitialObjectHasFields(field),
|
|
178
|
+
);
|
|
123
179
|
|
|
124
180
|
let templateFields = [];
|
|
125
181
|
|