import type { focusSafely } from '@react-aria/focus'; import type { CSSProperties, HTMLAttributes, ReactNode, RefObject } from 'react'; import type { ButtonProps as RACButtonProps, LinkProps as RACLinkProps, PressEvent as RACPressEvent, ValidationResult as RACValidationResult } from 'react-aria-components'; import type { ForegroundTone } from '../utils/style/types.js'; /** Represents an identifier for a collection item. */ export type Key = string | number; /** Represents a selection of items in a collection. */ export type Selection = 'all' | Set; /** Represents a direction (vertical or horizontal). */ export type Direction = 'vertical' | 'horizontal'; /** * Use this type when you want to restrict `children` to a string, * but also want to allow expressions that resolve to strings. */ export type StringLikeChildren = string | number | (string | number)[]; /** Any focusable element, including both HTML and SVG elements. */ export type FocusableElement = Parameters[0]; /** * A set of common props that are allowed on every component */ export interface CommonProps { /** * The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */ id?: string; /** * Use this attribute to "claim" the component tree for exclusive Cimpress UI usage. */ 'data-cim-style-root'?: boolean; /** * Sets the CSS className for the element. Only use as a **last resort**. Use style props instead. * * See [styling guide](https://ui.cimpress.io/dev-guides/styling/). */ UNSAFE_className?: string; /** * Sets the CSS style for the element. Only use as a **last resort**. Use style props instead. * * See [styling guide](https://ui.cimpress.io/dev-guides/styling/). */ UNSAFE_style?: CSSProperties; } /** * An event fired when a component is pressed. * * By default, press events stop propagation to parent elements. * In cases where a handler decides not to handle a specific event, * it can call `continuePropagation()` to allow a parent to handle it. */ export type PressEvent = RACPressEvent; /** An event fired when a component is hovered. */ export type HoverEvent = Parameters>[0]; /** * Props for components that require a label, which can be hidden if necessary. */ export interface LabellableProps extends AriaLabelingProps { /** The content to display as the label. */ label?: string; } export interface AriaLabelingProps { /** * Defines a string value that labels the current element. */ 'aria-label'?: string; /** * Identifies the element (or elements) that labels the current element. */ 'aria-labelledby'?: string; /** * Identifies the element (or elements) that describes the object. */ 'aria-describedby'?: string; /** * Identifies the element (or elements) that provide a detailed, extended description for the object. */ 'aria-details'?: string; } /** Provides details about the validation state of a form field. */ export type ValidationResult = RACValidationResult; /** Represents the error message(s) for a form field. */ export type FieldError = string | string[] | undefined | ((validation: ValidationResult) => string | string[] | undefined); /** Props available on form field components. */ export interface FieldProps extends LabellableProps { /** * The `
` element to associate the input with. * The value of this attribute must be the id of a `` in the same document. * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form). */ form?: string; /** * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name). */ name?: string; /** A description for the field. Provides a hint such as specific requirements for what to choose. */ description?: string; /** An error message for the field. */ error?: FieldError; /** * A function that returns an error message (or `true`) if a given value is invalid. * Validation errors are displayed to the user when the form is submitted. * For real-time validation, use the `error` prop instead. */ validate?: (value: T) => string | string[] | true | undefined; } /** Props available on form field components with text inputs. */ export interface FieldWithPlaceholderProps extends FieldProps { /** The placeholder text displayed in the input field. */ placeholder?: string; } /** Changes specified optional properties within the provided type to be required. */ export type WithRequired = T & { [P in K]-?: T[P]; }; /** * This interface allows configuring navigation props with router options and type-safe URLs via TypeScript module augmentation. * By default, this is an empty interface. Extend with `href` and `routerOptions` properties to configure your router. */ export interface RouterConfig { } /** * Represents a URL for navigation components. * This type can be configured by augmenting `RouterConfig` with an `href` property. */ export type Href = RouterConfig extends { href: infer H; } ? H : string; /** * Represents router options for navigation components. * This type can be configured by augmenting `RouterConfig` with a `routerOptions` property. */ export type RouterOptions = RouterConfig extends { routerOptions: infer O; } ? O : never; /** * Props available on components that perform navigation. */ export interface NavigationProps extends Pick { /** A URL to link to. */ href?: Href; /** Options for the configured client side router. */ routerOptions?: RouterOptions; } /** Represents a minimal data shape of a dynamic item in collection components. */ export interface CollectionItem { /** Unique identifier for the item or group. */ id: Key; } /** Props available on components that render collections. */ export interface CollectionProps { /** The contents of the collection. */ children?: ReactNode | ((item: T) => ReactNode); /** The items to display in the collection. */ items?: Iterable; } /** Props available on components that support asynchronous loading of items. */ export interface AsyncItemLoadingProps { /** Whether items are currently being loaded. */ UNSTABLE_isLoading?: boolean; /** A callback function that is called when more items should be loaded. */ UNSTABLE_onLoadMore?: () => void; } /** Props available on icons. */ export interface IconProps extends CommonProps, Pick { /** * Whether the icon is hidden from assistive technologies. * @default true */ 'aria-hidden'?: boolean; /** The size of the icon in pixels. */ size?: 16 | 24 | 32; /** The tone of the icon. */ tone?: ForegroundTone; } /** Props available on native HTML elements. */ export interface NativeElementProps extends HTMLAttributes { [dataProp: `data-${string}`]: string | number | boolean | undefined; } /** * Props available on components that support affixes. */ export interface AffixProps { /** The content displayed at the start of the component. Can be either an icon or a piece of text. */ prefix?: ReactNode; /** The content displayed at the end of the component. Can be either an icon or a piece of text. */ suffix?: ReactNode; } /** Props available on components that expose an imperative API. */ export interface ApiProps { /** A React ref that allows access to the imperative API of this component. */ apiRef?: RefObject; } //# sourceMappingURL=types.d.ts.map