@engagebay/engagebay-form-module 1.0.8-beta.5 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engagebay/engagebay-form-module",
3
- "version": "1.0.8-beta.5",
3
+ "version": "1.0.8-beta.6",
4
4
  "description": "Provide base form components to reacho",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -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) => {
@@ -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
+ };