diff --git a/example/src/Onboarding.tsx b/example/src/Onboarding.tsx
index 76a3a355..7f3ea2eb 100644
--- a/example/src/Onboarding.tsx
+++ b/example/src/Onboarding.tsx
@@ -436,6 +436,10 @@ const OnboardingWithProps = ({
// Nigeria
contract_details: 2,
},
+ NLD: {
+ // Netherlands
+ contract_details: 2,
+ },
NOR: {
// Norway
contract_details: 2,
diff --git a/src/components/form/fields/ForcedValueField.tsx b/src/components/form/fields/ForcedValueField.tsx
index 8e77f057..fb43648e 100644
--- a/src/components/form/fields/ForcedValueField.tsx
+++ b/src/components/form/fields/ForcedValueField.tsx
@@ -1,39 +1,9 @@
import { useFormContext } from 'react-hook-form';
import { sanitizeHtml } from '@/src/lib/utils';
import { useEffect } from 'react';
-import { ZendeskTriggerButton } from '@/src/components/shared/zendesk-drawer/ZendeskTriggerButton';
-
-const Description = ({
- name,
- description,
- helpCenter,
-}: {
- name: string;
- description: string;
- helpCenter?: {
- callToAction: string;
- id: number;
- url: string;
- label: string;
- };
-}) => {
- return (
-
-
- {helpCenter?.callToAction && helpCenter?.id && (
-
- {helpCenter.callToAction}
-
- )}
-
- );
-};
+import { HelpCenterDataProps } from '@/src/types/fields';
+import { BaseFormDescription as Description } from '@/src/components/ui/form';
+import { HelpCenter } from '@/src/components/shared/zendesk-drawer/HelpCenter';
export type ForcedValueFieldProps = {
name: string;
@@ -44,12 +14,7 @@ export type ForcedValueFieldProps = {
description?: string;
};
label: string;
- helpCenter?: {
- callToAction: string;
- id: number;
- url: string;
- label: string;
- };
+ helpCenter?: HelpCenterDataProps;
};
export function ForcedValueField({
@@ -61,40 +26,54 @@ export function ForcedValueField({
helpCenter,
}: ForcedValueFieldProps) {
const { setValue } = useFormContext();
- const descriptionSanitized = sanitizeHtml(
- statement?.description || description,
- );
+ const forcedValueDescription = statement?.description || description;
- const titleSanitized = statement?.title
+ const forcedValueTitle = statement?.title
? sanitizeHtml(statement?.title)
: sanitizeHtml(label);
+ const titleId = `forced-value-${name}-title`;
+ const descriptionId = `forced-value-${name}-description`;
+
useEffect(() => {
setValue(name, value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- const isHiddenValue = !descriptionSanitized && !statement?.title;
+ const isHiddenValue = !forcedValueDescription && !statement?.title;
if (isHiddenValue) {
return null;
}
return (
-
- {titleSanitized && (
+
+ {forcedValueTitle && (
)}
+ as='span'
+ id={descriptionId}
+ className={`text-xs RemoteFlows__ForcedValue__Description__${name}`}
+ helpCenter={
+
+ }
+ >
+ {forcedValueDescription}
+
);
}
diff --git a/src/components/shared/zendesk-drawer/HelpCenter.tsx b/src/components/shared/zendesk-drawer/HelpCenter.tsx
index f0fe47a6..e088df73 100644
--- a/src/components/shared/zendesk-drawer/HelpCenter.tsx
+++ b/src/components/shared/zendesk-drawer/HelpCenter.tsx
@@ -3,15 +3,16 @@ import { HelpCenterDataProps } from '@/src/types/fields';
type HelpCenterProps = {
helpCenter?: HelpCenterDataProps;
+ className?: string;
};
-export function HelpCenter({ helpCenter }: HelpCenterProps) {
+export function HelpCenter({ helpCenter, className }: HelpCenterProps) {
if (!helpCenter || !helpCenter.id || !helpCenter.callToAction) {
return null;
}
return (
-
+
{helpCenter.callToAction}
);
diff --git a/src/components/ui/form.tsx b/src/components/ui/form.tsx
index e485d381..377291f0 100644
--- a/src/components/ui/form.tsx
+++ b/src/components/ui/form.tsx
@@ -131,26 +131,26 @@ const FormControl = React.forwardRef<
FormControl.displayName = 'FormControl';
-function FormDescription({
+export function BaseFormDescription({
helpCenter,
className,
children,
as,
+ id,
...props
}: React.ComponentProps<'p'> & {
helpCenter?: React.ReactNode;
children?: React.ReactNode | (() => React.ReactNode);
as?: T;
-} & Omit, 'children' | 'className'>) {
- const { formDescriptionId } = useFormField();
+ id?: string;
+} & Omit, 'children' | 'className' | 'id'>) {
const Component = as || 'p';
-
if (typeof children === 'string') {
return (
<>
({
>
);
}
-
return (
{typeof children === 'function' ? children() : children}
@@ -176,6 +175,17 @@ function FormDescription({
);
}
+function FormDescription({
+ ...props
+}: React.ComponentProps<'p'> & {
+ helpCenter?: React.ReactNode;
+ children?: React.ReactNode | (() => React.ReactNode);
+ as?: T;
+} & Omit, 'children' | 'className' | 'id'>) {
+ const { formDescriptionId } = useFormField();
+ return ;
+}
+
function FormMessage({ className, ...props }: React.ComponentProps<'p'>) {
const { error, formMessageId } = useFormField();
const body = error ? String(error?.message ?? '') : props.children;