@engagebay/engagebay-form-module 1.0.8-beta.4 → 1.0.8-beta.6
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
|
@@ -10,6 +10,7 @@ import React from "react";
|
|
|
10
10
|
import RenderFormField from "../util/RenderFormField";
|
|
11
11
|
import clsx from "clsx";
|
|
12
12
|
import { XMarkIcon } from "@heroicons/react/20/solid";
|
|
13
|
+
import { normalizeFileFieldUrls } from "../util/normalizeCustomFieldValues";
|
|
13
14
|
const FileUploadField: React.FC<FormFieldComponentPropSchema> = (
|
|
14
15
|
props: FormFieldComponentPropSchema
|
|
15
16
|
) => {
|
|
@@ -127,7 +128,7 @@ const FileUploadField: React.FC<FormFieldComponentPropSchema> = (
|
|
|
127
128
|
) : (
|
|
128
129
|
<div className="flex">
|
|
129
130
|
<span className="m-2 max-w-xs truncate">
|
|
130
|
-
{file?.name || file?.toString?.() || ''}
|
|
131
|
+
{normalizeFileFieldUrls(file?.name || file?.toString?.() || '')}
|
|
131
132
|
</span>{" "}
|
|
132
133
|
<button
|
|
133
134
|
onClick={(e) => {
|
|
@@ -199,7 +199,12 @@ const Typeahead2: React.FC<FormFieldComponentPropSchema> = (
|
|
|
199
199
|
: result.includes(resData.value)
|
|
200
200
|
? [...result.filter((v: string) => v != resData.value), resData.value]
|
|
201
201
|
: [...result, resData.value];
|
|
202
|
-
|
|
202
|
+
handleChange(
|
|
203
|
+
result,
|
|
204
|
+
formContext,
|
|
205
|
+
props.fieldConfig,
|
|
206
|
+
props.onChange,
|
|
207
|
+
);
|
|
203
208
|
};
|
|
204
209
|
|
|
205
210
|
const getInput = () => {
|
|
@@ -121,3 +121,29 @@ export const normalizeMultiSelectValueForStringArrayValues = (fieldConfig: FormF
|
|
|
121
121
|
return value;
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
+
|
|
125
|
+
export const normalizeFileFieldUrls = (value: any): string[] => {
|
|
126
|
+
if (value == null) return [];
|
|
127
|
+
|
|
128
|
+
if (Array.isArray(value)) {
|
|
129
|
+
return value.map((v) => String(v).trim()).filter(Boolean);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (typeof value === 'string') {
|
|
133
|
+
const s = value.trim();
|
|
134
|
+
if (!s || s === '[]') return [];
|
|
135
|
+
if (s.startsWith('[')) {
|
|
136
|
+
try {
|
|
137
|
+
const parsed = JSON.parse(s);
|
|
138
|
+
if (Array.isArray(parsed)) {
|
|
139
|
+
return parsed.map((v) => String(v).trim()).filter(Boolean);
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
// fall through — treat as single URL
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return [s];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return [];
|
|
149
|
+
};
|