{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA2BM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,4CAAiB,EAAE,+BAAS,MAAM,KAAK,GAAG,+BAAS,MAAM,YAAY,KAAK,IAAI,MAAM,QAAQ;IAEpH,OAAO;eACL;kBACA;IACF;AACF;AAEA,SAAS,+BAAS,GAAG;IACnB,IAAI,OAAO,MACT;IAGF,OAAO,IAAI,QAAQ;AACrB","sources":["packages/react-stately/src/searchfield/useSearchFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {FocusableProps, HelpTextProps, InputBase, LabelableProps, TextInputBase, Validation, ValueBase} from '@react-types/shared';\nimport {useControlledState} from '../utils/useControlledState';\n\n// Copied here to avoid depending on @react-aria/textfield from stately.\nexport interface TextFieldProps<T = HTMLInputElement> extends InputBase, Validation<string>, HelpTextProps, FocusableProps<T>, TextInputBase, ValueBase<string>, LabelableProps {}\n\nexport interface SearchFieldProps extends TextFieldProps {\n  /** Handler that is called when the SearchField is submitted. */\n  onSubmit?: (value: string) => void,\n\n  /** Handler that is called when the clear button is pressed. */\n  onClear?: () => void\n}\n\nexport interface SearchFieldState {\n  /** The current value of the search field. */\n  readonly value: string,\n\n  /** Sets the value of the search field. */\n  setValue(value: string): void\n}\n\n/**\n * Provides state management for a search field.\n */\nexport function useSearchFieldState(props: SearchFieldProps): SearchFieldState {\n  let [value, setValue] = useControlledState(toString(props.value), toString(props.defaultValue) || '', props.onChange);\n\n  return {\n    value,\n    setValue\n  };\n}\n\nfunction toString(val) {\n  if (val == null) {\n    return;\n  }\n\n  return val.toString();\n}\n"],"names":[],"version":3,"file":"useSearchFieldState.cjs.map"}