import { Key, Selection, ValidationError } from "@react-types/shared"; import { WidthProp } from "@marigold/system"; import { ReactNode, Ref } from "react"; import RAC from "react-aria-components"; import { TagListProps } from "react-aria-components/TagGroup"; type RemoveProps = 'className' | 'style' | 'children' | 'isInvalid' | 'isRequired' | 'isDisabled' | 'onSelectionChange'; export interface TagGroupProps extends Omit, Pick, 'items' | 'children'> { /** * Visual variant of the component. Which values exist is defined by the theme * and listed in the "Appearance" section of the component's documentation. */ variant?: string; /** * Size of the component. Which values exist is defined by the theme and listed * in the "Appearance" section of the component's documentation. */ size?: string; /** * Values that invalidate the cached items, like a hook's dependency array. * Only needed for `items` plus a render function: rendered items are cached * per item object, so anything the function reads from outside the item — * state, a lookup, a prop — has to be listed here or it renders stale. */ dependencies?: TagListProps['dependencies']; /** * The label of the field. */ label?: ReactNode; /** * Content after the label, such as a `` or ``. Keeps * the label row's height, and a badge is read as the field's description. */ addon?: ReactNode; /** * A helpful description rendered below the list. */ description?: ReactNode; /** * An error message rendered below the list when `error` is true. */ errorMessage?: ReactNode | ((v: RAC.ValidationResult) => ReactNode); /** * If `true`, the field is considered invalid and the `errorMessage` is shown. * @default false */ error?: boolean; /** * If `true`, the field is required. * @default false */ required?: boolean; /** * If `true`, the group is disabled. * @default false */ disabled?: boolean; /** * The name of the field, used when submitting form data. */ name?: string; /** * Associates the hidden input with a `
` element by id. */ form?: string; /** * Sets the width of the field. You can see allowed tokens here: https://tailwindcss.com/docs/width * * Numeric/scale values are spacing-scale tokens, not pixels: `width={64}` * resolves to `calc(var(--spacing) * 64)` ~= 16rem (256px), not 64px. * @default full */ width?: WidthProp['width']; /** * Provides content to display when there are no items in the tag list. */ emptyState?: TagListProps['renderEmptyState']; /** * Renders a "remove all" option, when a the `onRemove` prop is also set. * @default false */ removeAll?: boolean; /** * Custom client-side validation. Receives the array of selected keys. * Return a string (or array of strings) to mark the field invalid, or * `true`/`null`/`undefined` for valid. */ validate?: (value: Key[]) => ValidationError | true | null; /** * Whether to use native HTML form validation or ARIA validation. * Inherits from an ancestor `` when omitted. */ validationBehavior?: 'aria' | 'native'; /** * Handler that is called when the selection changes. */ onChange?: (keys: Selection) => void; /** * The number of tags to display before collapsing the rest behind a * "Show more" / "Show less" toggle. Only applies to static children; * ignored for dynamic collections (`items` + a render function). * * @default undefined */ collapseAt?: number; /** Ref to the DOM element the component renders. */ ref?: Ref; } declare const TagGroup: ({ ref, items, children, dependencies, emptyState, variant, size, label, addon, description, errorMessage, error, required, disabled, name, form, width, removeAll, selectedKeys, defaultSelectedKeys, selectionMode, onChange, onRemove, validate, validationBehavior: validationBehaviorProp, collapseAt, ...rest }: TagGroupProps) => import("react").JSX.Element; export { TagGroup };