UNPKG

@tiller-ds/form-elements

Version:

Form elements module of Tiller Design System

68 lines (67 loc) 2.56 kB
import * as React from "react"; import { ComponentTokens, TokenProps } from "@tiller-ds/theme"; export declare type FieldGroupProps = { /** * Field content (not exclusively text). */ children: React.ReactNode; /** * Custom classes for the container. * Overrides conflicting default styles, if any. * * The provided `className` is processed using `tailwind-merge` to eliminate redundant or conflicting Tailwind classes. */ className?: string; /** * Value passed through from validation indicating to display the error on the component. */ error?: string | React.ReactElement; /** * The help text displayed below the field. */ help?: string | React.ReactElement; /** * Represents the label above the field. */ label: string | React.ReactElement; /** * Turns this field into a required field in the form. Only applies visual representation (* next to label), * still requires validation on frontend or backend to accompany this value if set to true. */ required?: boolean; /** * Displays the field items vertically instead of horizontally by default. */ vertical?: boolean; /** * A unique identifier for testing purposes. * This identifier can be used in testing frameworks like Jest or Cypress to locate specific elements for testing. * It helps ensure that UI components are behaving as expected across different scenarios. * @type {string} * @example * // Usage: * <MyComponent data-testid="my-component" /> * // In tests: * getByTestId('my-component'); */ "data-testid"?: string; } & FieldGroupTokens; export declare type FieldGroupItemProps = { label: string | React.ReactElement; help?: string | React.ReactElement; id: string; children: React.ReactNode; className?: string; disabled?: boolean; "data-testid"?: string; } & TokenProps<"FieldGroup">; declare type FieldGroupTokens = { fieldGroupTokens?: ComponentTokens<"FieldGroup">; inputTokens?: ComponentTokens<"Input">; }; declare function FieldGroup({ label, help, error, className, required, vertical, children, ...props }: FieldGroupProps & FieldGroupTokens): JSX.Element; declare namespace FieldGroup { var Item: typeof FieldGroupItem; } declare function FieldGroupItem({ label, help, id, children, className, disabled, ...props }: FieldGroupItemProps): JSX.Element; export default FieldGroup;