{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA2CM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,4CAAiB,EACvC,+BAAS,MAAM,KAAK,GACpB,+BAAS,MAAM,YAAY,KAAK,IAChC,MAAM,QAAQ;IAGhB,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 {\n  FocusableProps,\n  HelpTextProps,\n  InputBase,\n  LabelableProps,\n  TextInputBase,\n  Validation,\n  ValueBase\n} 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>\n  extends\n    InputBase,\n    Validation<string>,\n    HelpTextProps,\n    FocusableProps<T>,\n    TextInputBase,\n    ValueBase<string>,\n    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(\n    toString(props.value),\n    toString(props.defaultValue) || '',\n    props.onChange\n  );\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"}