/* * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ import { CoordinateFieldProps } from "../../components/coordinate-field/types.js"; import { useCoordinateCopy } from "./use-coordinate-copy.js"; import { useCoordinateFieldState } from "./use-coordinate-field-state.js"; import { useCoordinateFocus } from "./use-coordinate-focus.js"; import { useCoordinatePaste } from "./use-coordinate-paste.js"; import { ValidationResult } from "react-aria-components/TextField"; //#region src/hooks/coordinate-field/use-coordinate-field.d.ts /** Return value from the useCoordinateField hook */ interface UseCoordinateFieldResult { /** Coordinate state management utilities */ state: ReturnType; /** Focus management utilities */ focus: ReturnType; /** Paste handling utilities */ paste: ReturnType; /** Copy handling utilities */ copy: ReturnType; /** Register timeouts for cleanup */ registerTimeout: (timeoutId: NodeJS.Timeout) => void; /** ARIA props for the field container */ fieldProps: { id: string; role: 'group'; 'aria-labelledby': string | undefined; 'aria-describedby': string | undefined; 'aria-label': string | undefined; 'aria-details': string | undefined; 'aria-invalid': boolean | undefined; 'aria-required': boolean | undefined; 'aria-disabled': boolean | undefined; }; /** Props for the label element */ labelProps: { id: string; htmlFor: string; }; /** Props for the description element */ descriptionProps: { id: string; }; /** Props for the error message element */ errorProps: { id: string; }; /** Validation result for react-aria */ validation: ValidationResult; /** Generated element IDs */ ids: { fieldId: string; labelId: string; descriptionId: string; errorId: string; }; /** First error message or null */ effectiveErrorMessage: string | null; /** Whether the field is in an invalid state */ isInvalid: boolean; } /** * Manages coordinate field state, focus, copy, paste, and accessibility props * * @example * ```tsx * function CoordinateFieldComponent() { * const [value, setValue] = useState(null); * * const { * state, * focus, * paste, * copy, * fieldProps, * labelProps, * isInvalid, * effectiveErrorMessage, * } = useCoordinateField({ * value, * onChange: setValue, * format: 'dd', * label: 'Location', * }); * * return ( *
* * {state.editableSegmentConfigs.map((config, index) => ( * state.handleSegmentChange(index, e.target.value)} * /> * ))} * {isInvalid && {effectiveErrorMessage}} *
* ); * } * ``` * * @param props - {@link CoordinateFieldProps} * @param customAriaLabel - Custom aria-label for the field. * @param customAriaDescribedby - Custom aria-describedby IDs. * @param customAriaDetails - Custom aria-details ID. * @returns {@link UseCoordinateFieldResult} Combined state, focus, copy, paste utilities and accessibility props. */ declare function useCoordinateField(props: CoordinateFieldProps, customAriaLabel?: string, customAriaDescribedby?: string, customAriaDetails?: string): UseCoordinateFieldResult; //#endregion export { UseCoordinateFieldResult, useCoordinateField }; //# sourceMappingURL=use-coordinate-field.d.ts.map