map • Lines: 1{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoCM,SAAS,0CAAqB,KAA+B;IAClE,IAAI,EACF,eAAe,kBAAkB,EACjC,YAAY,eAAe,EAC3B,mBAAmB,yBAAyB,EAAE,EAC/C,GAAG;IAEJ,IAAI,gBAAgB,CAAA;QAClB,IAAI,oBACF,mBAAmB;IAEvB;IAEA,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAChE,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,4CAAiB,EACjD,iBACA,wBACA;IAGF,OAAO;oBACL;uBACA;uBACA;0BACA;IACF;AACF","sources":["packages/react-stately/src/autocomplete/useAutocompleteState.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ReactNode, useState} from 'react';\nimport {useControlledState} from '../utils/useControlledState';\n\nexport interface AutocompleteState {\n /** The current value of the autocomplete input. */\n inputValue: string;\n /** Sets the value of the autocomplete input. */\n setInputValue(value: string): void;\n /** The id of the current aria-activedescendant of the autocomplete input. */\n focusedNodeId: string | null;\n /** Sets the id of the current aria-activedescendant of the autocomplete input. */\n setFocusedNodeId(value: string | null): void;\n}\n\nexport interface AutocompleteProps {\n /** The value of the autocomplete input (controlled). */\n inputValue?: string;\n /** The default value of the autocomplete input (uncontrolled). */\n defaultInputValue?: string;\n /** Handler that is called when the autocomplete input value changes. */\n onInputChange?: (value: string) => void;\n /**\n * The children wrapped by the autocomplete. Consists of at least an input element and a\n * collection element to filter.\n */\n children: ReactNode;\n}\n\n// Emulate our other stately hooks which accept all \"base\" props even if not used\nexport interface AutocompleteStateOptions extends Omit<AutocompleteProps, 'children'> {}\n\n/**\n * Provides state management for an autocomplete component.\n */\nexport function useAutocompleteState(props: AutocompleteStateOptions): AutocompleteState {\n let {\n onInputChange: propsOnInputChange,\n inputValue: propsInputValue,\n defaultInputValue: propsDefaultInputValue = ''\n } = props;\n\n let onInputChange = value => {\n if (propsOnInputChange) {\n propsOnInputChange(value);\n }\n };\n\n let [focusedNodeId, setFocusedNodeId] = useState<string | null>(null);\n let [inputValue, setInputValue] = useControlledState(\n propsInputValue,\n propsDefaultInputValue!,\n onInputChange\n );\n\n return {\n inputValue,\n setInputValue,\n focusedNodeId,\n setFocusedNodeId\n };\n}\n"],"names":[],"version":3,"file":"useAutocompleteState.cjs.map"}