@bindu-dashing/dam-solution-v2 5.8.173 → 5.8.175
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.
|
@@ -29,28 +29,47 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
29
29
|
const [defaultValueInput, setDefaultValueInput] = useState("");
|
|
30
30
|
const [loading, setLoading] = useState(false);
|
|
31
31
|
const [form] = Form.useForm();
|
|
32
|
-
// Watch form values and errors to determine if Update button should be enabled
|
|
33
32
|
const formValues = Form.useWatch([], form);
|
|
34
33
|
const [isFormValid, setIsFormValid] = useState(false);
|
|
34
|
+
const [disabledReason, setDisabledReason] = useState(null);
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
const checkFormValidity = () => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
var _a;
|
|
37
38
|
try {
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
39
|
+
// Only check errors for main fields (name, placeholder, defaultValue)
|
|
40
|
+
const mainFieldNames = ["name", "placeholder", "defaultValue"];
|
|
41
|
+
const errors = form.getFieldsError(mainFieldNames);
|
|
42
|
+
const hasMainFieldErrors = errors.some((error) => { var _a; return ((_a = error.errors) === null || _a === void 0 ? void 0 : _a.length) > 0; });
|
|
42
43
|
// Get current form values
|
|
43
44
|
const values = form.getFieldsValue();
|
|
44
45
|
const nameFilled = !!(values.name && typeof values.name === 'string' && values.name.trim() !== '');
|
|
45
46
|
const placeholderFilled = !!(values.placeholder && typeof values.placeholder === 'string' && values.placeholder.trim() !== '');
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const valid = nameFilled && placeholderFilled && !hasMainFieldErrors;
|
|
48
|
+
setIsFormValid(valid);
|
|
49
|
+
// Set reason for disabled state so user knows why
|
|
50
|
+
if (!valid) {
|
|
51
|
+
if (!nameFilled) {
|
|
52
|
+
setDisabledReason("Name is required");
|
|
53
|
+
}
|
|
54
|
+
else if (!placeholderFilled) {
|
|
55
|
+
setDisabledReason("Placeholder is required");
|
|
56
|
+
}
|
|
57
|
+
else if (hasMainFieldErrors) {
|
|
58
|
+
const firstError = errors.find((e) => { var _a; return ((_a = e.errors) === null || _a === void 0 ? void 0 : _a.length) > 0; });
|
|
59
|
+
const errorMsg = (_a = firstError === null || firstError === void 0 ? void 0 : firstError.errors) === null || _a === void 0 ? void 0 : _a[0];
|
|
60
|
+
setDisabledReason(errorMsg ? `Fix error: ${errorMsg}` : "Please fix the form errors above");
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
setDisabledReason(null);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
setDisabledReason(null);
|
|
68
|
+
}
|
|
51
69
|
}
|
|
52
70
|
catch (error) {
|
|
53
71
|
setIsFormValid(false);
|
|
72
|
+
setDisabledReason("Unable to validate form");
|
|
54
73
|
}
|
|
55
74
|
});
|
|
56
75
|
checkFormValidity();
|
|
@@ -59,8 +78,11 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
59
78
|
try {
|
|
60
79
|
setLoading(true);
|
|
61
80
|
const allValues = Object.assign({}, values);
|
|
62
|
-
|
|
63
|
-
|
|
81
|
+
// Format defaultValue if it exists (including empty string/null/undefined)
|
|
82
|
+
if (allValues.hasOwnProperty("defaultValue")) {
|
|
83
|
+
const formattedValue = getFormattedDefaultValue(allValues);
|
|
84
|
+
// Set to undefined if empty/null, otherwise use formatted value
|
|
85
|
+
allValues["defaultValue"] = formattedValue === null || formattedValue === "" ? undefined : formattedValue;
|
|
64
86
|
}
|
|
65
87
|
if (get(field, "_id", null)) {
|
|
66
88
|
allValues["_id"] = get(field, "_id");
|
|
@@ -103,6 +125,23 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
103
125
|
return defaultValue || [];
|
|
104
126
|
case InputTypes.SELECT:
|
|
105
127
|
return allowMultiple ? defaultValue || [] : defaultValue || undefined;
|
|
128
|
+
case InputTypes.NUMBERS:
|
|
129
|
+
// Ensure defaultValue is a valid number, convert string to number if needed
|
|
130
|
+
if (defaultValue === null || defaultValue === undefined || defaultValue === "") {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (typeof defaultValue === "number" && !isNaN(defaultValue) && isFinite(defaultValue)) {
|
|
134
|
+
return defaultValue;
|
|
135
|
+
}
|
|
136
|
+
if (typeof defaultValue === "string") {
|
|
137
|
+
const parsed = Number(defaultValue);
|
|
138
|
+
const trimmedValue = defaultValue.trim();
|
|
139
|
+
if (!isNaN(parsed) && isFinite(parsed) && trimmedValue !== "") {
|
|
140
|
+
return parsed;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// If value is not a valid number, return undefined
|
|
144
|
+
return undefined;
|
|
106
145
|
default:
|
|
107
146
|
return defaultValue;
|
|
108
147
|
}
|
|
@@ -122,6 +161,25 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
122
161
|
return allowMultiple ? value || [] : value !== null && value !== void 0 ? value : undefined;
|
|
123
162
|
case InputTypes.CHECKBOX:
|
|
124
163
|
return value || [];
|
|
164
|
+
case InputTypes.NUMBERS:
|
|
165
|
+
// Convert string to number if valid, otherwise return undefined
|
|
166
|
+
if (value === null || value === undefined || value === "") {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
const valueType = typeof value;
|
|
170
|
+
if (valueType === "number" && !isNaN(value) && isFinite(value)) {
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
if (valueType === "string") {
|
|
174
|
+
const stringVal = value;
|
|
175
|
+
const parsed = Number(stringVal);
|
|
176
|
+
const trimmedValue = stringVal.trim();
|
|
177
|
+
if (!isNaN(parsed) && isFinite(parsed) && trimmedValue !== "") {
|
|
178
|
+
return parsed;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// If value is not a valid number, return undefined
|
|
182
|
+
return undefined;
|
|
125
183
|
default:
|
|
126
184
|
return value;
|
|
127
185
|
}
|
|
@@ -131,13 +189,29 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
131
189
|
handleFormValuesChange();
|
|
132
190
|
// Check initial form validity after setting field values
|
|
133
191
|
setTimeout(() => {
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
const
|
|
192
|
+
var _a;
|
|
193
|
+
const mainFieldNames = ["name", "placeholder", "defaultValue"];
|
|
194
|
+
const errors = form.getFieldsError(mainFieldNames);
|
|
195
|
+
const hasMainFieldErrors = errors.some((error) => error.errors && error.errors.length > 0);
|
|
137
196
|
const values = form.getFieldsValue();
|
|
138
197
|
const nameFilled = !!(values.name && typeof values.name === 'string' && values.name.trim() !== '');
|
|
139
198
|
const placeholderFilled = !!(values.placeholder && typeof values.placeholder === 'string' && values.placeholder.trim() !== '');
|
|
140
|
-
|
|
199
|
+
const valid = nameFilled && placeholderFilled && !hasMainFieldErrors;
|
|
200
|
+
setIsFormValid(valid);
|
|
201
|
+
if (!valid) {
|
|
202
|
+
if (!nameFilled)
|
|
203
|
+
setDisabledReason("Name is required");
|
|
204
|
+
else if (!placeholderFilled)
|
|
205
|
+
setDisabledReason("Placeholder is required");
|
|
206
|
+
else if (hasMainFieldErrors) {
|
|
207
|
+
const firstError = errors.find((e) => { var _a; return ((_a = e.errors) === null || _a === void 0 ? void 0 : _a.length) > 0; });
|
|
208
|
+
setDisabledReason(((_a = firstError === null || firstError === void 0 ? void 0 : firstError.errors) === null || _a === void 0 ? void 0 : _a[0]) ? `Fix error: ${firstError.errors[0]}` : "Please fix the form errors above");
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
setDisabledReason(null);
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
setDisabledReason(null);
|
|
141
215
|
}, 100);
|
|
142
216
|
}, [field, form]);
|
|
143
217
|
// Update defaultValueInput whenever form values change
|
|
@@ -147,7 +221,6 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
147
221
|
const defaultName = currentInputType === null || currentInputType === void 0 ? void 0 : currentInputType.defaultName;
|
|
148
222
|
const options = ((_a = formValues.options) === null || _a === void 0 ? void 0 : _a.filter((opt) => (opt === null || opt === void 0 ? void 0 : opt.label) && (opt === null || opt === void 0 ? void 0 : opt.value))) || [];
|
|
149
223
|
const settings = formValues.inputTypeSettings || {};
|
|
150
|
-
// For SELECT/RADIO/CHECKBOX fields, only show Default Value when options exist
|
|
151
224
|
const isOptionsBasedField = includes([InputTypes.SELECT, InputTypes.CHECKBOX, InputTypes.RADIO], defaultName);
|
|
152
225
|
if (isOptionsBasedField && options.length === 0) {
|
|
153
226
|
// Don't show Default Value field if no options exist
|
|
@@ -185,6 +258,24 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
185
258
|
},
|
|
186
259
|
});
|
|
187
260
|
}
|
|
261
|
+
// Rule for NUMBERS: reject strings - only accept number type
|
|
262
|
+
if (defaultName === InputTypes.NUMBERS) {
|
|
263
|
+
rules.push({
|
|
264
|
+
validator: (_, value) => {
|
|
265
|
+
if (value === undefined || value === null || value === "") {
|
|
266
|
+
return Promise.resolve();
|
|
267
|
+
}
|
|
268
|
+
// Only accept actual number type - reject all strings
|
|
269
|
+
if (typeof value !== "number") {
|
|
270
|
+
return Promise.reject("Default value must be a number, not text");
|
|
271
|
+
}
|
|
272
|
+
if (isNaN(value) || !isFinite(value)) {
|
|
273
|
+
return Promise.reject("Default value must be a valid number");
|
|
274
|
+
}
|
|
275
|
+
return Promise.resolve();
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
}
|
|
188
279
|
// Rule for DATE and DATE_RANGE: check time part if allow time is selected
|
|
189
280
|
if ((defaultName === InputTypes.DATE ||
|
|
190
281
|
defaultName === InputTypes.DATE_RANGE) &&
|
|
@@ -196,9 +287,6 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
196
287
|
return Promise.resolve();
|
|
197
288
|
// For DATE
|
|
198
289
|
if (defaultName === InputTypes.DATE) {
|
|
199
|
-
// Check if value has time methods (dayjs object with time support)
|
|
200
|
-
// When showTime is enabled, dayjs object will have hour/minute/second methods
|
|
201
|
-
// 00:00:00 is a valid time, so we check for the presence of time methods, not non-zero values
|
|
202
290
|
const hasTimeMethods = value &&
|
|
203
291
|
typeof value.hour === "function" &&
|
|
204
292
|
typeof value.minute === "function" &&
|
|
@@ -213,8 +301,6 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
213
301
|
// For DATE_RANGE
|
|
214
302
|
if (defaultName === InputTypes.DATE_RANGE && Array.isArray(value)) {
|
|
215
303
|
const [start, end] = value;
|
|
216
|
-
// Check for presence of time methods, not non-zero values
|
|
217
|
-
// 00:00:00 is a valid time selection
|
|
218
304
|
const startHasTimeMethods = start &&
|
|
219
305
|
typeof start.hour === "function" &&
|
|
220
306
|
typeof start.minute === "function" &&
|
|
@@ -238,7 +324,7 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
238
324
|
const defaultValueItem = getFormItem(Object.assign(Object.assign({}, item), { additionalRules: rules }), true);
|
|
239
325
|
setDefaultValueInput(defaultValueItem);
|
|
240
326
|
};
|
|
241
|
-
return (_jsxs("div", { className: "md-lib-p-4", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx("h2", { className: "md-lib-text-xl md-lib-font-semibold", children: "Properties" }), _jsxs("p", { className: "md-lib-ml-auto md-lib-text-sm md-lib-truncate", style: { color: styles === null || styles === void 0 ? void 0 : styles.secondaryTextColor }, children: ["Type: ", get(field, "name", "N/A")] })] }), _jsx("div", { className: "md-lib-mt-4 md-lib-relative", children: _jsxs(Form, { layout: "vertical", form: form, requiredMark: true, scrollToFirstError: true, onFinish: onUpdate, initialValues: field, onValuesChange: handleFormValuesChange, className: "md-lib-pb-20", children: [_jsx(Form.Item, { name: "isMandatory", valuePropName: "checked", children: _jsx(Checkbox, { children: "Marks as mandatory field" }) }), _jsx(Form.Item, { name: "name", label: "
|
|
327
|
+
return (_jsxs("div", { className: "md-lib-p-4", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx("h2", { className: "md-lib-text-xl md-lib-font-semibold", children: "Properties" }), _jsxs("p", { className: "md-lib-ml-auto md-lib-text-sm md-lib-truncate", style: { color: styles === null || styles === void 0 ? void 0 : styles.secondaryTextColor }, children: ["Type: ", get(field, "name", "N/A")] })] }), _jsx("div", { className: "md-lib-mt-4 md-lib-relative", children: _jsxs(Form, { layout: "vertical", form: form, requiredMark: true, scrollToFirstError: true, onFinish: onUpdate, initialValues: field, onValuesChange: handleFormValuesChange, className: "md-lib-pb-20", children: [_jsx(Form.Item, { name: "isMandatory", valuePropName: "checked", children: _jsx(Checkbox, { children: "Marks as mandatory field" }) }), _jsx(Form.Item, { name: "name", label: "Name", rules: [
|
|
242
328
|
{ required: true, message: "Name is required" },
|
|
243
329
|
{
|
|
244
330
|
validator: (_, value) => {
|
|
@@ -249,12 +335,12 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
249
335
|
return Promise.reject("Name must be unique");
|
|
250
336
|
},
|
|
251
337
|
},
|
|
252
|
-
], children: _jsx(Input, { placeholder: "Enter name", className: "md-lib-h-12" }) }), _jsx(Form.Item, { label: "Placeholder", name: "placeholder", rules: [
|
|
338
|
+
], children: _jsx(Input, { placeholder: "Enter name", className: "md-lib-h-12", maxLength: 255, showCount: true }) }), _jsx(Form.Item, { label: "Placeholder", name: "placeholder", rules: [
|
|
253
339
|
{
|
|
254
340
|
required: true,
|
|
255
341
|
message: "Placeholder is required",
|
|
256
342
|
},
|
|
257
|
-
], children: _jsx(Input, { placeholder: "Enter Field Placeholder", className: "md-lib-h-12" }) }), defaultValueInput && defaultValueInput, _jsxs("div", { children: [!!get(currentInputType, "supportedTypes.length") && (_jsx("h3", { className: "md-lib-text-md md-lib-font-semibold md-lib-mb-2", children: "Field Validations" })), _jsxs(Form.Item, { name: "field_validations", children: [includes([InputTypes.PARAGRAPH, InputTypes.TEXT, InputTypes.LINK], get(currentInputType, "defaultName")) && (_jsx(TextField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), get(currentInputType, "defaultName") == InputTypes.NUMBERS && (_jsx(NumberField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), (get(currentInputType, "defaultName") == InputTypes.DATE ||
|
|
343
|
+
], children: _jsx(Input, { placeholder: "Enter Field Placeholder", className: "md-lib-h-12", maxLength: 255, showCount: true }) }), defaultValueInput && defaultValueInput, _jsxs("div", { children: [!!get(currentInputType, "supportedTypes.length") && (_jsx("h3", { className: "md-lib-text-md md-lib-font-semibold md-lib-mb-2", children: "Field Validations" })), _jsxs(Form.Item, { name: "field_validations", children: [includes([InputTypes.PARAGRAPH, InputTypes.TEXT, InputTypes.LINK], get(currentInputType, "defaultName")) && (_jsx(TextField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), get(currentInputType, "defaultName") == InputTypes.NUMBERS && (_jsx(NumberField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), (get(currentInputType, "defaultName") == InputTypes.DATE ||
|
|
258
344
|
get(currentInputType, "defaultName") ==
|
|
259
345
|
InputTypes.DATE_RANGE) && (_jsx(DateField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), includes([
|
|
260
346
|
InputTypes.SELECT,
|
|
@@ -262,12 +348,12 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
262
348
|
InputTypes.TEAM,
|
|
263
349
|
InputTypes.CHECKBOX,
|
|
264
350
|
InputTypes.RADIO,
|
|
265
|
-
], get(currentInputType, "defaultName")) && (_jsx(OptionsField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []), currentInputType: currentInputType }))] })] }), _jsxs(Form.Item, { className: "md-lib-flex md-lib-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
351
|
+
], get(currentInputType, "defaultName")) && (_jsx(OptionsField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []), currentInputType: currentInputType }))] })] }), _jsxs(Form.Item, { className: "md-lib-flex md-lib-flex-col md-lib-items-end md-lib-absolute md-lib-bottom-0 md-lib-right-0 md-lib-pr-4 md-lib-pb-4", children: [disabledReason && (_jsxs("p", { className: "md-lib-text-sm md-lib-mb-2 md-lib-mr-2", style: { color: styles === null || styles === void 0 ? void 0 : styles.secondaryTextColor }, children: ["Update disabled: ", disabledReason] })), _jsxs("div", { className: "md-lib-flex md-lib-items-center", children: [_jsx(Button, { color: "primary", variant: "text", onClick: () => {
|
|
352
|
+
if (onCancel && index !== null) {
|
|
353
|
+
onCancel(index);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
setCurrentFieldIndex(null);
|
|
357
|
+
}
|
|
358
|
+
}, size: "large", children: "Cancel" }), _jsx(Button, { color: "primary", htmlType: "submit", className: "md-lib-ml-2 md-lib-border-primaryColor md-lib-text-primaryColor", size: "large", loading: loading, disabled: !isFormValid || loading, title: disabledReason || undefined, children: "Update" })] })] })] }) })] }));
|
|
273
359
|
}
|
|
@@ -55,7 +55,6 @@ export default function CreateOrEditAssetTemplate() {
|
|
|
55
55
|
try {
|
|
56
56
|
const response = yield api.get(FETCH_INPUT_TYPES_URL);
|
|
57
57
|
const filteredData = (_a = get(response, "data", [])) === null || _a === void 0 ? void 0 : _a.filter((input) => get(input, "defaultName") !== InputTypes.PERSON);
|
|
58
|
-
// Sort widgets alphabetically by name
|
|
59
58
|
const sortedData = filteredData === null || filteredData === void 0 ? void 0 : filteredData.sort((a, b) => {
|
|
60
59
|
const nameA = get(a, "name", "").toLowerCase();
|
|
61
60
|
const nameB = get(b, "name", "").toLowerCase();
|
|
@@ -47,7 +47,6 @@ export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
|
|
|
47
47
|
const navigate = useAppNavigate();
|
|
48
48
|
const damConfig = useDamConfig();
|
|
49
49
|
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
50
|
-
// Track original values for change detection
|
|
51
50
|
const originalName = useMemo(() => get(assetTemplate, "name", ""), [assetTemplate]);
|
|
52
51
|
const originalDescription = useMemo(() => get(assetTemplate, "description", ""), [assetTemplate]);
|
|
53
52
|
const originalFields = useMemo(() => get(assetTemplate, "metadataFields", []), [assetTemplate]);
|
|
@@ -69,23 +68,18 @@ export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
|
|
|
69
68
|
});
|
|
70
69
|
}, [assetTemplate]);
|
|
71
70
|
const { name, description, currentFieldIndex, fields, loading, showOutputFormat, imagePickerOutputFormat, imagePickerOutputFormatError, } = state;
|
|
72
|
-
// Check if there are changes to name or description
|
|
73
71
|
const hasNameOrDescriptionChanges = useMemo(() => {
|
|
74
72
|
return name.trim() !== originalName.trim() ||
|
|
75
73
|
description.trim() !== originalDescription.trim();
|
|
76
74
|
}, [name, description, originalName, originalDescription]);
|
|
77
|
-
// Check if there are changes to fields
|
|
78
75
|
const hasFieldChanges = useMemo(() => {
|
|
79
76
|
if (fields.length !== originalFields.length)
|
|
80
77
|
return true;
|
|
81
|
-
// Simple comparison - can be enhanced if needed
|
|
82
78
|
return JSON.stringify(fields) !== JSON.stringify(originalFields);
|
|
83
79
|
}, [fields, originalFields]);
|
|
84
|
-
// Check if there are changes to imagePickerOutputFormat
|
|
85
80
|
const hasImagePickerOutputFormatChanges = useMemo(() => {
|
|
86
81
|
return JSON.stringify(imagePickerOutputFormat) !== JSON.stringify(originalImagePickerOutputFormat);
|
|
87
82
|
}, [imagePickerOutputFormat, originalImagePickerOutputFormat]);
|
|
88
|
-
// Enable save button if there are changes and no field is being edited
|
|
89
83
|
const canSave = hasNameOrDescriptionChanges || hasFieldChanges || hasImagePickerOutputFormatChanges;
|
|
90
84
|
const transformInputTypePayload = (updatedValues, field, mapId) => {
|
|
91
85
|
const supportedTypes = get(field, "supportedTypes", []);
|
|
@@ -35,8 +35,6 @@ import { EMPTY_ASSET_TEMPLATE_WIDGETS_URL } from "../utilities/constants/imageUr
|
|
|
35
35
|
import _ from "lodash";
|
|
36
36
|
import useAppParams from "../utilities/useAppParams";
|
|
37
37
|
export const getWidgetIcon = (defaultName) => {
|
|
38
|
-
// Guard against undefined, null, or non-string values
|
|
39
|
-
// Use explicit checks and ensure we have a valid string before calling toUpperCase
|
|
40
38
|
if (defaultName === undefined || defaultName === null) {
|
|
41
39
|
return null;
|
|
42
40
|
}
|
|
@@ -254,14 +252,12 @@ export default function FieldsSection({ name, inputTypes, transformInputTypePayl
|
|
|
254
252
|
: `selected-${index}`}`)))) }), provided.placeholder] }))) }) }), !!currentField && !showOutputFormat && (_jsx("div", { className: "md-lib-col-span-1 md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor", children: _jsx(AddFieldProperties, { field: currentField, index: currentFieldIndex, setCurrentFieldIndex: (val) => setCurrentFieldIndex(val), onUpdateField: (updatedValues, field, index) => onUpdateField(updatedValues, field, index), currentInputType: currentInputType, allFields: fields, onCancel: (index) => {
|
|
255
253
|
if (index !== null) {
|
|
256
254
|
const fieldToCancel = fields[index];
|
|
257
|
-
// If field doesn't have _id, it's a new unsaved field - remove it
|
|
258
255
|
if (!get(fieldToCancel, "_id")) {
|
|
259
256
|
const updatedFields = filter(fields, (field, i) => i !== index);
|
|
260
257
|
const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field) => get(field, "mapId") !== get(fieldToCancel, "mapId"));
|
|
261
258
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
|
|
262
259
|
}
|
|
263
260
|
else {
|
|
264
|
-
// Existing field - just close the properties panel
|
|
265
261
|
setCurrentFieldIndex(null);
|
|
266
262
|
}
|
|
267
263
|
}
|
|
@@ -91,11 +91,9 @@ export const getFormItem = (item, fromDefaultValue, userOptions) => {
|
|
|
91
91
|
message = `Maximum ${max} characters allowed.`;
|
|
92
92
|
}
|
|
93
93
|
rules.push(Object.assign(Object.assign(Object.assign({}, (hasMin ? { min } : {})), (hasMax ? { max } : {})), { message }));
|
|
94
|
-
// Set maxLength for Input/TextArea components - use configured max or default to 255
|
|
95
94
|
if (hasMax && isNumber(max)) {
|
|
96
95
|
maxLength = max;
|
|
97
96
|
}
|
|
98
|
-
// If character limit is enabled but no max is set, keep default 255
|
|
99
97
|
}
|
|
100
98
|
// REGEX
|
|
101
99
|
if (get(settings, "REGEX.allow") && get(settings, "REGEX.value")) {
|