Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

form fields now support tooltip termid

aashub600e616ef8e
diff --git a/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx b/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
index a3e00f8084..549349fbdb 100644
--- a/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
@@ -1,4 +1,3 @@
-import { LabelWithHelp } from "@carbon/field-help";
import { ValidatedForm } from "@carbon/form";
import {
Button,
@@ -100,19 +99,13 @@ const CostCenterForm = ({
<Input name="name" label="Cost Center Name" />
<CostCenter
name="parentCostCenterId"
- label={
- <LabelWithHelp termId="parent-cost-center">
- Parent Cost Center
- </LabelWithHelp>
- }
+ label="Parent Cost Center"
+ termId="parent-cost-center"
/>
<Employee
name="ownerId"
- label={
- <LabelWithHelp termId="cost-center-owner">
- Owner
- </LabelWithHelp>
- }
+ label="Owner"
+ termId="cost-center-owner"
isOptional={!approvalsActive}
/>
<CustomFormFields table="costCenter" />
diff --git a/packages/form/package.json b/packages/form/package.json
index 91f31052c5..53bf463463 100644
--- a/packages/form/package.json
+++ b/packages/form/package.json
@@ -25,6 +25,8 @@
"vitest": "catalog:"
},
"dependencies": {
+ "@carbon/field-help": "workspace:*",
+ "@carbon/glossary": "workspace:*",
"@internationalized/date": "catalog:",
"@react-aria/i18n": "catalog:",
"cookie": "catalog:",
diff --git a/packages/form/src/components/Array.tsx b/packages/form/src/components/Array.tsx
index 3d35bf4902..24ae3083ea 100644
--- a/packages/form/src/components/Array.tsx
+++ b/packages/form/src/components/Array.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -18,7 +20,8 @@ import { useFieldArray } from "../internal/state/fieldArray";
type FormArrayProps = InputProps & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isRequired?: boolean;
};
@@ -27,6 +30,7 @@ const Array = forwardRef<HTMLInputElement, FormArrayProps>(
{
name,
label,
+ termId,
isRequired,
isDisabled: isDisabledProp,
isReadOnly: isReadOnlyProp,
@@ -55,7 +59,7 @@ const Array = forwardRef<HTMLInputElement, FormArrayProps>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={`${name}`} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<VStack className="mb-4" ref={listRef}>
diff --git a/packages/form/src/components/ArrayNumeric.tsx b/packages/form/src/components/ArrayNumeric.tsx
index 85af21aad6..4d364f5e7c 100644
--- a/packages/form/src/components/ArrayNumeric.tsx
+++ b/packages/form/src/components/ArrayNumeric.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -24,7 +26,8 @@ import { useFieldArray } from "../internal/state/fieldArray";
type FormArrayNumericProps = InputProps & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isRequired?: boolean;
defaults?: number[];
};
@@ -34,6 +37,7 @@ const ArrayNumeric = forwardRef<HTMLInputElement, FormArrayNumericProps>(
{
name,
label,
+ termId,
isDisabled: isDisabledProp,
isReadOnly: isReadOnlyProp,
isRequired,
@@ -65,7 +69,7 @@ const ArrayNumeric = forwardRef<HTMLInputElement, FormArrayNumericProps>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={`${name}`} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<VStack className="mb-4" ref={listRef}>
diff --git a/packages/form/src/components/Boolean.tsx b/packages/form/src/components/Boolean.tsx
index b84bb013b2..de680ae599 100644
--- a/packages/form/src/components/Boolean.tsx
+++ b/packages/form/src/components/Boolean.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import {
cn,
FormControl,
@@ -16,7 +18,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormBooleanProps = {
name: string;
variant?: "large" | "small";
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
value?: boolean;
helperText?: string;
isDisabled?: boolean;
@@ -31,6 +34,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
{
name,
label,
+ termId,
description,
helperText,
onChange,
@@ -68,7 +72,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
htmlFor={name}
className="text-sm text-foreground cursor-pointer"
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</Label>
)}
{description && (
@@ -85,11 +89,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
setValue(checked);
onChange?.(checked);
}}
- // `aria-label` requires a plain string; when `label` is JSX
- // (e.g. wrapped in a `<LabelWithHelp>`), there's no sensible
- // single-string accessible name to derive — fall back to the
- // associated `<FormLabel>` for accessibility.
- aria-label={typeof label === "string" ? label : undefined}
+ aria-label={label}
{...props}
/>
</HStack>
@@ -106,7 +106,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
<FormControl isInvalid={!!error} className={cn("pt-2", className)}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<HStack>
@@ -119,7 +119,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
setValue(checked);
onChange?.(checked);
}}
- aria-label={typeof label === "string" ? label : undefined}
+ aria-label={label}
{...props}
/>
{description && (
diff --git a/packages/form/src/components/Choice.tsx b/packages/form/src/components/Choice.tsx
index e88ec9df7c..9faf99e758 100644
--- a/packages/form/src/components/Choice.tsx
+++ b/packages/form/src/components/Choice.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import { cn, RadioGroup, RadioGroupItem } from "@carbon/react";
import type { ReactNode } from "react";
@@ -20,7 +22,9 @@ export type ChoiceCardOption<V extends string = string> = {
type ChoiceCardGroupProps<V extends string = string> = {
/** Optional small label rendered above the stack of cards. */
- label?: React.ReactNode;
+ label?: string;
+ /** Glossary term id; renders a help-icon tooltip next to the label. */
+ termId?: TermId;
/** Currently selected value. */
value: V;
/** Called with the new value when the user picks a different card. */
@@ -51,6 +55,7 @@ type ChoiceCardGroupProps<V extends string = string> = {
*/
export function ChoiceCardGroup<V extends string = string>({
label,
+ termId,
value,
onChange,
options,
@@ -60,7 +65,7 @@ export function ChoiceCardGroup<V extends string = string>({
<div className={cn("space-y-2 w-full", className)}>
{label && (
<span className="text-xs font-medium text-muted-foreground">
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</span>
)}
<RadioGroup
diff --git a/packages/form/src/components/Combobox.tsx b/packages/form/src/components/Combobox.tsx
index 09a2b2c767..15332cde7d 100644
--- a/packages/form/src/components/Combobox.tsx
+++ b/packages/form/src/components/Combobox.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { ComboboxProps as ComboboxBaseProps } from "@carbon/react";
import {
Combobox as ComboboxBase,
@@ -13,7 +15,8 @@ import { useFormStateContext } from "../internal/formStateContext";
export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isLoading?: boolean;
isOptional?: boolean;
isRequired?: boolean;
@@ -34,6 +37,7 @@ export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {
const Combobox = ({
name,
label,
+ termId,
isLoading = false,
isOptional,
isRequired,
@@ -65,7 +69,7 @@ const Combobox = ({
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/packages/form/src/components/CreatableCombobox.tsx b/packages/form/src/components/CreatableCombobox.tsx
index 5e1b53d0cc..0a9f7175fc 100644
--- a/packages/form/src/components/CreatableCombobox.tsx
+++ b/packages/form/src/components/CreatableCombobox.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { CreatableComboboxProps as CreatableComboboxBaseProps } from "@carbon/react";
import {
CreatableCombobox as CreatableComboboxBase,
@@ -19,7 +21,8 @@ export type CreatableComboboxProps = Omit<
autoSelectSingleOption?: boolean;
isClearable?: boolean;
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
@@ -41,6 +44,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
isClearable,
name,
label,
+ termId,
helperText,
isConfigured = false,
isOptional,
@@ -94,7 +98,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
onConfigure={onConfigure}
isOptional={resolvedIsOptional}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/packages/form/src/components/CreatableMultiSelect.tsx b/packages/form/src/components/CreatableMultiSelect.tsx
index c0f125c063..4176b65640 100644
--- a/packages/form/src/components/CreatableMultiSelect.tsx
+++ b/packages/form/src/components/CreatableMultiSelect.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { CreatableMultiSelectProps as CreatableMultiSelectBaseProps } from "@carbon/react";
import {
CreatableMultiSelect as CreatableMultiSelectBase,
@@ -16,7 +18,8 @@ export type CreatableMultiSelectProps = Omit<
"onChange" | "value"
> & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
helperText?: string;
isOptional?: boolean;
value?: string[];
@@ -26,77 +29,84 @@ export type CreatableMultiSelectProps = Omit<
const CreatableMultiSelect = forwardRef<
HTMLButtonElement,
CreatableMultiSelectProps
->(({ name, label, helperText, isOptional, options = [], ...props }, ref) => {
- const { error, isOptional: fieldIsOptional } = useField(name);
- const [value, setValue] = useControlField<string[] | undefined>(name);
- const formState = useFormStateContext();
- const isReadOnly =
- formState.isReadOnly || formState.isDisabled || props.isReadOnly;
- const resolvedIsOptional = isOptional ?? fieldIsOptional ?? false;
+>(
+ (
+ { name, label, termId, helperText, isOptional, options = [], ...props },
+ ref
+ ) => {
+ const { error, isOptional: fieldIsOptional } = useField(name);
+ const [value, setValue] = useControlField<string[] | undefined>(name);
+ const formState = useFormStateContext();
+ const isReadOnly =
+ formState.isReadOnly || formState.isDisabled || props.isReadOnly;
+ const resolvedIsOptional = isOptional ?? fieldIsOptional ?? false;
- useEffect(() => {
- if (props.value !== null && props.value !== undefined)
- setValue(props.value);
- }, [props.value, setValue]);
+ useEffect(() => {
+ if (props.value !== null && props.value !== undefined)
+ setValue(props.value);
+ }, [props.value, setValue]);
- const onChange = (value: string[]) => {
- setValue(value);
- props.onChange?.(value);
- };
+ const onChange = (value: string[]) => {
+ setValue(value);
+ props.onChange?.(value);
+ };
- const sortedOptions = useMemo(() => {
- // Split options into selected and unselected
- const selectedOptions = options.filter((opt) => value?.includes(opt.value));
- const unselectedOptions = options.filter(
- (opt) => !value?.includes(opt.value)
- );
+ const sortedOptions = useMemo(() => {
+ // Split options into selected and unselected
+ const selectedOptions = options.filter((opt) =>
+ value?.includes(opt.value)
+ );
+ const unselectedOptions = options.filter(
+ (opt) => !value?.includes(opt.value)
+ );
- // Sort unselected options alphabetically by label
- const sortedUnselected = [...unselectedOptions].sort((a, b) =>
- a.label.localeCompare(b.label)
- );
+ // Sort unselected options alphabetically by label
+ const sortedUnselected = [...unselectedOptions].sort((a, b) =>
+ a.label.localeCompare(b.label)
+ );
- // Combine selected options first, followed by sorted unselected options
- return [...selectedOptions, ...sortedUnselected];
- }, [options, value]);
+ // Combine selected options first, followed by sorted unselected options
+ return [...selectedOptions, ...sortedUnselected];
+ }, [options, value]);
- return (
- <FormControl isInvalid={!!error}>
- {label && (
- <FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
- </FormLabel>
- )}
- {(value ?? []).filter(Boolean).map((selection, index) => (
- <input
- key={`${name}[${index}]`}
- type="hidden"
- name={`${name}[${index}]`}
- value={selection}
+ return (
+ <FormControl isInvalid={!!error}>
+ {label && (
+ <FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
+ </FormLabel>
+ )}
+ {(value ?? []).filter(Boolean).map((selection, index) => (
+ <input
+ key={`${name}[${index}]`}
+ type="hidden"
+ name={`${name}[${index}]`}
+ value={selection}
+ />
+ ))}
+ <CreatableMultiSelectBase
+ ref={ref}
+ {...props}
+ options={sortedOptions}
+ value={value ?? []}
+ onChange={(newValue) => {
+ setValue(newValue ?? []);
+ onChange(newValue ?? []);
+ }}
+ isReadOnly={isReadOnly}
+ label={label}
+ className="w-full"
/>
- ))}
- <CreatableMultiSelectBase
- ref={ref}
- {...props}
- options={sortedOptions}
- value={value ?? []}
- onChange={(newValue) => {
- setValue(newValue ?? []);
- onChange(newValue ?? []);
- }}
- isReadOnly={isReadOnly}
- label={label}
- className="w-full"
- />
- {error ? (
- <FormErrorMessage>{error}</FormErrorMessage>
- ) : (
- helperText && <FormHelperText>{helperText}</FormHelperText>
- )}
- </FormControl>
- );
-});
+ {error ? (
+ <FormErrorMessage>{error}</FormErrorMessage>
+ ) : (
+ helperText && <FormHelperText>{helperText}</FormHelperText>
+ )}
+ </FormControl>
+ );
+ }
+);
CreatableMultiSelect.displayName = "CreatableMultiSelect";
diff --git a/packages/form/src/components/DatePicker.tsx b/packages/form/src/components/DatePicker.tsx
index 72700485b8..d14b3e5a04 100644
--- a/packages/form/src/components/DatePicker.tsx
+++ b/packages/form/src/components/DatePicker.tsx
@@ -1,4 +1,6 @@
+import { LabelWithHelp } from "@carbon/field-help";
import { useFormContext } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import {
DatePicker as DatePickerBase,
FormControl,
@@ -16,7 +18,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type DatePickerProps = {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isDisabled?: boolean;
isRequired?: boolean;
minValue?: CalendarDate;
@@ -30,6 +33,7 @@ type DatePickerProps = {
const DatePicker = ({
name,
label,
+ termId,
isDisabled: isDisabledProp = false,
isRequired,
minValue,
@@ -98,7 +102,7 @@ const DatePicker = ({
htmlFor={name}
isOptional={isRequired ? false : (fieldIsOptional ?? false)}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input type="hidden" name={name} value={utcValue} />
diff --git a/packages/form/src/components/DateTimePicker.tsx b/packages/form/src/components/DateTimePicker.tsx
index 39d4b4e420..2aa7d1f364 100644
--- a/packages/form/src/components/DateTimePicker.tsx
+++ b/packages/form/src/components/DateTimePicker.tsx
@@ -1,4 +1,6 @@
+import { LabelWithHelp } from "@carbon/field-help";
import { useFormContext } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import {
DateTimePicker as DateTimePickerBase,
FormControl,
@@ -21,7 +23,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type DateTimePickerProps = {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
size?: "sm" | "md" | "lg";
isDisabled?: boolean;
minValue?: CalendarDateTime;
@@ -34,6 +37,7 @@ type DateTimePickerProps = {
const DateTimePicker = ({
name,
label,
+ termId,
size,
isDisabled: isDisabledProp = false,
minValue,
@@ -91,7 +95,7 @@ const DateTimePicker = ({
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input type="hidden" name={name} value={utcValue} />
diff --git a/packages/form/src/components/Input.tsx b/packages/form/src/components/Input.tsx
index ca88077ca9..081af853f1 100644
--- a/packages/form/src/components/Input.tsx
+++ b/packages/form/src/components/Input.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
FormControl,
@@ -18,6 +20,7 @@ import type { ValidationBehaviorOptions } from "../internal/getInputProps";
type FormInputProps = InputProps & {
name: string;
label?: ReactNode;
+ termId?: TermId;
isConfigured?: boolean;
isOptional?: boolean;
isRequired?: boolean;
@@ -34,6 +37,7 @@ const Input = forwardRef<HTMLInputElement, FormInputProps>(
{
name,
label,
+ termId,
isConfigured,
isOptional,
isRequired,
@@ -81,7 +85,7 @@ const Input = forwardRef<HTMLInputElement, FormInputProps>(
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
) : (
<label htmlFor={name} className="sr-only">
diff --git a/packages/form/src/components/MultiSelect.tsx b/packages/form/src/components/MultiSelect.tsx
index 8a9f5b9462..c181582dae 100644
--- a/packages/form/src/components/MultiSelect.tsx
+++ b/packages/form/src/components/MultiSelect.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { MultiSelectProps as MultiSelectBaseProps } from "@carbon/react";
import {
Badge,
@@ -17,7 +19,8 @@ export type MultiSelectProps = Omit<
"onChange" | "value" | "inline"
> & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
helperText?: string;
value?: string[];
onChange?: (newValue: { value: string; label: string }[]) => void;
@@ -62,6 +65,7 @@ const MultiSelectPreview = (
const MultiSelect = ({
name,
label,
+ termId,
helperText,
maxPreview,
...props
@@ -85,7 +89,7 @@ const MultiSelect = ({
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
{(value ?? []).filter(Boolean).map((selection, index) => (
diff --git a/packages/form/src/components/Number.tsx b/packages/form/src/components/Number.tsx
index 432df353c0..785c0c1204 100644
--- a/packages/form/src/components/Number.tsx
+++ b/packages/form/src/components/Number.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { NumberFieldProps } from "@carbon/react";
import {
FormControl,
@@ -20,7 +22,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormNumberProps = NumberFieldProps & {
name: string;
size?: "sm" | "md" | "lg";
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isConfigured?: boolean;
isOptional?: boolean;
isRequired?: boolean;
@@ -34,6 +37,7 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
name,
size = "md",
label,
+ termId,
isConfigured = false,
isOptional,
isRequired,
@@ -76,7 +80,7 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<NumberField
diff --git a/packages/form/src/components/Password.tsx b/packages/form/src/components/Password.tsx
index 79167691fd..9fd0f8d8f3 100644
--- a/packages/form/src/components/Password.tsx
+++ b/packages/form/src/components/Password.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
FormControl,
@@ -15,12 +17,13 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormPasswordProps = InputProps & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isRequired?: boolean;
};
const Password = forwardRef<HTMLInputElement, FormPasswordProps>(
- ({ name, label, isRequired, ...rest }, ref) => {
+ ({ name, label, termId, isRequired, ...rest }, ref) => {
const {
getInputProps,
error,
@@ -36,7 +39,7 @@ const Password = forwardRef<HTMLInputElement, FormPasswordProps>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<InputGroup>
diff --git a/packages/form/src/components/PhoneInput.tsx b/packages/form/src/components/PhoneInput.tsx
index 2f94eaf3a3..41f592c6ed 100644
--- a/packages/form/src/components/PhoneInput.tsx
+++ b/packages/form/src/components/PhoneInput.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -32,7 +34,8 @@ const PhoneInputComponent = ReactPhoneInput.default;
type PhoneInputProps = InputProps & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
isRequired?: boolean;
} & Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> &
Omit<ReactPhoneInput.Props<typeof ReactPhoneInput.default>, "onChange"> & {
@@ -43,7 +46,7 @@ type PhoneInputProps = InputProps & {
const PhoneInput: ForwardRefExoticComponent<PhoneInputProps> = forwardRef<
ElementRef<typeof ReactPhoneInput.default>,
PhoneInputProps
->(({ name, label, isRequired, className, ...props }, ref) => {
+>(({ name, label, termId, isRequired, className, ...props }, ref) => {
const { getInputProps, error, isOptional: fieldIsOptional } = useField(name);
const [value, setValue] = useControlField<string>(name);
const formState = useFormStateContext();
@@ -61,7 +64,7 @@ const PhoneInput: ForwardRefExoticComponent<PhoneInputProps> = forwardRef<
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<PhoneInputComponent
diff --git a/packages/form/src/components/Radios.tsx b/packages/form/src/components/Radios.tsx
index 5fe9157a95..9501d0f196 100644
--- a/packages/form/src/components/Radios.tsx
+++ b/packages/form/src/components/Radios.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import {
FormControl,
FormErrorMessage,
@@ -11,7 +13,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type RadiosProps = {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
options: { label: string; value: string }[];
orientation?: "horizontal" | "vertical";
};
@@ -19,6 +22,7 @@ type RadiosProps = {
const Radios = ({
name,
label,
+ termId,
options,
orientation = "vertical"
}: RadiosProps) => {
@@ -31,7 +35,7 @@ const Radios = ({
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<RadioGroup
diff --git a/packages/form/src/components/Select.tsx b/packages/form/src/components/Select.tsx
index 1183a1b9a4..c646c7127b 100644
--- a/packages/form/src/components/Select.tsx
+++ b/packages/form/src/components/Select.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import {
buttonVariants,
Select as CarbonSelect,
@@ -23,7 +25,8 @@ import { useFormStateContext } from "../internal/formStateContext";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
@@ -42,6 +45,7 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
const Select = ({
name,
label,
+ termId,
helperText,
isConfigured = false,
isOptional,
@@ -80,7 +84,7 @@ const Select = ({
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
diff --git a/packages/form/src/components/SelectControlled.tsx b/packages/form/src/components/SelectControlled.tsx
index 180aedf0bd..1c34cca6fb 100644
--- a/packages/form/src/components/SelectControlled.tsx
+++ b/packages/form/src/components/SelectControlled.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import {
FormControl,
FormErrorMessage,
@@ -13,7 +15,8 @@ import { SelectBase } from "./Select";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
@@ -27,6 +30,7 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
const SelectControlled = ({
name,
label,
+ termId,
helperText,
options,
isConfigured,
@@ -65,7 +69,7 @@ const SelectControlled = ({
isOptional={resolvedIsOptional}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/packages/form/src/components/Textarea.tsx b/packages/form/src/components/Textarea.tsx
index e8f8f3d4c3..64e1bf8ed7 100644
--- a/packages/form/src/components/Textarea.tsx
+++ b/packages/form/src/components/Textarea.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { TextareaProps } from "@carbon/react";
import {
FormControl,
@@ -12,7 +14,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormTextArea = TextareaProps & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
size?: "sm" | "md" | "lg";
characterLimit?: number;
isRequired?: boolean;
@@ -24,6 +27,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, FormTextArea>(
{
name,
label,
+ termId,
size,
characterLimit,
isRequired,
@@ -54,7 +58,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, FormTextArea>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<TextAreaBase
diff --git a/packages/form/src/components/TextareaControlled.tsx b/packages/form/src/components/TextareaControlled.tsx
index 3bb6f02ceb..6e3789a459 100644
--- a/packages/form/src/components/TextareaControlled.tsx
+++ b/packages/form/src/components/TextareaControlled.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import type { TextareaProps } from "@carbon/react";
import {
FormControl,
@@ -13,7 +15,8 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormTextAreaControlledProps = Omit<TextareaProps, "value" | "onChange"> & {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
characterLimit?: number;
isOptional?: boolean;
isRequired?: boolean;
@@ -31,6 +34,7 @@ const TextAreaControlled = forwardRef<
{
name,
label,
+ termId,
characterLimit,
isOptional,
isRequired,
@@ -77,7 +81,7 @@ const TextAreaControlled = forwardRef<
>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<TextAreaBase
diff --git a/packages/form/src/components/TimePicker.tsx b/packages/form/src/components/TimePicker.tsx
index 12d2686f96..1cf0df582e 100644
--- a/packages/form/src/components/TimePicker.tsx
+++ b/packages/form/src/components/TimePicker.tsx
@@ -1,3 +1,5 @@
+import { LabelWithHelp } from "@carbon/field-help";
+import type { TermId } from "@carbon/glossary";
import {
FormControl,
FormErrorMessage,
@@ -16,14 +18,15 @@ import { useFormStateContext } from "../internal/formStateContext";
type TimePickerProps = {
name: string;
- label?: React.ReactNode;
+ label?: string;
+ termId?: TermId;
minValue?: TimeValue;
maxValue?: TimeValue;
onChange?: (time: TimeValue) => void;
};
type TimeValue = Time | CalendarDateTime | ZonedDateTime;
-const TimePicker = ({ name, label, onChange }: TimePickerProps) => {
+const TimePicker = ({ name, label, termId, onChange }: TimePickerProps) => {
const formState = useFormStateContext();
const isDisabled = formState.isDisabled || formState.isReadOnly;
const {
@@ -46,7 +49,7 @@ const TimePicker = ({ name, label, onChange }: TimePickerProps) => {
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input type="hidden" name={name} value={time?.toString()} />
diff --git a/packages/react/src/CreateableCombobox.tsx b/packages/react/src/CreateableCombobox.tsx
index 19008bf228..6a2f36a400 100644
--- a/packages/react/src/CreateableCombobox.tsx
+++ b/packages/react/src/CreateableCombobox.tsx
@@ -32,7 +32,7 @@ export type CreatableComboboxProps = Omit<
selected?: string[];
isClearable?: boolean;
isReadOnly?: boolean;
- label?: React.ReactNode;
+ label?: string;
placeholder?: string;
inline?: (
value: string,
@@ -172,11 +172,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
}}
>
<VirtualizedCommand
- // Used inside a templated "Create ${label}" hint string, so we
- // can only pass it through when `label` is plain text. JSX labels
- // (e.g. `<LabelWithHelp>…</LabelWithHelp>`) fall back to the
- // bare "Create" hint — acceptable tradeoff to keep one prop.
- label={typeof label === "string" ? label : undefined}
+ label={label}
options={options}
selected={selected}
value={value}
diff --git a/packages/react/src/CreateableMultiSelect.tsx b/packages/react/src/CreateableMultiSelect.tsx
index ed8890ad10..8851b05573 100644
--- a/packages/react/src/CreateableMultiSelect.tsx
+++ b/packages/react/src/CreateableMultiSelect.tsx
@@ -35,7 +35,7 @@ export type CreatableMultiSelectProps = Omit<
}[];
selected?: string[];
isReadOnly?: boolean;
- label?: React.ReactNode;
+ label?: string;
createLabel?: string;
placeholder?: string;
maxPreview?: number;
@@ -201,11 +201,7 @@ const CreatableMultiSelect = forwardRef<
onCreateOption={onCreateOption}
itemHeight={itemHeight}
setOpen={setOpen}
- // Used inside a templated "Create ${label}" hint string, so we
- // can only pass it through when `label` is plain text. JSX labels
- // (e.g. `<LabelWithHelp>…</LabelWithHelp>`) fall back to the
- // bare "Create" hint — acceptable tradeoff to keep one prop.
- label={typeof label === "string" ? label : undefined}
+ label={label}
createLabel={createLabel}
search={search}
setSearch={setSearch}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 307fb9edef..d4790eee14 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -660,7 +660,7 @@ importers:
version: 3.4.5([email protected])
'@react-router/remix-routes-option-adapter':
specifier: 'catalog:'
'@react-router/serve':
specifier: 'catalog:'
@@ -705,7 +705,7 @@ importers:
'@vercel/react-router':
specifier: 'catalog:'
'@visx/responsive':
specifier: 2.17.0
version: 2.17.0([email protected])
@@ -931,16 +931,16 @@ importers:
'@lingui/vite-plugin':
specifier: 'catalog:'
'@react-router/dev':
specifier: 'catalog:'
'@tailwindcss/typography':
specifier: 'catalog:'
version: 0.5.19([email protected])
'@tailwindcss/vite':
specifier: 'catalog:'
'@types/d3':
specifier: 7.4.3
version: 7.4.3
@@ -997,13 +997,13 @@ importers:
version: 5.8.3
vite:
specifier: 'catalog:'
vite-plugin-babel-macros:
specifier: 'catalog:'
vitest:
specifier: 'catalog:'
apps/mes:
dependencies:
@@ -2191,6 +2191,12 @@ importers:
packages/form:
dependencies:
+ '@carbon/field-help':
+ specifier: workspace:*
+ version: link:../field-help
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../glossary
'@carbon/react':
specifier: workspace:*
version: link:../react
@@ -15746,6 +15752,16 @@ snapshots:
'@lingui/babel-plugin-lingui-macro': 5.9.4([email protected])([email protected])
babel-plugin-macros: 3.1.0
+ dependencies:
+ '@lingui/cli': 5.9.4([email protected])([email protected])
+ '@lingui/conf': 5.9.4([email protected])
+ transitivePeerDependencies:
+ - babel-plugin-macros
+ - supports-color
+ - typescript
+
dependencies:
'@lingui/cli': 5.9.4([email protected])([email protected])
@@ -19288,6 +19304,56 @@ snapshots:
'@react-pdf/primitives': 4.2.0
'@react-pdf/stylesheet': 6.1.4
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/generator': 7.29.1
+ '@babel/parser': 7.29.2
+ '@babel/plugin-syntax-jsx': 7.28.6(@babel/[email protected])
+ '@babel/preset-typescript': 7.28.5(@babel/[email protected])
+ '@babel/traverse': 7.29.0
+ '@babel/types': 7.29.0
+ '@remix-run/node-fetch-server': 0.13.1
+ arg: 5.0.2
+ babel-dead-code-elimination: 1.0.12
+ chokidar: 4.0.3
+ dedent: 1.7.2([email protected])
+ es-module-lexer: 1.7.0
+ exit-hook: 2.2.1
+ isbot: 5.1.37
+ jsesc: 3.0.2
+ lodash: 4.17.21
+ p-map: 7.0.4
+ pathe: 1.1.2
+ picocolors: 1.1.1
+ pkg-types: 2.3.0
+ prettier: 3.8.1
+ react-refresh: 0.14.2
+ semver: 7.7.4
+ tinyglobby: 0.2.16
+ valibot: 1.3.1([email protected])
+ optionalDependencies:
+ typescript: 5.8.3
+ transitivePeerDependencies:
+ - '@types/node'
+ - babel-plugin-macros
+ - jiti
+ - less
+ - lightningcss
+ - sass
+ - sass-embedded
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+ - tsx
+ - yaml
+
dependencies:
'@babel/core': 7.29.0
@@ -19492,6 +19558,12 @@ snapshots:
optionalDependencies:
typescript: 5.8.3
+ dependencies:
+ optionalDependencies:
+ typescript: 5.8.3
+
dependencies:
@@ -20723,6 +20795,13 @@ snapshots:
postcss-selector-parser: 6.0.10
tailwindcss: 4.3.0
+ dependencies:
+ '@tailwindcss/node': 4.3.0
+ '@tailwindcss/oxide': 4.3.0
+ tailwindcss: 4.3.0
+
dependencies:
'@tailwindcss/node': 4.3.0
@@ -21551,6 +21630,16 @@ snapshots:
'@vercel/[email protected]': {}
+ dependencies:
+ '@vercel/static-config': 3.2.0
+ isbot: 5.1.37
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ ts-morph: 12.0.0
+
dependencies:
@@ -21691,6 +21780,14 @@ snapshots:
optionalDependencies:
+ dependencies:
+ '@vitest/spy': 4.1.6
+ estree-walker: 3.0.3
+ magic-string: 0.30.21
+ optionalDependencies:
+
dependencies:
'@vitest/spy': 4.1.6
@@ -27774,6 +27871,17 @@ snapshots:
- tsx
- yaml
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/plugin-syntax-jsx': 7.28.6(@babel/[email protected])
+ '@babel/plugin-syntax-typescript': 7.28.6(@babel/[email protected])
+ '@types/babel__core': 7.20.5
+ babel-plugin-macros: 3.1.0
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
'@babel/core': 7.29.0
@@ -27847,6 +27955,21 @@ snapshots:
tsx: 4.21.0
yaml: 2.8.3
+ dependencies:
+ lightningcss: 1.32.0
+ picomatch: 4.0.4
+ postcss: 8.5.14
+ rolldown: 1.0.0-rc.17
+ tinyglobby: 0.2.16
+ optionalDependencies:
+ '@types/node': 24.12.2
+ esbuild: 0.27.7
+ fsevents: 2.3.3
+ jiti: 2.7.0
+ tsx: 4.21.0
+ yaml: 2.8.3
+
dependencies:
lightningcss: 1.32.0
@@ -27961,6 +28084,34 @@ snapshots:
transitivePeerDependencies:
- msw
+ dependencies:
+ '@vitest/expect': 4.1.6
+ '@vitest/pretty-format': 4.1.6
+ '@vitest/runner': 4.1.6
+ '@vitest/snapshot': 4.1.6
+ '@vitest/spy': 4.1.6
+ '@vitest/utils': 4.1.6
+ es-module-lexer: 2.0.0
+ expect-type: 1.3.0
+ magic-string: 0.30.21
+ obug: 2.1.1
+ pathe: 2.0.3
+ picomatch: 4.0.4
+ std-env: 4.0.0
+ tinybench: 2.9.0
+ tinyexec: 1.1.1
+ tinyglobby: 0.2.16
+ tinyrainbow: 3.1.0
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@opentelemetry/api': 1.9.0
+ '@types/node': 24.12.2
+ transitivePeerDependencies:
+ - msw
+
dependencies:
'@vitest/expect': 4.1.6