@engagebay/engagebay-form-module 1.0.8-beta.2 → 1.0.8-beta.4
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
|
@@ -9,6 +9,7 @@ import { Description } from "@headlessui/react";
|
|
|
9
9
|
import React from "react";
|
|
10
10
|
import RenderFormField from "../util/RenderFormField";
|
|
11
11
|
import clsx from "clsx";
|
|
12
|
+
import { XMarkIcon } from "@heroicons/react/20/solid";
|
|
12
13
|
const FileUploadField: React.FC<FormFieldComponentPropSchema> = (
|
|
13
14
|
props: FormFieldComponentPropSchema
|
|
14
15
|
) => {
|
|
@@ -103,7 +104,7 @@ const FileUploadField: React.FC<FormFieldComponentPropSchema> = (
|
|
|
103
104
|
<Description>Loading...</Description>
|
|
104
105
|
) : (
|
|
105
106
|
props.fieldConfig.fieldContainer ? <props.fieldConfig.fieldContainer /> :
|
|
106
|
-
<div className={"flex flex-col items-center justify-center pt-5 pb-6"}>
|
|
107
|
+
<div className={"flex flex-col items-center justify-center pt-5 pb-6 px-2"}>
|
|
107
108
|
{file ? (
|
|
108
109
|
<>
|
|
109
110
|
{isImageFile(file) ? (
|
|
@@ -125,19 +126,19 @@ const FileUploadField: React.FC<FormFieldComponentPropSchema> = (
|
|
|
125
126
|
</div>
|
|
126
127
|
) : (
|
|
127
128
|
<div className="flex">
|
|
128
|
-
<span className="m-2">
|
|
129
|
-
|
|
129
|
+
<span className="m-2 max-w-xs truncate">
|
|
130
|
+
{file?.name || file?.toString?.() || ''}
|
|
130
131
|
</span>{" "}
|
|
131
132
|
<button
|
|
132
133
|
onClick={(e) => {
|
|
133
134
|
e.preventDefault();
|
|
134
135
|
formContext.setValue(
|
|
135
|
-
props.fieldConfig.name,
|
|
136
|
+
props.fieldConfig.name,null
|
|
136
137
|
);
|
|
137
138
|
setFile(null);
|
|
138
139
|
}}
|
|
139
|
-
className="btn btn-
|
|
140
|
-
|
|
140
|
+
className="btn btn-sm ">
|
|
141
|
+
<XMarkIcon className="w-3.5 h-3.5 text-gray-800"/>
|
|
141
142
|
</button>
|
|
142
143
|
</div>
|
|
143
144
|
)}
|
|
@@ -243,7 +243,7 @@ export class FormFieldPatternsImpl implements FormFieldPatterns {
|
|
|
243
243
|
static readonly EMAIL = new FormFieldPatternsImpl(
|
|
244
244
|
"EMAIL",
|
|
245
245
|
"Please enter a valid email address",
|
|
246
|
-
/^([
|
|
246
|
+
/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i
|
|
247
247
|
);
|
|
248
248
|
// static readonly PASSWORD = new FormFieldPatternsImpl(
|
|
249
249
|
// "PASSWORD",
|
|
@@ -11,14 +11,14 @@ import { handleChange } from ".";
|
|
|
11
11
|
import { LoaderWithText } from "../../util/LoaderWithText";
|
|
12
12
|
import SVGIcon from "../../util/svg/SVGIcon";
|
|
13
13
|
import { FormContextType } from "../context/FormContext";
|
|
14
|
+
import Tippy from "@tippyjs/react";
|
|
14
15
|
import {
|
|
15
16
|
FieldOptionsSchema,
|
|
16
17
|
FormFieldSchema,
|
|
17
18
|
FormFieldType,
|
|
18
19
|
OutputFormatType,
|
|
19
20
|
} from "../schema/FormFieldSchema";
|
|
20
|
-
import
|
|
21
|
-
import { normalizeMultiSelectValue } from "./normalizeCustomFieldValues";
|
|
21
|
+
import { normalizeMultiSelectValue, normalizeMultiSelectValueForStringArrayValues } from "./normalizeCustomFieldValues";
|
|
22
22
|
type RenderListOptionsProps = {
|
|
23
23
|
formContext: FormContextType;
|
|
24
24
|
fieldConfig: FormFieldSchema;
|
|
@@ -373,7 +373,7 @@ export function renderListBoxValue(
|
|
|
373
373
|
listOptions: FieldOptionsSchema[],
|
|
374
374
|
onChange?: (value: any) => void,
|
|
375
375
|
): JSX.Element {
|
|
376
|
-
let value =
|
|
376
|
+
let value = normalizeMultiSelectValueForStringArrayValues(fieldConfig, formContext.getValues(fieldConfig.name));
|
|
377
377
|
const renderAsString = () => {
|
|
378
378
|
// if (!listOptions) {
|
|
379
379
|
// return value;
|
|
@@ -476,7 +476,7 @@ export function renderListBoxValue(
|
|
|
476
476
|
if (!value && !listOptions) {
|
|
477
477
|
return getPlaceholder();
|
|
478
478
|
}
|
|
479
|
-
if (
|
|
479
|
+
if (Array.isArray(value)) {
|
|
480
480
|
return renderAsArray();
|
|
481
481
|
}
|
|
482
482
|
return renderAsString();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import moment from "moment";
|
|
2
|
+
import { FormFieldSchema, OutputFormatType } from "../schema/FormFieldSchema";
|
|
2
3
|
|
|
3
4
|
const normalizeStringToken = (value: unknown): string => {
|
|
4
5
|
return typeof value === "string" ? value.trim() : String(value).trim();
|
|
@@ -113,3 +114,10 @@ export const normalizeDateInputValue = (
|
|
|
113
114
|
};
|
|
114
115
|
|
|
115
116
|
|
|
117
|
+
export const normalizeMultiSelectValueForStringArrayValues = (fieldConfig: FormFieldSchema, value: any): string[] => {
|
|
118
|
+
if (fieldConfig.outputFormat === OutputFormatType.STRING) {
|
|
119
|
+
return normalizeMultiSelectValue(value);
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
};
|
|
123
|
+
|